/// <summary> /// PassPlayerが存在していない場合挿入 /// </summary> /// <param name="player"></param> /// <returns></returns> public void SetFirstPassPlayer(GamePlayerBase player) { if (this.m_passStartPlayer == null) { this.m_passStartPlayer = player; } }
/// <summary> /// 当玩家退出游戏时,调用此方法 /// </summary> /// <param name="player">退出游戏的玩家</param> public override void OnPlayerQuitted(GamePlayerBase player) { lock ( SyncRoot ) { if (GameState == GameState.NotInitialized) { throw new InvalidOperationException(); } if (!PlayerCollection.Contains(player)) //如果不存在这个玩家,则忽略。 { return; } AnnounceSystemMessage("玩家 {0} 退出了游戏", player.PlayerName); PlayerCollection.Remove(player); lock ( SyncRoot ) { if (!Players.Any()) //若已经没有玩家了,释放游戏资源 { ReleaseGame(); } if (GameState == GameState.Running) //如果游戏正在进行,则强行终止游戏。 { Abort(); } } } }
private void PutCard(GamePlayerBase player, Card card) { this.m_field.PutCard(card); player.RemoveHand(card); Console.WriteLine($"{player.Name}が{CreateCardStr(card)}を場に置きました"); this.NextTurn(); }
/// <summary> /// パスの処理 /// </summary> /// <param name="player"></param> private void DoPassPlayer(GamePlayerBase player) { Console.WriteLine(this.CreatePassStr(player)); this.m_field.SetFirstPassPlayer(this.TurnPlayer); this.NextTurn(); if (this.m_field.PassHandle(this.TurnPlayer)) { Console.WriteLine("場が流れました"); Console.WriteLine(this.DoField()); } }
/// <summary> /// 全員がパスしたとき、場のカードを変える /// </summary> /// <param name="player"></param> public bool PassHandle(GamePlayerBase player) { if (this.m_passStartPlayer == null) { this.m_passStartPlayer = player; return(false); } if (this.m_passStartPlayer != player) { return(false); } this.ChangeField(); this.m_passStartPlayer = null; return(true); }
/// <summary> /// パス時のメッセージ /// </summary> /// <param name="player"></param> /// <returns></returns> private string CreatePassStr(GamePlayerBase player) { return($"{player.Name}がパスしました"); }
/// <summary> /// Playerが上がった時の文字 /// </summary> /// <param name="player"></param> /// <returns></returns> private string CreateGoalStr(GamePlayerBase player) { return($"{player.Name}が上がりました\n"); }
/// <summary> /// 場にカードを置く /// </summary> /// <param name="card"></param> public void PutCard(Card card) { this.m_cemetery.Add(this.FieldCard); this.FieldCard = card; this.m_passStartPlayer = null; }