예제 #1
0
        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;
        }
예제 #2
0
        public void Bet(GamePeer peer, SendBetRequest sendBet)
        {
            BaccaratPlayer player = playerManager.GetPlayer(peer) as BaccaratPlayer;
            var bet = new BaccaratBet(sendBet.BankerBet, sendBet.PlayerBet, sendBet.TieBet);

            if (HasBet(player) == false && CanBet(player, bet))
            {
                playersBetDic.Add(player, bet);
            }

            CheckAllBet();
        }
예제 #3
0
 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());
         }
     });
 }
예제 #4
0
 private bool CanBet(BaccaratPlayer player, BaccaratBet bet)
 {
     return player.money >= (bet.BankerBet + bet.PlayerBet + bet.TieBet);
 }