Esempio n. 1
0
        protected Jury chooseJuryChoice(List <Jury> juries, Player curPlayer, string desc)
        {
            Jury jury = null;

            while (jury == null)
            {
                BoardChoices boardChoices;
                curPlayer.ChoiceHandler.ChooseBoardObjects(
                    juries.Cast <BoardObject>().ToList(),
                    (Dictionary <BoardObject, int> selected) => { return(true); },
                    (List <BoardObject> remainingChoices, Dictionary <BoardObject, int> selected) =>
                {
                    return(remainingChoices.Where(obj => !selected.ContainsKey(obj)).ToList());
                },
                    (Dictionary <BoardObject, int> selected) => { return(selected.Keys.Count == 1); },
                    game,
                    curPlayer,
                    desc,
                    out boardChoices);

                if (boardChoices.NotCancelled)
                {
                    jury = (Jury)boardChoices.SelectedObjs.Keys.First();
                }
            }

            return(jury);
        }
Esempio n. 2
0
            public JuryAspect(Game game, Jury _owner, Property trait, Property aspect)
                : base(game, trait, aspect)
            {
                Properties.Add(Property.Jury);
                Properties.Add(Property.Aspect);

                Trait  = trait;
                Aspect = aspect;

                seenStatus.Add(Player.PlayerSide.Prosecution, false);
                seenStatus.Add(Player.PlayerSide.Defense, false);

                Owner = _owner;
            }
Esempio n. 3
0
        public static Func <List <BoardObject>, Dictionary <BoardObject, int>, List <BoardObject> > GenActionFilterChoicesFunc(int actionPts, Jury delibJury)
        {
            return
                ((List <BoardObject> choicesLeft, Dictionary <BoardObject, int> selected) =>
            {
                List <BoardObject> filtChoices = new List <BoardObject>();
                foreach (BoardObject bo in choicesLeft)
                {
                    int affectLimit = 2;
                    if (delibJury != null)
                    {
                        affectLimit = 0;
                        foreach (Jury.JuryAspect aspect in delibJury.Aspects)
                        {
                            affectLimit += (bo.Properties.Contains(aspect.Aspect)) ? 1 : 0;
                        }
                    }

                    if (!selected.ContainsKey(bo) || selected[bo] < affectLimit)
                    {
                        filtChoices.Add(bo);
                    }
                }

                // Filter out any already selected aspect tracks if only 1 action pt left.
                int actionPtsLeft = actionPts - CalcActionPtUsage(selected);
                if (actionPtsLeft == 1)
                {
                    filtChoices = filtChoices.Where(bo => (bo.GetType() == typeof(SwayTrack)) || (bo.GetType() == typeof(AspectTrack) && !selected.ContainsKey(bo))).ToList();
                }

                // Filter out any swayTracks that have been selected and by result can no longer be affected.
                List <BoardObject> finalChoices = new List <BoardObject>();
                foreach (BoardObject obj in filtChoices)
                {
                    if (obj.GetType() == typeof(SwayTrack) && selected.ContainsKey(obj))
                    {
                        SwayTrack track = (SwayTrack)obj;
                        if ((selected[obj] + Math.Abs(track.Value)) < track.MaxValue)
                        {
                            finalChoices.Add(obj);
                        }
                    }
                    else
                    {
                        finalChoices.Add(obj);
                    }
                }

                return finalChoices;
            });
        }
Esempio n. 4
0
        public static Func <Dictionary <BoardObject, int>, bool> GenActionValidateChoicesFunc(int actionPts, Jury delibJury)
        {
            return
                ((Dictionary <BoardObject, int> selected) =>
            {
                bool isValid = true;
                int actionPtsLeft = actionPts;

                foreach (BoardObject bo in selected.Keys)
                {
                    int affectLimit = 2;
                    if (delibJury != null)
                    {
                        affectLimit = 0;
                        foreach (Jury.JuryAspect aspect in delibJury.Aspects)
                        {
                            affectLimit += (bo.Properties.Contains(aspect.Aspect)) ? 1 : 0;
                        }
                    }

                    if (selected[bo] > affectLimit)
                    {
                        isValid = false;
                        break;
                    }
                }

                if (isValid)
                {
                    actionPtsLeft -= CalcActionPtUsage(selected);
                    isValid &= (actionPtsLeft >= 0);
                }

                return isValid;
            });
        }
Esempio n. 5
0
 public void RemoveJury(Jury jury)
 {
     Juries.Remove(jury);
     game.RemoveBoardObject(jury);
 }
Esempio n. 6
0
 public SwayTrack(int min, int max, Game game, Jury _owner, params Property[] _properties)
     : base(0, min, max, game, _properties)
 {
     owner = _owner;
     Properties.Add(Property.Sway);
 }