예제 #1
0
        public GameMoveResultModel(DomainModel.Player player, DomainModel.Game result)
        {
            var defender = result.GameStatus.OtherPlayer;
            var human    = player.IsComputerControlled ? defender : player;

            this.GameID            = result.ID;
            this.Result            = result.GameStatus.CurrentMoveResult;
            this.AttackerTokenType = result.GameStatus.AttackerToken.TokenType;
            this.DefenderTokenType = result.GameStatus.DefenderToken == null ? DomainModel.TokenType.Empty : result.GameStatus.DefenderToken.TokenType;
            this.AttackerTokenID   = result.GameStatus.CurrentMove.Token.ID;
            this.MoveToX           = result.GameStatus.CurrentMove.MoveTo.X;
            this.MoveToY           = result.GameStatus.CurrentMove.MoveTo.Y;
            this.Rows   = result.GameBoard.NumRows;
            this.Cols   = result.GameBoard.NumCols;
            this.Tokens = result.GameBoard.GetTokens().Select(token => new GameTokenModel(token, human.ID)).ToArray();

            switch (result.GameStatus.CurrentMoveResult)
            {
            case DomainModel.GameMoveResultType.AttackerWins:
                this.Message = string.Format("{0} attacks {1} - {0} Wins!", AttackerTokenType, DefenderTokenType);
                break;

            case DomainModel.GameMoveResultType.DefenderWins:
                this.Message = string.Format("{0} attacks {1} - {1} Wins!", AttackerTokenType, DefenderTokenType);
                break;

            case DomainModel.GameMoveResultType.BothLose:
                this.Message = string.Format("{0} attacks {1} - Everyone Loses!", AttackerTokenType, DefenderTokenType);
                break;

            case DomainModel.GameMoveResultType.FlagCapturedByAttacker:
                this.Message = string.Format("Player {0} Wins!  Game Over.", player.Name);
                break;

            case DomainModel.GameMoveResultType.AttackerOutOfPieces:
                this.Message = string.Format("Player {0} ran out of pieces.  Player {1} Wins!  Game Over.", player.Name, defender.Name);
                break;

            case DomainModel.GameMoveResultType.DefenderOutOfPieces:
                this.Message = string.Format("Player {0} ran out of pieces.  Player {1} Wins!  Game Over.", defender.Name, player.Name);
                break;

            case DomainModel.GameMoveResultType.BothOutOfPieces:
                this.Message = "Its a tie!  Game Over.";
                break;
            }
        }
예제 #2
0
 public void Add(DomainModel.Player player, DomainModel.Game result)
 {
     this.Results.Add(new GameMoveResultModel(player, result));
 }