예제 #1
0
        protected CardEffectPair genAttorneyTrialAddSwayEffectPair(int infoIdx)
        {
            return(new CardEffectPair(
                       (Game game, Player choosingPlayer, ChoiceHandler choiceHandler) =>
            {
                List <BoardObject> bos = game.FindBO(
                    (BoardObject bo) =>
                {
                    return
                    bo.Properties.Contains(Property.Sway) &&
                    bo.Properties.Contains(Property.Track) &&
                    bo.Properties.Contains(Property.Jury);
                });

                BoardChoices boardChoices;
                choiceHandler.ChooseBoardObjects(
                    bos,
                    (Dictionary <BoardObject, int> selected) =>
                {
                    int actionPtsLeft = ActionPts - HTUtility.CalcActionPtUsage(selected);
                    return (actionPtsLeft >= 0);
                },
                    (List <BoardObject> choicesLeft, Dictionary <BoardObject, int> selected) =>
                {
                    return choicesLeft.FindAll(t =>
                                               (choosingPlayer.Side == Player.PlayerSide.Prosecution) ? !((SwayTrack)t).IsLockedByProsecution : !((SwayTrack)t).IsLockedByDefense);
                },
                    (Dictionary <BoardObject, int> selected) =>
                {
                    int actionPtsLeft = ActionPts - HTUtility.CalcActionPtUsage(selected);
                    return (actionPtsLeft == 0);
                },
                    game,
                    choosingPlayer,
                    this.CardInfo.TrialInChiefInfos[infoIdx].Description,
                    out boardChoices);

                return boardChoices;
            },
                       (Game game, Player choosingPlayer, BoardChoices boardChoices) =>
            {
                int sideMod = (choosingPlayer.Side == Player.PlayerSide.Prosecution) ? 1 : -1;
                foreach (KeyValuePair <BoardObject, int> kv in boardChoices.SelectedObjs)
                {
                    SwayTrack track = (SwayTrack)kv.Key;
                    track.AddToValue(sideMod * kv.Value);
                }
            }));
        }
예제 #2
0
        public bool PlayAsAction(Game game, Player choosingPlayer, ChoiceHandler choiceHandler)
        {
            bool isSummation = game.CurState.StateType == GameState.GameStateType.Summation;

            int modValue = (choosingPlayer.Side == Player.PlayerSide.Prosecution) ? 1 : -1;
            List <BoardObject> choices = game.FindBO(
                (BoardObject bo) =>
            {
                return((bo.Properties.Contains(Property.Track) &&
                        ((bo.Properties.Contains(Property.Jury) && bo.Properties.Contains(Property.Sway)) ||
                         (!isSummation && bo.Properties.Contains(Property.Aspect)))) &&
                       ((Track)bo).CanModifyByAction(modValue));
            }).ToList();

            int actionPtsForState = isSummation ? 2 : Template.ActionPts;

            BoardChoices boardChoices;

            choiceHandler.ChooseBoardObjects(choices,
                                             HTUtility.GenActionValidateChoicesFunc(actionPtsForState, null),
                                             HTUtility.GenActionFilterChoicesFunc(actionPtsForState, null),
                                             HTUtility.GenActionChoicesCompleteFunc(actionPtsForState, null),
                                             game,
                                             choosingPlayer,
                                             "Select usage for " + actionPtsForState + " action points",
                                             out boardChoices);

            if (boardChoices.NotCancelled)
            {
                string str = "";

                foreach (BoardObject bo in boardChoices.SelectedObjs.Keys)
                {
                    str += bo + " modified by " + modValue * boardChoices.SelectedObjs[bo] + "\n";
                    if (bo.GetType() == typeof(AspectTrack))
                    {
                        ((AspectTrack)bo).ModTrackByAction(modValue * boardChoices.SelectedObjs[bo]);
                    }
                    else
                    {
                        ((Track)bo).AddToValue(modValue * boardChoices.SelectedObjs[bo]);
                    }
                }
                FileLogger.Instance.Log(str);
            }

            return(boardChoices.NotCancelled);
        }