private void NextActionForcedRearrangement(ref ImmobileCapturePieceStepState token)
        {
            var forcedRearrangementToken = new ForcedRearrangementStepState
            {
                PieceToRearrange = token.PieceToCapture
            };

            postMoveActionSequence.Next(this, ref forcedRearrangementToken, (int)PostMoveState.FORCED_REARRANGEMENT);
        }
        private void NextActionBetrayal(ref ImmobileCapturePieceStepState token)
        {
            var betrayalToken = new BetrayalStepState
            {
                PieceMoved    = token.pieceToStrike,
                PieceCaptured = token.PieceToCapture
            };

            postMoveActionSequence.Next(this, ref betrayalToken, (int)PostMoveState.BETRAYAL);
        }
예제 #3
0
        private void NextActionInitiateImmobileCapture(PieceEV piece)
        {
            /**
             * Scenarios, [Tier1, Tier2, Tier3], F=Friendly, E=Enemy:
             * * FO, FOO, OFO
             * * OF, OFF, FOF
             *
             * The pieceToCapture is either the piece param (piece that was clicked) or an
             * adjacent piece.  Business logic:
             *
             * If topOfTower is NOT turn player color, then it's piece that was clicked
             * Else it's the adjacent piece that is NOT turn player color; there will only
             * be one of those
             */

            PieceEV pieceToCapture  = piece;
            PieceEV topOfTowerPiece = pieceFindService.FindTopPieceByLocation(piece.Location.Location, entitiesDB).Value;
            TurnEV  currentTurn     = turnService.GetCurrentTurnEV(entitiesDB);

            //if (topOfTowerPiece.PlayerOwner.PlayerColor != currentTurn.TurnPlayer.PlayerColor)
            //{
            //    pieceToCapture = piece;
            //}
            //else
            if (topOfTowerPiece.PlayerOwner.PlayerColor == currentTurn.TurnPlayer.PlayerColor)
            {
                List <PieceEV> pieces     = pieceFindService.FindPiecesByLocation(piece.Location.Location, entitiesDB);
                bool           pieceFound = false;

                foreach (PieceEV pieceToCheck in pieces)
                {
                    if (Math.Abs(piece.Tier.Tier - pieceToCheck.Tier.Tier) == 1 &&
                        currentTurn.TurnPlayer.PlayerColor != pieceToCheck.PlayerOwner.PlayerColor)
                    {
                        pieceToCapture = pieceToCheck;
                        pieceFound     = true;
                        break;
                    }
                }

                if (!pieceFound)
                {
                    throw new InvalidOperationException("Did not find adjacent piece of opposite color.");
                }
            }

            var immobileCapturePieceStepState = new ImmobileCapturePieceStepState
            {
                PieceToCapture = pieceToCapture
            };

            towerModalConfirmSequence.Next(this, ref immobileCapturePieceStepState, (int)TowerAnswerState.INITIATE_IMMOBILE_CAPTURE);
        }
        public void Step(ref ImmobileCapturePieceStepState token, int condition)
        {
            handService.AddPieceToHand(token.PieceToCapture, entitiesDB);

            if (token.BetrayalPossible)
            {
                NextActionBetrayal(ref token);
            }
            else
            {
                NextActionForcedRearrangement(ref token);
            }
        }
예제 #5
0
        private void NextActionImmobileCapture()
        {
            ModalEV modal          = modalService.FindModalEV(entitiesDB);
            TileEV  clickedTile    = FindDestinationTile(modal);
            PieceEV pieceToCapture = FindSecondFromTopPiece(clickedTile);

            var token = new ImmobileCapturePieceStepState
            {
                BetrayalPossible = false,
                PieceToCapture   = pieceToCapture
            };

            captureStackModalAnswerSequence.Next(this, ref token, (int)MoveState.IMMOBILE_CAPTURE);
        }