private void SendResultToPlayers() { playerManager.ForEach((player) => { BlackjackPlayer bPlayer = player as BlackjackPlayer; if (bPlayer.status == PlayerStatus.Playing) { BlackjackDeckResults deckResults = new BlackjackDeckResults(); deckResults.deckResults = new List <BlackjackResult>(); int moneyDelta = 0; for (int i = 0; i < playerCards[bPlayer].Count; i++) { BlackjackResult result = GetGameResult(bPlayer, i, playerBetsDic[player].initialBet); deckResults.deckResults.Add(result); moneyDelta += result.Money; } GameResultResponse response = new GameResultResponse(); response.deckResults = PacketHelper.Serialize <BlackjackDeckResults>(deckResults); response.BetMoney = playerBetsDic[player].initialBet; response.DealerCards = PacketHelper.Serialize <CardSet>(dealerCards); bPlayer.peer.SendOperationResponse(new OperationResponse(CommonOperationCode.BaccaratGameResult, response), new SendParameters()); bPlayer.money += moneyDelta; //WebHelper.UpdatePlayerMoney(player.name, moneyDelta); } else { GameResultResponse response = new GameResultResponse(); response.BetMoney = 0; response.DealerCards = PacketHelper.Serialize <CardSet>(dealerCards); bPlayer.peer.SendOperationResponse(new OperationResponse(CommonOperationCode.BaccaratGameResult, response), new SendParameters()); } }); }
public GameResultResponse GetBetResult(BaccaratBet bet) { int money = 0; if (result == BaccaratResultType.Banker) { money = bet.BankerBet * 95 / 100 - bet.PlayerBet - bet.TieBet; } else if (result == BaccaratResultType.Player) { money = bet.PlayerBet - bet.BankerBet - bet.TieBet; } else { money = bet.TieBet * 8; } int betMoney = bet.BankerBet + bet.PlayerBet + bet.TieBet; BaccaratResult betResult = new BaccaratResult(result, money, betMoney); GameResultResponse response = new GameResultResponse(); response.BankerCards = PacketHelper.Serialize(bankerCards); response.PlayerCards = PacketHelper.Serialize(playerCards); response.GameResult = (byte)betResult.Type; response.BetMoney = betResult.BetMoney; response.MoneyDelta = betResult.Money; return(response); }
private void SendResultToPlayers() { playerManager.ForEach((player) => { BaccaratPlayer bPlayer = player as BaccaratPlayer; if (playersBetDic.ContainsKey(bPlayer)) { var bet = playersBetDic[bPlayer]; GameResultResponse response = game.GetBetResult(bet); bPlayer.peer.SendOperationResponse(new OperationResponse(CommonOperationCode.BaccaratGameResult, response), new SendParameters()); bPlayer.money += response.MoneyDelta; //WebHelper.UpdatePlayerMoney(player.name, response.MoneyDelta); } else { var bet = new BaccaratBet(0, 0, 0); GameResultResponse response = game.GetBetResult(bet); bPlayer.peer.SendOperationResponse(new OperationResponse(CommonOperationCode.BaccaratGameResult, response), new SendParameters()); } }); }