/// <summary> /// 扣款成功 /// </summary> /// <param name="player"></param> /// <param name="amount"></param> /// <returns></returns> private bool IsDecutMoneySuccess(IPlayerJoinRoom player, decimal amount) { if (IsAccountEnougth(player, amount)) { player.DecutMoney(amount); return(true); } NotifySinglePlayer(new Alert(player.Id, "账户余额不足"), player.Id); return(false); }
/// <summary> /// 玩家加入 /// </summary> /// <param name="player_">玩家</param> public bool AddPlayer(IPlayerJoinRoom player_) { if (Players.Exists(p => p.Id == player_.Id)) { return(true); } if (Players.Count >= PlayerCountTopLimit) { AddPlayerFailRoomFullEvent?.Invoke(player_, new PlayerEventArgs(player_)); return(false); } if (player_.Id != RoomManager.Id && TicketPrice > 0 && player_.Account < TicketPrice) { PlayCanNotPayTicketEvent?.Invoke(player_, new PlayerEventArgs(player_)); return(false); } if (player_.Id != RoomManager.Id) { if (!player_.DecutMoney(TicketPrice)) { return(false); } } if (!Players.Exists(p => p.Id == player_.Id)) { Players.Add(player_); try { InningGame.PlaySitDown(player_); } catch (Exception) { throw; } finally { CheckFull(); //AddPlayerSuccessEvent?.Invoke(this, new PlayerEventArgs(player_)); AddPlayer_SuccessEvent?.Invoke(this, new PlayerEventArgs(player_)); } } return(true); }