Ejemplo n.º 1
0
 //called from GUI
 public void DeclarePlayerTurn(PlayerTurn pt)
 {
     if (StateOfGame == StatesOfGame.GameEnded)
     {
         return;
     }
     if (StateOfGame != StatesOfGame.PlayerDeclaringTurn)
     {
         throw new ApplicationException("Wrong flow");
     }
     StateOfGame = StatesOfGame.WaitingForOpponent;
     ShowDebugMessage("Sending turn to gamecommunication");
     ShowDebugMessage("StatesOfGame.WaitingForOpponent");
     _gc.ThisPlayerTurn(pt);
 }
Ejemplo n.º 2
0
        //calculate turn return turnresults
        public static TurnResults ResolveTurn(PlayerTurn player1, PlayerTurn player2, Map map)
        {
            var results = new List <Action>(50);

            while (player1.Moves.Count > 0 && player2.Moves.Count > 0)
            {
                Character char1 = null;
                Character char2 = null;
                if (player1.Moves.Count > 0)
                {
                    char1 = player1.Moves[0];
                    player1.Moves.RemoveAt(0);
                }
                if (player2.Moves.Count > 0)
                {
                    char2 = player2.Moves[0];
                    player2.Moves.RemoveAt(0);
                }
                if (char1?.PlannedMove != null && char2?.PlannedMove != null)
                {
                    MovementMethods.TwoPlayerMovement(char1, char2, map, results);
                    AttackMethods.TwoPlayerAttack(char1, char2, map, results);
                }
                if (char1 == null && char2?.PlannedMove != null)
                {
                    MovementMethods.OnePlayerMovement(char2, map, results);
                    AttackMethods.OnePlayerAttack(char2, map, results);
                }
                if (char1?.PlannedMove != null && char2 == null)
                {
                    MovementMethods.OnePlayerMovement(char1, map, results);
                    AttackMethods.OnePlayerAttack(char1, map, results);
                }
            }

            var res = new TurnResults
            {
                Results   = results,
                GameEnded = player1.Moves.Any(x => !x.Isdead()) || player2.Moves.Any(x => !x.Isdead())
            };

            return(res);
        }
Ejemplo n.º 3
0
 //called from GameCommunication when client turn arrive
 public void ActualizeMap(PlayerTurn oponentTurn)
 {
     Map.UpdateCharacters(oponentTurn.Moves);
 }