public BoolResponseBox dealBreakerCard(int dealBreakerCardID, Guid targetedPlayerGuid, Guid setTargeted, Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState = null;
            PlayerModel playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            ActionCard playedActionCard = monopolyDeal.deck.getCardByID(dealBreakerCardID) as ActionCard;
            if (playedActionCard != null && checkIfCardInHand(playedActionCard, playerModelAtCurrentState) != null)
            {
                MoveInfo playdealBreaker = new MoveInfo();
                playdealBreaker.playerWhoseTurnItIs = currentState.guidOfPlayerWhosTurnItIs;
                playdealBreaker.playerMakingMove = playerGuid;
                playdealBreaker.moveBeingMade = TurnActionTypes.PlayActionCard;
                playdealBreaker.idOfCardBeingUsed = dealBreakerCardID;

                playdealBreaker.actionCardActionType = ActionCardAction.DealBreaker;

                playdealBreaker.guidOfFullSetToBeDealBreakered = setTargeted;
                playdealBreaker.guidOfPlayerWhoIsBeingDealBreakered = targetedPlayerGuid;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playdealBreaker.moveBeingMade, playdealBreaker);
                return result;
            }
            return new BoolResponseBox(false, "Selected Card is not in players hand or is not a Action card");
        }
        public bool bankCard(int playedCardID, Guid playerGuid, Guid serverGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState = null;
            PlayerModel playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            Card playedcard = monopolyDeal.deck.getCardByID(playedCardID);
            if (checkIfCardInHand(playedcard, playerModelAtCurrentState) != null)
            {
                if (playedcard is PropertyCard)
                {
                    return new BoolResponseBox(false, "Property Cards can not be Banked").success;
                }
                else
                {
                    MoveInfo bankCardInfo = new MoveInfo();
                    bankCardInfo.playerWhoseTurnItIs = playerGuid;
                    bankCardInfo.playerMakingMove = playerGuid;
                    bankCardInfo.moveBeingMade = TurnActionTypes.BankMoneyCard;
                    bankCardInfo.idOfCardBeingUsed = playedCardID;

                    BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, bankCardInfo.moveBeingMade, bankCardInfo);
                    return result.success;
                }
            }
            return new BoolResponseBox(false, "Selected Card is not in players hand.").success;
        }
 public Board(ArrayList pos)
     : base()
 {
     figure = new Figure ();
     position = new Position (pos);
     info = new MoveInfo ();
     layout = new Pango.Layout (PangoContext);
 }
Exemple #4
0
 public void moveTo(Transform obj, Vector3 loc, float t, CallBack mcb)
 {
     MoveInfo moveInfo = new MoveInfo();
     moveInfo.movingObj = obj;
     moveInfo.startLocation = obj.position;
     moveInfo.toLocation = loc;
     moveInfo.dtAccum = 0;
     moveInfo.moveTime = t;
     moveInfo.moveCallback = mcb;
     moveInfos.Add(moveInfo);
 }
        public CairoBoard(ArrayList pos)
            : base()
        {
            //figure = new Figure ();
            fm = new FigureManager ();
            position = new Position (pos);
            info = new MoveInfo ();

            layout = new Pango.Layout (PangoContext);
            if (Config.WindowsBuild)
                colors = new CustomColorProvider ();
            else
                colors = new GtkBasedColorProvider (this);
        }
        public Board(ArrayList pos)
            : base(GType)
        {
            figure = new Figure ();
                        position = new Position (pos);
                        info = new MoveInfo ();
            layout = new Pango.Layout (PangoContext);

                        Events = EventMask.ButtonPressMask
                                | EventMask.ButtonReleaseMask
                                | EventMask.PointerMotionHintMask
                                | EventMask.ButtonMotionMask
                                | Gdk.EventMask.KeyPressMask;
                        CanFocus = true;
        }
Exemple #7
0
        /// <summary>
        /// Replays a its my birthday card after being just say no'd
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="nextStatePhase"></param>
        /// <param name="moveInformation"></param>
        /// <returns></returns>
        private BoolResponseBox replayActionCardItsMyBirthday(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            ActionCardEvent acevent = currentState.actionCardEvent;

            foreach (PlayerModel player in nextState.playerModels)
            {
                if (player.guid.CompareTo(acevent.playerAffectedByAction) != 0)
                {
                    player.owesAnotherPlayer = true;
                    player.amountOwedToAnotherPlayer = ActionCard.Its_My_Birthday_Value;
                    break;
                }
            }

            //Change state on success
            //has been performed, advance the phase of the game
            nextState.currentPhase = nextStatePhase;
            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
            onTurn = setAllowableActionsOnTurn(onTurn, nextState);
            updateAllowableStatesDebtPaid(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnInDebt(new List<TurnActionTypes>(), nextState));
            nextState.actionCardEvent = new ActionCardEvent();
            nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;
            nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.ItsMyBirthday;
            //change the current state to the next state
            addNextState(nextState);
            return new BoolResponseBox(true, "Player:" + getPlayerModel(currentState.guidOfPlayerWhosTurnItIs, currentState).name + " Has used a It's My Birthday after Just Say No");
        }
Exemple #8
0
        private BoolResponseBox replayActionCardSlyDeal(PlayFieldModel currentState, PlayFieldModel nextState, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(currentState.guidOfPlayerWhosTurnItIs, nextState);
            PlayerModel playerModelForPlayerToSlyDeal = getPlayerModel(currentState.actionCardEvent.playerAffectedByAction, nextState);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Do action
            PropertyCardSet setToSlyDealFrom = getPropertyCardSet(playerModelForPlayerToSlyDeal.propertySets, currentState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn[0].setGuid);
            PropertyCard cardToSlyDeal = nextState.deck.getCardByID(currentState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn[0].cardID) as PropertyCard;
            if (setToSlyDealFrom != null && cardToSlyDeal != null)
            {
                if (setToSlyDealFrom.removeProperty(cardToSlyDeal))
                {
                    //Card Removed from set
                    //Create new set with card Sly Dealed in it
                    PropertyCardSet newSet = new PropertyCardSet(cardToSlyDeal);
                    playerModelForPlayer.propertySets.addSet(newSet);
                    //Change state on success
                    //has been performed, advance the phase of the game
                    nextState.currentPhase = nextStatePhase;
                    //Used to set the allowable actions for player
                    playerModelForPlayerToSlyDeal.hasHadCardsTaken = true;
                    //Create event information for rollback and display
                    nextState.actionCardEvent = new ActionCardEvent();
                    nextState.actionCardEvent.playerAffectedByAction = currentState.actionCardEvent.playerAffectedByAction;
                    nextState.actionCardEvent.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove;
                    nextState.actionCardEvent.playerOnTurnPerformingAction = true;
                    nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;

                    nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.SlyDeal;
                    List<CardIDSetGuid> listOfCardsSlyDealed = new List<CardIDSetGuid>();
                    listOfCardsSlyDealed.Add(new CardIDSetGuid(cardToSlyDeal.cardID, setToSlyDealFrom.guid));
                    nextState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn = listOfCardsSlyDealed;
                    //change the current state to the next state

                    List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                    List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                    onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                    updateAllowableStatesPerPlayerCardsTaken(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnCardsTaken(new List<TurnActionTypes>(), nextState));

                    addNextState(nextState);
                    return new BoolResponseBox(true, "Player:" + playerModelForPlayer.name + " Has used a Sly Deal Card");
                }
                else
                {
                    return new BoolResponseBox(false, "Unable to remove card from set");
                }
            }
            else
            {
                return new BoolResponseBox(false, "Card to Sly Deal or set the card is in does not exist");
            }
        }
Exemple #9
0
        /// <summary>
        /// Plays a Wild Rent Card on a players turn.
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="nextStatePhase"></param>
        /// <param name="moveInformation"></param>
        /// <returns></returns>
        private BoolResponseBox playActionCardRentMultiColor(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);
            PlayerModel playerModelForPlayerToRent = getPlayerModel(moveInformation.guidOfPlayerToPayRent, nextState);
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.RentMultiColor) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    PropertyCardSet ps = getPropertyCardSet(playerModelForPlayer.propertySets, moveInformation.guidOfSetToCollectRentOnAgainstOnePlayer);
                    if (ps != null)
                    {
                        //rent card is wild so is compatible
                        PropertySetInfo psinfo = new PropertySetInfo(ps.getPropertySetColor());
                        int rentValue = psinfo.getRentValue(ps.getPropertySetColor(), ps.properties.Count, ps.hasHouse, ps.hasHotel);

                        nextState.actionCardEvent = new ActionCardEvent();
                        nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;
                        nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.RentMultiColor;
                        nextState.actionCardEvent.doubleTheRentCardUsed = false;

                        //Double the rent card is being used
                        if (moveInformation.isDoubleTheRentCardBeingUsed == true)
                        {
                            ActionCard cardDoubleTheRentPlayed = removeCardFromHand(nextState.deck.getCardByID(moveInformation.idOfDoubleTheRentCardBeingUsed), playerModelForPlayer) as ActionCard;
                            if (cardDoubleTheRentPlayed != null && cardDoubleTheRentPlayed.actionType.CompareTo(ActionCardAction.DoubleTheRent) == 0)
                            {
                                //Check if the player has not played more than one card on turn so far
                                if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_0_Cards_Played) == 0 || currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played) == 0)
                                {
                                    rentValue *= 2;
                                    nextState.actionCardEvent.doubleTheRentCardUsed = true;
                                }
                                else
                                {
                                    return new BoolResponseBox(false, "Can not use double the rent card as you do not have enough card plays left in your turn");
                                }
                            }
                            else
                            {
                                //Card is not in hand
                                return new BoolResponseBox(false, "Double the rent card selected is not in players hand");
                            }
                        }

                        //Do action
                        playerModelForPlayerToRent.owesAnotherPlayer = true;
                        playerModelForPlayerToRent.amountOwedToAnotherPlayer = rentValue;

                        //Change state on success
                        //has been performed, advance the phase of the game
                        nextState.currentPhase = nextStatePhase;
                        //Put card in discard pile
                        nextState.playpile.playCardOnPile(actionCard);
                        List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                        List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                        onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                        updateAllowableStatesDebtPaid(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnInDebt(new List<TurnActionTypes>(), nextState));

                        //change the current state to the next state
                        addNextState(nextState);
                        return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Wild Rent Card");
                    }
                }

                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card is not in hand or is not a Wild Rent card");
        }
        private bool CheckTeamSwitch(String name, int toTeam)
        {
            if (fPluginState != PluginState.Active || fGameState != GameState.Playing) return false;

            // Get model
            PlayerModel player = GetPlayer(name);
            if (player == null) return false;
            bool bogusMove = false;
            int lastMoveTo = 0;
            int lastMoveFrom = player.LastMoveFrom;

            // Same team?
            if (toTeam == player.Team) {
            /*
            This could happen with the following sequence of actions:
            + Player died and was moved from 1 to 2 for balance immediately, spawn messages set
            + While still dead, player switches himself back to 1 before respawning
            + All of this happens before a listPlayers refresh, so the model still thinks he is in team 1
            We have to detect that the switch is not to the intended team and fix everything up.
            */
            if (player.LastMoveTo != 0 && player.LastMoveTo != toTeam) {
            DebugUnswitch("Player team switch: ^b" + name + "^n trying to switch to " + GetTeamName(toTeam) + " during a plugin move to " + GetTeamName(player.LastMoveTo));
            bogusMove = true;
            lastMoveTo = player.LastMoveTo;
            player.LastMoveTo = 0;
            DebugUnswitch("Ovewriting previous chat message for ^b" + name + "^n: " + player.SpawnChatMessage);
            player.SpawnChatMessage = String.Empty;
            player.SpawnYellMessage = String.Empty;
            } else {
            DebugUnswitch("Player team switch: ^b" + name + "^n, player model already updated to " + GetTeamName(toTeam) + " team");
            return true;
            }
            } else {
            DebugUnswitch("Player team switch: ^b" + name + "^n from " + GetTeamName(player.Team) + " team to " + GetTeamName(toTeam) + " team");
            }

            // Check if move already in progress for this player and abort it
            bool sendAbortMessage = false;
            lock (fMoveStash) {
            if (fMoveStash.Count > 0) {
             // list only ever has one item
            if (fMoveStash[0].Name == name) {
                fMoveStash.Clear();
            }
            }
            }
            if (sendAbortMessage) {
            DebugUnswitch("ABORTED (by move stash): abort previous move by ^b" + name);
            sendAbortMessage = false;
            }

            // Whitelisted?
            if (OnWhitelist) {
            if (CheckWhitelist(player, WL_SWITCH)) {
            DebugUnswitch("ALLOWED: On whitelist: ^b" + name);
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }
            }

            // Check forbidden cases
            PerModeSettings perMode = GetPerModeSettings();
            bool isSQDM = IsSQDM();
            bool isDispersal = IsDispersal(player, false);
            bool isRank = IsRankDispersal(player);
            bool forbidden = (((isDispersal || isRank) && Forbid(perMode, ForbidSwitchingAfterDispersal)) || (player.MovesByMBRound > 0 && !isSQDM && Forbid(perMode, ForbidSwitchingAfterAutobalance)));

            // Unlimited time?
            if (!forbidden && UnlimitedTeamSwitchingDuringFirstMinutesOfRound > 0 && GetTimeInRoundMinutes() < UnlimitedTeamSwitchingDuringFirstMinutesOfRound) {
            DebugUnswitch("ALLOWED: Time in round " + GetTimeInRoundMinutes().ToString("F0") + " < " + UnlimitedTeamSwitchingDuringFirstMinutesOfRound.ToString("F0"));
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }

            // Helps?
            int diff = 0;
            int biggestTeam = 0;
            int smallestTeam = 0;
            int winningTeam = 0;
            int losingTeam = 0;
            int[] ascendingSize = null;
            int[] descendingTickets = null;
            int fromTeam = player.Team;
            MoveInfo move = null;
            bool toLosing = false;
            bool toSmallest = false;

            /*
            A player that was previously moved by the plugin is forbidden from moving to any
            other team by their own initiative for the rest of the round, unless this is
            SQDM mode. In SQDM, if a player is moved from A to B and then later decides
            to move to C, the losing team, that is allowed. Even in SQDM, though, no player
            is allowed to move to the winning team.

            All dispersal players are forbidden from moving themselves.
            */

            AnalyzeTeams(out diff, out ascendingSize, out descendingTickets, out biggestTeam, out smallestTeam, out winningTeam, out losingTeam);

            int iFrom = 0;
            int iTo = 0;

            if (isSQDM) {
            // Moving to any team with fewer tickets is encouraged
            for (int i = 0; i < descendingTickets.Length; ++i) {
            if (fromTeam == descendingTickets[i]) iFrom = i;
            if (toTeam == descendingTickets[i]) iTo = i;
            }
            toLosing = (iTo > iFrom);
            } else {
            toLosing = (toTeam == losingTeam);
            }

            // Trying to switch to losing team?
            if (!forbidden && toLosing && toTeam != biggestTeam) {
            move = new MoveInfo(player.Name, player.Tag, fromTeam, GetTeamName(fromTeam), toTeam, GetTeamName(toTeam));
            move.Format(this, ChatDetectedGoodTeamSwitch, false, true);
            move.Format(this, YellDetectedGoodTeamSwitch, true, true);
            DebugUnswitch("ALLOWED: Team switch to losing team ^b: " + name);
            SetSpawnMessages(name, move.ChatBefore, move.YellBefore, false);
            CheckAbortMove(name);
            return true;
            }

            if (isSQDM) {
            // Moving to any team with fewer players is encouraged
            for (int i = 0; i < ascendingSize.Length; ++i) {
            if (fromTeam == ascendingSize[i]) iFrom = i;
            if (toTeam == ascendingSize[i]) iTo = i;
            }
            toSmallest = (iTo < iFrom);
            } else {
            toSmallest = (toTeam == smallestTeam);
            }

            // Trying to switch to smallest team?
            if (!forbidden && toSmallest && toTeam != winningTeam) {
            move = new MoveInfo(player.Name, player.Tag, fromTeam, GetTeamName(fromTeam), toTeam, GetTeamName(toTeam));
            move.Format(this, ChatDetectedGoodTeamSwitch, false, true);
            move.Format(this, YellDetectedGoodTeamSwitch, true, true);
            DebugUnswitch("ALLOWED: Team switch to smallest team ^b: " + name);
            SetSpawnMessages(name, move.ChatBefore, move.YellBefore, false);
            CheckAbortMove(name);
            return true;
            }

            // Adjust for SQDM
            if (isSQDM && fServerInfo != null) {
            if (GetPopulation(perMode, true) == Population.Low) {
            // Allow team switch to any team except biggest and winning
            if (!forbidden && toTeam != biggestTeam && toTeam != winningTeam) {
                DebugUnswitch("ALLOWED: SQDM Low population and not switching to biggest or winning team: ^b" + name);
                SetSpawnMessages(name, String.Empty, String.Empty, false);
                CheckAbortMove(name);
                return true;
            }
            }
            }

            // Allow if ticket/point difference is less than allowed margin
            double win = 0;
            double lose = 0;
            double margin = 100;
            if (IsCTF()) {
            win = GetTeamPoints(winningTeam);
            if (win == 0) win = 1;
            lose = GetTeamPoints(losingTeam);
            if (lose == 0) lose = 1;
            margin = ((win > lose) ? win/lose : lose/win);
            // margin is 110%
            if (!forbidden && (margin * 100) <= 110) {
            DebugUnswitch("ALLOWED: CTF move by ^b" + name + "^n because margin is only " + (margin*100).ToString("F0") + "%");
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }
            } else {
            win = fTickets[winningTeam];
            if (win == 0) win = 1;
            lose = fTickets[losingTeam];
            if (lose == 0) lose = 1;
            margin = ((win > lose) ? win/lose : lose/win);
            // margin is 105%
            if (!forbidden && (margin * 100) <= 105) {
            DebugUnswitch("ALLOWED: move by ^b" + name + "^n because margin is only " + (margin*100).ToString("F0") + "%");
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }
            }

            // Otherwise, do not allow the team switch
            int origTeam = player.Team;
            String origName = GetTeamName(player.Team);

            if (lastMoveFrom != 0 && toTeam != lastMoveFrom) {
            DebugUnswitch("Setting toTeam from " + GetTeamName(toTeam) + " to original LastMoveFrom = " + GetTeamName(lastMoveFrom));
            toTeam = lastMoveFrom;
            }

            if (bogusMove) {
            origTeam = lastMoveTo;
            origName = GetTeamName(lastMoveTo);
            }

            // select forbidden message from: moved by autobalance, moved to unstack, dispersal, ...
            String badChat = ChatDetectedBadTeamSwitch;
            String badYell = YellDetectedBadTeamSwitch;

            ForbidBecause why = ForbidBecause.None;

            if (player.MovesByMBRound > 0 && !isSQDM) {
            why = ForbidBecause.MovedByBalancer;
            if (!Forbid(perMode, ForbidSwitchingAfterAutobalance)) {
            DebugUnswitch("ALLOWED: move by ^b" + name + "^n because ^bForbid Switch After Autobalance^n is False");
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }
            } else if (toTeam == winningTeam) {
            why = ForbidBecause.ToWinning;
            if (!Forbid(perMode, ForbidSwitchingToWinningTeam)) {
            DebugUnswitch("ALLOWED: move by ^b" + name + "^n because ^bForbid Switch To Winning Team^n is False");
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }
            } else if (toTeam == biggestTeam) {
            why = ForbidBecause.ToBiggest;
            if (!Forbid(perMode, ForbidSwitchingToBiggestTeam)) {
            DebugUnswitch("ALLOWED: move by ^b" + name + "^n because ^bForbid Switch To Biggest Team^n is False");
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }
            } else if (isDispersal) {
            why = ForbidBecause.DisperseByList;
            if (!Forbid(perMode, ForbidSwitchingAfterDispersal)) {
            DebugUnswitch("ALLOWED: move by ^b" + name + "^n because ^bForbid Switch After Dispersal^n is False");
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }
            } else if (isRank) {
            why = ForbidBecause.DisperseByRank;
            if (!Forbid(perMode, ForbidSwitchingAfterDispersal)) {
            DebugUnswitch("ALLOWED: move by ^b" + name + "^n because ^bForbid Switch After Dispersal^n is False");
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            CheckAbortMove(name);
            return true;
            }
            }

            if (toTeam == origTeam) {
            ConsoleDebug("CheckTeamSwitch: ^b" + name + "^n, can't forbid unswitch to same team " + GetTeamName(toTeam) + "?");
            return true;
            }

            // Tried to switch toTeam from origTeam, so moving from toTeam back to origTeam
            move = new MoveInfo(name, player.Tag, toTeam, GetTeamName(toTeam), origTeam, origName);
            move.For = MoveType.Unswitch;
            move.Because = why;
            move.Format(this, badChat, false, true);
            move.Format(this, badYell, true, true);
            move.Format(this, ChatAfterUnswitching, false, false);
            move.Format(this, YellAfterUnswitching, true, false);
            player.LastMoveFrom = 0;

            if (DebugLevel >= 8) DebugUnswitch(move.ToString());

            if (isSQDM || !EnableImmediateUnswitch) {
            // Delay action until after the player spawns
            DebugUnswitch("FORBIDDEN: delaying unswitch action until spawn of ^b" + name + "^n from " + move.SourceName + " back to " + move.DestinationName);

            if (player.DelayedMove != null) {
            CheckAbortMove(name);
            }
            player.DelayedMove = move;

            if (!String.IsNullOrEmpty(player.SpawnChatMessage)) {
            DebugUnswitch("IGNORED: previously delayed spawn message for ^b" + name + "^n: " + player.SpawnChatMessage);
            SetSpawnMessages(name, String.Empty, String.Empty, false);
            }
            } else {
            // Do the move immediately
            DebugUnswitch("FORBIDDEN: immediately unswitch ^b" + name + "^n from " + move.SourceName + " back to " + move.DestinationName);
            String log = "^4^bUNSWITCHING^n^0 ^b" + player.FullName + "^n from " + move.SourceName + " back to " + move.DestinationName;
            log = (EnableLoggingOnlyMode) ? "^9(SIMULATING)^0 " + log : log;
            DebugWrite(log, 3);
            StartMoveImmediate(move, true);
            }

            return false;
        }
Exemple #11
0
        private MoveInfo getMoveInfo(Piece piece, Point newCoordinates)
        {
            if (piece == null)
            {
                throw new ArgumentNullException();
            }
            if (newCoordinates == null)
            {
                throw new ArgumentNullException();
            }
            var rtnMove = new MoveInfo();

            if (newCoordinates.X >= Board.GRID_SIZE || newCoordinates.Y >= Board.GRID_SIZE ||
                newCoordinates.X < 0 || newCoordinates.Y < 0)
            {
                return(rtnMove);
            }

            int dX = newCoordinates.X - piece.Location.X,
                dY = newCoordinates.Y - piece.Location.Y;

            Board.Direction directionOfMove = Board.getMoveDirection(dY, dX);

            bool isJumpMove = Math.Abs(dX) == 2 && Math.Abs(dY) == 2;
            bool isMove     = Math.Abs(dX) == 1 && Math.Abs(dY) == 1;

            Tuple <Player, Piece> pieceInfo    = getPieceInfo(newCoordinates.X, newCoordinates.Y);
            Tuple <Player, Piece> oldPieceInfo = getPieceInfo(piece.Location.X, piece.Location.Y);

            if (pieceInfo == null)
            {
                if (isMove)
                {
                    if (oldPieceInfo.Item1.Color == Player.EnumColor.White)
                    {
                        if (piece.TypeOfPiece == Piece.PieceType.Man)
                        {
                            rtnMove.isValidMove = directionOfMove == Board.Direction.SE || directionOfMove == Board.Direction.SW;
                        }
                    }
                    else
                    {
                        if (piece.TypeOfPiece == Piece.PieceType.Man)
                        {
                            rtnMove.isValidMove = directionOfMove == Board.Direction.NE || directionOfMove == Board.Direction.NW;
                        }
                    }
                }
                else if (isJumpMove)
                {
                    bool validDirection = true;
                    if (oldPieceInfo.Item1.Color == Player.EnumColor.White)
                    {
                        if (piece.TypeOfPiece == Piece.PieceType.Man)
                        {
                            validDirection = directionOfMove == Board.Direction.SE || directionOfMove == Board.Direction.SW;
                        }
                    }
                    else
                    {
                        if (piece.TypeOfPiece == Piece.PieceType.Man)
                        {
                            validDirection = directionOfMove == Board.Direction.NE || directionOfMove == Board.Direction.NW;
                        }
                    }
                    if (validDirection)
                    {
                        Tuple <bool, Piece> validate = validateJumpMove(directionOfMove, oldPieceInfo, newCoordinates);
                        rtnMove.isValidJumpMove = validate.Item1;
                        rtnMove.JumpedPiece     = validate.Item2;
                    }
                }
            }
            return(rtnMove);
        }
Exemple #12
0
        /// <summary>
        /// Allows a player on their turn to play a Pass Go card
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="nextStatePhaseIfSuccessful"></param>
        /// <param name="passGoInfo"></param>
        /// <returns></returns>
        public BoolResponseBox playActionCardPassGo(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhaseIfSuccessful, MoveInfo passGoInfo)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);

            Card cardInHandToBePlayed = nextState.deck.getCardByID(passGoInfo.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            PlayerModel player = getPlayerModel(passGoInfo.playerMakingMove, nextState);
            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.PassGo) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, player);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    player.hand.addCardToHand(nextState.drawPile.drawcard());
                    player.hand.addCardToHand(nextState.drawPile.drawcard());
                    //Change state on success
                    //has been performed, advance the phase of the game
                    nextState.currentPhase = nextStatePhaseIfSuccessful;
                    //Put card in discard pile
                    nextState.playpile.playCardOnPile(card);
                    List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                    List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                    onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                    updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                    //change the current state to the next state
                    addNextState(nextState);
                    return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has passed go and drawn 2 cards");
                }
                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card is not in hand or is not a pass go card");
        }
Exemple #13
0
        /// <summary>
        /// Plays a Property Card from a Players Hand on their turn to a new Property Set
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="notJustSayNoAble"></param>
        /// <returns></returns>
        private BoolResponseBox playPropertyCardFromHandToNewSet(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase notJustSayNoAble)
        {
            //Clone the current state to create next state
            nextState = currentState.clone(generateGuidForNextState());
            //Get CurrentPlayFieldModelState
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            PlayerModel player = getPlayerModel(playerPerformingAction.guid, nextState);
            Card card = removeCardFromHand(cardInHandToBePlayed, player);
            if (card != null)
            {
                PropertyCard cP = cardInHandToBePlayed as PropertyCard;
                cP.setPropertyColor(moveInformation.isPropertyToPlayOrientedUp);
                PropertyCardSet ps = new PropertyCardSet(cP);

                player.propertySets.addSet(ps);
                //Change state on success
                //has been performed, advance the phase of the game
                nextState.currentPhase = notJustSayNoAble;
                List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                //change the current state to the next state
                addNextState(nextState);
                return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has played to a new set " + card.cardName);
            }
            return new BoolResponseBox(false, "Card is not in hand.");
        }
Exemple #14
0
 public ZMove(MoveInfo Info, Move BaseMove) : base(Info)
 {
     this.BaseMove = BaseMove;
 }
Exemple #15
0
 private void linkEntities(Move move, MoveInfo info)
 {
     move.Category = GetCategory(info.CategoryName);
     move.Out      = GetAccount(info.OutUrl);
     move.In       = GetAccount(info.InUrl);
 }
Exemple #16
0
 public void MoveBeingPlayedHandler(MoveInfo move)
 {
     gameHistoryPrivs[Game.GameMoveNumber] = searchStackPrivs[1];
     searchStackPrivs[0] = searchStackPrivs[1];
 }
Exemple #17
0
 public override void resolveFromMove(MoveInfo move)
 {
     passInTileCustom(Owner.board.Grid[move.targetTilePos.x, move.targetTilePos.y]);
 }
        // *** OPERATIONS *** //

        public void MovePlayed(MoveInfo moveInfo)
        {
            UpdateUnmatchedPieceLists();
            Invalidate();
        }
        public override void MoveBeingUnmade(MoveInfo move, int ply)
        {
            //	This function exactly reverses the operations performed
            //	in MoveBeingMade when the move was first made.

            // *** OPENING PROGRESS *** //

            //	a castling move advanced the count by 3
            if (move.MoveType == MoveType.Castling)
            {
                OpeningProgress -= 3;
            }
            //	any capture advanced the count by 2
            else if (move.MoveType == MoveType.StandardCapture)
            {
                OpeningProgress -= 2;
            }
            //	the first (non-capture) move of any piece advanced the count 1
            else if (move.PieceMoved != null && move.PieceMoved.MoveCount == 1)
            {
                OpeningProgress--;
            }
            else
            {
                //	the only other way we would have advanced the counter by 1 is
                //	if the moving piece is a standard pawn (can't move backwards)
                //	and the move took it to a rank farther than it could have
                //	moved on its first move.
                if (move.PieceMoved != null && move.PieceMoved.TypeNumber == PawnPieceType &&
                    game.Board.GetRank(game.Board.PlayerSquare(move.Player, move.ToSquare)) > PawnMaxRankFirstMove)
                {
                    OpeningProgress--;
                }
            }

            // *** EVALUATION ADJUSTMENT *** //

            //	castling is worth a significant bonus
            if (move.MoveType == MoveType.Castling)
            {
                EvalAdjustment[move.Player] -= CastlingBonus;
            }
            else
            {
                //	The first move of a piece may be given a penalty
                if (move.PieceMoved != null && move.PieceMoved.MoveCount == 1)
                {
                    //	Moving a major piece in the opening is penalized
                    if (move.PieceMoved != null && move.PieceMoved.PieceType.MidgameValue > HeavyPieceThreshold + 25)
                    {
                        int adj = (int)Math.Log(move.PieceMoved.PieceType.MidgameValue - HeavyPieceThreshold, 1.03) - MajorPieceInOpeningPenalty;
                        EvalAdjustment[move.Player] += adj;
                    }
                    //	Pushing an edge pawn is penalized
                    else if (move.PieceMoved != null && move.PieceMoved.PieceType.MidgameValue < 150 &&
                             (board.GetFile(move.FromSquare) == 0 ||
                              board.GetFile(move.FromSquare) == board.NumFiles - 1))
                    {
                        EvalAdjustment[move.Player] += EdgePawnPenalty;
                    }
                }
                //	Moving a piece twice is penalized
                else if (move.MoveType == MoveType.StandardMove)
                {
                    if (move.PieceMoved.PieceType.MidgameValue > 150)
                    {
                        EvalAdjustment[move.Player] += MovePieceTwicePenalty;
                    }
                    else
                    {
                        EvalAdjustment[move.Player] += 10;
                    }
                }
                //	Moving a king in a non-castling move is penalized
                //	if this game has a castling rule
                else if (move.PieceMoved != null && move.PieceMoved.PieceType.MidgameValue == 0 && CastlingRule != null)
                {
                    EvalAdjustment[move.Player] += LossOfCastlingPenalty;
                }
            }
        }
        public override void MoveBeingMade(MoveInfo move, int ply)
        {
            // *** OPENING PROGRESS *** //

            //	The purpose of this is to advance the OpeningProgress
            //	appropriately for the given move.  The OpeningProgress is
            //	the measure by which we estimate how far we've come
            //	from beginning of game, through opening, and into midgame.
            //	This way we can phase out the development adjustments.

            //	a castling move advances the count by 3
            if (move.MoveType == MoveType.Castling)
            {
                OpeningProgress += 3;
            }
            //	any capture advances the count by 2
            else if (move.MoveType == MoveType.StandardCapture)
            {
                OpeningProgress += 2;
            }
            //	the first (non-capture) move of any piece advances the count 1
            else if (move.PieceMoved != null && move.PieceMoved.MoveCount == 1)
            {
                OpeningProgress++;
            }
            else
            {
                //	the only other way we will advance the counter by 1 is if
                //	the moving piece is a standard pawn (can't move backwards)
                //	and the move takes it to a rank farther than it could have
                //	moved on its first move.
                if (move.PieceMoved != null && move.PieceMoved.TypeNumber == PawnPieceType &&
                    game.Board.GetRank(game.Board.PlayerSquare(move.Player, move.ToSquare)) > PawnMaxRankFirstMove)
                {
                    OpeningProgress++;
                }
            }

            // *** EVALUATION ADJUSTMENT *** //

            //	castling is worth a significant bonus
            if (move.MoveType == MoveType.Castling)
            {
                EvalAdjustment[move.Player] += CastlingBonus;
            }
            else
            {
                //	The first move of a piece may be given a penalty
                if (move.PieceMoved != null && move.PieceMoved.MoveCount == 1)
                {
                    //	Moving a major piece in the opening is penalized
                    if (move.PieceMoved != null && move.PieceMoved.PieceType.MidgameValue > HeavyPieceThreshold + 25)
                    {
                        int adj = (int)Math.Log(move.PieceMoved.PieceType.MidgameValue - HeavyPieceThreshold, 1.03) - MajorPieceInOpeningPenalty;
                        EvalAdjustment[move.Player] -= adj;
                    }
                    //	Pushing an edge pawn is penalized
                    else if (move.PieceMoved != null && move.PieceMoved.PieceType.MidgameValue < 150 &&
                             (board.GetFile(move.FromSquare) <= LeftPawnPenaltyFile ||
                              board.GetFile(move.FromSquare) >= RightPawnPenaltyFile))
                    {
                        EvalAdjustment[move.Player] -= EdgePawnPenalty;
                    }
                }
                //	Moving a piece twice is penalized
                else if (move.MoveType == MoveType.StandardMove)
                {
                    if (move.PieceMoved.PieceType.MidgameValue > 150)
                    {
                        EvalAdjustment[move.Player] -= MovePieceTwicePenalty;
                    }
                    else
                    {
                        EvalAdjustment[move.Player] -= 10;
                    }
                }
                //	Moving a king in a non-castling move is penalized
                //	if this game has a castling rule
                else if (move.PieceMoved != null && move.PieceMoved.PieceType.MidgameValue == 0 && CastlingRule != null)
                {
                    EvalAdjustment[move.Player] -= LossOfCastlingPenalty;
                }
            }
        }
Exemple #21
0
        /// <summary>
        /// Allows a player on their turn to Play A Debt Collector Action Card
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="nextStatePhaseIfSuccessful"></param>
        /// <param name="debtCollectorInfo"></param>
        /// <returns></returns>
        private BoolResponseBox playActionCardDebtCollector(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhaseIfSuccessful, MoveInfo debtCollectorInfo)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);
            PlayerModel playerModelForPlayerToDebtCollect = getPlayerModel(debtCollectorInfo.guidOfPlayerBeingDebtCollected, nextState);
            Card cardInHandToBePlayed = nextState.deck.getCardByID(debtCollectorInfo.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.DebtCollector) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    //Do action
                    playerModelForPlayerToDebtCollect.owesAnotherPlayer = true;
                    playerModelForPlayerToDebtCollect.amountOwedToAnotherPlayer = ActionCard.Debt_Collector_Value;

                    //Change state on success
                    //has been performed, advance the phase of the game
                    nextState.currentPhase = nextStatePhaseIfSuccessful;
                    //Put card in discard pile
                    nextState.playpile.playCardOnPile(actionCard);
                    List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                    List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                    onTurn = setAllowableActionsOnTurn(onTurn, nextState);
                    updateAllowableStatesDebtPaid(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnInDebt(new List<TurnActionTypes>(), nextState));

                    nextState.actionCardEvent = new ActionCardEvent();
                    nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;
                    nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.DebtCollector;
                    //change the current state to the next state
                    addNextState(nextState);
                    return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Debt Collector");
                }

                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card is not in hand or is not a Debt Collector card");
        }
Exemple #22
0
        /// <summary>
        /// Allows a Player to discard one card from their Hand when they have finished thier turn with more than the max allowable cards in hand
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="notJustSayNoAble"></param>
        /// <returns></returns>
        private BoolResponseBox discard1Card(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase notJustSayNoAble)
        {
            //Clone the current state to create next state then draws two cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            Card cardInHandToBeDiscarded = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel
            PlayerModel playerWhoIsDiscardingCard = getPlayerModel(playerPerformingAction.guid, nextState);
            //Get the reference to the Card in the current PlayFieldModel

            Card card = removeCardFromHand(cardInHandToBeDiscarded, playerWhoIsDiscardingCard);
            if (card != null)
            {
                nextState.drawPile.discardCard(card);

                //action is valid for player at this time
                List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                //Could perform the action here instead, for now just change the phase of the state
                //Not an action so cant be just say no'd
                //Change phase
                switch (playerWhoIsDiscardingCard.hand.cardsInHand.Count)
                {
                    case 8:
                        {
                            nextState.currentPhase = Statephase.Turn_Ended_8_Cards_In_Hand_Discard_1_Card;
                            onTurn.Add(TurnActionTypes.Discard_1_Card);
                            //Update the moves for players
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 8 cards and must discard 1 card");
                        }
                    case 9:
                        {
                            nextState.currentPhase = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                            onTurn.Add(TurnActionTypes.Discard_1_Card);
                            //Update the moves for players
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 9 cards and must discard 2 cards");
                        }
                    case 10:
                        {
                            nextState.currentPhase = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                            onTurn.Add(TurnActionTypes.Discard_1_Card);
                            //Update the moves for players
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 10 cards and must discard 3 cards");
                        }
                    case 11:
                        {
                            nextState.currentPhase = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                            onTurn.Add(TurnActionTypes.Discard_1_Card);
                            //Update the moves for players
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 11 cards and must discard 4 cards");
                        }
                    case 12:
                        {
                            nextState.currentPhase = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                            onTurn.Add(TurnActionTypes.Discard_1_Card);
                            //Update the moves for players
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 12 cards and must discard 5 cards");
                        }
                    default:
                        {
                            nextState.currentPhase = Statephase.Turn_Ended_7_Or_Less_Cards_In_Hand_Setup_NextPlayer;
                            setNextPlayerOnTurn(nextState);
                            if (getPlayerModel(nextState.guidOfPlayerWhosTurnItIs, nextState).hand.cardsInHand.Count == 0)
                            {
                                //Player has 0 cards draws 5 on turn start instead of 2
                                nextState.currentPhase = Statephase.Turn_Started_Draw_5_Cards;
                                onTurn.Add(TurnActionTypes.drawFiveCardsAtStartOfTurn);
                                //Update the moves for players
                                updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                                //change the current state to the next state
                                addNextState(nextState);
                                return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn." + "Player:" + getPlayerModel(nextState.guidOfPlayerWhosTurnItIs, nextState).name + "\'s Turn. Draw 5 Cards.");
                            }
                            else
                            {
                                //Player has at least one and at most seven cards, draws 2
                                nextState.currentPhase = Statephase.Turn_Started_Draw_2_Cards;
                                onTurn.Add(TurnActionTypes.drawTwoCardsAtStartOfTurn);
                                //Update the moves for players
                                updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                                //change the current state to the next state
                                addNextState(nextState);
                                return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn." + "Player:" + getPlayerModel(nextState.guidOfPlayerWhosTurnItIs, nextState).name + "\'s Turn. Draw 2 Cards.");
                            }
                        }
                }
            }
            else
            {
                //Card not in players hand, can't be discarded
                return new BoolResponseBox(false, "Card not in hand");
            }
        }
        void MoveBeingPlayedHandler(MoveInfo move)
        {
            UInt64 hash = Game.GetPositionHashCode(2);

            gameHistoryHashes[Game.GameMoveNumber] = hash;
        }
Exemple #24
0
        /// <summary>
        /// Moves a property card that has been played to a set to a new set
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="rearrangeProperties"></param>
        /// <returns></returns>
        private BoolResponseBox movePropertyCard(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase rearrangeProperties)
        {
            //Clone the current state to create next state
            nextState = currentState.clone(generateGuidForNextState());

            PropertyColor oldColour = ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).getPropertyColor();
            bool oldOrientation = ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).isCardUp;
            ((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).setPropertyColor(moveInformation.isPropertyToMoveOrientedUp);

            if (moveInformation.addPropertyToMoveToExistingSet == false || getPropertyCardSet(getPlayerModel(playerPerformingAction.guid, nextState).propertySets, moveInformation.guidOfExistingSetToMovePropertyTo).isPropertyCompatible((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)))
            {
                //Get CurrentPlayFieldModelState
                PropertyCard propertyCardToMove = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed) as PropertyCard;
                PlayerModel player = getPlayerModel(playerPerformingAction.guid, nextState);
                //Remove Property Card from it's current set.
                PropertyCard property = player.removePropertyCardFromPlayersPropertySet(propertyCardToMove, moveInformation.guidOfSetPropertyToMoveIsIn);
                if (property != null)
                {
                    PropertyCard cP = propertyCardToMove;
                    bool propertyAdded = false;
                    cP.setPropertyColor(moveInformation.isPropertyToPlayOrientedUp);
                    PropertyCardSet ps = getPropertyCardSet(player.propertySets, moveInformation.guidOfExistingSetToMovePropertyTo);
                    if (moveInformation.addPropertyToMoveToExistingSet == false)
                    {
                        player.propertySets.addSet(new PropertyCardSet(cP));
                    }
                    else if (ps == null)
                    {
                        //card was intended to be played to an existing set
                        return new BoolResponseBox(false, "Property not moved. Selected set does not exist");
                    }
                    else if (ps != null)
                    {
                        propertyAdded = ps.addProperty(cP);
                    }
                    if (propertyAdded == false)
                    {
                        return new BoolResponseBox(false, "Property Card not played. Set full or card incompatible.");
                    }
                    //Change state on success
                    //has been performed, advance the phase of the game
                    nextState.currentPhase = rearrangeProperties;
                    List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                    List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                    onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                    updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                    //change the current state to the next state
                    addNextState(nextState);
                    return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has moved a Property to a existing set " + propertyCardToMove.cardName);
                }
                return new BoolResponseBox(false, "Card is not in set.");
            }
            else
            {
                nextState = null;
                ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).setPropertyColor(oldOrientation);//change back the orientation of the property
                return new BoolResponseBox(false, "Property Card is not the correct colour to be added to this set");
            }
        }
Exemple #25
0
 protected virtual void OnHit(HitBox strokeHitBox, MoveInfo move, CharacterInfo player)
 {
     // player.playerNum = 1 or 2
     // You can use this to have your own custom events when a character gets hit
 }
Exemple #26
0
        private BoolResponseBox doNotPlayJustSayNo(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase justSayNoAble, Statephase notJustSayNoAble)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());

            //Player Not using Just Say No
            PlayerModel playerModelForNotUsingJustSayNo = getPlayerModel(moveInformation.playerMakingMove, nextState);

            //Player no longer can Just Say no
            playerModelForNotUsingJustSayNo.hasHadCardsTaken = false;

            //Change state on success
            //has been performed, advance the phase of the game
            Statephase nextStatePhaseIfSuccessful;
            nextStatePhaseIfSuccessful = notJustSayNoAble;
            nextState.currentPhase = nextStatePhaseIfSuccessful;

            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
            onTurn = setAllowableActionsOnTurn(onTurn, nextState);

            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);

            //change the current state to the next state
            addNextState(nextState);
            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has chosen to not use a Just Say No!");
        }
Exemple #27
0
 protected virtual void OnBlock(HitBox strokeHitBox, MoveInfo move, CharacterInfo player)
 {
     // You can use this to have your own custom events when a player blocks.
     // player.playerNum = 1 or 2
     // player = character blocking
 }
        /* ======================== CORE ENGINE ============================= */
        private void BalanceAndUnstack(String name)
        {
            /* Useful variables */

            PlayerModel player = null;
            String simpleMode = String.Empty;
            PerModeSettings perMode = null;
            bool isStrong = false; // this player
            int winningTeam = 0;
            int losingTeam = 0;
            int biggestTeam = 0;
            int smallestTeam = 0;
            int[] ascendingSize = null;
            int[] descendingTickets = null;
            String strongMsg = String.Empty;
            int diff = 0;
            DateTime now = DateTime.Now;
            bool needsBalancing = false;
            bool loggedStats = false;
            bool isSQDM = IsSQDM();
            String log = String.Empty;

            /* Sanity checks */

            if (fServerInfo == null) {
            return;
            }

            int totalPlayerCount = this.TotalPlayerCount;

            if (DebugLevel >= 8) DebugBalance("BalanceAndUnstack(^b" + name + "^n), " + totalPlayerCount + " players");

            if (totalPlayerCount >= (MaximumServerSize-1)) {
            if (DebugLevel >= 6) DebugBalance("Server is full, no balancing or unstacking will be attempted!");
            IncrementTotal(); // no matching stat, reflect total deaths handled
            CheckDeativateBalancer("Full");
            return;
            }

            int floorPlayers = 6;
            if (totalPlayerCount < floorPlayers) {
            if (DebugLevel >= 6) DebugBalance("Not enough players in server, minimum is " + floorPlayers);
            CheckDeativateBalancer("Not enough players");
            return;
            }

            if (totalPlayerCount > 0) {
            AnalyzeTeams(out diff, out ascendingSize, out descendingTickets, out biggestTeam, out smallestTeam, out winningTeam, out losingTeam);
            } else {
            CheckDeativateBalancer("Empty");
            return;
            }

            /* Pre-conditions */

            player = GetPlayer(name);
            if (player == null) {
            CheckDeativateBalancer("Unknown player " + name);
            return;
            }

            if (!fModeToSimple.TryGetValue(fServerInfo.GameMode, out simpleMode)) {
            DebugBalance("Unknown game mode: " + fServerInfo.GameMode);
            simpleMode = fServerInfo.GameMode;
            }
            if (String.IsNullOrEmpty(simpleMode)) {
            DebugBalance("Simple mode is null: " + fServerInfo.GameMode);
            CheckDeativateBalancer("Unknown mode");
            return;
            }
            if (!fPerMode.TryGetValue(simpleMode, out perMode)) {
            DebugBalance("No per-mode settings for " + simpleMode + ", using defaults");
            perMode = new PerModeSettings();
            }
            if (perMode == null) {
            DebugBalance("Per-mode settings null for " + simpleMode + ", using defaults");
            perMode = new PerModeSettings();
            }

            /* Per-mode and player info */

            String extractedTag = ExtractTag(player);
            Speed balanceSpeed = GetBalanceSpeed(perMode);
            double unstackTicketRatio = GetUnstackTicketRatio(perMode);
            int lastMoveFrom = player.LastMoveFrom;

            if (totalPlayerCount >= (perMode.MaxPlayers-1)) {
            if (DebugLevel >= 6) DebugBalance("Server is full by per-mode Max Players, no balancing or unstacking will be attempted!");
            IncrementTotal(); // no matching stat, reflect total deaths handled
            CheckDeativateBalancer("Full per-mode");
            return;
            }

            /* Check dispersals */

            bool mustMove = false;
            bool lenient = false;
            int maxDispersalMoves = 2;
            bool isDisperseByRank = IsRankDispersal(player);
            bool isDisperseByList = IsDispersal(player, false);
            if (isDisperseByList) {
            String dispersalMode = (lenient) ? "LENIENT MODE" : "STRICT MODE";
            DebugBalance("ON MUST MOVE LIST ^b" + player.FullName + "^n T:" + player.Team + ", disperse evenly enabled, " + dispersalMode);
            mustMove = true;
            lenient = !perMode.EnableStrictDispersal; // the opposite of strict is lenient
            maxDispersalMoves = (lenient) ? 1 : 2;
            } else if (isDisperseByRank) {
            DebugBalance("ON MUST MOVE LIST ^b" + name + "^n T:" + player.Team + ", Rank " + player.Rank + " >= " + perMode.DisperseEvenlyByRank);
            mustMove = true;
            lenient = LenientRankDispersal;
            maxDispersalMoves = (lenient) ? 1 : 2;
            }

            /* Check if balancing is needed */

            if (diff > MaxDiff()) {
            needsBalancing = true; // needs balancing set to true, unless speed is Unstack only
            if (balanceSpeed == Speed.Unstack) {
            DebugBalance("Needs balancing, but balance speed is set to Unstack, so no balancing will be done");
            needsBalancing = false;
            }
            }

            /* Per-mode settings */

            // Adjust for duration of balance active
            if (needsBalancing && fBalanceIsActive && balanceSpeed == Speed.Adaptive && fLastBalancedTimestamp != DateTime.MinValue) {
            double secs = now.Subtract(fLastBalancedTimestamp).TotalSeconds;
            if (secs > SecondsUntilAdaptiveSpeedBecomesFast) {
            DebugBalance("^8^bBalancing taking too long (" + secs.ToString("F0") + " secs)!^n^0 Forcing to Fast balance speed.");
            balanceSpeed = Speed.Fast;
            }
            }
            String orSlow = (balanceSpeed == Speed.Slow) ? " or speed is Slow" : String.Empty;

            // Do not disperse mustMove players if speed is Stop or Phase is Late
            if (mustMove && balanceSpeed == Speed.Stop) {
            DebugBalance("Removing MUST MOVE status from dispersal player ^b" + player.FullName + "^n T:" + player.Team + ", due to Balance Speed = Stop");
            mustMove = false;
            } else if (mustMove && GetPhase(perMode, false) == Phase.Late) {
            DebugBalance("Removing MUST MOVE status from dispersal player ^b" + player.FullName + "^n T:" + player.Team + ", due to Phase = Late");
            mustMove = false;
            }

            /* Activation check */

            if (balanceSpeed != Speed.Stop && needsBalancing) {
            if (!fBalanceIsActive) {
            DebugBalance("^2^bActivating autobalance!");
            fLastBalancedTimestamp = now;
            }
            fBalanceIsActive = true;
            } else {
            CheckDeativateBalancer("Deactiving autobalance");
            }

            // Wait for unassigned
            if (!mustMove && needsBalancing && balanceSpeed != Speed.Fast && (diff > MaxDiff()) && fUnassigned.Count >= (diff - MaxDiff())) {
            DebugBalance("Wait for " + fUnassigned.Count + " unassigned players to be assigned before moving active players");
            IncrementTotal(); // no matching stat, reflect total deaths handled
            return;
            }

            /* Exclusions */

            // Exclude if on Whitelist or Reserved Slots if enabled
            if (OnWhitelist || (needsBalancing && balanceSpeed == Speed.Slow)) {
            if (CheckWhitelist(player, WL_BALANCE)) {
            DebugBalance("Excluding ^b" + player.FullName + "^n: whitelisted" + orSlow);
            fExcludedRound = fExcludedRound + 1;
            IncrementTotal();
            return;
            }
            }

            // Sort player's team by the strong method
            List<PlayerModel> fromList = GetTeam(player.Team);
            if (fromList == null) {
            DebugBalance("Unknown team " + player.Team + " for player ^b" + player.Name);
            return;
            }
            switch (perMode.DetermineStrongPlayersBy) {
            case DefineStrong.RoundScore:
            fromList.Sort(DescendingRoundScore);
            strongMsg = "Determing strong by: Round Score";
            break;
            case DefineStrong.RoundSPM:
            fromList.Sort(DescendingRoundSPM);
            strongMsg = "Determing strong by: Round SPM";
            break;
            case DefineStrong.RoundKills:
            fromList.Sort(DescendingRoundKills);
            strongMsg = "Determing strong by: Round Kills";
            break;
            case DefineStrong.RoundKDR:
            fromList.Sort(DescendingRoundKDR);
            strongMsg = "Determing strong by: Round KDR";
            break;
            case DefineStrong.PlayerRank:
            fromList.Sort(DescendingPlayerRank);
            strongMsg = "Determing strong by: Player Rank";
            break;
            case DefineStrong.RoundKPM:
            fromList.Sort(DescendingRoundKPM);
            strongMsg = "Determing strong by: Round KPM";
            break;
            case DefineStrong.BattlelogSPM:
            fromList.Sort(DescendingSPM);
            strongMsg = "Determing strong by: Battlelog SPM";
            break;
            case DefineStrong.BattlelogKDR:
            fromList.Sort(DescendingKDR);
            strongMsg = "Determing strong by: Battlelog KDR";
            break;
            case DefineStrong.BattlelogKPM:
            fromList.Sort(DescendingKPM);
            strongMsg = "Determing strong by: Battlelog KPM";
            break;
            default:
            fromList.Sort(DescendingRoundScore);
            strongMsg = "Determing strong by: Round Score";
            break;
            }

            double above = ((fromList.Count * perMode.PercentOfTopOfTeamIsStrong) / 100.0) + 0.5;
            int strongest = Math.Max(0, Convert.ToInt32(above));
            int playerIndex = 0;
            int minPlayers = (isSQDM) ? 5 : fromList.Count; // for SQDM, apply top/strong/weak only if team has 5 or more players

            // Exclude if TopScorers enabled and a top scorer on the team
            int topPlayersPerTeam = 0;
            if (balanceSpeed != Speed.Fast && (TopScorers || balanceSpeed == Speed.Slow)) {
            if (isSQDM) {
            int maxCount = fromList.Count;
            if (maxCount < 5) {
                topPlayersPerTeam = 0;
            } else if (maxCount <= 8) {
                topPlayersPerTeam = 1;
            } else if (totalPlayerCount <= 16) {
                topPlayersPerTeam = 2;
            } else {
                topPlayersPerTeam = 3;
            }
            } else {
            if (totalPlayerCount <= 22) {
                topPlayersPerTeam = 1;
            } else if (totalPlayerCount >= 42) {
                topPlayersPerTeam = 3;
            } else {
                topPlayersPerTeam = 2;
            }
            }
            }
            for (int i = 0; i < fromList.Count; ++i) {
            if (fromList[i].Name == player.Name) {
            if (!mustMove
            && needsBalancing
            && balanceSpeed != Speed.Fast
            && fromList.Count >= minPlayers
            && topPlayersPerTeam != 0
            && i < topPlayersPerTeam) {
                String why = (balanceSpeed == Speed.Slow) ? "Speed is slow, excluding top scorers" : "Top Scorers enabled";
                if (!loggedStats) {
                    DebugBalance(GetPlayerStatsString(name));
                    loggedStats = true;
                }
                DebugBalance("Excluding ^b" + player.FullName + "^n: " + why + " and this player is #" + (i+1) + " on team " + GetTeamName(player.Team));
                fExcludedRound = fExcludedRound + 1;
                IncrementTotal();
                return;
            } else {
                playerIndex = i;
                break;
            }
            }
            }
            isStrong = (playerIndex < strongest);

            // Exclude if too soon since last move
            if ((!mustMove || lenient) && player.MovedByMBTimestamp != DateTime.MinValue) {
            double mins = DateTime.Now.Subtract(player.MovedByMBTimestamp).TotalMinutes;
            if (mins < MinutesAfterBeingMoved) {
            DebugBalance("Excluding ^b" + player.Name + "^n: last move was " + mins.ToString("F0") + " minutes ago, less than required " + MinutesAfterBeingMoved.ToString("F0") + " minutes");
            fExcludedRound = fExcludedRound + 1;
            IncrementTotal();
            return;
            } else {
            // reset
            player.MovedByMBTimestamp = DateTime.MinValue;
            }
            }

            // Exclude if player joined less than MinutesAfterJoining
            double joinedMinutesAgo = GetPlayerJoinedTimeSpan(player).TotalMinutes;
            double enabledForMinutes = now.Subtract(fEnabledTimestamp).TotalMinutes;
            if ((!mustMove || lenient)
            && needsBalancing
            && (enabledForMinutes > MinutesAfterJoining)
            && balanceSpeed != Speed.Fast
            && (joinedMinutesAgo < MinutesAfterJoining)) {
            if (!loggedStats) {
            DebugBalance(GetPlayerStatsString(name));
            loggedStats = true;
            }
            DebugBalance("Excluding ^b" + player.FullName + "^n: joined less than " + MinutesAfterJoining.ToString("F1") + " minutes ago (" + joinedMinutesAgo.ToString("F1") + ")");
            fExcludedRound = fExcludedRound + 1;
            IncrementTotal();
            return;
            }

            // Special exemption if tag not verified and first/partial round
            if (!player.TagVerified && player.Rounds <= 1) {
            if (DebugLevel >= 7) DebugBalance("Skipping ^b" + player.Name + "^n, clan tag not verified yet");
            // Don't count this as an excemption
            // Don't increment the total
            return;
            }

            // Exclude if in squad with same tags
            if ((!mustMove || lenient) && SameClanTagsInSquad) {
            int cmt =  CountMatchingTags(player, Scope.SameSquad);
            if (cmt >= 2) {
            String et = ExtractTag(player);
            DebugBalance("Excluding ^b" + name + "^n, " + cmt + " players in squad with tag [" + et + "]");
            fExcludedRound = fExcludedRound + 1;
            IncrementTotal();
            return;
            }
            }

            // Exclude if in team with same tags
            if ((!mustMove || lenient) && SameClanTagsInTeam) {
            int cmt =  CountMatchingTags(player, Scope.SameTeam);
            if (cmt >= 5) {
            String et = ExtractTag(player);
            DebugBalance("Excluding ^b" + name + "^n, " + cmt + " players in team with tag [" + et + "]");
            fExcludedRound = fExcludedRound + 1;
            IncrementTotal();
            return;
            }
            }

            // Exclude if on friends list
            if ((!mustMove || lenient) && OnFriendsList) {
            int cmf = CountMatchingFriends(player, Scope.SameSquad);
            if (cmf >= 2) {
            DebugBalance("Excluding ^b" + player.FullName + "^n, " + cmf + " players in squad are friends (friendex = " + player.Friendex + ")");
            fExcludedRound = fExcludedRound + 1;
            IncrementTotal();
            return;
            }
            if (ApplyFriendsListToTeam) {
            cmf = CountMatchingFriends(player, Scope.SameTeam);
            if (cmf >= 5) {
                DebugBalance("Excluding ^b" + player.FullName + "^n, " + cmf + " players in team are friends (friendex = " + player.Friendex + ")");
                fExcludedRound = fExcludedRound + 1;
                IncrementTotal();
                return;
            }
            }
            }

            // Exempt if this player already been moved for balance or unstacking
            if ((!mustMove && GetMoves(player) >= 1) || (mustMove && GetMoves(player) >= maxDispersalMoves)) {
            DebugBalance("Exempting ^b" + name + "^n, already moved this round");
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }

            /* Balance */

            int toTeamDiff = 0;
            int toTeam = ToTeam(name, player.Team, false, out toTeamDiff, ref mustMove); // take into account dispersal by Rank, etc.

            if (toTeam == 0 || toTeam == player.Team) {
            if (needsBalancing || mustMove) {
            if (DebugLevel >= 8) DebugBalance("Exempting ^b" + name + "^n, target team selected is same or zero");
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }
            }

            int numTeams = 2; //(isSQDM) ? 4 : 2; // TBD, what is max squad size for SQDM?
            int maxTeamSlots = (MaximumServerSize/numTeams);
            int maxTeamPerMode = (perMode.MaxPlayers/numTeams);
            List<PlayerModel> lt = GetTeam(toTeam);
            int toTeamSize = (lt == null) ? 0 : lt.Count;

            if (toTeamSize == maxTeamSlots || toTeamSize == maxTeamPerMode) {
            if (DebugLevel >= 8) DebugBalance("Exempting ^b" + name + "^n, target team is full " + toTeamSize);
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }

            if (mustMove) DebugBalance("^4MUST MOVE^0 ^b" + name + "^n from " + GetTeamName(player.Team) + " to " + GetTeamName(toTeam));

            if ((!mustMove || lenient) && needsBalancing && toTeamDiff <= MaxDiff()) {
            DebugBalance("Exempting ^b" + name + "^n, difference between " + GetTeamName(player.Team) + " team and " + GetTeamName(toTeam) + " team is only " + toTeamDiff);
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }

            if ((fBalanceIsActive || mustMove) && toTeam != 0) {
            String ts = null;
            if (isSQDM) {
            ts = fTeam1.Count + "(A) vs " + fTeam2.Count + "(B) vs " + fTeam3.Count + "(C) vs " + fTeam4.Count + "(D)";
            } else {
            ts = fTeam1.Count + "(US) vs " + fTeam2.Count + "(RU)";
            }
            if (mustMove) {
            DebugBalance("Autobalancing because ^b" + name + "^n must be moved");
            } else {
            DebugBalance("Autobalancing because difference of " + diff + " is greater than " + MaxDiff() + ", [" + ts + "]");
            }
            double abTime = now.Subtract(fLastBalancedTimestamp).TotalSeconds;
            if (abTime > 0) {
            DebugBalance("^2^bAutobalance has been active for " + abTime.ToString("F1") + " seconds!");
            }

            if (!loggedStats) {
            DebugBalance(GetPlayerStatsString(name) + ((isStrong) ? " STRONG" : " WEAK"));
            loggedStats = true;
            }

            /* Exemptions */

            // Already on the smallest team
            if ((!mustMove || lenient) && player.Team == smallestTeam) {
            DebugBalance("Exempting ^b" + name + "^n, already on the smallest team");
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }

            // SQDM, not on the biggest team
            if (isSQDM && !mustMove && balanceSpeed != Speed.Fast && player.Team != biggestTeam) {
            // Make sure player's team isn't the same size as biggest
            List<PlayerModel> aTeam = GetTeam(player.Team);
            List<PlayerModel> bigTeam = GetTeam(biggestTeam);
            if (aTeam == null || bigTeam == null || (aTeam != null && bigTeam != null && aTeam.Count < bigTeam.Count)) {
                DebugBalance("Exempting ^b" + name + "^n, not on the biggest team");
                fExemptRound = fExemptRound + 1;
                IncrementTotal();
                return;
            }
            }

            // Exempt if only moving weak players and is strong
            if (!mustMove && perMode.OnlyMoveWeakPlayers && isStrong) {
            DebugBalance("Exempting strong ^b" + name + "^n, Only Move Weak Players set to True for " + simpleMode);
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }

            // Strong/Weak exemptions and clan tag
            if (!mustMove && balanceSpeed != Speed.Fast && fromList.Count >= minPlayers) {
            if (DebugLevel > 5) DebugBalance(strongMsg);
            // don't move weak player to losing team, unless we are only moving weak players
            if (!isStrong  && toTeam == losingTeam && !perMode.OnlyMoveWeakPlayers) {
                DebugBalance("Exempting ^b" + name + "^n, don't move weak player to losing team (#" + (playerIndex+1) + " of " + fromList.Count + ", top " + (strongest) + ")");
                fExemptRound = fExemptRound + 1;
                IncrementTotal();
                return;
            }

            // don't move strong player to winning team
            if (isStrong && toTeam == winningTeam) {
                DebugBalance("Exempting ^b" + name + "^n, don't move strong player to winning team (#" + (playerIndex+1) + " of " + fromList.Count + ", median " + (strongest) + ")");
                fExemptRound = fExemptRound + 1;
                IncrementTotal();
                return;
            }

            // Don't move to same team
            if (player.Team == toTeam) {
                if (DebugLevel >= 7) DebugBalance("Exempting ^b" + name + "^n, don't move player to his own team!");
                IncrementTotal(); // no matching stat, reflect total deaths handled
                return;
            }
            }

            /* Move for balance */

            int origTeam = player.Team;
            String origName = GetTeamName(player.Team);

            if (lastMoveFrom != 0) {
            origTeam = lastMoveFrom;
            origName = GetTeamName(origTeam);
            }

            MoveInfo move = new MoveInfo(name, player.Tag, origTeam, origName, toTeam, GetTeamName(toTeam));
            move.For = MoveType.Balance;
            move.Format(this, ChatMovedForBalance, false, false);
            move.Format(this, YellMovedForBalance, true, false);
            String why = (mustMove) ? "to disperse evenly" : ("because difference is " + diff);
            log = "^4^bBALANCE^n^0 moving ^b" + player.FullName + "^n from " + move.SourceName + " team to " + move.DestinationName + " team " + why;
            log = (EnableLoggingOnlyMode) ? "^9(SIMULATING)^0 " + log : log;
            DebugWrite(log, 3);

            DebugWrite("^9" + move, 8);

            player.LastMoveFrom = player.Team;
            StartMoveImmediate(move, false);

            if (EnableLoggingOnlyMode) {
            // Simulate completion of move
            OnPlayerTeamChange(name, toTeam, 0);
            OnPlayerMovedByAdmin(name, toTeam, 0, false); // simulate reverse order
            }
            // no increment total, handled later when move is processed
            return;
            }

            if (!fBalanceIsActive) {
            fLastBalancedTimestamp = now;
            if (DebugLevel >= 8) ConsoleDebug("fLastBalancedTimestamp = " + fLastBalancedTimestamp.ToString("HH:mm:ss"));
            }

            /* Unstack */

            // Not enabled or not full round
            if (!EnableUnstacking) {
            if (DebugLevel >= 8) DebugBalance("Unstack is disabled, Enable Unstacking is set to False");
            IncrementTotal();
            return;
            } else if (!fIsFullRound) {
            if (DebugLevel >= 7) DebugBalance("Unstack is disabled, not a full round");
            IncrementTotal();
            return;
            }

            // Sanity checks
            if (winningTeam <= 0 || winningTeam >= fTickets.Length || losingTeam <= 0 || losingTeam >= fTickets.Length || balanceSpeed == Speed.Stop) {
            if (DebugLevel >= 5) DebugBalance("Skipping unstack for player that was killed ^b" + name +"^n: winning = " + winningTeam + ", losingTeam = " + losingTeam + ", speed = " + balanceSpeed);
            IncrementTotal(); // no matching stat, reflect total deaths handled
            return;
            }

            // Server is full, can't swap
            if (totalPlayerCount > (MaximumServerSize-2) || totalPlayerCount > (perMode.MaxPlayers-2)) {
            // TBD - kick idle players?
            if (DebugLevel >= 7) DebugBalance("No room to swap players for unstacking");
            IncrementTotal(); // no matching stat, reflect total deaths handled
            return;
            }

            // Disabled per-mode
            if (perMode.CheckTeamStackingAfterFirstMinutes == 0) {
            if (DebugLevel >= 5) DebugBalance("Unstacking has been disabled, Check Team Stacking After First Minutes set to zero");
            IncrementTotal(); // no matching stat, reflect total deaths handled
            return;
            }

            double tirMins = GetTimeInRoundMinutes();

            // Too soon to unstack
            if (tirMins < perMode.CheckTeamStackingAfterFirstMinutes) {
            DebugBalance("Too early to check for unstacking, skipping ^b" + name + "^n");
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }

            // Maximum swaps already done
            if ((fUnstackedRound/2) >= perMode.MaxUnstackingSwapsPerRound) {
            if (DebugLevel >= 6) DebugBalance("Maximum swaps have already occurred this round (" + (fUnstackedRound/2) + ")");
            fUnstackState = UnstackState.Off;
            IncrementTotal(); // no matching stat, reflect total deaths handled
            return;
            }

            // Whitelisted
            if (OnWhitelist) {
            if (CheckWhitelist(player, WL_UNSTACK)) {
            DebugBalance("Excluding from unstacking due to being whitelisted, ^b" + name + "^n");
            fExcludedRound = fExcludedRound + 1;
            IncrementTotal();
            return;
            }
            }

            double ratio = 1;
            double t1Tickets = 0;
            double t2Tickets = 0;
            if (IsCTF()) {
            // Use team points, not tickets
            double usPoints = GetTeamPoints(1);
            double ruPoints = GetTeamPoints(2);
            if (usPoints <= 0) usPoints = 1;
            if (ruPoints <= 0) ruPoints = 1;
            ratio = (usPoints > ruPoints) ? (usPoints/ruPoints) : (ruPoints/usPoints);
            } else {
            // Otherwise use ticket ratio
            if (fTickets[losingTeam] >= 1) {
            if (IsRush()) {
                // normalize Rush ticket ratio
                double attackers = fTickets[1];
                double defenders = fMaxTickets - (fRushMaxTickets - fTickets[2]);
                defenders = Math.Max(defenders, attackers/2);
                ratio = (attackers > defenders) ? (attackers/Math.Max(1, defenders)) : (defenders/Math.Max(1, attackers));
                t1Tickets = attackers;
                t2Tickets = defenders;
            } else {
                t1Tickets = Convert.ToDouble(fTickets[winningTeam]);
                t2Tickets = Convert.ToDouble(fTickets[losingTeam]);
                ratio =  t1Tickets / Math.Max(1, t2Tickets);
            }
            }
            }

            // Ticket difference greater than per-mode maximum for unstacking
            int ticketGap = Convert.ToInt32(Math.Abs(t1Tickets - t2Tickets));
            if (perMode.MaxUnstackingTicketDifference > 0 && ticketGap > perMode.MaxUnstackingTicketDifference) {
            DebugBalance("Ticket difference of " + ticketGap + " exceeds Max Unstacking Ticket Difference of " + perMode.MaxUnstackingTicketDifference + ", skipping ^b" + name + "^n");
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }

            String um = "Ticket ratio " + (ratio*100.0).ToString("F0") + " vs. unstack ratio of " + (unstackTicketRatio*100.0).ToString("F0");

            // Using ticket loss instead of ticket ratio?
            if (perMode.EnableTicketLossRatio && false) { // disable for this release
            double a1 = GetAverageTicketLossRate(1, false);
            double a2 = GetAverageTicketLossRate(2, false);
            ratio = (a1 > a2) ? (a1/Math.Max(1, a2)) : (a2/Math.Max(1, a1));
            ratio = Math.Min(ratio, 50.0); // cap at 50x
            um = "Ticket loss ratio is " + (ratio*100.0).ToString("F0") + " vs. unstack ratio of " + (unstackTicketRatio*100.0).ToString("F0");

            // Don't unstack if the team with the highest loss rate is the winning team
            // We don't want to send strong players to the team with the highest score!
            if ((a1 > a2 && winningTeam == 1)
            ||  (a2 > a1 && winningTeam == 2)) {
            if (DebugLevel >= 7) DebugBalance("Team with highest ticket loss rate is the winning team, do not unstack: " + a1.ToString("F1") + " vs " + a2.ToString("F1") + ", winning team is " + TeamName(winningTeam));
            IncrementTotal();
            return;
            }
            }

            if (unstackTicketRatio == 0 || ratio < unstackTicketRatio) {
            if (DebugLevel >= 6) DebugBalance("No unstacking needed: " + um);
            IncrementTotal(); // no matching stat, reflect total deaths handled
            return;
            }

            /*
            Cases:
            1) Never unstacked before, timer is 0 and group count is 0
            2) Within a group, timer is 0 and group count is > 0 but < max
            3) Between groups, timer is > 0 and group count is 0
            */

            double nsis = NextSwapGroupInSeconds(perMode); // returns 0 for case 1 and case 2

            if (nsis > 0) {
            if (DebugLevel >= 6) DebugBalance("Too soon to do another unstack swap group, wait another " + nsis.ToString("F1") + " seconds!");
            IncrementTotal(); // no matching stat, reflect total deaths handled
            return;
            } else {
            fFullUnstackSwapTimestamp = DateTime.MinValue; // turn off timer
            }

            // Are the minimum number of players present to decide strong vs weak?
            if (!mustMove && balanceSpeed != Speed.Fast && fromList.Count < minPlayers) {
            DebugBalance("Not enough players in team to determine strong vs weak, skipping ^b" + name + "^n, ");
            fExemptRound = fExemptRound + 1;
            IncrementTotal();
            return;
            }

            // Otherwise, unstack!
            DebugBalance("^6Unstacking!^0 " + um);

            if (DebugLevel >= 6) {
            if (isStrong) {
            DebugBalance("Player ^b" + player.Name + "^n is strong: #" + (playerIndex+1) + " of " + fromList.Count + ", above #" + strongest + " at " + perMode.PercentOfTopOfTeamIsStrong.ToString("F0") + "%");
            } else {
            DebugBalance("Player ^b" + player.Name + "^n is weak: #" + (playerIndex+1) + " of " + fromList.Count + ", equal or below #" + strongest + " at " + perMode.PercentOfTopOfTeamIsStrong.ToString("F0") + "%");
            }
            }

            if (!loggedStats) {
            DebugBalance(GetPlayerStatsString(name));
            loggedStats = true;
            }

            MoveInfo moveUnstack = null;

            int origUnTeam = player.Team;
            String origUnName = GetTeamName(player.Team);
            String strength = "strong";

            if (lastMoveFrom != 0) {
            origUnTeam = lastMoveFrom;
            origUnName = GetTeamName(origUnTeam);
            }

            if (fUnstackState == UnstackState.Off) {
            // First swap
            DebugBalance("For ^b" + name + "^n, first swap of " + perMode.NumberOfSwapsPerGroup);
            fUnstackState = UnstackState.SwappedWeak;
            }

            switch (fUnstackState) {
            case UnstackState.SwappedWeak:
            // Swap strong to losing team
            if (isStrong) {
                // Don't move to same team
                if (player.Team == losingTeam) {
                    if (DebugLevel >= 6) DebugBalance("Skipping strong ^b" + name + "^n, don't move player to his own team!");
                    fExemptRound = fExemptRound + 1;
                    IncrementTotal();
                    return;
                }
                DebugBalance("Sending strong player ^0^b" + player.FullName + "^n^9 to losing team " + GetTeamName(losingTeam));
                moveUnstack = new MoveInfo(name, player.Tag, origUnTeam, origUnName, losingTeam, GetTeamName(losingTeam));
                toTeam = losingTeam;
                fUnstackState = UnstackState.SwappedStrong;
                if (EnableTicketLossRateLogging) UpdateTicketLossRateLog(DateTime.Now, losingTeam, 0);
            } else {
                DebugBalance("Skipping ^b" + name + "^n, don't move weak player to losing team (#" + (playerIndex+1) + " of " + fromList.Count + ", median " + (strongest) + ")");
                fExemptRound = fExemptRound + 1;
                IncrementTotal();
                return;
            }
            break;
            case UnstackState.SwappedStrong:
            // Swap weak to winning team
            if (!isStrong) {
                // Don't move to same team
                if (player.Team == winningTeam) {
                    if (DebugLevel >= 6) DebugBalance("Skipping weak ^b" + name + "^n, don't move player to his own team!");
                    fExemptRound = fExemptRound + 1;
                    IncrementTotal();
                    return;
                }
                DebugBalance("Sending weak player ^0^b" + player.FullName + "^n^9 to winning team " + GetTeamName(winningTeam));
                moveUnstack = new MoveInfo(name, player.Tag, origUnTeam, origUnName, winningTeam, GetTeamName(winningTeam));
                toTeam = winningTeam;
                fUnstackState = UnstackState.SwappedWeak;
                strength = "weak";
                FinishedFullSwap(name, perMode); // updates group count
                if (EnableTicketLossRateLogging) UpdateTicketLossRateLog(DateTime.Now, 0, winningTeam);
            } else {
                DebugBalance("Skipping ^b" + name + "^n, don't move strong player to winning team (#" + (playerIndex+1) + " of " + fromList.Count + ", median " + (strongest) + ")");
                fExemptRound = fExemptRound + 1;
                IncrementTotal();
                return;
            }
            break;
            case UnstackState.Off:
            // fall thru
            default: return;
            }

            /* Move for unstacking */

            log = "^4^bUNSTACK^n^0 moving " + strength + " ^b" + player.FullName + "^n from " + moveUnstack.SourceName + " to " + moveUnstack.DestinationName + " because: " + um;
            log = (EnableLoggingOnlyMode) ? "^9(SIMULATING)^0 " + log : log;
            DebugWrite(log, 3);
            moveUnstack.For = MoveType.Unstack;
            moveUnstack.Format(this, ChatMovedToUnstack, false, false);
            moveUnstack.Format(this, YellMovedToUnstack, true, false);

            DebugWrite("^9" + moveUnstack, 8);

            if (player.LastMoveFrom == 0) player.LastMoveFrom = player.Team;
            StartMoveImmediate(moveUnstack, false);

            if (EnableLoggingOnlyMode) {
            // Simulate completion of move
            OnPlayerTeamChange(name, toTeam, 0);
            OnPlayerMovedByAdmin(name, toTeam, 0, false); // simulate reverse order
            }
            // no increment total, handled by unstacking move
        }
Exemple #29
0
 protected virtual void OnParry(HitBox strokeHitBox, MoveInfo move, CharacterInfo player)
 {
     // You can use this to have your own custom events when a character parries an attack
     // player.playerNum = 1 or 2
     // player = character parrying
 }
 private void KillAndMoveAsync(MoveInfo move)
 {
     lock (fMoveQ) {
     fMoveQ.Enqueue(move);
     Monitor.Pulse(fMoveQ);
     }
 }
Exemple #31
0
 protected virtual void OnMove(MoveInfo move, CharacterInfo player)
 {
     // Fires when a player successfully executes a move
     // player.playerNum = 1 or 2
 }
Exemple #32
0
        /// <summary>
        /// Allows a player to play a just say no on their turn or when an action is played against them
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="nextStatePhase"></param>
        /// <param name="justSayNoAble"></param>
        /// <param name="JustSayNoUsedByOpposition"></param>
        /// <param name="moveInformation"></param>
        /// <returns></returns>
        private BoolResponseBox playActionCardJustSayNo(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, Statephase justSayNoAble, Statephase JustSayNoUsedByOpposition, MoveInfo moveInformation)
        {
            #region Player not on turn canceling effect of ActionCard being played against them

            if (currentState.actionCardEvent != null && currentState.actionCardEvent.actionJustSayNoUsedByAffectedPlayer == false)
            {
                #region Just Say No used against debt incurring card

                if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.DebtCollector) == 0 || currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.DoubleTheRent) == 0 || currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.ItsMyBirthday) == 0 || currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.RentMultiColor) == 0 || currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.RentStandard) == 0)
                {
                    //Money events are just say noable before action is taken so rollback is unneccessary
                    //Check
                    //Perform action in next state
                    //Clone the current state to create next state
                    nextState = currentState.clone(generateGuidForNextState());

                    //Player Paying Debt
                    PlayerModel playerModelForPlayerPaying = getPlayerModel(playerPerformingAction.guid, nextState);

                    //Player Being paid debt
                    PlayerModel playerModelForPlayerToBePaid = getPlayerModel(moveInformation.guidOfPlayerToPayDebtTo, nextState);
                    //Discard Just say no card
                    Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
                    //Get the reference to the players playerModel in the current PlayFieldModel

                    //Get the reference to the Card in the current PlayFieldModel
                    if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.JustSayNo) == 0)
                    {
                        Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayerPaying);
                        if (card != null)
                        {
                            ActionCard actionCard = card as ActionCard;
                            //Do action

                            bool otherPlayersPaying = false;
                            //Get if player paying is the only player who has to pay
                            foreach (PlayerModel player in nextState.playerModels)
                            {
                                if (player.guid.CompareTo(playerModelForPlayerPaying.guid) != 0 && player.owesAnotherPlayer)
                                {
                                    //Another player owes money
                                    otherPlayersPaying = true;
                                    break;
                                }
                            }
                            Statephase nextStatePhaseIfSuccessful;
                            if (otherPlayersPaying)
                            {
                                //Other players must pay so states phase does not change
                                nextStatePhaseIfSuccessful = JustSayNoUsedByOpposition;
                            }
                            else
                            {
                                //No other players have to pay debt
                                nextStatePhaseIfSuccessful = JustSayNoUsedByOpposition;
                            }
                            //Generate action card event to give the chance to just say no
                            ActionCardEvent justSayNoUsedAgainstDebt = new ActionCardEvent();
                            justSayNoUsedAgainstDebt.actionCardTypeUsed = currentState.actionCardEvent.actionCardTypeUsed;//Will be a debt incurring card
                            justSayNoUsedAgainstDebt.actionJustSayNoUsedByAffectedPlayer = true;//The player affected by the debt inccuring card has used a just say no to cancel the debt incurring card
                            justSayNoUsedAgainstDebt.debtAmount = playerModelForPlayerPaying.amountOwedToAnotherPlayer;//The amount the player would owe if a just say no is played against thier just say no
                            justSayNoUsedAgainstDebt.actionTypeTaken = TurnActionTypes.PlayJustSayNo;//The action type taken
                            justSayNoUsedAgainstDebt.playerAffectedByAction = playerModelForPlayerPaying.guid;//The player using a just say no to cancel the debt incurring card
                            justSayNoUsedAgainstDebt.playerWhoPerformedActionOnTurn = currentState.guidOfPlayerWhosTurnItIs;//The player on turn who played a debt inccuring card who can play a just say not against the cancelling players just say no
                            //Set the action card event
                            nextState.actionCardEvent = justSayNoUsedAgainstDebt;

                            //Player has now paid debt
                            playerModelForPlayerPaying.owesAnotherPlayer = false;
                            playerModelForPlayerPaying.amountOwedToAnotherPlayer = 0;
                            //Update the state

                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = nextStatePhaseIfSuccessful;
                            List<TurnActionTypes> notInDebt = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> inDebt = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);
                            inDebt = setAllowableActionsNotOnTurnInDebt(inDebt, nextState);
                            updateAllowableStatesDebtPaid(nextState, notInDebt, onTurn, nextState.guidOfPlayerWhosTurnItIs, inDebt);

                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Just Say No to avoid paying.");
                        }
                    }
                }

                #endregion Just Say No used against debt incurring card

                #region Just Say No used against non-debt incurring card

                #region DealBreaker Being Just Say No'd

                else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.DealBreaker) == 0)
                {
                    //Money events are just say noable before action is taken so rollback is unneccessary
                    //Check
                    //Perform action in next state
                    //Clone the current state to create next state
                    nextState = currentState.clone(generateGuidForNextState());

                    //Player Lost Set in DealBreaker using Just Say No to get it back
                    PlayerModel playerModelForLostSet = getPlayerModel(playerPerformingAction.guid, nextState);

                    //Player Gained Set in DealBreaker
                    PlayerModel playerModelForPlayerGainedSet = getPlayerModel(moveInformation.guidOfPlayerToPayDebtTo, nextState);
                    //Discard Just say no card
                    Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
                    //Get the reference to the players playerModel in the current PlayFieldModel

                    //Get the reference to the Card in the current PlayFieldModel
                    if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.JustSayNo) == 0)
                    {
                        Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForLostSet);
                        if (card != null)
                        {
                            ActionCard actionCard = card as ActionCard;
                            //Do action
                            if (undoDealBreaker(currentState, nextState) == false)
                            {
                                return new BoolResponseBox(false, "Failed to undo dealbreaker");
                            }
                            else
                            {
                                Statephase nextStatePhaseIfSuccessful;

                                nextStatePhaseIfSuccessful = JustSayNoUsedByOpposition;

                                //Generate action card event to give the chance to just say no
                                ActionCardEvent justSayNoUsedAgainstDealBreaker = new ActionCardEvent();
                                justSayNoUsedAgainstDealBreaker.actionCardTypeUsed = currentState.actionCardEvent.actionCardTypeUsed;//Will be a debt incurring card
                                justSayNoUsedAgainstDealBreaker.actionJustSayNoUsedByAffectedPlayer = true;//The player affected by the DealBreaker card has used a just say no to cancel the debt incurring card
                                justSayNoUsedAgainstDealBreaker.actionTypeTaken = TurnActionTypes.PlayJustSayNo;//The action type taken
                                justSayNoUsedAgainstDealBreaker.playerAffectedByAction = playerModelForLostSet.guid;//The player using a just say no to cancel the DealBreaker card
                                justSayNoUsedAgainstDealBreaker.playerWhoPerformedActionOnTurn = currentState.guidOfPlayerWhosTurnItIs;//The player on turn who played a DealBreaker card who can play a just say not against the cancelling players just say no
                                justSayNoUsedAgainstDealBreaker.propertySetTakenFromPlayer = currentState.actionCardEvent.propertySetTakenFromPlayer;
                                justSayNoUsedAgainstDealBreaker.originalActionCardId = currentState.actionCardEvent.originalActionCardId;//Dealbreaker card id
                                justSayNoUsedAgainstDealBreaker.playerOnTurnPerformingAction = false;//Player using Just Say No is performing this action
                                justSayNoUsedAgainstDealBreaker.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove;
                                //Set the action card event
                                nextState.actionCardEvent = justSayNoUsedAgainstDealBreaker;

                                //Update the state

                                //Change state on success
                                //has been performed, advance the phase of the game
                                nextState.currentPhase = nextStatePhaseIfSuccessful;
                                List<TurnActionTypes> allowedForPlayerWhoDontHaveCardsTaken = new List<TurnActionTypes>();
                                List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                                List<TurnActionTypes> allowedForPlayersWhoDoHaveCardsTaken = new List<TurnActionTypes>();
                                onTurn = setAllowableActionsOnTurn(onTurn, nextState);
                                updateAllowableStatesPerPlayerCardsTaken(nextState, allowedForPlayerWhoDontHaveCardsTaken, onTurn, currentState.guidOfPlayerWhosTurnItIs, allowedForPlayersWhoDoHaveCardsTaken);

                                //change the current state to the next state
                                addNextState(nextState);
                                return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Just Say No to regain Set.");
                            }
                        }
                    }
                }

                #endregion DealBreaker Being Just Say No'd

                #region Forced Deal Being Just Say No'd

                else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.ForcedDeal) == 0)
                {
                    //Money events are just say noable before action is taken so rollback is unneccessary
                    //Check
                    //Perform action in next state
                    //Clone the current state to create next state
                    nextState = currentState.clone(generateGuidForNextState());

                    //Player Lost Set in DealBreaker using Just Say No to get it back
                    PlayerModel playerModelForLostSet = getPlayerModel(playerPerformingAction.guid, nextState);

                    //Player Gained Set in DealBreaker
                    PlayerModel playerModelForPlayerGainedSet = getPlayerModel(moveInformation.guidOfPlayerToPayDebtTo, nextState);
                    //Discard Just say no card
                    Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
                    //Get the reference to the players playerModel in the current PlayFieldModel

                    //Get the reference to the Card in the current PlayFieldModel
                    if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.JustSayNo) == 0)
                    {
                        Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForLostSet);
                        if (card != null)
                        {
                            ActionCard actionCard = card as ActionCard;
                            //Do action

                            Statephase nextStatePhaseIfSuccessful;

                            nextStatePhaseIfSuccessful = JustSayNoUsedByOpposition;

                            //Generate action card event to give the chance to just say no
                            ActionCardEvent justSayNoUsedAgainstForcedDeal = new ActionCardEvent();
                            justSayNoUsedAgainstForcedDeal.actionCardTypeUsed = currentState.actionCardEvent.actionCardTypeUsed;//
                            justSayNoUsedAgainstForcedDeal.actionJustSayNoUsedByAffectedPlayer = true;//The player affected by the Forced Deal card has used a just say no to cancel the debt incurring card
                            justSayNoUsedAgainstForcedDeal.actionTypeTaken = TurnActionTypes.PlayJustSayNo;//The action type taken
                            justSayNoUsedAgainstForcedDeal.playerAffectedByAction = playerModelForLostSet.guid;//The player using a just say no to cancel the Forced Deal card
                            justSayNoUsedAgainstForcedDeal.playerWhoPerformedActionOnTurn = currentState.guidOfPlayerWhosTurnItIs;//The player on turn who played a Forced Deal card who can play a just say not against the cancelling players just say no
                            justSayNoUsedAgainstForcedDeal.originalActionCardId = currentState.actionCardEvent.originalActionCardId;//Forced Deal card id
                            justSayNoUsedAgainstForcedDeal.playerOnTurnPerformingAction = false;//Player using Just Say No is performing this action
                            justSayNoUsedAgainstForcedDeal.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove;
                            justSayNoUsedAgainstForcedDeal.propertyCardGivenUpInForcedDeal = currentState.actionCardEvent.propertyCardGivenUpInForcedDeal;
                            justSayNoUsedAgainstForcedDeal.propertyCardsTakenFromPlayerAndSetTheCardWasIn = currentState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn;

                            //Set the action card event
                            nextState.actionCardEvent = justSayNoUsedAgainstForcedDeal;

                            //Update the state
                            undoForcedDeal(currentState, nextState);

                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = nextStatePhaseIfSuccessful;
                            List<TurnActionTypes> allowedForPlayerWhoDontHaveCardsTaken = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> allowedForPlayersWhoDoHaveCardsTaken = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);
                            updateAllowableStatesPerPlayerCardsTaken(nextState, allowedForPlayerWhoDontHaveCardsTaken, onTurn, currentState.guidOfPlayerWhosTurnItIs, allowedForPlayersWhoDoHaveCardsTaken);

                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Just Say No to undo Forced Deal.");
                        }
                    }
                }

                #endregion Forced Deal Being Just Say No'd

                #region Sly Deal Being Just Say No'd

                else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.SlyDeal) == 0)
                {
                    //Money events are just say noable before action is taken so rollback is unneccessary
                    //Check
                    //Perform action in next state
                    //Clone the current state to create next state
                    nextState = currentState.clone(generateGuidForNextState());

                    //Player Lost Set in DealBreaker using Just Say No to get it back
                    PlayerModel playerModelForLostCard = getPlayerModel(playerPerformingAction.guid, nextState);

                    //Player Gained Set in DealBreaker
                    PlayerModel playerModelForPlayerGainedCard = getPlayerModel(currentState.guidOfPlayerWhosTurnItIs, nextState);
                    //Discard Just say no card
                    Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
                    //Get the reference to the players playerModel in the current PlayFieldModel

                    //Get the reference to the Card in the current PlayFieldModel
                    if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.JustSayNo) == 0)
                    {
                        Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForLostCard);
                        if (card != null)
                        {
                            ActionCard actionCard = card as ActionCard;
                            //Do action

                            Statephase nextStatePhaseIfSuccessful;

                            nextStatePhaseIfSuccessful = JustSayNoUsedByOpposition;

                            //Generate action card event to give the chance to just say no
                            ActionCardEvent justSayNoUsedAgainstSlyDeal = new ActionCardEvent();
                            justSayNoUsedAgainstSlyDeal.actionCardTypeUsed = currentState.actionCardEvent.actionCardTypeUsed;//
                            justSayNoUsedAgainstSlyDeal.actionJustSayNoUsedByAffectedPlayer = true;//The player affected by the Forced Deal card has used a just say no to cancel the debt incurring card
                            justSayNoUsedAgainstSlyDeal.actionTypeTaken = TurnActionTypes.PlayJustSayNo;//The action type taken
                            justSayNoUsedAgainstSlyDeal.playerAffectedByAction = playerModelForLostCard.guid;//The player using a just say no to cancel the Forced Deal card
                            justSayNoUsedAgainstSlyDeal.playerWhoPerformedActionOnTurn = currentState.guidOfPlayerWhosTurnItIs;//The player on turn who played a Forced Deal card who can play a just say not against the cancelling players just say no
                            justSayNoUsedAgainstSlyDeal.originalActionCardId = currentState.actionCardEvent.originalActionCardId;//Forced Deal card id
                            justSayNoUsedAgainstSlyDeal.playerOnTurnPerformingAction = false;//Player using Just Say No is performing this action
                            justSayNoUsedAgainstSlyDeal.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove;
                            justSayNoUsedAgainstSlyDeal.propertyCardsTakenFromPlayerAndSetTheCardWasIn = currentState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn;//card that was sly dealed
                            //Set the action card event
                            nextState.actionCardEvent = justSayNoUsedAgainstSlyDeal;

                            //Update the state
                            undoSlyDeal(currentState, nextState);

                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = nextStatePhaseIfSuccessful;
                            List<TurnActionTypes> allowedForPlayerWhoDontHaveCardsTaken = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> allowedForPlayersWhoDoHaveCardsTaken = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);
                            updateAllowableStatesPerPlayerCardsTaken(nextState, allowedForPlayerWhoDontHaveCardsTaken, onTurn, currentState.guidOfPlayerWhosTurnItIs, allowedForPlayersWhoDoHaveCardsTaken);

                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Just Say No to undo Sly Deal.");
                        }
                    }
                }

                #endregion Sly Deal Being Just Say No'd

                #endregion Just Say No used against non-debt incurring card
            }

            #endregion Player not on turn canceling effect of ActionCard being played against them

            #region Player on turn is playing a Just Say No to Cancel the Effect of another Just Say No against them

            else if (currentState.actionCardEvent.actionJustSayNoUsedByAffectedPlayer == true)
            {
                //The on turn player has played a just say no to cancel a just say no

                #region Use Just Say No to Cancel Another Just Say No For Debt Collector, It's My Birthday, Standard and MultiColor Rent Cards

                if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.DebtCollector) == 0 || currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.DoubleTheRent) == 0 || currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.ItsMyBirthday) == 0 || currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.RentMultiColor) == 0 || currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.RentStandard) == 0)
                {
                    //Perform action again
                    //Clone the current state to create next state
                    nextState = currentState.clone(generateGuidForNextState());

                    #region Debt Redo

                    if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.DebtCollector) == 0)
                    {
                        //Card Played was a debt collector card
                        return replayActionCardDebtCollector(currentState, nextState, getPlayerModel(moveInformation.guidOfPlayerToPayDebtTo, currentState), nextStatePhase, moveInformation);
                    }
                    else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.ItsMyBirthday) == 0)
                    {
                        return replayActionCardItsMyBirthday(currentState, nextState, getPlayerModel(moveInformation.guidOfPlayerToPayDebtTo, currentState), nextStatePhase, moveInformation);
                    }
                    else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.RentStandard) == 0)
                    {
                        return replayActionCardRentStandard(currentState, nextState, getPlayerModel(moveInformation.guidOfPlayerToPayDebtTo, currentState), nextStatePhase, moveInformation);
                    }
                    else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.RentMultiColor) == 0)
                    {
                        return replayActionCardRentWild(currentState, nextState, getPlayerModel(moveInformation.guidOfPlayerToPayDebtTo, currentState), nextStatePhase, moveInformation);
                    }

                    #endregion Debt Redo

                #endregion Use Just Say No to Cancel Another Just Say No For Debt Collector, It's My Birthday, Standard and MultiColor Rent Cards
                }
                else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.DealBreaker) == 0)
                {
                    return replayActionCardDealBreaker(currentState, nextState, nextStatePhase, moveInformation);
                }
                else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.ForcedDeal) == 0)
                {
                    return replayActionCardForcedDeal(currentState, nextState, nextStatePhase, moveInformation);
                }
                else if (currentState.actionCardEvent.actionCardTypeUsed.CompareTo(ActionCardAction.SlyDeal) == 0)
                {
                    return replayActionCardSlyDeal(currentState, nextState, nextStatePhase, moveInformation);
                }
            }

            #endregion Player on turn is playing a Just Say No to Cancel the Effect of another Just Say No against them

            throw new NotImplementedException("Replaying action card type " + moveInformation.actionCardActionType.ToString() + " is not implemented");
        }
Exemple #33
0
 protected virtual void OnBodyVisibilityChange(MoveInfo move, CharacterInfo player, BodyPartVisibilityChange bodyPartVisibilityChange, HitBox hitBox)
 {
     // Fires when a move casts a body part visibility change
     // player.playerNum = 1 or 2
 }
Exemple #34
0
        private BoolResponseBox replayActionCardRentWild(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerModel, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            //Get the reference to the players playerModel in the current PlayFieldModel
            //Do action

            foreach (PlayerModel p in nextState.playerModels)
            {
                if (p.guid.CompareTo(currentState.actionCardEvent.playerAffectedByAction) != 0)
                {
                    p.owesAnotherPlayer = true;
                    p.amountOwedToAnotherPlayer = currentState.actionCardEvent.debtAmount;
                    break;//Only replay for the player who used a just say no against debt
                }
                else
                {
                    //Player on turn does not have to pay rent
                }
            }

            //Change state on success
            //has been performed, advance the phase of the game
            nextState.currentPhase = nextStatePhase;
            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
            onTurn = setAllowableActionsOnTurn(onTurn, nextState);

            updateAllowableStatesDebtPaid(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnInDebt(new List<TurnActionTypes>(), nextState));

            nextState.actionCardEvent = new ActionCardEvent();
            nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;
            nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.RentMultiColor;
            //change the current state to the next state
            addNextState(nextState);
            return new BoolResponseBox(true, "Player:" + getPlayerModel(currentState.guidOfPlayerWhosTurnItIs, currentState).name + " Has used a Wild Rent Card after a Just Say No");
        }
Exemple #35
0
 protected virtual void OnParticleEffects(MoveInfo move, CharacterInfo player, MoveParticleEffect particleEffects)
 {
     // Fires when a move casts a particle effect
     // player.playerNum = 1 or 2
 }
Exemple #36
0
        /// <summary>
        /// Allows a player to pay their debt owing from rent, birthday or debt collector cards
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="justSayNoAble"></param>
        /// <param name="notJustSayNoAble"></param>
        /// <returns></returns>
        private BoolResponseBox payDebt(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase justSayNoAble, Statephase notJustSayNoAble)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());

            //Player Paying Debt
            PlayerModel playerModelForPlayerPaying = getPlayerModel(playerPerformingAction.guid, nextState);

            //Player Being paid debt
            PlayerModel playerModelForPlayerToBePaid = getPlayerModel(moveInformation.guidOfPlayerToPayDebtTo, nextState);

            //Get all the cards the player intends to pay with
            List<Card> cardsToUseToPayDebt = new List<Card>();
            foreach (int i in moveInformation.listOfIDsOfCardsBeingUsedToPayDebt)
            {
                Card card = nextState.deck.getCardByID(i);
                if (card is PropertyCard)
                {
                    PropertyCard property = (PropertyCard)card;
                    if (playerModelForPlayerPaying.removePropertyCardFromPlayersPropertySets(property) != null)
                    {
                        //Property was in set and has been removed
                        cardsToUseToPayDebt.Add(property);
                    }
                }
                else if (playerModelForPlayerPaying.bank.removeCardFromBank(card) != null)
                {
                    //not a propertyCard
                    cardsToUseToPayDebt.Add(card);
                }
            }
            bool otherPlayersPaying = false;
            //Get if player paying is the only player who has to pay
            foreach (PlayerModel player in nextState.playerModels)
            {
                if (player.guid.CompareTo(playerModelForPlayerPaying.guid) != 0 && player.owesAnotherPlayer)
                {
                    //Another player owes money
                    otherPlayersPaying = true;
                    break;
                }
            }

            //Determine if payment is sufficent
            //Value of all cards must be at least the same as the debt owed or must be every property, house, hotel, banked card the player has
            int valueOfPayment = 0;
            foreach (Card c in cardsToUseToPayDebt)
            {
                valueOfPayment += c.cardValue;
            }
            if (valueOfPayment < moveInformation.amountOwed)
            {
                if (hasPlayerEnoughCardsToPayFullValue(playerModelForPlayerPaying, moveInformation.amountOwed))
                {
                    return new BoolResponseBox(false, "Player has enough played cards to pay debt but has not selected enough to pay.");
                }

                else
                {
                    //Player does not have enough to pay. Take all players played cards
                    cardsToUseToPayDebt = takeAllCardsFromPlayer(playerModelForPlayerPaying);
                }
            }
            //put properties used as payment into new sets for player being paid and put money and actioncards into player being paids bank
            foreach (Card card in cardsToUseToPayDebt)
            {
                if (card is PropertyCard)
                {
                    playerModelForPlayerPaying.removePropertyCardFromPlayersPropertySets((PropertyCard)card);
                    playerModelForPlayerToBePaid.propertySets.addSet(new PropertyCardSet((PropertyCard)card));
                }
                else
                {
                    removeCardFromHand(card, playerModelForPlayerPaying);
                    playerModelForPlayerToBePaid.bank.addCardToBank(card);
                }
            }
            //Player has now paid debt
            playerModelForPlayerPaying.owesAnotherPlayer = false;
            playerModelForPlayerPaying.amountOwedToAnotherPlayer = 0;
            //Update the state

            //Change state on success
            //has been performed, advance the phase of the game
            Statephase nextStatePhaseIfSuccessful;
            if (otherPlayersPaying)
            {
                //Other players must pay so states phase does not change
                nextStatePhaseIfSuccessful = nextState.currentPhase;
            }
            else
            {
                //No other players have to pay debt
                if (currentState.actionCardEvent != null && currentState.actionCardEvent.doubleTheRentCardUsed)
                {
                    if (notJustSayNoAble.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played) == 0)
                    {
                        //zero cards played before turn. Advance to 2 cards played as double the rent counts as a card played
                        nextStatePhaseIfSuccessful = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;
                    }
                    else if (notJustSayNoAble.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played) == 0)
                    {
                        //one card played before turn. Advance to 3 cards played as double the rent counts as a card played
                        nextStatePhaseIfSuccessful = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;
                    }
                    else
                    {
                        //Double the rent card should not have been used
                        throw new Exception("Invalid State");
                    }
                }
                else
                {
                    nextStatePhaseIfSuccessful = notJustSayNoAble;
                }
            }
            nextState.currentPhase = nextStatePhaseIfSuccessful;
            if (nextStatePhaseIfSuccessful.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played) == 0 || nextStatePhaseIfSuccessful.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played) == 0 || nextStatePhaseIfSuccessful.CompareTo(Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only) == 0)
            {
                List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
            }
            else
            {
                List<TurnActionTypes> notInDebt = new List<TurnActionTypes>();
                List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                List<TurnActionTypes> inDebt = new List<TurnActionTypes>();
                onTurn = setAllowableActionsOnTurn(onTurn, nextState);
                inDebt = setAllowableActionsNotOnTurnInDebt(inDebt, nextState);

                updateAllowableStatesDebtPaid(nextState, notInDebt, onTurn, nextState.guidOfPlayerWhosTurnItIs, inDebt);
            }
            //change the current state to the next state
            addNextState(nextState);
            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has paid");
        }
Exemple #37
0
 public override MoveEventResponse MoveBeingMade(MoveInfo move, int ply)
 {
     lastDestinationSquare[ply] = (move.MoveType == MoveType.Pass || move.MoveType == MoveType.NullMove) ? -1 : move.ToSquare;
     return(MoveEventResponse.NotHandled);
 }
Exemple #38
0
        /// <summary>
        /// Plays a debt collector cards effect again after it being canceled then uncanceled by Just Say No Cards
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="nextStatePhaseIfSuccessful"></param>
        /// <param name="debtCollectorInfo"></param>
        /// <returns></returns>
        private BoolResponseBox replayActionCardDebtCollector(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhaseIfSuccessful, MoveInfo debtCollectorInfo)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(nextState.guidOfPlayerWhosTurnItIs, nextState);
            PlayerModel playerModelForPlayerToDebtCollect = getPlayerModel(debtCollectorInfo.guidOfPlayerBeingDebtCollected, nextState);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Do action
            playerModelForPlayerToDebtCollect.owesAnotherPlayer = true;
            playerModelForPlayerToDebtCollect.amountOwedToAnotherPlayer = ActionCard.Debt_Collector_Value;

            //Change state on success
            //has been performed, advance the phase of the game
            nextState.currentPhase = nextStatePhaseIfSuccessful;

            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
            onTurn = setAllowableActionsOnTurn(onTurn, nextState);
            updateAllowableStatesDebtPaid(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnInDebt(new List<TurnActionTypes>(), nextState));

            //change the current state to the next state
            addNextState(nextState);
            return new BoolResponseBox(true, "Debt Collector replayed after Just Say No");
        }
Exemple #39
0
    public void ApplyForces(MoveInfo move)
    {
        if (freeze)
        {
            return;
        }

        controlScript.normalizedJumpArc = (Fix64)1 - ((verticalForce + verticalTotalForce) / (verticalTotalForce * 2));


        Fix64 appliedFriction = (moveDirection != 0 || controlScript.myInfo.physics.highMovingFriction) ?
                                UFE.config.selectedStage._groundFriction : controlScript.myInfo.physics._friction;


        if (move != null && move.ignoreFriction)
        {
            appliedFriction = 0;
        }

        if (controlScript.activePullIn != null)
        {
            worldTransform.position = FPVector.Lerp(worldTransform.position,
                                                    controlScript.activePullIn.position,
                                                    UFE.fixedDeltaTime * controlScript.activePullIn.speed);

            if (controlScript.activePullIn.forceStand && !IsGrounded())
            {
                ForceGrounded();
            }

            if (FPVector.Distance(controlScript.activePullIn.position, worldTransform.position) <= controlScript.activePullIn._targetDistance ||
                controlScript.currentSubState != SubStates.Stunned)
            {
                controlScript.activePullIn = null;
            }
        }
        else
        {
            if (!IsGrounded())
            {
                appliedFriction = 0;
                if (verticalForce == 0)
                {
                    verticalForce = -.1;
                }
            }

            if (horizontalForce != 0 && !isTakingOff)
            {
                if (horizontalForce > 0)
                {
                    horizontalForce -= appliedFriction * UFE.fixedDeltaTime;
                    horizontalForce  = FPMath.Max(0, horizontalForce);
                }
                else if (horizontalForce < 0)
                {
                    horizontalForce += appliedFriction * UFE.fixedDeltaTime;
                    horizontalForce  = FPMath.Min(0, horizontalForce);
                }

                Fix64 leftCameraBounds  = opWorldTransform.position.x - (UFE.config.cameraOptions._maxDistance / 2);
                Fix64 rightCameraBounds = opWorldTransform.position.x + (UFE.config.cameraOptions._maxDistance / 2);

                bool bouncingOnCamera = false;
                if (controlScript.currentHit != null &&
                    controlScript.currentHit.bounceOnCameraEdge &&
                    (worldTransform.position.x <= leftCameraBounds ||
                     worldTransform.position.x >= rightCameraBounds))
                {
                    bouncingOnCamera = true;
                }


                if (wallBounceTimes < UFE.config.wallBounceOptions._maximumBounces &&
                    controlScript.currentSubState == SubStates.Stunned &&
                    controlScript.currentState != PossibleStates.Down &&
                    UFE.config.wallBounceOptions.bounceForce != Sizes.None &&
                    FPMath.Abs(horizontalForce) >= UFE.config.wallBounceOptions._minimumBounceForce &&
                    (worldTransform.position.x <= UFE.config.selectedStage._leftBoundary ||
                     worldTransform.position.x >= UFE.config.selectedStage._rightBoundary || bouncingOnCamera) &&
                    controlScript.currentHit != null && controlScript.currentHit.wallBounce &&
                    !isWallBouncing)
                {
                    if (controlScript.currentHit.overrideForcesOnWallBounce)
                    {
                        if (controlScript.currentHit.resetWallBounceHorizontalPush)
                        {
                            horizontalForce = 0;
                        }
                        if (controlScript.currentHit.resetWallBounceVerticalPush)
                        {
                            verticalForce = 0;
                        }

                        Fix64 addedH = -controlScript.currentHit._wallBouncePushForce.x;
                        Fix64 addedV = controlScript.currentHit._wallBouncePushForce.y;

                        AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror);
                    }
                    else
                    {
                        if (UFE.config.wallBounceOptions.bounceForce == Sizes.Small)
                        {
                            horizontalForce /= -1.4;
                        }
                        else if (UFE.config.wallBounceOptions.bounceForce == Sizes.Medium)
                        {
                            horizontalForce /= -1.2;
                        }
                        else if (UFE.config.wallBounceOptions.bounceForce == Sizes.High)
                        {
                            horizontalForce *= -1;
                        }
                    }

                    wallBounceTimes++;

                    if (verticalForce > 0 || !IsGrounded())
                    {
                        if (moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                        {
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.airWallBounce.name;
                        }
                    }
                    else
                    {
                        if (controlScript.currentHit.knockOutOnWallBounce)
                        {
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounceKnockdown);
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounceKnockdown.name;
                        }
                        else
                        {
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounce);
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounce.name;
                        }
                    }

                    if (UFE.config.wallBounceOptions.bouncePrefab != null)
                    {
                        GameObject pTemp = UFE.SpawnGameObject(UFE.config.wallBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.wallBounceOptions.bounceKillTime * UFE.config.fps));
                        pTemp.transform.rotation = UFE.config.wallBounceOptions.bouncePrefab.transform.rotation;
                        if (UFE.config.wallBounceOptions.sticky)
                        {
                            pTemp.transform.parent = transform;
                        }
                        //pTemp.transform.localPosition = Vector3.zero;
                    }

                    if (UFE.config.wallBounceOptions.shakeCamOnBounce)
                    {
                        controlScript.shakeCameraDensity = UFE.config.wallBounceOptions._shakeDensity;
                    }

                    UFE.PlaySound(UFE.config.wallBounceOptions.bounceSound);
                    isWallBouncing = true;
                }

                worldTransform.Translate((horizontalForce * UFE.fixedDeltaTime), 0, 0);
            }

            if (move == null || (move != null && !move.ignoreGravity))
            {
                if ((verticalForce < 0 && !IsGrounded()) || verticalForce > 0)
                {
                    verticalForce -= appliedGravity * UFE.fixedDeltaTime;
                    worldTransform.Translate((moveDirection * UFE.fixedDeltaTime) * controlScript.myInfo.physics._jumpDistance, (verticalForce * UFE.fixedDeltaTime), 0);
                }
                else if (verticalForce < 0 &&
                         IsGrounded() &&
                         controlScript.currentSubState != SubStates.Stunned)
                {
                    verticalForce = 0;
                }
            }
        }

        Fix64 minDist = opWorldTransform.position.x - UFE.config.cameraOptions._maxDistance;
        Fix64 maxDist = opWorldTransform.position.x + UFE.config.cameraOptions._maxDistance;

        worldTransform.position = new FPVector(FPMath.Clamp(worldTransform.position.x, minDist, maxDist), worldTransform.position.y, worldTransform.position.z);

        worldTransform.position = new FPVector(
            FPMath.Clamp(worldTransform.position.x,
                         UFE.config.selectedStage._leftBoundary,
                         UFE.config.selectedStage._rightBoundary),
            FPMath.Max(worldTransform.position.y, UFE.config.selectedStage._groundHeight),
            worldTransform.position.z);

        if (controlScript.currentState == PossibleStates.Down)
        {
            return;
        }

        if (IsGrounded() && controlScript.currentState != PossibleStates.Down)
        {
            if (verticalTotalForce != 0)
            {
                if (groundBounceTimes < UFE.config.groundBounceOptions._maximumBounces &&
                    controlScript.currentSubState == SubStates.Stunned &&
                    UFE.config.groundBounceOptions.bounceForce != Sizes.None &&
                    verticalForce <= -UFE.config.groundBounceOptions._minimumBounceForce &&
                    controlScript.currentHit.groundBounce)
                {
                    if (controlScript.currentHit.overrideForcesOnGroundBounce)
                    {
                        if (controlScript.currentHit.resetGroundBounceHorizontalPush)
                        {
                            horizontalForce = 0;
                        }
                        if (controlScript.currentHit.resetGroundBounceVerticalPush)
                        {
                            verticalForce = 0;
                        }

                        Fix64 addedH = controlScript.currentHit._groundBouncePushForce.x;
                        Fix64 addedV = controlScript.currentHit._groundBouncePushForce.y;

                        AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror);
                    }
                    else
                    {
                        if (UFE.config.groundBounceOptions.bounceForce == Sizes.Small)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 2.4), 0), 1);
                        }
                        else if (UFE.config.groundBounceOptions.bounceForce == Sizes.Medium)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 1.8), 0), 1);
                        }
                        else if (UFE.config.groundBounceOptions.bounceForce == Sizes.High)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 1.2), 0), 1);
                        }
                    }

                    groundBounceTimes++;

                    if (!isGroundBouncing)
                    {
                        controlScript.stunTime += airTime + UFE.config.knockDownOptions.air._knockedOutTime;

                        if (moveSetScript.basicMoves.groundBounce.animMap[0].clip != null)
                        {
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.groundBounce.name;
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.groundBounce);
                        }

                        if (UFE.config.groundBounceOptions.bouncePrefab != null)
                        {
                            GameObject pTemp = UFE.SpawnGameObject(UFE.config.groundBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.groundBounceOptions.bounceKillTime * UFE.config.fps));
                            pTemp.transform.rotation = UFE.config.groundBounceOptions.bouncePrefab.transform.rotation;
                            if (UFE.config.groundBounceOptions.sticky)
                            {
                                pTemp.transform.parent = transform;
                            }
                            //pTemp.transform.localPosition = Vector3.zero;
                        }
                        if (UFE.config.groundBounceOptions.shakeCamOnBounce)
                        {
                            controlScript.shakeCameraDensity = UFE.config.groundBounceOptions._shakeDensity;
                        }
                        UFE.PlaySound(UFE.config.groundBounceOptions.bounceSound);
                        isGroundBouncing = true;
                    }
                    return;
                }
                verticalTotalForce          = 0;
                airTime                     = 0;
                moveSetScript.totalAirMoves = 0;
                currentAirJumps             = 0;

                BasicMoveInfo airAnimation  = null;
                string        downAnimation = "";

                isGroundBouncing  = false;
                groundBounceTimes = 0;

                Fix64 animationSpeed = 0;
                Fix64 delayTime      = 0;
                if (controlScript.currentMove != null && controlScript.currentMove.hitAnimationOverride)
                {
                    return;
                }
                if (controlScript.currentSubState == SubStates.Stunned)
                {
                    if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airRecovery.name))
                    {
                        controlScript.stunTime     = 0;
                        controlScript.currentState = PossibleStates.Stand;
                    }
                    else
                    {
                        controlScript.stunTime = UFE.config.knockDownOptions.air._knockedOutTime + UFE.config.knockDownOptions.air._standUpTime;

                        // Hit Clips
                        if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitKnockBack.name) &&
                            moveSetScript.basicMoves.getHitKnockBack.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.getHitKnockBack;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitHighKnockdown.name) &&
                                 moveSetScript.basicMoves.getHitHighKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitHighKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.high._knockedOutTime + UFE.config.knockDownOptions.high._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitMidKnockdown.name) &&
                                 moveSetScript.basicMoves.getHitMidKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitMidKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.highLow._knockedOutTime + UFE.config.knockDownOptions.highLow._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitSweep.name) &&
                                 moveSetScript.basicMoves.getHitSweep.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitSweep;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.sweep._knockedOutTime + UFE.config.knockDownOptions.sweep._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitCrumple.name) &&
                                 moveSetScript.basicMoves.getHitCrumple.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.getHitCrumple;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);

                            // Stage Clips
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.standingWallBounceKnockdown.name) &&
                                 moveSetScript.basicMoves.standingWallBounceKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.standingWallBounceKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airWallBounce.name) &&
                                 moveSetScript.basicMoves.airWallBounce.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.airWallBounce;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime;

                            // Fall Clips
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromAirHit.name) &&
                                 moveSetScript.basicMoves.fallingFromAirHit.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.fallingFromAirHit;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromGroundBounce.name) &&
                                 moveSetScript.basicMoves.fallingFromGroundBounce.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.fallingFromGroundBounce;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else
                        {
                            if (moveSetScript.basicMoves.fallDown.animMap[0].clip == null)
                            {
                                Debug.LogError("Fall Down From Air Hit animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Down From Air Hit");
                            }

                            airAnimation  = moveSetScript.basicMoves.fallDown;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 1);
                        }

                        controlScript.currentState = PossibleStates.Down;
                    }
                }
                else if (controlScript.currentState != PossibleStates.Stand)
                {
                    if (moveSetScript.basicMoves.landing.animMap[0].clip != null &&
                        (controlScript.currentMove == null ||
                         (controlScript.currentMove != null && controlScript.currentMove.cancelMoveWheLanding)))
                    {
                        controlScript.isAirRecovering = false;
                        airAnimation  = moveSetScript.basicMoves.landing;
                        moveDirection = 0;
                        isLanding     = true;
                        controlScript.KillCurrentMove();
                        delayTime = (Fix64)controlScript.myInfo.physics.landingDelay / (Fix64)UFE.config.fps;
                        UFE.DelaySynchronizedAction(ResetLanding, delayTime);

                        if (airAnimation.autoSpeed)
                        {
                            animationSpeed = moveSetScript.GetAnimationLength(airAnimation.name) / delayTime;
                        }
                    }

                    if (controlScript.currentState != PossibleStates.Crouch)
                    {
                        controlScript.currentState = PossibleStates.Stand;
                    }
                }

                if (airAnimation != null)
                {
                    if (downAnimation != "")
                    {
                        moveSetScript.PlayBasicMove(airAnimation, downAnimation);
                    }
                    else
                    {
                        moveSetScript.PlayBasicMove(airAnimation);
                    }

                    if (animationSpeed != 0)
                    {
                        moveSetScript.SetAnimationSpeed(airAnimation.name, animationSpeed);
                    }
                }
            }

            if (controlScript.currentSubState != SubStates.Stunned &&
                !controlScript.isBlocking && !controlScript.blockStunned &&
                move == null &&
                !isTakingOff &&
                !isLanding &&
                controlScript.currentState == PossibleStates.Stand)
            {
                if (moveDirection > 0 && controlScript.mirror == -1 ||
                    moveDirection < 0 && controlScript.mirror == 1)
                {
                    if (moveSetScript.basicMoves.moveForward.animMap[0].clip == null)
                    {
                        Debug.LogError("Move Forward animation not found! Make sure you have it set on Character -> Basic Moves -> Move Forward");
                    }
                    if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveForward.name))
                    {
                        moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveForward);
                    }
                }
                else if (moveDirection > 0 && controlScript.mirror == 1 ||
                         moveDirection < 0 && controlScript.mirror == -1)
                {
                    if (moveSetScript.basicMoves.moveBack.animMap[0].clip == null)
                    {
                        Debug.LogError("Move Back animation not found! Make sure you have it set on Character -> Basic Moves -> Move Back");
                    }
                    if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveBack.name))
                    {
                        moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveBack);
                    }
                }
            }
        }
        else if (verticalForce > 0 || !IsGrounded())
        {
            if (move != null && controlScript.currentState == PossibleStates.Stand)
            {
                controlScript.currentState = PossibleStates.NeutralJump;
            }
            if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1)
            {
                if (isGroundBouncing)
                {
                    return;
                }

                if (moveDirection == 0)
                {
                    controlScript.currentState = PossibleStates.NeutralJump;
                }
                else
                {
                    if (moveDirection > 0 && controlScript.mirror == -1 ||
                        moveDirection < 0 && controlScript.mirror == 1)
                    {
                        controlScript.currentState = PossibleStates.ForwardJump;
                    }

                    if (moveDirection > 0 && controlScript.mirror == 1 ||
                        moveDirection < 0 && controlScript.mirror == -1)
                    {
                        controlScript.currentState = PossibleStates.BackJump;
                    }
                }

                BasicMoveInfo airAnimation = moveSetScript.basicMoves.jumpStraight;
                if (controlScript.currentSubState == SubStates.Stunned)
                {
                    if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                    {
                        airAnimation = moveSetScript.basicMoves.airWallBounce;
                    }
                    else if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null &&
                             FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce &&
                             UFE.config.comboOptions._knockBackMinForce > 0)
                    {
                        airAnimation = moveSetScript.basicMoves.getHitKnockBack;
                        airTime     *= (Fix64)2;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null)
                        {
                            Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air");
                        }

                        airAnimation = moveSetScript.basicMoves.getHitAir;
                    }
                    if (overrideStunAnimation != null)
                    {
                        airAnimation = overrideStunAnimation;
                    }
                }
                else if (controlScript.isAirRecovering &&
                         (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null))
                {
                    airAnimation = moveSetScript.basicMoves.airRecovery;
                }
                else
                {
                    if (moveSetScript.basicMoves.jumpForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump)
                    {
                        airAnimation = moveSetScript.basicMoves.jumpForward;
                    }
                    else if (moveSetScript.basicMoves.jumpBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump)
                    {
                        airAnimation = moveSetScript.basicMoves.jumpBack;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.jumpStraight.animMap[0].clip == null)
                        {
                            Debug.LogError("Jump animation not found! Make sure you have it set on Character -> Basic Moves -> Jump Straight");
                        }

                        airAnimation = moveSetScript.basicMoves.jumpStraight;
                    }
                }

                if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name))
                {
                    moveSetScript.PlayBasicMove(airAnimation);

                    if (airAnimation.autoSpeed)
                    {
                        moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime));
                    }
                }
            }
            else if (move == null && verticalForce / verticalTotalForce <= 0)
            {
                BasicMoveInfo airAnimation = moveSetScript.basicMoves.fallStraight;
                if (isGroundBouncing && moveSetScript.basicMoves.fallingFromGroundBounce.animMap[0].clip != null)
                {
                    airAnimation = moveSetScript.basicMoves.fallingFromGroundBounce;
                }
                else if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                {
                    airAnimation = moveSetScript.basicMoves.airWallBounce;
                }
                else
                {
                    if (controlScript.currentSubState == SubStates.Stunned)
                    {
                        if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null &&
                            FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce &&
                            UFE.config.comboOptions._knockBackMinForce > 0)
                        {
                            airAnimation = moveSetScript.basicMoves.getHitKnockBack;
                        }
                        else
                        {
                            airAnimation = moveSetScript.basicMoves.getHitAir;
                            if (moveSetScript.basicMoves.fallingFromAirHit.animMap[0].clip != null)
                            {
                                airAnimation = moveSetScript.basicMoves.fallingFromAirHit;
                            }
                            else if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null)
                            {
                                Debug.LogError("Air Juggle animation not found! Make sure you have it set on Character -> Basic Moves -> Air Juggle");
                            }
                        }
                        if (overrideStunAnimation != null)
                        {
                            airAnimation = overrideStunAnimation;
                        }
                    }
                    else if (controlScript.isAirRecovering &&
                             (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null))
                    {
                        airAnimation = moveSetScript.basicMoves.airRecovery;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.fallForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump)
                        {
                            airAnimation = moveSetScript.basicMoves.fallForward;
                        }
                        else if (moveSetScript.basicMoves.fallBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump)
                        {
                            airAnimation = moveSetScript.basicMoves.fallBack;
                        }
                        else
                        {
                            if (moveSetScript.basicMoves.fallStraight.animMap[0].clip == null)
                            {
                                Debug.LogError("Fall animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Straight");
                            }

                            airAnimation = moveSetScript.basicMoves.fallStraight;
                        }
                    }
                }

                if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name))
                {
                    moveSetScript.PlayBasicMove(airAnimation);

                    if (airAnimation.autoSpeed)
                    {
                        moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime));
                    }
                }
            }
        }
        if (horizontalForce == 0 && verticalForce == 0)
        {
            moveDirection = 0;
        }
    }
Exemple #40
0
        /// <summary>
        /// Plays a Card from a Players Hand on their turn to their Bank
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="notJustSayNoAble"></param>
        /// <returns></returns>
        private BoolResponseBox playCardFromHandToBank(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase notJustSayNoAble)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);

            Card cardInHandToBePlayed = currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            PlayerModel player = getPlayerModel(moveInformation.playerMakingMove, nextState);
            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, player);
                if (card != null)
                {
                    player.bank.addCardToBank(card);
                    //Change state on success
                    //has been performed, advance the phase of the game
                    nextState.currentPhase = notJustSayNoAble;
                    List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                    List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                    onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                    updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                    //change the current state to the next state
                    addNextState(nextState);
                    return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has banked " + card.cardName);
                }
                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card id does not exist");
        }
Exemple #41
0
        private BoolResponseBox playActionCardDealBreaker(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);
            PlayerModel playerModelForPlayerToDealBreaker = getPlayerModel(moveInformation.guidOfPlayerWhoIsBeingDealBreakered, nextState);
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.DealBreaker) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    //Do action
                    PropertyCardSet setToDealBreaker = getPropertyCardSet(playerModelForPlayerToDealBreaker.propertySets, moveInformation.guidOfFullSetToBeDealBreakered);
                    if (setToDealBreaker != null && setToDealBreaker.isFullSet() == true)
                    {
                        if (playerModelForPlayerToDealBreaker.propertySets.playersPropertySets.Remove(setToDealBreaker) == true)
                        {
                            //Set taken from player
                            //give to player using dealbreaker card
                            playerModelForPlayer.propertySets.addSet(setToDealBreaker);

                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = nextStatePhase;
                            //Used to set the allowable actions for player
                            playerModelForPlayerToDealBreaker.hasHadCardsTaken = true;
                            //Put card in discard pile
                            nextState.playpile.playCardOnPile(actionCard);
                            //Create event information for rollback and display
                            nextState.actionCardEvent = new ActionCardEvent();
                            nextState.actionCardEvent.playerAffectedByAction = moveInformation.guidOfPlayerWhoIsBeingDealBreakered;
                            nextState.actionCardEvent.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove;
                            nextState.actionCardEvent.playerOnTurnPerformingAction = true;
                            nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;
                            nextState.actionCardEvent.propertySetTakenFromPlayer = setToDealBreaker.guid;
                            nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.DealBreaker;
                            List<CardIDSetGuid> listOfCardDealbreakered = new List<CardIDSetGuid>();
                            foreach (Card property in setToDealBreaker.properties)
                            {
                                listOfCardDealbreakered.Add(new CardIDSetGuid(property.cardID, setToDealBreaker.guid));
                            }
                            if (setToDealBreaker.hasHouse)
                            {
                                listOfCardDealbreakered.Add(new CardIDSetGuid(setToDealBreaker.house.cardID, setToDealBreaker.guid));
                            }
                            if (setToDealBreaker.hasHotel)
                            {
                                listOfCardDealbreakered.Add(new CardIDSetGuid(setToDealBreaker.hotel.cardID, setToDealBreaker.guid));
                            }
                            nextState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn = listOfCardDealbreakered;
                            //change the current state to the next state

                            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                            updateAllowableStatesPerPlayerCardsTaken(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnCardsTaken(new List<TurnActionTypes>(), nextState));

                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Deal Breaker Card");
                        }
                        else
                        {
                            return new BoolResponseBox(false, "Unable to take set from player");
                        }
                    }
                    else
                    {
                        return new BoolResponseBox(false, "Set to Deal Breaker is not a full set or does not exist");
                    }
                }

                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card id does not exist or is not a Deal Breaker Card");
        }
Exemple #42
0
        /// <summary>
        /// Plays a Property Card from a Players Hand on their turn to an existing Property Set
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="notJustSayNoAble"></param>
        /// <returns></returns>
        private BoolResponseBox playPropertyCardFromHand(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase notJustSayNoAble)
        {
            if (moveInformation.guidOfExistingSetToPlayPropertyTo.CompareTo(new Guid()) != 0)
            {
                //Clone the current state to create next state
                nextState = currentState.clone(generateGuidForNextState());
                PropertyColor oldColour = ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).getPropertyColor();
                bool oldOrientation = ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).isCardUp;
                ((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).setPropertyColor(moveInformation.isPropertyToPlayOrientedUp);

                /*
                if ((getPropertyCardSet(getPlayerModel(playerPerformingAction.guid, nextState).propertySets, moveInformation.guidOfExistingSetToPlayPropertyTo)).propertySetColor.CompareTo(
                    ((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).currentPropertyColor) == 0)
                {
                 */
                if (getPropertyCardSet(getPlayerModel(playerPerformingAction.guid, nextState).propertySets, moveInformation.guidOfExistingSetToPlayPropertyTo).isPropertyCompatible((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)))
                {
                    //Get CurrentPlayFieldModelState
                    Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
                    PlayerModel player = getPlayerModel(playerPerformingAction.guid, nextState);
                    Card card = removeCardFromHand(cardInHandToBePlayed, player);
                    if (card != null)
                    {
                        PropertyCard cP = cardInHandToBePlayed as PropertyCard;
                        cP.setPropertyColor(moveInformation.isPropertyToPlayOrientedUp);
                        PropertyCardSet ps = getPropertyCardSet(player.propertySets, moveInformation.guidOfExistingSetToPlayPropertyTo);
                        if (ps.addProperty(cP) == false)
                        {
                            return new BoolResponseBox(false, "Property Card not played. Set full or card incompatible.");
                        }
                        else
                        {
                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = notJustSayNoAble;
                            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has played to a existing set " + card.cardName);
                        }
                    }
                    return new BoolResponseBox(false, "Card is not in hand.");
                }
                else
                {
                    nextState = null;
                    ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).setPropertyColor(oldOrientation);//change back the orientation of the property
                    return new BoolResponseBox(false, "Property Card is not the correct colour to be added to this set");
                }
            }
            else
            {
                return playPropertyCardFromHandToNewSet(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
        }
Exemple #43
0
    private MoveInfo TestMoveExecution(MoveInfo move, MoveInfo currentMove, ButtonPress[] buttonPress, bool inputUp, bool fromSequence)
    {
        if (move.onRelease && !inputUp)
        {
            return(null);
        }
        if (!HasEnoughGauge(move.gaugeUsage))
        {
            return(null);
        }
        if (move.previousMoves.Length > 0 && currentMove == null)
        {
            return(null);
        }
        if (move.previousMoves.Length > 0 && !searchMove(currentMove.name, move.previousMoves))
        {
            return(null);
        }
        if (Array.IndexOf(move.possibleStates, controlsScript.currentState) == -1)
        {
            return(null);
        }

        Array.Sort(buttonPress);
        Array.Sort(move.buttonExecution);

        if (fromSequence)
        {
            if (move.buttonSequence.Length == 0)
            {
                return(null);
            }
            if (move.chargeMove && !charged)
            {
                return(null);
            }

            /*string allbp = "";
             * foreach(ButtonPress bp in lastButtonPresses) allbp += bp.ToString();
             * string allbp2 = "";
             * foreach(ButtonPress bp in move.buttonSequence) allbp2 += bp.ToString();
             * Debug.Log(allbp +"="+ allbp2 +"? "+ ArraysEqual<ButtonPress>(buttonPress, move.buttonExecution));*/

            if (lastButtonPresses.Count >= move.buttonSequence.Length)
            {
                ButtonPress[] compareSequence = lastButtonPresses.GetRange(
                    lastButtonPresses.Count - move.buttonSequence.Length, move.buttonSequence.Length).ToArray();

                if (!ArraysEqual <ButtonPress>(compareSequence, move.buttonSequence))
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }

            //Debug.Log("Sequence pass! Testing Execution:"+ ArraysEqual<ButtonPress>(buttonPress, move.buttonExecution));
        }
        else
        {
            if (move.buttonSequence.Length > 0)
            {
                return(null);
            }
        }

        if (!ArraysEqual <ButtonPress>(buttonPress, move.buttonExecution))
        {
            return(null);
        }

        if (controlsScript.storedMove != null &&
            move.moveName != currentMove.moveName &&
            move.moveName == controlsScript.storedMove.moveName)
        {
            MoveInfo newMove = Instantiate(move) as MoveInfo;
            newMove.name = move.name;
            return(newMove);
        }

        if (controlsScript.currentState == PossibleStates.StraightJump ||
            controlsScript.currentState == PossibleStates.ForwardJump ||
            controlsScript.currentState == PossibleStates.BackJump)
        {
            if (totalAirMoves >= controlsScript.myInfo.possibleAirMoves)
            {
                return(null);
            }
            totalAirMoves++;
        }

        if (currentMove == null || searchMove(move.name, currentMove.frameLink.linkableMoves))
        {
            changeMoveStances(move.changeCombatStance);
            MoveInfo newMove = Instantiate(move) as MoveInfo;
            newMove.name = move.name;
            UFE.FireMove(newMove, controlsScript.myInfo);
            RemoveGauge(move.gaugeUsage);
            //Debug.Log("move "+ newMove.name +" executed.");
            return(newMove);
        }

        return(null);
    }
Exemple #44
0
        /// <summary>
        /// Determines what state the game is currently in and sets the appropriate possible next states for the move being played and calls doAppropriateAction to play the move
        /// </summary>
        /// <param name="lastState"></param>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="typeOfActionToPerform"></param>
        /// <param name="cardsAndPlayersInvolved"></param>
        /// <returns></returns>
        public BoolResponseBox evaluateMove(PlayFieldModel lastState, PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, TurnActionTypes typeOfActionToPerform, MoveInfo cardsAndPlayersInvolved)
        {
            BoolResponseBox result;

            #region Draw2State

            if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Draw_2_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Only action allowable at this phase
                Statephase discard = Statephase.Turn_Started_Draw_2_Cards;
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion Draw2State

            #region Draw5State

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Draw_5_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Only action allowable at this phase
                Statephase discard = Statephase.Turn_Started_Draw_5_Cards;
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion Draw5State

            #region Turn Started Cards Drawn 0 Cards Played

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_0_Cards_Played) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//No cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards can be rearranged at this phase
                //Draw
                Statephase discard = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Only action allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion Turn Started Cards Drawn 0 Cards Played

            #region 0 Cards Played Just Say Noable Card Played

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 0 Cards Played Just Say Noable Card Played

            #region 0 Cards Played Just Say Noable Card Just Say No'd

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Invalid_Action_For_Turn;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase except just say no
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 0 Cards Played Just Say Noable Card Just Say No'd

            #region 1 Card Played State

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                Statephase discard = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 1 Card Played State

            #region 1 Card Played Just Say Noable Card Played

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 1 Card Played Just Say Noable Card Played

            #region 1 Card Played Just Say Noable Card Just Say No'd

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Invalid_Action_For_Turn;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 1 Card Played Just Say Noable Card Just Say No'd

            #region 2 Cards Played State

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No;//Action cards playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;//cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);

                Statephase discard = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 2 Cards Played State

            #region 2 Cards Played State Just Say Noable Card Played

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 2 Cards Played State Just Say Noable Card Played

            #region 2 Cards Played State Just Say Noable Card just Say No'd

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Invalid_Action_For_Turn;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase except just say no
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 2 Cards Played State Just Say Noable Card just Say No'd

            #region 3 Cards Played State

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Invalid_Action_For_Turn;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Invalid_Action_For_Turn;//cards not playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Invalid_Action_For_Turn;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase

                Statephase discard = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 3 Cards Played State

            #region Too many cards in hand at end of turn states

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }
            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }
            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }
            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_8_Cards_In_Hand_Discard_1_Card;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }
            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_8_Cards_In_Hand_Discard_1_Card) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_7_Or_Less_Cards_In_Hand_Setup_NextPlayer;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion Too many cards in hand at end of turn states

            else if (currentState.currentPhase.CompareTo(Statephase.Game_Over) == 0)
            {
                return new BoolResponseBox(false, "Game is over, move not possible");
            }
            else
            {
                return new BoolResponseBox(false, "Game is in an invalid state");
            }
        }
Exemple #45
0
    public void changeMoveStances(CombatStances newStance)
    {
        if (controlsScript.myInfo.currentCombatStance == newStance)
        {
            return;
        }
        foreach (MoveSetData moveSetData in controlsScript.myInfo.moves)
        {
            if (moveSetData.combatStance == newStance)
            {
                basicMoves  = moveSetData.basicMoves;
                attackMoves = moveSetData.attackMoves;
                //moves = moveSetData.attackMoves;

                GameObject opponent = GameObject.Find(gameObject.name);
                if (!opponent.Equals(gameObject) && opponent.name == gameObject.name)                  // Mirror Match Move cloning
                {
                    List <MoveInfo> moveList      = new List <MoveInfo>();
                    bool            alreadyCloned = false;
                    foreach (MoveInfo move in attackMoves)
                    {
                        if (move.name.IndexOf("(Clone)") != -1)
                        {
                            alreadyCloned = true;
                            break;
                        }
                        moveList.Add(Instantiate(move) as MoveInfo);
                    }
                    if (alreadyCloned)
                    {
                        moves = attackMoves;
                    }
                    else
                    {
                        moves = moveList.ToArray();
                    }
                }
                else
                {
                    moves = attackMoves;
                }

                fillMoves();

                if (moveSetData.cinematicIntro != null)
                {
                    intro = Instantiate(moveSetData.cinematicIntro) as MoveInfo;
                    attachAnimation(intro.animationClip, intro.name, intro.animationSpeed, intro.wrapMode);
                }
                if (moveSetData.cinematicOutro != null)
                {
                    outro = Instantiate(moveSetData.cinematicOutro) as MoveInfo;
                    attachAnimation(outro.animationClip, outro.name, outro.animationSpeed, outro.wrapMode);
                }

                controlsScript.myInfo.currentCombatStance = newStance;

                System.Array.Sort(moves, delegate(MoveInfo move1, MoveInfo move2) {
                    return(move1.buttonSequence.Length.CompareTo(move2.buttonSequence.Length));
                });
                System.Array.Reverse(moves);

                return;
            }
        }
    }
Exemple #46
0
        /// <summary>
        /// Determines the type of action to perform and calls the correct method to perform it
        /// </summary>
        /// <param name="lastState">The state previous to the current state.</param>
        /// <param name="currentState">The current state.</param>
        /// <param name="nextState">A reference for the next state</param>
        /// <param name="playerPerformingAction">The Guid of the player who is performing the action.</param>
        /// <param name="typeOfActionToPerform">The type of action the player is performing.</param>
        /// <param name="justSayNoAble">The StatePhase the state should be if the action is performed and is able to be Just Say No'd</param>
        /// <param name="notJustSayNoAble">The StatePhase the state should be if the action is performed and is not able to be Just Say No'd</param>
        /// <param name="rearrangeProperties">The StatePhase the state should be if the action is performed is to move properties between sets</param>
        /// <param name="drawCardsAtTurnStart">The StatePhase the state should be if the action is performed is to draw cards at the start of a turn</param>
        /// <param name="JustSayNoUsedByOpposition">The StatePhase the state should be if the action is performed and is a player using a Just Say No card against an Action Card affecting them played by the player who is on their turn</param>
        /// <param name="moveInformation">The MoveInfo containing the information required to perform the action.</param>
        /// <param name="discard">The StatePhase the state should be if the action is performed is to end a turn and the player has to discard cards</param>
        /// <returns></returns>
        private BoolResponseBox doAppropriateAction(PlayFieldModel lastState, PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, TurnActionTypes typeOfActionToPerform, Statephase justSayNoAble, Statephase notJustSayNoAble, Statephase rearrangeProperties, Statephase drawCardsAtTurnStart, Statephase JustSayNoUsedByOpposition, MoveInfo moveInformation, Statephase discard)
        {
            if (typeOfActionToPerform.CompareTo(TurnActionTypes.drawTwoCardsAtStartOfTurn) == 0)
            {
                return draw2CardsAtStartOfTurn(currentState, nextState, playerPerformingAction, drawCardsAtTurnStart);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.drawFiveCardsAtStartOfTurn) == 0)
            {
                return draw5CardsAtStartOfTurn(currentState, nextState, playerPerformingAction, drawCardsAtTurnStart);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.EndTurn) == 0)
            {
                return endTurn(currentState, nextState, playerPerformingAction);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.MovePropertyCard) == 0)
            {
                return movePropertyCard(currentState, nextState, playerPerformingAction, moveInformation, rearrangeProperties);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PlayPropertyCardFromHand) == 0)
            {
                return playPropertyCardFromHand(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PlayPropertyCard_New_Set) == 0)
            {
                return playPropertyCardFromHandToNewSet(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.BankActionCard) == 0)
            {
                return playCardFromHandToBank(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.BankMoneyCard) == 0)
            {
                return playCardFromHandToBank(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.Discard_1_Card) == 0)
            {
                return discard1Card(currentState, nextState, playerPerformingAction, moveInformation, discard);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PayDebt) == 0)
            {
                return payDebt(currentState, nextState, playerPerformingAction, moveInformation, justSayNoAble, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.Dont_Play_Just_Say_No) == 0)
            {
                return doNotPlayJustSayNo(currentState, nextState, playerPerformingAction, moveInformation, justSayNoAble, notJustSayNoAble);
            }

            //ActionCards
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PlayActionCard) == 0 || typeOfActionToPerform.CompareTo(TurnActionTypes.PlayCard) == 0)
            {
                if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.PassGo) == 0)
                {
                    Statephase nextStatePhase = notJustSayNoAble;
                    return playActionCardPassGo(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.DebtCollector) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardDebtCollector(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.ItsMyBirthday) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardItsMyBirthday(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.JustSayNo) == 0)
                {
                    Statephase nextStatePhase = notJustSayNoAble;//TODO switch to justsaynoable
                    return playActionCardJustSayNo(currentState, nextState, playerPerformingAction, nextStatePhase, justSayNoAble, JustSayNoUsedByOpposition, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.RentMultiColor) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardRentMultiColor(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.RentStandard) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardRentStandard(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.SlyDeal) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardSlyDeal(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.ForcedDeal) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardForcedDeal(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.DealBreaker) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardDealBreaker(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.House) == 0)
                {
                    Statephase nextStatePhase = notJustSayNoAble;
                    return playActionCardHouse(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.Hotel) == 0)
                {
                    Statephase nextStatePhase = notJustSayNoAble;
                    return playActionCardHotel(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                throw new NotImplementedException();
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PlayJustSayNo) == 0)
            {
                Statephase nextStatePhase = notJustSayNoAble;//should be just say noable
                return playActionCardJustSayNo(currentState, nextState, playerPerformingAction, nextStatePhase, justSayNoAble, JustSayNoUsedByOpposition, moveInformation);
            }
            else
            {
                return new BoolResponseBox(false, "Unsupported action:" + typeOfActionToPerform.ToString());
            }
        }
            public void ResetRound()
            {
                ScoreTotal = ScoreTotal + ScoreRound;
                KillsTotal = KillsTotal + KillsRound;
                DeathsTotal = DeathsTotal + DeathsRound;
                MovesTotal = MovesTotal + MovesRound;
                MovesByMBTotal = MovesByMBTotal + MovesByMBRound;
                Rounds = (Rounds > 0) ? Rounds + 1 : 1;

                ScoreRound = -1;
                KillsRound = -1;
                DeathsRound = -1;
                KDRRound = -1;
                SPMRound = -1;
                KPMRound = -1;
                IsDeployed = false;
                SpawnChatMessage = String.Empty;
                SpawnYellMessage = String.Empty;
                QuietMessage = false;
                DelayedMove = null;
                LastMoveTo = 0;
                LastMoveFrom = 0;

                MovesRound = 0;
                MovesByMBRound = 0;
                DispersalGroup = 0;
                MovedTimestamp = DateTime.MinValue;
                // MovedByMBTimestamp reset when minutes exceeds MinutesAfterBeingMoved
            }
Exemple #48
0
        private BoolResponseBox playActionCardHouse(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.House) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    PropertyCardSet ps = getPropertyCardSet(playerModelForPlayer.propertySets, moveInformation.guidFullSetToAddHouseTo);
                    if (ps != null)
                    {
                        if (ps.addHouse(actionCard))
                        {
                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = nextStatePhase;
                            //Put card in discard pile
                            nextState.playpile.playCardOnPile(actionCard);
                            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has added a house to a set");
                        }
                        else
                        {
                            return new BoolResponseBox(false, "House can not be added to this set");
                        }
                    }
                    return new BoolResponseBox(false, "Set does not exist");
                }
                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card is not in hand or is not a House card");
        }
Exemple #49
0
 void MovePlayedHandler(MoveInfo move)
 {
     gameHistoryCounter[Game.GameMoveNumber] = searchStackCounter[1];
     searchStackCounter[0] = searchStackCounter[1];
 }
Exemple #50
0
        private BoolResponseBox playActionCardForcedDeal(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);
            PlayerModel playerModelForPlayerToForcedDeal = getPlayerModel(moveInformation.guidOfPlayerWhoIsBeingForcedDealed, nextState);
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.ForcedDeal) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    //Do action
                    PropertyCardSet setToForcedDealFrom = getPropertyCardSet(playerModelForPlayerToForcedDeal.propertySets, moveInformation.guidOfSetCardToBeForcedDealedIsIn);
                    PropertyCard cardToForcedDealFor = nextState.deck.getCardByID(moveInformation.idOfCardToBeForcedDealed) as PropertyCard;

                    PropertyCardSet setToGiveUpCardFrom = getPropertyCardSet(playerModelForPlayer.propertySets, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn);
                    PropertyCard cardToGiveUp = nextState.deck.getCardByID(moveInformation.idOfCardToBeGivenUpInForcedDeal) as PropertyCard;
                    if (setToForcedDealFrom != null && cardToForcedDealFor != null && setToGiveUpCardFrom != null && cardToGiveUp != null)
                    {
                        if (playerModelForPlayerToForcedDeal.removePropertyCardFromPlayersPropertySet(cardToForcedDealFor, moveInformation.guidOfSetCardToBeForcedDealedIsIn) != null)
                        {
                            //Card Removed from set
                            //Create new set with card Forced Dealed in it
                            PropertyCardSet newSetForcedDealCard = new PropertyCardSet(cardToForcedDealFor);
                            playerModelForPlayer.propertySets.addSet(newSetForcedDealCard);
                            if (playerModelForPlayer.removePropertyCardFromPlayersPropertySet(cardToGiveUp, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn) != null)
                            {
                                //Forced dealed player recieves card given up in forced deal
                                PropertyCardSet newSetGivenUpCard = new PropertyCardSet(cardToGiveUp);
                                playerModelForPlayerToForcedDeal.propertySets.addSet(newSetGivenUpCard);
                                playerModelForPlayerToForcedDeal.hasHadCardsTaken = true;
                                //Change state on success
                                //has been performed, advance the phase of the game
                                nextState.currentPhase = nextStatePhase;
                                //Put card in discard pile
                                nextState.playpile.playCardOnPile(actionCard);
                                List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                                List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                                onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                                nextState.actionCardEvent = new ActionCardEvent();
                                nextState.actionCardEvent.playerAffectedByAction = moveInformation.guidOfPlayerWhoIsBeingForcedDealed;
                                nextState.actionCardEvent.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove;
                                nextState.actionCardEvent.playerOnTurnPerformingAction = true;
                                nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;

                                nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.ForcedDeal;
                                List<CardIDSetGuid> listOfCardsForcedDealed = new List<CardIDSetGuid>();
                                listOfCardsForcedDealed.Add(new CardIDSetGuid(moveInformation.idOfCardToBeForcedDealed, moveInformation.guidOfSetCardToBeForcedDealedIsIn));
                                nextState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn = listOfCardsForcedDealed;
                                nextState.actionCardEvent.propertyCardGivenUpInForcedDeal = new CardIDSetGuid(moveInformation.idOfCardToBeGivenUpInForcedDeal, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn);
                                //change the current state to the next state

                                updateAllowableStatesPerPlayerCardsTaken(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnCardsTaken(new List<TurnActionTypes>(), nextState));
                                addNextState(nextState);
                                return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Forced Deal Card");
                            }
                            else
                            {
                                return new BoolResponseBox(false, "Unable to remove card to be given up");
                            }
                        }
                        else
                        {
                            return new BoolResponseBox(false, "Unable to remove card from player being forced dealed set");
                        }
                    }
                    else
                    {
                        return new BoolResponseBox(false, "Card to Forced Deal or set the card is in does not exist");
                    }
                }

                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card is not in hand or is not a Forced Deal Card");
        }
Exemple #51
0
 protected virtual void OnHit(HitBox strokeHitBox, MoveInfo move, CharacterInfo player)
 {
     // You can use this to have your own custom events when a character gets hit
     // TODO: we should use the player number instead of the character info because both players could use the same character
 }