public void ReceiveBetting(Betting betting, IndianPokerGamePacket gamePacketParam) { if (gamePacketParam.playerTurn == myTurn) { PrintBetting(betting); } this.otherPlayerMoney = gamePacketParam.MyMoney; this.otherPlayerBettingMoney = gamePacketParam.BettingMoney; this.totalBettingMoney = totalBettingMoney + gamePacketParam.BettingMoney; Dispatcher.BeginInvoke(new Action(() => { Label_OtherPlayerMoney.Content = this.otherPlayerMoney.ToString(); Label_BetTotalMoney.Content = totalBettingMoney.ToString(); })); if (gamePacketParam.Betting == (short)Betting.BettingCall) { if (gamePacketParam.VictoryUser == myIndex) { myMoney = myMoney + totalBettingMoney; Dispatcher.BeginInvoke(new Action(() => { TextBox_UserLog.AppendText("게임에서 이겼습니다. \n"); TextBox_UserLog.AppendText("새로운 게임을 시작하겠습니다. 준비하세요.\n"); Button_MyCard.Content = this.myCard.ToString(); })); } else { Dispatcher.BeginInvoke(new Action(() => { TextBox_UserLog.AppendText("게임에서 졌습니다. \n"); TextBox_UserLog.AppendText("새로운 게임을 시작하겠습니다. 준비하세요.\n"); Button_MyCard.Content = this.myCard.ToString(); })); } newGameStart = new Thread(new ThreadStart(SendNewGameThread)); newGameStart.Start(); } else if (gamePacketParam.Betting == (short)Betting.BettingDie) { myMoney = myMoney + totalBettingMoney; if (gamePacketParam.VictoryUser == myIndex) { Dispatcher.BeginInvoke(new Action(() => { TextBox_UserLog.AppendText("상대방이 베팅을 포기하여 게임에서 이겼습니다. \n"); TextBox_UserLog.AppendText("새로운 게임을 시작하겠습니다. 준비하세요.\n"); Label_MyMoney.Content = myMoney.ToString(); })); } else if (gamePacketParam.VictoryUser != myIndex) { Dispatcher.BeginInvoke(new Action(() => { TextBox_UserLog.AppendText("게임에서 졌습니다. \n"); TextBox_UserLog.AppendText("새로운 게임을 시작하겠습니다. 준비하세요.\n"); })); } newGameStart = new Thread(new ThreadStart(SendNewGameThread)); newGameStart.Start(); } else { StrMyBetting = string.Empty; } }
public void RequestBetting(GamePlayer player, IndianPokerGamePacket gamePacketParam) { ///////////////////////////////////////////////////////////////////// if (player.PlayerIndex == 1) { player1.PlayerMoney = gamePacketParam.MyMoney; } else { player2.PlayerMoney = gamePacketParam.MyMoney; } ///////////////////////////////////////////////////////////////////// //IndianPokerGamePacket pokerGamePacket = gamePacketParam; this.totalBettingMoney = this.totalBettingMoney + gamePacketParam.BettingMoney; if (gamePacketParam.Betting == (short)Betting.BettingCall) { IndianPokerGamePacket SendToPlayer1 = new IndianPokerGamePacket(); IndianPokerGamePacket SendToPlayer2 = new IndianPokerGamePacket(); if (player.PlayerIndex == 1) { if (this.player1Card > this.player2Card) { player1.PlayerMoney = player1.PlayerMoney + this.totalBettingMoney; victoryUser = 1; SendToPlayer2 = gamePacketParam; SendToPlayer2.VictoryUser = victoryUser; SendToPlayer2.playerTurn = player2.PlayerTurn; SendToPlayer1.MyMoney = player2.PlayerMoney; SendToPlayer1.VictoryUser = victoryUser; } else if (this.player1Card < this.player2Card) { player2.PlayerMoney = player2.PlayerMoney + this.totalBettingMoney; victoryUser = 2; SendToPlayer2 = gamePacketParam; SendToPlayer2.VictoryUser = victoryUser; SendToPlayer2.playerTurn = player2.PlayerTurn; SendToPlayer1.MyMoney = player2.PlayerMoney; SendToPlayer1.VictoryUser = victoryUser; } } else { if (this.player1Card > this.player2Card) { player1.PlayerMoney = player1.PlayerMoney + this.totalBettingMoney; victoryUser = 1; SendToPlayer1 = gamePacketParam; SendToPlayer1.VictoryUser = victoryUser; SendToPlayer1.playerTurn = player1.PlayerTurn; SendToPlayer2.MyMoney = player1.PlayerMoney; SendToPlayer2.VictoryUser = victoryUser; } else if (this.player1Card < this.player2Card) { player2.PlayerMoney = player2.PlayerMoney + this.totalBettingMoney; victoryUser = 2; SendToPlayer1 = gamePacketParam; SendToPlayer1.VictoryUser = victoryUser; SendToPlayer1.playerTurn = player1.PlayerTurn; SendToPlayer2.MyMoney = player2.PlayerMoney; SendToPlayer2.VictoryUser = victoryUser; } } SendPokerGameMessage(Header.GameMotion, SendToPlayer1, player1.owner); SendPokerGameMessage(Header.GameMotion, SendToPlayer2, player2.owner); } else if (gamePacketParam.Betting == (short)Betting.BettingDie) { IndianPokerGamePacket SendToPlayer1 = new IndianPokerGamePacket(); IndianPokerGamePacket SendToPlayer2 = new IndianPokerGamePacket(); if (player.PlayerIndex == 1) { SendToPlayer2 = gamePacketParam; player2.PlayerMoney = player2.PlayerMoney + this.totalBettingMoney; victoryUser = 2; SendToPlayer2.VictoryUser = victoryUser; SendToPlayer2.playerTurn = player2.PlayerTurn; SendToPlayer1.MyMoney = player2.PlayerMoney; //이부분 수정 필요 SendToPlayer1.VictoryUser = victoryUser; SendToPlayer1.Betting = gamePacketParam.Betting; SendToPlayer1.BettingMoney = 0; } else { SendToPlayer1 = gamePacketParam; player1.PlayerMoney = player1.PlayerMoney + this.totalBettingMoney; victoryUser = 1; SendToPlayer1.VictoryUser = victoryUser; SendToPlayer1.playerTurn = player1.PlayerTurn; SendToPlayer2.MyMoney = player1.PlayerMoney; //이부분 수정 필요 SendToPlayer2.VictoryUser = victoryUser; SendToPlayer2.Betting = gamePacketParam.Betting; SendToPlayer2.BettingMoney = 0; } SendPokerGameMessage(Header.GameMotion, SendToPlayer1, player1.owner); SendPokerGameMessage(Header.GameMotion, SendToPlayer2, player2.owner); } else { IndianPokerGamePacket SendToPlayer = gamePacketParam; SendToPlayer.playerIndex = player.PlayerIndex; if (player.PlayerTurn == 1) { SendToPlayer.playerTurn = 2; } else { SendToPlayer.playerTurn = 1; } if (player.PlayerIndex == 1) { SendPokerGameMessage(Header.GameMotion, SendToPlayer, player2.owner); } else { SendPokerGameMessage(Header.GameMotion, SendToPlayer, player1.owner); } } }
public void SendBetting(Betting bettingParam) { IndianPokerGamePacket gamePacket = new IndianPokerGamePacket(); int bettingMoney = 0; short betting = (short)bettingParam; switch (bettingParam) { case Betting.BettingCall: //게임 끝, 새로운 게임 시작 bettingMoney = otherPlayerBettingMoney; if (this.myMoney - bettingMoney < 0) { bettingMoney = this.myMoney; this.myMoney = 0; this.totalBettingMoney = this.totalBettingMoney + bettingMoney; } else { this.myMoney = myMoney - bettingMoney; this.totalBettingMoney = totalBettingMoney + bettingMoney; } this.StrMyBetting = "콜"; break; case Betting.BettingDie: this.StrMyBetting = "다이"; break; case Betting.BettingDouble: bettingMoney = otherPlayerBettingMoney * 2; if (this.myMoney - bettingMoney < 0) { bettingMoney = this.myMoney; this.myMoney = 0; this.totalBettingMoney = this.totalBettingMoney + bettingMoney; betting = (short)Betting.BettingCall; this.StrMyBetting = "콜"; } else { this.myMoney = this.myMoney - bettingMoney; this.totalBettingMoney = this.totalBettingMoney + (this.otherPlayerBettingMoney * 2); this.StrMyBetting = "따당"; } break; case Betting.BettingCheck: if (this.isFirstTurn) { //첫번째 베팅일땐 체크버튼 활성화 this.isFirstTurn = false; } else { //첫번째 베팅일땐 체크버튼 비활성화 } this.StrMyBetting = "체크"; break; case Betting.BettingQueter: bettingMoney = otherPlayerBettingMoney + ((totalBettingMoney + otherPlayerBettingMoney) / 4); if (this.myMoney - bettingMoney < 0) { bettingMoney = this.myMoney; this.myMoney = 0; this.totalBettingMoney = this.totalBettingMoney + bettingMoney; betting = (short)Betting.BettingCall; this.StrMyBetting = "콜"; } else { this.myMoney = this.myMoney - bettingMoney; this.StrMyBetting = "쿼터"; } this.totalBettingMoney = (this.totalBettingMoney + this.otherPlayerBettingMoney) + ((this.totalBettingMoney + this.otherPlayerBettingMoney) / 4); break; case Betting.BettingHalf: //첫베팅은 무조건 하프만 됨. if (this.isFirstTurn) { this.isFirstTurn = false; bettingMoney = totalBettingMoney / 2; this.myMoney = this.myMoney - bettingMoney; this.totalBettingMoney = this.totalBettingMoney + bettingMoney; } else { //총베팅금액 + 상대방의 베팅금액 / 2 bettingMoney = otherPlayerBettingMoney + ((totalBettingMoney + otherPlayerBettingMoney) / 2); if (this.myMoney - bettingMoney < 0) { bettingMoney = this.myMoney; this.myMoney = 0; this.totalBettingMoney = this.totalBettingMoney + bettingMoney; betting = (short)Betting.BettingCall; this.StrMyBetting = "콜"; } else { this.myMoney = this.myMoney - bettingMoney; this.StrMyBetting = "하프"; } this.totalBettingMoney = (this.totalBettingMoney + this.otherPlayerBettingMoney) + ((this.totalBettingMoney + this.otherPlayerBettingMoney) / 2); } break; } StrOtherPlayerBetting = string.Empty; gamePacket.playerTurn = myTurn; gamePacket.Betting = (short)betting; gamePacket.BettingMoney = bettingMoney; gamePacket.MyMoney = myMoney; SendGamePacketMessage(gamePacket); Dispatcher.BeginInvoke(new Action(() => { Label_MyMoney.Content = myMoney.ToString(); Label_BetTotalMoney.Content = totalBettingMoney.ToString(); })); }
private void SendGameMessage(IndianPokerGamePacket gamePacketParam) { gamePacketParam.clientID = this.ClientID; indianPokerClient.SendMessage(Header.GameMotion, gamePacketParam, indianPokerClient.ao.WorkingSocket); }