Esempio n. 1
0
        public static Dictionary <Guid, IntegrityCheck> GetErrors(Modifiable mod)
        {
            var graph = GraphExplorer.PreSaving(() => GraphExplorer.FromRoot(mod));
            var error = GraphExplorer.FullIntegrityCheck(graph);

            return(error);
        }
Esempio n. 2
0
        protected TypedBuilderSettings()
        {
            Items = new Dictionary <string, object>();

            _resultTypeValue  = new Modifiable <Type>(typeof(string));
            _contentTypeValue = new Modifiable <Type>(typeof(string));
            _errorTypeValue   = new Modifiable <Type>(typeof(EmptyError));

            HandlerRegister   = new TypedHandlerRegister();
            DeserializeResult = true;

            SuppressCancellationErrors     = false;
            SuppressTypeMismatchExceptions = false;
            MediaType            = "application/json";
            MediaTypeFormatters  = new MediaTypeFormatterCollection().FluentAdd(new StringMediaFormatter());
            ResultType           = typeof(string);
            ErrorType            = typeof(string);
            ContentType          = typeof(EmptyRequest);
            DefaultResultFactory = TypeHelpers.GetDefaultValueForType;
            DefaultErrorFactory  = (type, exception) => TypeHelpers.GetDefaultValueForType(type);
            ExceptionFactory     = ObjectHelpers.CreateTypedException;

            HttpContentFactory = ObjectHelpers.CreateHttpContent;
            ResultFactory      = ObjectHelpers.CreateResult;
            ErrorFactory       = ObjectHelpers.CreateError;
        }
Esempio n. 3
0
    static void Main(string[] args)
    {
        Modifiable <int> modInt = new Modifiable <int>(5);

        modInt.OnModified += (old, val) => { Console.WriteLine("Modified from {0} to {1}", old, val); };
        modInt.SetValue(4);
        Console.ReadLine();
    }
Esempio n. 4
0
        protected override void Awake()
        {
            base.Awake();
            ManaStat manaStat = this.GetComponent <ManaStat>();

            this.manaBaseModifier = manaStat.Base.Modify((ref float manaBase) => manaBase += this.value * this.manaPerIntelligence);
            ManaRegenerationStat manaRegenerationStat = this.GetComponent <ManaRegenerationStat>();

            this.manaRegenerationBaseModifier = manaRegenerationStat.Base.Modify((ref float manaRegenerationBase) => manaRegenerationBase += this.value * this.manaRegenerationPerIntelligence);
        }
Esempio n. 5
0
        protected override void Awake()
        {
            base.Awake();
            HealthStat healthStat = this.GetComponent <HealthStat>();

            this.healthBaseModifier = healthStat.Base.Modify((ref float healthBase) => healthBase += this.value * this.healthPerStrength);
            HealthRegenerationStat healthRegenerationStat = this.GetComponent <HealthRegenerationStat>();

            this.healthRegenerationBaseModifier = healthRegenerationStat.Base.Modify((ref float healthRegenerationBase) => healthRegenerationBase += this.value * this.healthRegenerationPerStrength);
        }
Esempio n. 6
0
	public GUICircularMenuOptions(GUICircularMenu owner, GUICircularData data) {
		isRadioGroup = 	 new Modifiable<bool>(data.isRadioGroup,ValueChanged);
		openFromCenter = new Modifiable<bool>(data.openFromCenter,ValueChanged);
		radius = 		 new Modifiable<float>(data.radius,ValueChanged);
		startAngle = 	 new Modifiable<float>(data.startAngle,ValueChanged);
		arcDegrees = 	 new Modifiable<float>(data.arcDegrees,ValueChanged);
		direction = 	 new Modifiable<GUIObject.Direction>(data.direction,ValueChanged);
		buttonSize =	 new Modifiable<float>(data.buttonSize,ValueChanged);
		
		this.owner = owner;
	}
Esempio n. 7
0
        public static bool AssertErrors(Modifiable mod, Window window)
        {
            var error = GetErrors(mod);

            if (error != null)
            {
                MessageBox.Show(window, NormalWindowMessage.ImpossibleToSaveIntegrityCheckFailed.NiceToString() + error.Values.SelectMany(a => a.Errors.Values).ToString("\r\n"), NormalWindowMessage.ThereAreErrors.NiceToString(),
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            return(true);
        }
Esempio n. 8
0
        static void Propagate(Modifiable item, DirectedGraph <Modifiable> inverseGraph)
        {
            if (item.Modified == ModifiedState.Modified)
            {
                return;
            }

            item.Modified = ModifiedState.Modified;
            foreach (var other in inverseGraph.RelatedTo(item))
            {
                Propagate(other, inverseGraph);
            }
        }
        public static IEnumerable <Modifiable> IdentifiableExplore(Modifiable obj)
        {
            if (obj == null)//|| obj is Lite)
            {
                yield break;
            }

            if (Reflector.IsMList(obj.GetType()))
            {
                Type t = obj.GetType().ElementType();

                if (t.IsModifiable() && !t.IsEntity())
                {
                    IEnumerable col = obj as IEnumerable;
                    foreach (Modifiable item in col)
                    {
                        if (item != null)
                        {
                            yield return(item);
                        }
                    }
                }
            }
            else
            {
                foreach (Func <object, object> getter in ModifiableFieldGetters(obj.GetType()))
                {
                    object field = getter(obj);

                    if (field == null || field is Entity)
                    {
                        continue;
                    }

                    yield return((Modifiable)field);
                }

                Entity ident = obj as Entity;
                if (ident != null)
                {
                    foreach (var mixin in ident.Mixins)
                    {
                        yield return(mixin);
                    }
                }
            }
        }
        public static IEnumerable <Modifiable> FullExploreVirtual(Modifiable obj)
        {
            if (obj == null)
            {
                yield break;
            }

            if (Reflector.IsMList(obj.GetType()))
            {
                Type t = obj.GetType().ElementType();
                if (Reflector.IsModifiableIdentifiableOrLite(t))
                {
                    IEnumerable col = obj as IEnumerable;
                    foreach (Modifiable item in col)
                    {
                        if (item != null)
                        {
                            yield return(item);
                        }
                    }
                }
            }
            else
            {
                foreach (Func <object, object> getter in ModifiableFieldGettersVirtual(obj.GetType()))
                {
                    object field = getter(obj);

                    if (field == null)
                    {
                        continue;
                    }

                    yield return((Modifiable)field);
                }

                if (obj is Entity ident)
                {
                    foreach (var mixin in ident.Mixins)
                    {
                        yield return(mixin);
                    }
                }
            }
        }
Esempio n. 11
0
        public static bool EmbeddedOrNew(Modifiable entity)
        {
            if (entity is EmbeddedEntity)
            {
                return(true);
            }

            if (entity is IEntity)
            {
                return(((IEntity)entity).IsNew);
            }

            if (entity is Lite <IEntity> )
            {
                return(((Lite <IEntity>)entity).IsNew);
            }

            return(false);
        }
Esempio n. 12
0
        protected override void CreateComponents()
        {
            base.CreateComponents();
            _abilitiable  = new Abilitiable(this);
            _armorable    = new Armorable(this);
            _healthable   = new Healthable(this);
            _magicable    = new Magicable(this);
            _teamable     = new Teamable(this);
            _attackerable = new Attackerable(this, _teamable);
            var agent    = GetComponent <NavMeshAgent>();
            var obstacle = GetComponent <NavMeshObstacle>();

            _movable       = new Movable(this, agent, obstacle);
            _targetable    = new Targetable(this);
            _killable      = new Killable(this);
            _damageTarget  = new Damageable(this, _healthable, _killable, _armorable);
            _modifiable    = new Modifiable(this);
            _inventoryable = new Inventoryable <IItem>(this, new LimitedInventory <IItem>(6));
            _healable      = new Healable(this, _healthable);
        }
Esempio n. 13
0
        public static bool IsGraphModified(Modifiable modifiable)
        {
            var graph = FromRoot(modifiable);

            return(graph.Any(a => a.IsGraphModified));
        }
Esempio n. 14
0
 public ModifyCardEvent(Card card, Modifiable m, Clojurex c, int value)
     : base(GameEventType.MODIFYCARD)
 {
     this.card = card;
     modifiable = m;
     this.value = value;
     clojure = c;
 }
Esempio n. 15
0
 public static bool HasChanges(Modifiable mod)
 {
     return(GraphExplorer.FromRoot(mod).Any(a => a.Modified == ModifiedState.SelfModified));
 }
Esempio n. 16
0
 public DynamicAura(Func<Card, bool> filter, Modifiable attribute, Func<int> function, string description)
     : base(filter, attribute, 0, description)
 {
     this.function = function;
 }
Esempio n. 17
0
 public Modifier(Modifiable <T> modifiable, Transformation transformation)
 {
     this.modifiable     = modifiable;
     this.transformation = transformation;
 }
Esempio n. 18
0
 public static DirectedGraph <Modifiable> FromRootVirtual(Modifiable root)
 {
     return(DirectedGraph <Modifiable> .Generate(root, ModifyInspector.FullExploreVirtual, ReferenceEqualityComparer <Modifiable> .Default));
 }
Esempio n. 19
0
 private void Modifiable_Recalc(On.Sunshine.Metric.Modifiable.orig_Recalc orig, Modifiable self, CharacterSheet ch)
 {
     orig(self, ch);
     if (self is Skill)
     {
         int  actualRankValue      = 0;
         bool hasActualAdvancement = false;
         foreach (var modifier in self.GetModifierList())
         {
             if (modifier.type == ModifierType.ADVANCEMENT)
             {
                 actualRankValue     += modifier.Amount;
                 hasActualAdvancement = true;
             }
         }
         self.rankValue      = actualRankValue;
         self.hasAdvancement = hasActualAdvancement;
     }
 }
Esempio n. 20
0
 public Aura(Func<Card, bool> filter, Modifiable attribute, int value, string description)
 {
     this.filter = filter;
     this.attribute = attribute;
     this.value = value;
     this.description = description;
 }
Esempio n. 21
0
        public Card(CardId c)
        {
            cardId = c;
            location = null;

            List<SubEffect> fx = new List<SubEffect>();

            keyAbilities = new List<KeyAbility>();
            string castDescription = "";
            int redCost = 0, greenCost = 0, whiteCost = 0, blackCost = 0, blueCost = 0, greyCost = 0;

            string s = cardId.ToString();
            StringBuilder b = new StringBuilder();
            b.Append(s[0]);
            for (int i = 1; i < s.Length; i++)
            {
                char ch = s[i];
                if ((byte)ch <= 90) { b.Append(' '); }

                b.Append(ch);
            }
            auras = new List<Aura>();
            name = b.ToString();
            baseActivatedAbilities = new List<ActivatedAbility>();
            baseTriggeredAbilities = new List<TriggeredAbility>();

            List<SubCost> castingCosts = new List<SubCost>();

            Colour? forceColour = null;
            int? basePower = null, baseToughness = null;

            switch (cardId)
            {
                #region Kappa
                case CardId.Kappa:
                    {
                        blueCost = 2;
                        greyCost = 2;
                        basePower = 1;
                        baseToughness = 3;
                        cardType = CardType.Creature;
                        race = Race.Salamander;
                        activatedAbilities.Add(new ActivatedAbility(this,
                        new Cost(new ExhaustCost(this)),
                            new Effect(new Mill(new ResolveTargetRule(ResolveTarget.CONTROLLER), 4)),
                            true,
                            LocationPile.FIELD,
                        "E: Target player mills 4 cards."));
                    }
                    break;
                #endregion
                #region GrizzlyBear
                case CardId.GrizzlyBear:
                    {
                        greenCost = 2;
                        cardType = CardType.Creature;
                        race = Race.Bear;
                        subType = SubType.Warrior;
                        basePower = 3;
                        baseToughness = 3;
                    }
                    break;
                #endregion
                #region LightningBolt
                case CardId.LightningBolt:
                    {
                        redCost = 1;
                        greyCost = 1;
                        cardType = CardType.Instant;
                        fx.Add(new Ping(new FilterTargetRule(1, FilterLambda.ZAPPABLE), 3));
                        castDescription = "Deal 3 damage to target player or creature.";
                    }
                    break;
                #endregion
                #region ForkedLightning
                case CardId.ForkedLightning:
                    {
                        redCost = 1;
                        greyCost = 1;
                        cardType = CardType.Sorcery;
                        fx.Add(new Ping(new FilterTargetRule(2, FilterLambda.ZAPPABLE), 1));
                        castDescription = "Deal 1 damage to 2 target players or creatures.";
                    }
                    break;
                #endregion
                #region SolemnAberration
                case CardId.SolemnAberration:
                    {
                        blackCost = 1;
                        cardType = CardType.Creature;
                        race = Race.Zombie;
                        basePower = 2;
                        baseToughness = 1;
                    }
                    break;
                #endregion
                #region PropheticVision
                case CardId.PropheticVision:
                    {
                        blueCost = 2;
                        cardType = CardType.Sorcery;
                        fx.Add(new Draw(new ResolveTargetRule(ResolveTarget.CONTROLLER), 2));
                        castDescription = "Draw 2 cards.";
                    }
                    break;
                #endregion
                #region DragonHatchling
                case CardId.DragonHatchling:
                    {
                        redCost = 1;
                        cardType = CardType.Creature;
                        race = Race.Dragon;
                        basePower = 1;
                        baseToughness = 1;
                        keyAbilities.Add(KeyAbility.Fervor);
                    }
                    break;
                #endregion
                #region TempleHealer
                case CardId.TempleHealer:
                    {
                        whiteCost = 3;
                        greyCost = 1;
                        cardType = CardType.Creature;
                        race = Race.Human;
                        subType = SubType.Cleric;
                        basePower = 4;
                        baseToughness = 4;
                        EventFilter e = vanillaETB;
                        baseTriggeredAbilities.Add(new TriggeredAbility(this,
                            friendlyETB,
                            underYourControlETBDescription + "gain 1 life.",
                            LocationPile.FIELD, EventTiming.Post, new GainLife(new ResolveTargetRule(ResolveTarget.CONTROLLER), 1)));
                    }
                    break;
                #endregion
                #region Rapture
                case CardId.Rapture:
                    {
                        whiteCost = 2;
                        greyCost = 1;
                        cardType = CardType.Instant;
                        fx.Add(new MoveTo(new FilterTargetRule(1, FilterLambda.ZAPPABLE, FilterLambda.CREATURE), LocationPile.EXILE));
                        castDescription = "Exile target creature";
                    }
                    break;
                #endregion
                #region CallToArms
                case CardId.CallToArms:
                    {
                        whiteCost = 1;
                        cardType = CardType.Sorcery;
                        fx.Add(new SummonTokens(new ResolveTargetRule(ResolveTarget.CONTROLLER), CardId.Squire, CardId.Squire));
                        castDescription = "Summon two Squires.";
                    }
                    break;
                #endregion
                #region Squire
                case CardId.Squire:
                    {
                        isToken = true;
                        race = Race.Human;
                        baseToughness = 1;
                        basePower = 1;
                        forceColour = Colour.WHITE;

                    }
                    break;
                #endregion
                #region ShimmeringKoi
                case CardId.ShimmeringKoi:
                    {
                        blueCost = 2;
                        greyCost = 2;
                        cardType = CardType.Creature;
                        race = Race.Fish;
                        basePower = 2;
                        baseToughness = 3;
                        baseTriggeredAbilities.Add(new TriggeredAbility(this,
                            thisETB(this),
                            thisETBDescription + "draw a card.",
                            LocationPile.FIELD, EventTiming.Post,
                            new Draw(new ResolveTargetRule(ResolveTarget.CONTROLLER), 1)
                            ));
                    }
                    break;
                #endregion
                #region Belwas
                case CardId.Belwas:
                    {
                        whiteCost = 2;
                        greyCost = 1;
                        basePower = 3;
                        baseToughness = 2;
                        cardType = CardType.Creature;
                        race = Race.Human;
                        Aura a = new Aura(
                            (crd) => crd.controller == this.controller && crd.colour == Colour.WHITE && crd != this,
                            Modifiable.Power,
                            1,
                            "Other white creatures you control get +1/+0.");
                        auras.Add(a);
                    }
                    break;
                #endregion
                #region AlterTime
                case CardId.AlterTime:
                    {
                        blueCost = 1;
                        cardType = CardType.Instant;
                        fx.Add(new Timelapse(2));
                        fx.Add(new Draw(new ResolveTargetRule(ResolveTarget.CONTROLLER), 1));
                        castDescription = "Timelapse 2 " + timelapseReminder2 + "\nDraw a card.";
                    }
                    break;
                #endregion
                #region GrizzlyCub
                case CardId.GrizzlyCub:
                    {
                        greenCost = 1;
                        cardType = CardType.Creature;
                        race = Race.Bear;
                        basePower = 2;
                        baseToughness = 2;
                    }
                    break;
                #endregion
                #region EvolveFangs
                case CardId.EvolveFangs:
                    {
                        greenCost = 1;
                        cardType = CardType.Instant;
                        fx.Add(new ModifyUntil(new FilterTargetRule(1, FilterLambda.ZAPPABLE, FilterLambda.CREATURE), Modifiable.Power, never, 2));
                        castDescription = "Target creature gets +2/+0.";
                    }
                    break;
                #endregion
                #region IlasGambit
                case CardId.IlasGambit:
                    {
                        name = "Ila's Gambit";
                        blackCost = 1;
                        castingCosts.Add(new PayLifeCost(3));
                        cardType = CardType.Sorcery;
                        fx.Add(
                            new MoveTo(new SelectFromTargetRule(
                                new ResolveTargetRule(ResolveTarget.CONTROLLER),
                                new FilterTargetRule(1, FilterLambda.PLAYER),
                                p => p.hand.cards.ToArray()),
                            LocationPile.GRAVEYARD));
                        castDescription =
                            "As an additional cost to casting this card pay 3 life.\nLook at target players hand and choose 1 card from it. The chosen card is discarded.";
                    }
                    break;
                #endregion
                #region YungLich
                case CardId.YungLich:
                    {
                        blackCost = 1;
                        blueCost = 1;
                        greyCost = 1;
                        cardType = CardType.Creature;
                        race = Race.Zombie;
                        subType = SubType.Wizard;
                        basePower = 2;
                        baseToughness = 2;
                        triggeredAbilities.Add(new TriggeredAbility(this, thisDies(this),
                            thisDiesDescription + "draw a card.",
                            LocationPile.GRAVEYARD, EventTiming.Post,
                            new Draw(new ResolveTargetRule(ResolveTarget.CONTROLLER), 1)));
                    }
                    break;
                #endregion
                #region Unmake
                case CardId.Unmake:
                    {
                        blueCost = 1;
                        cardType = CardType.Instant;
                        fx.Add(new MoveTo(new FilterTargetRule(1, FilterLambda.ZAPPABLE, FilterLambda.CREATURE), LocationPile.HAND));
                        castDescription = "Return target creature to its owners hand.";
                    }
                    break;
                #endregion
                #region EnragedDragon
                case CardId.EnragedDragon:
                    {
                        redCost = 2;
                        cardType = CardType.Creature;
                        race = Race.Dragon;
                        basePower = 3;
                        baseToughness = 2;
                        triggeredAbilities.Add(new TriggeredAbility(this, thisETB(this), thisETBDescription + " deal 1 damage to target player or creature.",
                            LocationPile.FIELD, EventTiming.Post,
                            () => true,
                            new Ping(new FilterTargetRule(1, FilterLambda.ZAPPABLE), 1)));
                    }
                    break;
                #endregion
                #region SteamBolt
                case CardId.SteamBolt:
                    {
                        redCost = 1;
                        blueCost = 1;
                        cardType = CardType.Instant;
                        fx.Add(new Ping(new FilterTargetRule(1, FilterLambda.ZAPPABLE), 1));
                        fx.Add(new Draw(new ResolveTargetRule(ResolveTarget.CONTROLLER), 1));
                        castDescription = "Deal 1 damage to target creature or player.\nDraw a card.";
                    }
                    break;
                #endregion
                #region IlasGravekeeper
                case CardId.IlasGravekeeper:
                    {
                        name = "Ila's Gravekeeper";
                        blackCost = 3;
                        basePower = 0;
                        baseToughness = 4;
                        cardType = CardType.Creature;
                        race = Race.Zombie;
                        auras.Add(new DynamicAura((a) => a == this, Modifiable.Power, () => owner.field.cards.Count(card => card.race == Race.Zombie), "Ila's Gravekeeper gets +1/+0 for each zombie under your control."));
                    }
                    break;
                #endregion
                #region RottingZombie
                //todo: phrasing and balance
                case CardId.RottingZombie:
                    {
                        //todo: phrasing and balance
                        blackCost = 2;
                        greyCost = 1;
                        basePower = 2;
                        baseToughness = 3;
                        cardType = CardType.Creature;
                        race = Race.Zombie;

                        EventFilter f = (e) =>
                        {
                            if (e.type != GameEventType.MOVECARD) return false;
                            MoveCardEvent mevent = (MoveCardEvent)e;
                            return mevent.from?.pile == LocationPile.FIELD && mevent.to?.pile == LocationPile.GRAVEYARD &&
                                   mevent.card.owner == owner && mevent.card.isCreature && mevent.card != this;
                        };

                    triggeredAbilities.Add(new TriggeredAbility(this, f, "Whenever a friendly creature dies this creature gets +1/+1.", LocationPile.FIELD, EventTiming.Post,
                            new ModifyUntil(new ResolveTargetRule(ResolveTarget.SELF), Modifiable.Power, () => false, 1),
                            new ModifyUntil(new ResolveTargetRule(ResolveTarget.SELF), Modifiable.Toughness, () => false, 1)));
                    }
                    break;
                #endregion
                #region Infiltrator
                case CardId.Infiltrator:
                    {
                        blueCost = 3;
                    basePower = 3;
                    baseToughness = 3;
                        cardType = CardType.Creature;
                        EventFilter f = (e) =>
                        {
                            if (e.type != GameEventType.DAMAGEPLAYER) { return false; }
                            DamagePlayerEvent devent = (DamagePlayerEvent)e;
                            return devent.source == this;
                        };
                    triggeredAbilities.Add(new TriggeredAbility(this, f, "Whenever this creature deals damage to a player that player Mills 3.", LocationPile.FIELD, EventTiming.Post,
                        new Mill(new ResolveTargetRule(ResolveTarget.OPPONENT), 3)));
                    }
                    break;
                #endregion
                #region RiderOfDeath
                case CardId.RiderOfDeath:
                    {
                        name = "Rider of Death";
                        blackCost = 3;
                        greyCost = 2;
                        cardType = CardType.Creature;
                        basePower = 5;
                        baseToughness = 4;
                        triggeredAbilities.Add(new TriggeredAbility(this, thisETB(this), thisETBDescription + "kill target creature.",
                            LocationPile.FIELD, EventTiming.Post, () => true, new MoveTo(new FilterTargetRule(1, FilterLambda.ZAPPABLE, FilterLambda.CREATURE), LocationPile.GRAVEYARD)));
                    }
                    break;
                #endregion
                #region IlatianWineMerchant
                case CardId.IlatianWineMerchant:
                    {
                        blackCost = 1;
                        greyCost = 2;
                        cardType = CardType.Creature;
                        basePower = 1;
                        baseToughness = 2;

                    activatedAbilities.Add(new ActivatedAbility(this, new Cost(new MoveToCost(LocationPile.HAND, LocationPile.GRAVEYARD, 1)), new Effect(new GainLife(new ResolveTargetRule(ResolveTarget.CONTROLLER), 3)), true, LocationPile.FIELD, "Discard a card: Gain 3 life."));
                        //triggeredAbilities.Add(new ActivatedAbility(this, new Cost(), ));
                        /*
                        Card c = fx.Add(new MoveTo(new FilterTargetRule(1, FilterLambda.INHAND), LocationPile.GRAVEYARD)); //todo jasin: take cost of creature and put it in gainlife
                        fx.Add(new GainLife(new ResolveTargetRule(ResolveTarget.CONTROLLER), c.manacost));
                        */
                    }
                    break;
                #endregion
                #region MeteorRain
                case CardId.MeteorRain: //todo: seba review
                    {
                        redCost = 2;
                        greyCost = 1;
                        cardType = CardType.Sorcery;
                        castDescription = "Deal 3 damage to all creatures.";
                    fx.Add(new Ping(new ResolveTargetRule(ResolveTarget.ALLCREATURES), 3));
                    }
                    break;
                #endregion
                #region FuryOfTheRighteous
                case CardId.FuryOfTheRighteous: //todo: seba review
                    {
                        name = "Fury of the Righteous";
                        whiteCost = 2;
                        greyCost = 2;
                        cardType = CardType.Sorcery;
                        castDescription = "Deal 2 damage to all creatures your opponent controls.";
                    fx.Add(new Ping(new ResolveTargetRule(ResolveTarget.OPPONENTCREATURES), 2));
                    }
                    break;
                #endregion
                #region Extinguish
                case CardId.Extinguish: //todo: seba review
                    {
                        blackCost = 2;
                        cardType = CardType.Instant;
                        castDescription = "Kill target creature.";
                        flavourText = "Be gone!";
                        fx.Add(new MoveTo(new FilterTargetRule(1, FilterLambda.ZAPPABLE, FilterLambda.CREATURE), LocationPile.GRAVEYARD));
                    }
                    break;
                #endregion
                #region ElderTreeant
                case CardId.ElderTreeant: //todo serious balance and flavor issues
                    {
                    greenCost = 2;
                    greyCost = 1;
                        basePower = 1;
                        baseToughness = 2;
                        cardType = CardType.Creature;
                    activatedAbilities.Add(new ActivatedAbility(this, new Cost(new ManaCost(0,0,0,0,2,1)),
                            new Effect(new ModifyUntil(new ResolveTargetRule(ResolveTarget.SELF), Modifiable.Power, never, 1),
                            new ModifyUntil(new ResolveTargetRule(ResolveTarget.SELF), Modifiable.Toughness, never, 1)), true,
                        LocationPile.FIELD, "1GG: Gain +1/+1."));
                    }
                    break;
                #endregion
                #region EssenceOfDemise
                //todo: each time player casts spell deal one damage to face
                case CardId.EssenceOfDemise:
                    {
                        name = "Essence of Demise";
                        blackCost = 3;
                        greyCost = 1;
                        cardType = CardType.Relic;
                        auras.Add(new Aura((crd) => crd.isCreature, Modifiable.Power, -1, "All creatures get -1/-1."));
                        auras.Add(new Aura((crd) => crd.isCreature, Modifiable.Toughness, -1, ""));
                    }
                    break;
                #endregion
                #region Counterspell
                case CardId.Counterspell:
                    {
                        blueCost = 2;
                        greyCost = 1;
                        cardType = CardType.Instant;
                        castDescription = "Counter target spell.";
                        fx.Add(new CounterSpell(new FilterTargetRule(1, FilterLambda.ONSTACK)));
                    }
                    break;
                #endregion
                #region EssenceOfRage
                case CardId.EssenceOfRage:
                    {
                        name = "Essence of Rage";
                        redCost = 3;
                        greyCost = 1;
                        cardType = CardType.Relic;

                        triggeredAbilities.Add(new TriggeredAbility(this, stepFilter(Step.END), "At the beginning of each end step deal 1 damage to all players.",
                            LocationPile.FIELD, EventTiming.Post, new Ping(new ResolveTargetRule(ResolveTarget.CONTROLLER), 1), new Ping(new ResolveTargetRule(ResolveTarget.OPPONENT), 1)));
                    }
                    break;
                #endregion
                #region EssenceOfClarity
                case CardId.EssenceOfClarity:
                    {
                        name = "Essence of Clarity";
                        blueCost = 3;
                        greyCost = 1;
                        cardType = CardType.Relic;

                        triggeredAbilities.Add(new TriggeredAbility(this, stepFilter(Step.END), "At the beginning of each player's end step that player draws a card.",
                            LocationPile.FIELD, EventTiming.Post, new Draw(new ResolveTargetRule(ResolveTarget.ACTIVE), 1)));
                    }
                    break;
                #endregion
                #region EssenceOfWilderness

                /*
                case CardId.EssenceOfWilderness:
                {
                    name = "Essence of Wilderness";
                    greenCost = 3;
                    cardType = CardType.Relic;

                    EventFilter f = (gevent) =>
                    {
                        if (gevent.type != GameEventType.MOVECARD) return false;
                        MoveCardEvent mevent = (MoveCardEvent) gevent;
                        return mevent.to.pile == LocationPile.FIELD &&mevent.card.cardType == CardType.Creature;
                    };

                    triggeredAbilities.Add(new TriggeredAbility(this, ));
                } break;
                */
                #endregion
                #region EssenceOfValor
                /*
                case CardId.EssenceOfValor:
                {
                    name = "Essence of Valor";
                    whiteCost = 3;
                    cardType = CardType.Relic;

                    //creatures with more than 3 damage cannot attack
                } break;
                */
                #endregion
                #region IlasMagicLamp
                /*
                case CardId.IlasMagicLamp:
                {
                    name = "Ila's Magic Lamp";
                    blackCost = 1;
                    cardType = CardType.Sorcery;

                    //has three charges, get card from deck and shuffle deck

                } break;
                */
                #endregion
                #region StampedingDragon
                case CardId.StampedingDragon:
                    {
                    redCost = 3;
                        baseToughness = 1;
                    basePower = 6;
                        cardType = CardType.Creature; ;

                        keyAbilities.Add(KeyAbility.Fervor);
                    triggeredAbilities.Add(new TriggeredAbility(this, stepFilter(Step.END), "At the end of turn sacrifice this creature.",
                            LocationPile.FIELD, EventTiming.Post, new MoveTo(new ResolveTargetRule(ResolveTarget.SELF), LocationPile.GRAVEYARD)));
                    }
                    break;
                #endregion
                #region MorenianMedic
                case CardId.MorenianMedic:
                    {
                        whiteCost = 2;
                        basePower = 2;
                        baseToughness = 2;
                        activatedAbilities.Add(new ActivatedAbility(this,
                        new Cost(new ExhaustCost(this), new ManaCost(1, 0, 0, 0, 0, 1)),
                            new Effect(new GainLife(new ResolveTargetRule(ResolveTarget.CONTROLLER), 2)),
                            true,
                            LocationPile.FIELD,
                        "E, 1W: Gain 2 life."));
                    }
                    break;
                #endregion
                #region MattysGambit
                case CardId.MattysGambit:
                    {
                        name = "Matty's Gambit";
                        redCost = 1;
                        castingCosts.Add(new PayLifeCost(3));
                        castDescription =
                            "As an additional cost to casting this card pay 3 life.\nDeal 4 damage to target creature or player.";
                        cardType = CardType.Instant;
                        fx.Add(new Ping(new FilterTargetRule(1, FilterLambda.ZAPPABLE), 4));
                    }
                    break;
                #endregion
                #region BelwasGambit
                case CardId.BelwasGambit:
                    {
                        name = "Belwas's Gambit";
                        whiteCost = 1;
                        castingCosts.Add(new PayLifeCost(4));
                        castDescription =
                            "As an additional cost to casting this card pay 4 life.\nTarget creature gets +3/+3.";
                        cardType = CardType.Instant;
                        fx.Add(new ModifyUntil(new FilterTargetRule(1, FilterLambda.CREATURE, FilterLambda.ONFIELD), Modifiable.Power, never, 3));
                        fx.Add(new ModifyUntil(new ResolveTargetRule(ResolveTarget.LAST), Modifiable.Toughness, never, 3));
                    }
                    break;
                #endregion
                #region GrazingBison
                case CardId.GrazingBison:
                    {
                        cardType = CardType.Creature;
                        race = Race.Bison;
                        greenCost = 2;
                        greyCost = 2;
                        basePower = 4;
                        baseToughness = 5;
                    }
                    break;
                #endregion
                #region RockhandOgre
                case CardId.RockhandOgre:
                    {
                        cardType = CardType.Creature;
                        race = Race.Ogre;
                        greenCost = 3;
                        greyCost = 3;
                        basePower = 6;
                        baseToughness = 7;
                    }
                    break;
                #endregion
                #region Figment
                case CardId.Figment:
                    {
                        blackCost = 2;
                        greyCost = 1;
                        cardType = CardType.Sorcery;
                        castDescription = "Search your deck for a card and put it to your hand. Shuffle your deck.";
                        fx.Add(new MoveTo(
                            new SelectFromTargetRule(new ResolveTargetRule(ResolveTarget.CONTROLLER), new ResolveTargetRule(ResolveTarget.LAST),
                        (p) => p.deck.cards.ToArray()),
                            LocationPile.HAND));
                        fx.Add(new Shuffle(new ResolveTargetRule(ResolveTarget.CONTROLLER), false));

                    }
                    break;
                #endregion
                #region SebasGambit
                case CardId.SebasGambit:
                    {
                        name = "Seba's Gambit";
                        blueCost = 1;
                        castingCosts.Add(new PayLifeCost(4));
                        castDescription =
                            "As an additional cost to casting this card pay 4 life.\nCounter target spell.";
                        cardType = CardType.Instant;
                        fx.Add(new CounterSpell(new FilterTargetRule(1, FilterLambda.ONSTACK)));
                    }
                    break;
                #endregion
                #region AberrantSacrifice
                case CardId.AberrantSacrifice:
                {
                    blackCost = 2;
                    castingCosts.Add(new MoveToCost(LocationPile.FIELD, LocationPile.GRAVEYARD, 1));
                    cardType = CardType.Sorcery;
                    fx.Add(new Draw(new ResolveTargetRule(ResolveTarget.CONTROLLER), 2));
                    castDescription = "As an additional cost to cast this card sacrifice a creature.\nDraw 2 cards.";
                } break;
                #endregion
                #region Spark
                case CardId.Spark:
                {
                    redCost = 1;
                    cardType = CardType.Instant;
                    fx.Add(new Ping(new FilterTargetRule(1, FilterLambda.ZAPPABLE), 2));
                    castDescription = "Deal 2 damage to target creature or player.";
                } break;
                #endregion
                #region MaleficentSpirit
                case CardId.MaleficentSpirit:
                {
                    blackCost = 2;
                    greyCost = 2;
                    basePower = 3;
                    baseToughness = 2;
                    cardType = CardType.Creature;
                    triggeredAbilities.Add(new TriggeredAbility(this,
                        thisETB(this),
                        thisETBDescription + "target player discards a card.",
                        LocationPile.FIELD,
                        EventTiming.Post,
                        new Effect(new MoveTo(new SelectFromTargetRule(
                            new FilterTargetRule(1, FilterLambda.PLAYER),
                            new ResolveTargetRule(ResolveTarget.LAST),
                            p => p.hand.cards.ToArray()), LocationPile.GRAVEYARD))
                        ));
                } break;
                #endregion
                #region Bubastis
                case CardId.Bubastis:
                {
                    blueCost = 4;
                    greyCost = 3;
                    basePower = 5;
                    baseToughness = 5;
                    cardType = CardType.Creature;
                    activatedAbilities.Add(new ActivatedAbility(this,
                        new Cost(new ManaCost(0, 2, 0, 0, 0, 1)),
                        new Effect(new Exhaust(new FilterTargetRule(1, FilterLambda.CREATURE, FilterLambda.ONFIELD))),
                        true,
                        LocationPile.FIELD,
                        "1UU: Exhaust target creature."
                        ));
                } break;
                #endregion
                #region HauntedChapel
                case CardId.HauntedChapel:
                {
                    blackCost = 2;
                    whiteCost = 2;
                    cardType = CardType.Relic;
                    activatedAbilities.Add(new ActivatedAbility(this,
                        new Cost(new ManaCost(1, 0, 1, 0, 0, 0), new MoveToCost(LocationPile.GRAVEYARD, LocationPile.EXILE, 1), new ExhaustCost(this)),
                        new Effect(new SummonTokens(new ResolveTargetRule(ResolveTarget.CONTROLLER), CardId.Spirit)),
                        true,
                        LocationPile.FIELD,
                        "E, BW, Exile a card from your graveyard: Put a 1/1 white Spirit token with flying onto the battlefield."
                        ));
                } break;
                #endregion
                #region Spirit
                case CardId.Spirit:
                {
                    isToken = true;
                    keyAbilities.Add(KeyAbility.Flying);
                    forceColour = Colour.WHITE;
                    basePower = 1;
                    baseToughness = 1;
                } break;
                #endregion
                #region OneWithNature
                case CardId.OneWithNature:
                {
                    greenCost = 1;
                    cardType = CardType.Sorcery;
                    fx.Add(new GainBonusMana(new ResolveTargetRule(ResolveTarget.CONTROLLER), Colour.GREEN, Colour.GREEN, Colour.GREEN));
                    castDescription = "Add GGG until end of step.";
                } break;
                #endregion
                #region MysteriousLilac
                case CardId.MysteriousLilac:
                {
                    blueCost = 1;
                    cardType = CardType.Relic;
                        triggeredAbilities.Add(new TriggeredAbility(this,
                            thisETB(this),
                            thisETBDescription + "draw 1 card.",
                            LocationPile.FIELD,
                            EventTiming.Post,
                            new Effect(new Draw(new ResolveTargetRule(ResolveTarget.CONTROLLER), 1))
                            ));
                    activatedAbilities.Add(new ActivatedAbility(this,
                        new Cost(new ManaCost(0, 0, 0, 0, 0, 2)),
                        new Effect(new GainBonusMana(new ResolveTargetRule(ResolveTarget.CONTROLLER), Colour.BLUE)),
                        true,
                        LocationPile.FIELD,
                        "2: Gain U until end of step."
                        ));
                } break;
                #endregion
                #region Overgrow
                case CardId.Overgrow:
                {
                    greenCost = 2;
                    cardType = CardType.Instant;
                    fx.Add(new MoveTo(new FilterTargetRule(1, FilterLambda.RELIC, FilterLambda.ONFIELD), LocationPile.GRAVEYARD));
                    castDescription = "Destroy target relic.";
                } break;
                #endregion
                #region Abolish
                case CardId.Abolish:
                    {
                        whiteCost = 2;
                        cardType = CardType.Instant;
                        fx.Add(new MoveTo(new FilterTargetRule(1, FilterLambda.RELIC, FilterLambda.ONFIELD), LocationPile.GRAVEYARD));
                        castDescription = "Destroy target relic.";
                    }
                    break;
                #endregion
                #region ElvenDruid
                case CardId.ElvenDruid:
                {
                    greenCost = 1;
                    cardType = CardType.Creature;
                    basePower = 1;
                    baseToughness = 1;
                    activatedAbilities.Add(new ActivatedAbility(this,
                        new Cost(new ExhaustCost(this)),
                        new Effect(new GainBonusMana(new ResolveTargetRule(ResolveTarget.CONTROLLER), Colour.GREEN)),
                        true,
                        LocationPile.FIELD,
                        "E: Gain G until end of step."
                        ));
                } break;
                #endregion
                #region ChromaticUnicorn
                case CardId.ChromaticUnicorn:
                {
                    greenCost = 1;
                    cardType = CardType.Creature;
                    basePower = 1;
                    baseToughness = 1;
                    auras.Add(new DynamicAura(crd => this == crd,
                        Modifiable.Power,
                        () => owner.getMaxMana((int)Colour.RED) > 0 ? 2 : 0,
                        "This creature gets +2/+0 as long as you have a red mana orb."
                        ));
                    auras.Add(new DynamicAura(crd => this == crd,
                        Modifiable.Toughness,
                        () => owner.getMaxMana((int)Colour.WHITE) > 0 ? 2 : 0,
                        "This creature gets +0/+2 as long as you have a white mana orb."
                        ));
                    } break;
                #endregion
                #region Flamemane
                case CardId.Flamemane:
                {
                    redCost = 3;
                    greyCost = 1;
                    cardType = CardType.Creature;
                    basePower = 4;
                    baseToughness = 4;
                    keyAbilities.Add(KeyAbility.Flying);
                    activatedAbilities.Add(new ActivatedAbility(this,
                        new Cost(new ManaCost(0, 0, 0, 2, 0, 0)),
                        new Effect(new Ping(new FilterTargetRule(1, FilterLambda.ZAPPABLE), 1)),
                        true,
                        LocationPile.FIELD,
                        "RR: Deal 1 damage to target creature or player."
                        ));
                } break;
                #endregion
                #region CoupDeGrace
                case CardId.CoupDeGrace:
                {
                    whiteCost = 1;
                    cardType = CardType.Instant;
                    fx.Add(
                        new MoveTo(
                            new FilterTargetRule(1, FilterLambda.CREATURE, FilterLambda.ONFIELD, FilterLambda.EXHAUSTED),
                            LocationPile.GRAVEYARD));
                    castDescription = "Destroy target exhausted creature.";
                }
                    break;

                    #endregion
                #region LoneRanger
                case CardId.LoneRanger:
                {
                    //better if it isnt when summoned, instead it should be dynamic when no other creatures are on board?
                    //filter doesn't account for relics on board
                    greenCost = 2;
                    cardType = CardType.Creature;
                    basePower = 2;
                    baseToughness = 2;
                    auras.Add(new DynamicAura(crd => crd == this,
                        Modifiable.Power,
                        () => owner.field.cards.Count() == 1 ? 1 : 0,
                        "This creature gains +1/+2 as long as you control no other permanents."));
                    auras.Add(new DynamicAura(crd => crd == this,
                        Modifiable.Toughness,
                        () => owner.field.cards.Count() == 1 ? 2 : 0,
                        ""));
                    } break;
                #endregion
                #region DecayingZombie
                case CardId.DecayingZombie:
                {
                    cardType = CardType.Creature;
                    blackCost = 2;
                    basePower = 4;
                    baseToughness = 5;
                    triggeredAbilities.Add(new TriggeredAbility(this, stepFilter(Step.END, true), "At the beginning of your endstep this creature gains -1/-1.",
                        LocationPile.FIELD, EventTiming.Post,
                        new ModifyUntil(new ResolveTargetRule(ResolveTarget.SELF), Modifiable.Power, never, -1),
                        new ModifyUntil(new ResolveTargetRule(ResolveTarget.SELF), Modifiable.Toughness, never, -1)));
                    race = Race.Zombie;
                } break;
                #endregion

                #region AsylumWarden
                case CardId.AsylumWarden:
                {
                    cardType = CardType.Creature;
                    blackCost = 1;
                    whiteCost = 1;
                    basePower = 2;
                    baseToughness = 2;
                        triggeredAbilities.Add(new TriggeredAbility(this, thisDies(this),
                                thisDiesDescription + "put a 1/1 white Spirit token with flying onto the battlefield.",
                                LocationPile.GRAVEYARD, EventTiming.Post,
                                new SummonTokens(new ResolveTargetRule(ResolveTarget.CONTROLLER), CardId.Spirit)));
                    } break;
                #endregion
                #region default
                default:
                    {
                        throw new Exception("pls no" + c.ToString());
                    }
                #endregion
            }
            if (basePower != null)
            {
                power = new Modifiable<int>(add, sub);
                power.setBaseValue(basePower.Value);
                toughness = new Modifiable<int>(add, sub);
                toughness.setBaseValue(baseToughness.Value);
            }

            Effect x = new Effect(fx.ToArray());
            castingCost = new ManaCost(whiteCost, blueCost, blackCost, redCost, greenCost, greyCost);
            castingCosts.Add(castingCost);
            Cost cc = new Cost(castingCosts.ToArray());
            castAbility = new ActivatedAbility(this,
                cc,
                new Effect(fx.ToArray()),
                cardType == CardType.Instant,
                LocationPile.HAND, castDescription);
            baseActivatedAbilities.Add(castAbility);

            if ((basePower == null) != (baseToughness == null))
            {
                throw new Exception("bad thing b0ss");
            }

            var vs = castingCost.costsEnumerable;
            List<int> n = new List<int>();
            int ctr = 0;
            foreach (var v in vs)
            {
                if (v != 0)
                {
                    n.Add(ctr);
                }
                if (++ctr == 5)
                {
                    break;
                }
            }
            if (n.Count() == 0)
            {
                if (!forceColour.HasValue)
                {
                    colour = Colour.GREY;
                }
                else
                {
                    colour = forceColour.Value;
                }
            }
            else if (n.Count() == 1)
            {
                colour = (Colour)n.First();
            }
            else
            {
                colour = Colour.MULTI;
            }
        }
Esempio n. 22
0
 public static DirectedGraph <Modifiable> FromRootIdentifiable(Modifiable root)
 {
     return(DirectedGraph <Modifiable> .Generate(root, ModifyInspector.IdentifiableExplore, ReferenceEqualityComparer <Modifiable> .Default));
 }
Esempio n. 23
0
 private static string Modified(Modifiable ie)
 {
     return("({0})".FormatWith(ie.Modified));
 }
Esempio n. 24
0
 public void modify(Modifiable m, int v, Clojurex c)
 {
     mods[(int)m].addModifier(v, c);
     notifyObservers();
 }
Esempio n. 25
0
	public override void SetPosition (Modifiable<Vector2> newPosition)
	{
		base.SetPosition (newPosition);
		AdjustElements();
	}
Esempio n. 26
0
 public ModifyUntil(TargetRule t, Modifiable attribute, Clojurex filter, int value)
     : base(t)
 {
     this.attribute = attribute;
     this.filter = filter;
     this.value = value;
 }