Skinrender card. CounterType.getInstance -> CounterType.createInstance. Updated EverflowingChalice.

This commit is contained in:
magenoxx 2010-12-30 09:10:53 +03:00
parent 3d9dd3f3a4
commit 2c4af82dfa
5 changed files with 99 additions and 8 deletions

View file

@ -0,0 +1,80 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddCountersTargetEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.counters.common.MinusOneCounter;
import mage.target.Target;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
/**
* @author nantuko
*/
public class Skinrender extends CardImpl<Skinrender> {
public Skinrender(UUID ownerId) {
super(ownerId, 78, "Skinrender", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{B}{B}");
this.expansionSetCode = "SOM";
this.subtype.add("Zombie");
this.color.setBlack(true);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
Effect putCountersEffect = new AddCountersTargetEffect(CounterType.M1M1.createInstance(3));
Ability ability = new EntersBattlefieldTriggeredAbility(putCountersEffect, false);
Target target = new TargetCreaturePermanent();
target.setRequired(true);
ability.addTarget(target);
this.addAbility(ability);
}
public Skinrender(final Skinrender card) {
super(card);
}
@Override
public Skinrender copy() {
return new Skinrender(this);
}
}

View file

@ -98,7 +98,7 @@ class EverflowingChaliceAbility extends ManaAbility<EverflowingChaliceAbility> {
public Mana getNetMana(Game game) { public Mana getNetMana(Game game) {
if (game == null) if (game == null)
return new Mana(); return new Mana();
return Mana.ColorlessMana(game.getPermanent(this.getSourceId()).getCounters().getCount("charge")); return Mana.ColorlessMana(game.getPermanent(this.getSourceId()).getCounters().getCount(CounterType.CHARGE));
} }
} }

View file

@ -43,6 +43,7 @@ public class AddCountersTargetEffect extends OneShotEffect<AddCountersTargetEffe
private int amount; private int amount;
private String name; private String name;
private Counter counter;
public AddCountersTargetEffect(String name, int amount) { public AddCountersTargetEffect(String name, int amount) {
super(Outcome.Benefit); super(Outcome.Benefit);
@ -50,17 +51,27 @@ public class AddCountersTargetEffect extends OneShotEffect<AddCountersTargetEffe
this.amount = amount; this.amount = amount;
} }
public AddCountersTargetEffect(Counter counter) {
super(Outcome.Benefit);
this.counter = counter;
}
public AddCountersTargetEffect(final AddCountersTargetEffect effect) { public AddCountersTargetEffect(final AddCountersTargetEffect effect) {
super(effect); super(effect);
this.amount = effect.amount; this.amount = effect.amount;
this.name = effect.name; this.name = effect.name;
this.counter = effect.counter;
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget()); Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) { if (permanent != null) {
permanent.addCounters(name, amount); if (counter != null) {
permanent.addCounters(counter);
} else {
permanent.addCounters(name, amount);
}
} }
return true; return true;
} }

View file

@ -64,21 +64,21 @@ public enum CounterType {
} }
/** /**
* Get instance of counter type with amount equal to 1. * Create instance of counter type with amount equal to 1.
* *
* @return * @return
*/ */
public Counter getInstance() { public Counter createInstance() {
return getInstance(1); return createInstance(1);
} }
/** /**
* Get instance of counter type with defined amount of counters of the given type. * Create instance of counter type with defined amount of counters of the given type.
* *
* @param amount amount of counters of the given type. * @param amount amount of counters of the given type.
* @return * @return
*/ */
public Counter getInstance(int amount) { public Counter createInstance(int amount) {
switch(this) { switch(this) {
case P1P1: case P1P1:
return new PlusOneCounter(amount); return new PlusOneCounter(amount);

View file

@ -631,7 +631,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
if (actualDamage > 0) { if (actualDamage > 0) {
Permanent source = game.getPermanent(sourceId); Permanent source = game.getPermanent(sourceId);
if (source != null && (source.getAbilities().containsKey(InfectAbility.getInstance().getId()))) { if (source != null && (source.getAbilities().containsKey(InfectAbility.getInstance().getId()))) {
getCounters().addCounter(CounterType.POISON.getInstance(actualDamage)); getCounters().addCounter(CounterType.POISON.createInstance(actualDamage));
} else { } else {
actualDamage = this.loseLife(actualDamage, game); actualDamage = this.loseLife(actualDamage, game);
} }