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; }); }
public Jury(int id, int swayMax, int _actionPoints, Game game, Property religionAspect, Property languageAspect, Property occupationAspect) : base(game, Property.Jury) { Id = id; ActionPoints = _actionPoints; SwayTrack = new SwayTrack(-swayMax, swayMax, game, this, Property.Jury); Aspects = new List <JuryAspect>(); Aspects.Add(new JuryAspect(game, this, Property.Religion, religionAspect)); Aspects.Add(new JuryAspect(game, this, Property.Language, languageAspect)); Aspects.Add(new JuryAspect(game, this, Property.Occupation, occupationAspect)); }
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); } })); }
protected CardEffectPair genAttorneySummationClearSwayEffectPair(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) => { return true; }, (List <BoardObject> choicesLeft, Dictionary <BoardObject, int> selected) => { return choicesLeft; }, (Dictionary <BoardObject, int> selected) => { return selected.Count == 1; }, game, choosingPlayer, this.CardInfo.SummationInfos[infoIdx].Description, out boardChoices); return boardChoices; }, (Game game, Player choosingPlayer, BoardChoices boardChoices) => { SwayTrack track = (SwayTrack)boardChoices.SelectedObjs.Keys.First(); track.ResetValue(); track.AddToValue((choosingPlayer.Side == Player.PlayerSide.Prosecution) ? 1 : -1); })); }