Example #1
0
 public void AddPlayer(Player newPlayer)
 {
     if (!this.GameStarted) {
         if (newPlayer.FighterCount > 0) {
             this.PlayerQueue.Enqueue(newPlayer);
         }
         else {
             newPlayer.SetFightersQuantity(this.DefaultFighterQuantity);
             this.PlayerQueue.Enqueue(newPlayer);
         }
     }
     else {
         throw new Exception("Game already started");
     }
 }
Example #2
0
        public void EndTurn()
        {
            if (GameStarted) {
                Player current = this.PlayerQueue.Dequeue();
                current.EndTurn();
                this.PlayerQueue.Enqueue(current);
                this.TurnCount++;
                this.PlayerQueue.Peek().StartTurn();
            }
            //sprawdzanie, czy gra została zakończona
            List<Player> playersAlive = new List<Player>();
            foreach (Player p in PlayerQueue) {
                foreach (Fighter f in p.Fighters) {
                    if (f.Life > 0) {
                        playersAlive.Add(p);
                        break;
                    }
                }
            }

            if (playersAlive.Count <= 1) {
                GameOver = true;
                Winner = playersAlive.FirstOrDefault();//t ojest do zmiany!
            }
        }