Exemplo n.º 1
0
        public Match()
        {
            Id = Guid.NewGuid();
            _matchState = MatchState.NotStarted;

            // TODO: set up teams based on docuDB
            Team1 = new Team(0, "red team");
            Team2 = new Team(1, "blue team");
        }
Exemplo n.º 2
0
        public Piece(PieceVariantModel model, Team owningTeam)
        {
            VariantId = model.VariantId;
            Name = model.Name;
            CaptureDoesGivePoint = model.CaptureDoesGivePoint;
            CapturePointValue = model.CapturePointValue;
            MoveAbilities = model.MoveAbilities;

            TeamId = owningTeam.Id;
        }
Exemplo n.º 3
0
 public bool IsTeam2(Team team)
 {
     return Team2.Id == team.Id;
 }
Exemplo n.º 4
0
 public bool IsTeam1(Team team)
 {
     return Team1.Id == team.Id;
 }
Exemplo n.º 5
0
 public bool IsCurrentTeam(Team team)
 {
     return _currentTeam == team;
 }
Exemplo n.º 6
0
 public Team GetOtherTeam(Team team)
 {
     return
         Team1.Id == team.Id
             ? Team2
             : Team1;
 }
Exemplo n.º 7
0
        public BoardInfoForClient EndGame(BoardInfoForClient boardinfoForClient, Team teamThatWon)
        {
            if (!IsOver)
            {
                _matchState = MatchState.GameOver;
                WinningTeam = teamThatWon;

                boardinfoForClient.GameOver = true;
                boardinfoForClient.WinningTeam = teamThatWon;
            }

            return boardinfoForClient;
        }
Exemplo n.º 8
0
        public static Piece GenerateFish(Match match, Team team)
        {
            var fishModel = new PieceVariantModel();
            fishModel.VariantId = 21;

            var fishName = "";
            var xChange = 0;

            if (team.Id == 0)
            {
                fishName = "red fish";
                xChange = 2;
            }
            else if (team.Id == 1)
            {
                fishName = "blue fish";
                xChange = -2;
            }

            if (match.IsTeam1(team))
            {
                    fishModel.Name = fishName;
                    fishModel.MoveAbilities.Add(new MoveAbility(
                                            canCapture: false,
                                            moveOnly: false,
                                            captureOnly: false,
                                            canHop: false,
                                            firstMoveOnly: false,
                                            xChange: xChange,
                                            yChange: 0,
                                            multiplicity: 1));
            }
            else
            {
                    fishModel.Name = fishName;
                    fishModel.MoveAbilities.Add(new MoveAbility(
                                            canCapture: false,
                                            moveOnly: false,
                                            captureOnly: false,
                                            canHop: false,
                                            firstMoveOnly: false,
                                            xChange: xChange,
                                            yChange: 0,
                                            multiplicity: 1));

            }

                return new Piece(fishModel, team);
        }
Exemplo n.º 9
0
        public static Piece GenerateSherman(Match match, Team team)
        {
            var shermanModel = new PieceVariantModel();
            shermanModel.VariantId = 11;
            shermanModel.Name = "Sherman Tank";

            shermanModel.CaptureDoesGivePoint = true;
            shermanModel.CapturePointValue = 1;

            if (match.IsTeam1(team))
            {
                // UPRIGHT 3
                shermanModel.MoveAbilities.Add(new MoveAbility(
                                            canCapture: true,
                                            moveOnly: false,
                                            captureOnly: false,
                                            canHop: false,
                                            firstMoveOnly: false,
                                            xChange: 1,
                                            yChange: -1,
                                            multiplicity: 2));

                // DOWN 3
                shermanModel.MoveAbilities.Add(new MoveAbility(
                                canCapture: true,
                                moveOnly: false,
                                captureOnly: false,
                                canHop: false,
                                firstMoveOnly: false,
                                xChange: -1,
                                yChange: 0,
                                multiplicity: 3));

                // UPLEFT 3
                shermanModel.MoveAbilities.Add(new MoveAbility(
                                            canCapture: true,
                                            moveOnly: false,
                                            captureOnly: false,
                                            canHop: false,
                                            firstMoveOnly: false,
                                            xChange: 1,
                                            yChange: 1,
                                            multiplicity: 2));
            }
            else
            {
                // DOWNRIGHT 3
                shermanModel.MoveAbilities.Add(new MoveAbility(
                                            canCapture: true,
                                            moveOnly: false,
                                            captureOnly: false,
                                            canHop: false,
                                            firstMoveOnly: false,
                                            xChange: -1,
                                            yChange: -1,
                                            multiplicity: 2));

                // UP 3
                shermanModel.MoveAbilities.Add(new MoveAbility(
                                canCapture: true,
                                moveOnly: false,
                                captureOnly: false,
                                canHop: false,
                                firstMoveOnly: false,
                                xChange: 1,
                                yChange: 0,
                                multiplicity: 3));

                // DOWNLEFT 2
                shermanModel.MoveAbilities.Add(new MoveAbility(
                                            canCapture: true,
                                            moveOnly: false,
                                            captureOnly: false,
                                            canHop: false,
                                            firstMoveOnly: false,
                                            xChange: -1,
                                            yChange: 1,
                                            multiplicity: 2));
            }

            return new Piece(shermanModel, team);
        }
Exemplo n.º 10
0
        public static Piece GenerateRook(Match match, Team team)
        {
            var rookName = "";

            if (team.Id == 0)
            {
                rookName = "red Rook";
            }
            else if (team.Id == 1)
            {
                rookName = "blue Rook";
            }

            var rookModel = new PieceVariantModel();
            rookModel.VariantId = 2;
            rookModel.Name = rookName;

            // UP infinitely
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 0,
                                        yChange: 1,
                                        multiplicity: 7));
            // RIGHT infinitely
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: 0,
                                        multiplicity: 7));

            // DOWN infinitely
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 0,
                                        yChange: -1,
                                        multiplicity: 7));

            // LEFT infinitely
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: 0,
                                        multiplicity: 7));

            return new Piece(rookModel, team);
        }
Exemplo n.º 11
0
        public static Piece GenerateBishop(Match match, Team team)
        {
            var bishopName = "";

            if (team.Id == 0)
            {
                bishopName = "red Bishop";
            }
            else if (team.Id == 1)
            {
                bishopName = "blue Bishop";
            }

            var bishopModel = new PieceVariantModel();
            bishopModel.VariantId = 4;
            bishopModel.Name = bishopName;

            // UPRIGHT infinitely
            bishopModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: 1,
                                        multiplicity: 7));
            // DOWNRIGHT infinitely
            bishopModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: -1,
                                        multiplicity: 7));

            // DOWNLEFT infinitely
            bishopModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: -1,
                                        multiplicity: 7));

            // UPLEFT infinitely
            bishopModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: 1,
                                        multiplicity: 7));

            return new Piece(bishopModel, team);
        }
Exemplo n.º 12
0
        public static Piece GenerateQueen(Match match, Team team)
        {
            var queenName = "";

            if (team.Id == 0)
            {
                queenName = "red Queen";
            }
            else if (team.Id == 1)
            {
                queenName = "blue Queen";
            }

            var queenModel = new PieceVariantModel();
            queenModel.VariantId = 6;
            queenModel.Name = queenName;

            // UP infinitely
            queenModel.MoveAbilities.Add(new MoveAbility(
                            canCapture: true,
                            moveOnly: false,
                            captureOnly: false,
                            canHop: false,
                            firstMoveOnly: false,
                            xChange: 0,
                            yChange: 1,
                            multiplicity: 8));

            // UPRIGHT infinitely
            queenModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: 1,
                                        multiplicity: 8));

            // RIGHT infinitely
            queenModel.MoveAbilities.Add(new MoveAbility(
                            canCapture: true,
                            moveOnly: false,
                            captureOnly: false,
                            canHop: false,
                            firstMoveOnly: false,
                            xChange: 1,
                            yChange: 0,
                            multiplicity: 8));

            // DOWNRIGHT infinitely
            queenModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: -1,
                                        multiplicity: 8));
            // DOWN infinitely
            queenModel.MoveAbilities.Add(new MoveAbility(
                            canCapture: true,
                            moveOnly: false,
                            captureOnly: false,
                            canHop: false,
                            firstMoveOnly: false,
                            xChange: 0,
                            yChange: -1,
                            multiplicity: 8));

            // DOWNLEFT infinitely
            queenModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: -1,
                                        multiplicity: 8));

            // LEFT infinitely
            queenModel.MoveAbilities.Add(new MoveAbility(
                            canCapture: true,
                            moveOnly: false,
                            captureOnly: false,
                            canHop: false,
                            firstMoveOnly: false,
                            xChange: -1,
                            yChange: 0,
                            multiplicity: 8));

            // UPLEFT infinitely
            queenModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: 1,
                                        multiplicity: 8));

            return new Piece(queenModel, team);
        }
Exemplo n.º 13
0
        // TODO:  to account for cases like the pawn's 2y move, both the 1y and the 2y have to be one distinct moveability.
        // Somehow need to track different bools for each multiplicity.
        public static Piece GeneratePawn(Match match, Team team)
        {
            var pawnName = "";
            var yChange = 0;

            if (team.Id == 0)
            {
                pawnName = "red Pawn";
                yChange = -1;
            }
            else if (team.Id == 1)
            {
                pawnName = "blue Pawn";
                yChange = 1;
            }

            var pawnModel = new PieceVariantModel();
            pawnModel.VariantId = 1;
            pawnModel.Name = pawnName;

            // DOWN 1 or DOWN 2
            pawnModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: false,
                                        moveOnly: true,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: true,
                                        xChange: 0,
                                        yChange: yChange*2,
                                        multiplicity: 1));
            // DOWN 1
            pawnModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: false,
                                        moveOnly: true,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 0,
                                        yChange: yChange,
                                        multiplicity: 1));
            // DOWN 1, LEFT 1
            pawnModel.MoveAbilities.Add(new MoveAbility(multiplicity: 1,
                                    canCapture: true,
                                    moveOnly: false,
                                    captureOnly: true,
                                    canHop: false,
                                    firstMoveOnly: false,
                                    xChange: -1,
                                    yChange: yChange));

            // DOWN 1, RIGHT 1
            pawnModel.MoveAbilities.Add(new MoveAbility(multiplicity: 1,
                                    canCapture: true,
                                    moveOnly: false,
                                    captureOnly: true,
                                    canHop: false,
                                    firstMoveOnly: false,
                                    xChange: 1,
                                    yChange: yChange));
            return new Piece(pawnModel, team);
        }
Exemplo n.º 14
0
        public static Piece GenerateKnight(Match match, Team team)
        {
            var knightName = "";

            if (team.Id == 0)
            {
                knightName = "red Knight";
            }
            else if (team.Id == 1)
            {
                knightName = "blue Knight";
            }

            var rookModel = new PieceVariantModel();
            rookModel.VariantId = 3;
            rookModel.Name = knightName;

            // UP, UP, RIGHT
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: true,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: 2,
                                        multiplicity: 1));
            // RIGHT, RIGHT, UP
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: true,
                                        firstMoveOnly: false,
                                        xChange: 2,
                                        yChange: 1,
                                        multiplicity: 1));

            // RIGHT RIGHT DOWN
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: true,
                                        firstMoveOnly: false,
                                        xChange: 2,
                                        yChange: -1,
                                        multiplicity: 1));

            // DOWN DOWN RIGHT
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: true,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: -2,
                                        multiplicity: 1));

            // DOWN DOWN LEFT
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: true,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: -2,
                                        multiplicity: 1));

            // LEFT LEFT DOWN
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: true,
                                        firstMoveOnly: false,
                                        xChange: -2,
                                        yChange: -1,
                                        multiplicity: 1));

            // LEFT LEFT UP
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: true,
                                        firstMoveOnly: false,
                                        xChange: -2,
                                        yChange: 1,
                                        multiplicity: 1));

            // UP UP LEFT
            rookModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: true,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: 2,
                                        multiplicity: 1));

            return new Piece(rookModel, team);
        }
Exemplo n.º 15
0
        public static Piece GenerateKing(Match match, Team team)
        {
            var kingName = "";

            if (team.Id == 0)
            {
                kingName = "red King";
            }
            else if (team.Id == 1)
            {
                kingName = "blue King";
            }

            var kingModel = new PieceVariantModel();
            kingModel.VariantId = 5;
            kingModel.Name = kingName;

            kingModel.CaptureDoesGivePoint = true;
            kingModel.CapturePointValue = 1;

            // UP 1
            kingModel.MoveAbilities.Add(new MoveAbility(
                            canCapture: true,
                            moveOnly: false,
                            captureOnly: false,
                            canHop: false,
                            firstMoveOnly: false,
                            xChange: 0,
                            yChange: 1,
                            multiplicity: 1));

            // UPRIGHT 1
            kingModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: 1,
                                        multiplicity: 1));

            // RIGHT 1
            kingModel.MoveAbilities.Add(new MoveAbility(
                            canCapture: true,
                            moveOnly: false,
                            captureOnly: false,
                            canHop: false,
                            firstMoveOnly: false,
                            xChange: 1,
                            yChange: 0,
                            multiplicity: 1));

            // DOWNRIGHT 1
            kingModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: 1,
                                        yChange: -1,
                                        multiplicity: 1));
            // DOWN 1
            kingModel.MoveAbilities.Add(new MoveAbility(
                            canCapture: true,
                            moveOnly: false,
                            captureOnly: false,
                            canHop: false,
                            firstMoveOnly: false,
                            xChange: 0,
                            yChange: -1,
                            multiplicity: 1));

            // DOWNLEFT 1
            kingModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: -1,
                                        multiplicity: 1));

            // LEFT 1
            kingModel.MoveAbilities.Add(new MoveAbility(
                            canCapture: true,
                            moveOnly: false,
                            captureOnly: false,
                            canHop: false,
                            firstMoveOnly: false,
                            xChange: -1,
                            yChange: 0,
                            multiplicity: 1));

            // UPLEFT 1
            kingModel.MoveAbilities.Add(new MoveAbility(
                                        canCapture: true,
                                        moveOnly: false,
                                        captureOnly: false,
                                        canHop: false,
                                        firstMoveOnly: false,
                                        xChange: -1,
                                        yChange: 1,
                                        multiplicity: 1));

            return new Piece(kingModel, team);
        }
Exemplo n.º 16
0
        public Team SetAndGetNextTeam()
        {
            _currentTeam =
                _currentTeam == Team1
                    ? Team2
                    : Team1;

            _currentTeamMovesLeft = Game.MovesPerTurn;

            GetHubContext().Clients.All.showMessage("Your turn - you can make " + _currentTeamMovesLeft + " moves.");

            return _currentTeam;
        }
Exemplo n.º 17
0
        public void Start()
        {
            if (IsNotStarted)
            {
                // TODO: MatchManager will probably set up players instead
                //_player1 = new Player();
                //_player2 = new Player();

                _currentTeam = Team1;

                _matchState = MatchState.AwaitingCurrentPlayer;

                _currentTeamMovesLeft = Game.MovesPerTurn;
            }
        }
Exemplo n.º 18
0
        public static Piece GenerateWhale(Match match, Team team)
        {
            var whaleModel = new PieceVariantModel();
            whaleModel.VariantId = 22;
            whaleModel.CaptureDoesGivePoint = true;
            whaleModel.CapturePointValue = 1;

            var whaleName = "";
            var xChange = 0;

            if (team.Id == 0)
            {
                whaleName = "red whale";
            }
            else if (team.Id == 1)
            {
                whaleName = "blue whale";
            }

            whaleModel.Name = whaleName;

            whaleModel.MoveAbilities.Add(new MoveAbility(
                                    canCapture: true,
                                    moveOnly: false,
                                    captureOnly: false,
                                    canHop: false,
                                    firstMoveOnly: false,
                                    xChange: 1,
                                    yChange: 1,
                                    multiplicity: 10));

            whaleModel.MoveAbilities.Add(new MoveAbility(
                        canCapture: true,
                        moveOnly: false,
                        captureOnly: false,
                        canHop: false,
                        firstMoveOnly: false,
                        xChange: 1,
                        yChange: -1,
                        multiplicity: 10));

            whaleModel.MoveAbilities.Add(new MoveAbility(
                        canCapture: true,
                        moveOnly: false,
                        captureOnly: false,
                        canHop: false,
                        firstMoveOnly: false,
                        xChange: -1,
                        yChange: -1,
                        multiplicity: 10));

            whaleModel.MoveAbilities.Add(new MoveAbility(
                    canCapture: true,
                    moveOnly: false,
                    captureOnly: false,
                    canHop: false,
                    firstMoveOnly: false,
                    xChange: -1,
                    yChange: 1,
                    multiplicity: 10));

            return new Piece(whaleModel, team);
        }