Skip to content

Commit

Permalink
Robot v1.0
Browse files Browse the repository at this point in the history
Robot v1.0
  • Loading branch information
KILNETA authored Jun 16, 2021
1 parent 56966c9 commit fc638a0
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 23 deletions.
3 changes: 1 addition & 2 deletions Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ using namespace std;

int main()
{
_getch();
Title();
PlaySound(L"Music\\MainScreen_JazzSong.WAV", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
while (1)
{
PlaySound(L"Music\\MainScreen_JazzSong.WAV", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
switch (MainScreen())
{
case 1:break;//單 人 遊 戲
Expand Down
131 changes: 110 additions & 21 deletions MultiplayerGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ void ShowPlayerCard(int playerNumber)
{
string species[] = { "紅心","方塊","梅花","黑桃" };
string ranks[] = { "","","","","","","","","","10","","","" };
if (player[playerNumber].getBot() == true){return;}

for (int i = 0; i < 2; i++)
{
Expand Down Expand Up @@ -335,32 +336,29 @@ int ShowWinner()
{
if(!player[j].getFold())
{
for (int i = 0; i < 5; i++)
if (nowWinnerPlayerMaxWinMode < player[j].getMaxWinMode())
{
if (nowWinnerPlayerMaxWinMode < player[j].getMaxWinMode())
nowWinnerPlayerNumber = j ;
nowWinnerPlayerMaxWinMode = player[j].getMaxWinMode();
for(int i=0;i<5;i++)
{
nowWinnerPlayerNumber = j ;
nowWinnerPlayerMaxWinMode = player[j].getMaxWinMode();
for(int i=0;i<5;i++)
{
nowWinnerPlayerMaxWinNumber[i] = player[j].getMaxWinNumber(i);
}
nowWinnerPlayerMaxWinNumber[i] = player[j].getMaxWinNumber(i);
}
else
{
if (nowWinnerPlayerMaxWinMode == player[j].getMaxWinMode())
}
else
{
if (nowWinnerPlayerMaxWinMode == player[j].getMaxWinMode())
{
for (int i = 0; i < 5; i++)
{
for (int i = 0; i < 5; i++)
if (nowWinnerPlayerMaxWinNumber[i] < player[j].getMaxWinNumber(i))
{
if (nowWinnerPlayerMaxWinNumber[i] < player[j].getMaxWinNumber(i))
nowWinnerPlayerNumber = j;
for (int f = 0; f < 5; f++)
{
nowWinnerPlayerNumber = j ;
for (int f = 0; f < 5; f++)
{
nowWinnerPlayerMaxWinNumber[f] = player[j].getMaxWinNumber(f);
}
break;
nowWinnerPlayerMaxWinNumber[f] = player[j].getMaxWinNumber(f);
}
break;
}
}
}
Expand Down Expand Up @@ -461,7 +459,7 @@ void CheckCard(vector<Card> Cards,int playerNumber)
int flush = 0, straight = 0, four_of_a_kind = 0, three_of_a_king = 0, i;
int pair = 0, count = 0, a_straight = 0, start, end=0;
int kind[4] = { 0 }, scard[13] = {}; // 4種花色 13個卡號
int compareNum[5] = {};
int compareNum[5] = {-1,-1,-1,-1,-1};
Card Cards_2[5]={};

for (i = 0; i < 5; i++)
Expand Down Expand Up @@ -521,7 +519,7 @@ void RecordingMaxWinNumber(int* compareNum,int cardNumber)
{
for (int i=0;i<5;i++)
{
if (*(compareNum + i) == 0)
if (*(compareNum + i) == -1)
{
*(compareNum + i) = cardNumber;
return;
Expand Down Expand Up @@ -616,6 +614,73 @@ void PlayerOperating(int playerNumber)
gotoxyGame(x + 79, y + 24);
while(1){
if (player[playerNumber].getFold()){return;}//此玩家已棄牌
if (player[playerNumber].getBot() == true)
{
while(1)
{
int num = rand() % 10 + 1;
if (num==1|| num == 2)
{ //加 注
LastBet = LastBet * 2;
AllBet += LastBet;
gotoxyGame(x + 38, y + 15); cout << ">";
player[playerNumber].setEnd(true);
player[playerNumber].setLastOperation(1);
if (AllBetExplosion) { return; }
gotoxyGame(x + 38, y + 15); cout << " ";
PreviousplayerNumber = playerNumber;
return;
}
if (num == 3 || num == 4|| num == 5 || num == 6 || num == 7)
{ //跟 注
gotoxyGame(x + 38, y + 17); cout << ">";
AllBet += LastBet;
gotoxyGame(x + 39, y + 23); cout << "彩池:" << right << setw(8) << AllBet << " $";
gotoxyGame(x + 39, y + 17);
player[playerNumber].setLastOperation(2);
AllBetExplosionVerification();
if (AllBetExplosion) { return; }
gotoxyGame(x + 38, y + 17); cout << " ";
PreviousplayerNumber = playerNumber;
return;
}
if (num == 8 || num == 9)
{ //過 牌
if (PreviousplayerNumber != -1)
{
if (player[PreviousplayerNumber].getLastOperation() != 1 && First_lap)
{
gotoxyGame(x + 38, y + 19); cout << ">";
player[playerNumber].setLastOperation(3);
gotoxyGame(x + 38, y + 19); cout << " ";
PreviousplayerNumber = playerNumber;
return;
}
}
else
{
gotoxyGame(x + 38, y + 17); cout << ">";
AllBet += LastBet;
gotoxyGame(x + 39, y + 23); cout << "彩池:" << right << setw(8) << AllBet << " $";
gotoxyGame(x + 39, y + 17);
player[playerNumber].setLastOperation(2);
AllBetExplosionVerification();
if (AllBetExplosion) { return; }
gotoxyGame(x + 38, y + 17); cout << " ";
PreviousplayerNumber = playerNumber;
return;
}
}
if (num == 10)
{ //蓋 牌
gotoxyGame(x + 38, y + 21); cout << ">";
player[playerNumber].Folding();
gotoxyGame(x + 38, y + 21); cout << " ";
PreviousplayerNumber = playerNumber;
return;
}
}
}
switch (_getch())
{
case 114://加 注
Expand Down Expand Up @@ -688,6 +753,29 @@ void PlayerBlind(int playerNumber,int Blind)
break;
}
while (1) {
if (player[playerNumber].getBot() == true)
{
if (Blind == 1)
{
gotoxyGame(x + 38, y + 15); cout << ">";
LastBet = LastBet + 20;
AllBet += LastBet;
player[playerNumber].setLastOperation(4);
gotoxyGame(x + 38, y + 15); cout << " ";
Blind++;
return;
}
else//大 盲 注
{
gotoxyGame(x + 38, y + 15); cout << ">";
player[playerNumber].setLastOperation(5);
LastBet *= 2;
AllBet += LastBet;
gotoxyGame(x + 38, y + 15); cout << " ";
Blind++;
return;
}
}
if(_getch()== 98)
{
if (Blind == 1)
Expand Down Expand Up @@ -717,6 +805,7 @@ void PlayerBlind(int playerNumber,int Blind)
//驗證
void Verification(int playerNumber)
{
if (player[playerNumber].getBot() == true) { return; }
if (player[playerNumber].getFold()) { return; }
srand(time(0)); //取時間
int verificationNumber = (rand()%36)+1;
Expand Down
8 changes: 8 additions & 0 deletions Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ void Player::Folding()
{
Fold = true;
}
void Player::setBot()
{
bot = true;
}


int Player::getCardNumber(int num)
Expand Down Expand Up @@ -119,4 +123,8 @@ bool Player::getEnd()
bool Player::getFold()
{
return Fold;
}
bool Player::getBot()
{
return bot;
}
3 changes: 3 additions & 0 deletions Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Player
int LastOperation = -1;
bool End = false;
bool Fold = false;
bool bot = true;

bool CalculationMaxWinNumber(int[]);
void ArrangeCards();
Expand All @@ -25,6 +26,7 @@ class Player
void setLastOperation(int);
void setEnd(bool);
void Folding();
void setBot();

int getCardNumber(int);
int getCardSpecies(int);
Expand All @@ -36,6 +38,7 @@ class Player
int getLastOperation();
bool getEnd();
bool getFold();
bool getBot();

};

0 comments on commit fc638a0

Please sign in to comment.