Beispiel #1
0
    public override IEnumerable<CardTemplate> GetCards()
    {
      yield return Card
        .Named("Thran Weaponry")
        .ManaCost("{4}")
        .Type("Artifact")
        .Text(
          "{Echo} {4}{EOL}You may choose not to untap Thran Weaponry during your untap step.{EOL}{2},{T}: All creatures get +2/+2 for as long as Thran Weaponry remains tapped.")
        .MayChooseToUntap()
        .Echo("{4}")
        .ActivatedAbility(p =>
          {
            p.Text = "{2},{T}: All creatures get +2/+2 for as long as Thran Weaponry remains tapped.";
            p.Cost = new AggregateCost(
              new PayMana(2.Colorless(), ManaUsage.Abilities),
              new Tap());

            p.Effect = () => new ApplyModifiersToPlayer(
              selector: e => e.Controller,
              modifiers: () =>
                {
                  var cp = new ContinuousEffectParameters
                    {
                      Modifier = () => new AddPowerAndToughness(2, 2),
                      CardFilter = (card, _) => card.Is().Creature
                    };
                  
                  var effect = new ContinuousEffect(cp);

                  var modifier = new AddContiniousEffect(effect);
                  modifier.AddLifetime(new ModifierSourceGetsUntapedLifetime());
                  
                  return modifier;
                });
            
            p.TimingRule(new OnYourTurn(Step.DeclareBlockers));
          });
    }
Beispiel #2
0
        public override IEnumerable <CardTemplate> GetCards()
        {
            yield return(Card
                         .Named("Thran Weaponry")
                         .ManaCost("{4}")
                         .Type("Artifact")
                         .Text(
                             "{Echo} {4}{EOL}You may choose not to untap Thran Weaponry during your untap step.{EOL}{2},{T}: All creatures get +2/+2 for as long as Thran Weaponry remains tapped.")
                         .MayChooseToUntap()
                         .Echo("{4}")
                         .ActivatedAbility(p =>
            {
                p.Text = "{2},{T}: All creatures get +2/+2 for as long as Thran Weaponry remains tapped.";
                p.Cost = new AggregateCost(
                    new PayMana(2.Colorless(), ManaUsage.Abilities),
                    new Tap());

                p.Effect = () => new ApplyModifiersToPlayer(
                    selector: e => e.Controller,
                    modifiers: () =>
                {
                    var cp = new ContinuousEffectParameters
                    {
                        Modifier = () => new AddPowerAndToughness(2, 2),
                        CardFilter = (card, _) => card.Is().Creature
                    };

                    var effect = new ContinuousEffect(cp);

                    var modifier = new AddContiniousEffect(effect);
                    modifier.AddLifetime(new ModifierSourceGetsUntapedLifetime());

                    return modifier;
                });

                p.TimingRule(new OnYourTurn(Step.DeclareBlockers));
            }));
        }
Beispiel #3
0
 public AddContiniousEffect(ContinuousEffect continiousEffect)
 {
     _continiousEffect = continiousEffect;
 }
 public void Remove(ContinuousEffect effect)
 {
     _continiousEffects.Remove(effect);
       effect.Deactivate();
 }
 public void Add(ContinuousEffect effect)
 {
     _continiousEffects.Add(effect);
 }
 public AddContiniousEffect(ContinuousEffect continiousEffect)
 {
     _continiousEffect = continiousEffect;
 }
Beispiel #7
0
        public void TestModifications()
        {
            var       mtg     = new MTG();
            MTGObject testobj = new MTGObject(new MTGObject.BaseCardAttributes
            {
                name      = "Test Creature",
                cardTypes = new HashSet <MTGObject.CardType> {
                    MTGObject.CardType.Creature
                },
                manaCost  = new ManaCost(2, ManaSymbol.Blue, ManaSymbol.Red),
                power     = 1,
                toughness = 1
            });;

            mtg.CreateObject(testobj);
            mtg.CalculateBoardState();
            Assert.AreEqual(testobj.attr.power, 1);
            Assert.AreEqual(testobj.attr.toughness, 1);

            var contEffect = new ContinuousEffect(null, ContinuousEffect.Duration.Infinite);

            // All creatures get +2/+0
            contEffect.AddModification(
                new PowerMod {
                value     = 2, operation = Modification.Operation.Add,
                condition = (obj) =>
                {
                    if (!obj.attr.cardTypes.Contains(MTGObject.CardType.Creature))
                    {
                        return(false);
                    }
                    return(true);
                }
            }
                );
            // All creatures get -0/-1
            contEffect.AddModification(
                new ToughnessMod
            {
                value     = 1,
                operation = Modification.Operation.Subtract,
                condition = (obj) =>
                {
                    if (!obj.attr.cardTypes.Contains(MTGObject.CardType.Creature))
                    {
                        return(false);
                    }
                    return(true);
                }
            }
                );

            mtg.continuousEffects.Add(contEffect);
            mtg.CalculateBoardState();
            Assert.AreEqual(testobj.attr.power, 3);
            Assert.AreEqual(testobj.attr.toughness, 0);

            // All blue creatures are green
            contEffect = new ContinuousEffect(null, ContinuousEffect.Duration.Infinite);
            contEffect.AddModification(
                new ColorMod
            {
                value     = Color.Green,
                operation = Modification.Operation.Override,
                condition = (obj) =>
                {
                    if (!obj.attr.cardTypes.Contains(MTGObject.CardType.Creature))
                    {
                        return(false);
                    }
                    if (!obj.attr.color.HasColor(Color.Blue))
                    {
                        return(false);
                    }
                    return(true);
                }
            }
                );
            mtg.continuousEffects.Clear();
            mtg.continuousEffects.Add(contEffect);
            mtg.CalculateBoardState();
            Assert.AreEqual(testobj.identity, Color.Green);

            // All creatures are artifacts
            contEffect.AddModification(
                new CardTypeMod
            {
                value = new HashSet <MTGObject.CardType> {
                    MTGObject.CardType.Artifact
                },
                operation = Modification.Operation.Override
            }
                );
            mtg.continuousEffects.Clear();
            mtg.continuousEffects.Add(contEffect);

            // Type is before color, so the color mod should fail as
            // the object is now an artifact
            mtg.CalculateBoardState();
            Assert.AreEqual(testobj.identity, Color.Izzet);
        }
        public override IEnumerable <CardTemplate> GetCards()
        {
            yield return(Card
                         .Named("Garruk, Apex Predator")
                         .ManaCost("{5}{B}{G}")
                         .Type("Planeswalker Garruk")
                         .Text("{+1}: Destroy another target planeswalker.{EOL}" +
                               "{+1}: Create a 3/3 black Beast creature token with deathtouch.{EOL}" +
                               "{-3}: Destroy target creature. You gain life equal to its toughness.{EOL}" +
                               "{-8}: Target opponent gets an emblem with 'Whenever a creature attacks you, it gets +5/+5 and gains trample until end of turn.'")
                         .Loyality(5)
                         .ActivatedAbility(p =>
            {
                p.Text = "{+1}: Destroy another target planeswalker.";

                p.Cost = new AddCountersCost(CounterType.Loyality, 1);
                p.Effect = () => new DestroyTargetPermanents();
                p.TargetSelector.AddEffect(trg => trg.Is.Card(c => c.Is().Planeswalker).On.Battlefield());
                p.TargetingRule(new EffectDestroy());
                p.TimingRule(new OnFirstMain());

                p.ActivateAsSorcery = true;
            })
                         .ActivatedAbility(p =>
            {
                p.Text = "{+1}: Create a 3/3 black Beast creature token with deathtouch.";
                p.Cost = new AddCountersCost(CounterType.Loyality, 1);

                p.Effect = () => new CreateTokens(
                    count: 1,
                    token: Card
                    .Named("Beast")
                    .Power(3)
                    .Toughness(3)
                    .Type("Token Creature - Beast")
                    .Colors(CardColor.Black)
                    .SimpleAbilities(Static.Deathtouch));

                p.TimingRule(new OnFirstMain());
                p.ActivateAsSorcery = true;
            })
                         .ActivatedAbility(p =>
            {
                p.Text = "{-3}: Destroy target creature. You gain life equal to its toughness.";

                p.Cost = new RemoveCounters(CounterType.Loyality, 3);
                p.Effect = () => new CompoundEffect(
                    new DestroyTargetPermanents(),
                    new ChangeLife(
                        amount: P(e => e.Target.Card().Toughness.GetValueOrDefault()),
                        whos: P(e => e.Controller)));

                p.TargetSelector.AddEffect(trg => trg.Is.Card(c => c.Is().Creature).On.Battlefield());
                p.TargetingRule(new EffectDestroy());
                p.TimingRule(new OnFirstMain());

                p.ActivateAsSorcery = true;
            })
                         .ActivatedAbility(p =>
            {
                p.Text =
                    "{-8}: Target opponent gets an emblem with 'Whenever a creature attacks you, it gets +5/+5 and gains trample until end of turn.'";

                p.Cost = new RemoveCounters(CounterType.Loyality, 8);

                p.Effect = () => new CreateEmblem(
                    text: "Whenever a creature attacks you, it gets +5/+5 and gains trample until end of turn.",
                    score: -600,
                    controller: P(e => e.Controller.Opponent),
                    modifiers: () =>
                {
                    var cp = new ContinuousEffectParameters
                    {
                        Modifier = () =>
                        {
                            var tp = new TriggeredAbility.Parameters
                            {
                                Text = "Whenever this creature attacks, it gets +5/+5 and gains trample until end of turn.",
                                Effect = () => new ApplyModifiersToSelf(
                                    () => new AddPowerAndToughness(5, 5)
                                {
                                    UntilEot = true
                                },
                                    () => new AddSimpleAbility(Static.Trample)
                                {
                                    UntilEot = true
                                })
                            };

                            tp.Trigger(new WhenThisAttacks(ap => ap.Attacker.Planeswalker == null));
                            return new AddTriggeredAbility(new TriggeredAbility(tp));
                        },

                        Selector = (card, ctx) => card.Controller != ctx.EffectOwner && card.Is().Creature
                    };

                    var effect = new ContinuousEffect(cp);
                    return new AddContiniousEffect(effect);
                });

                p.TimingRule(new OnFirstMain());
                p.ActivateAsSorcery = true;
            }));
        }