forked from External/mage
Implementing Blitz mechanic (WIP) (#8835)
* added blitz mechanic (mostly copy/paste of dash) * renamed class * reworked alt cost abilities, greatly reduced redundant code * updated text generation * removed all skips * added test for blitz * changed blitz implementation * [SNC] Implemented Tenacious Underdog
This commit is contained in:
parent
76daf4bd5a
commit
0e3252d256
31 changed files with 620 additions and 722 deletions
|
|
@ -1,23 +1,13 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.condition.common.ProwlCondition;
|
||||
import mage.abilities.costs.*;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.costs.AlternativeSourceCostsImpl;
|
||||
import mage.abilities.hint.common.ProwlHint;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.ProwlWatcher;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 702.74. Prowl #
|
||||
* <p>
|
||||
|
|
@ -30,26 +20,21 @@ import java.util.List;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ProwlAbility extends StaticAbility implements AlternativeSourceCosts {
|
||||
public class ProwlAbility extends AlternativeSourceCostsImpl {
|
||||
|
||||
private static final String PROWL_KEYWORD = "Prowl";
|
||||
private final List<AlternativeCost2> prowlCosts = new LinkedList<>();
|
||||
private String reminderText;
|
||||
private static final String reminderText = "You may cast this for its prowl cost if you dealt combat damage to a "
|
||||
+ "player this turn with a creature that shared a creature type with {this}";
|
||||
|
||||
public ProwlAbility(Card card, String manaString) {
|
||||
super(Zone.ALL, null);
|
||||
super(PROWL_KEYWORD, reminderText, manaString);
|
||||
this.setRuleAtTheTop(true);
|
||||
this.name = PROWL_KEYWORD;
|
||||
this.setReminderText(card);
|
||||
this.addProwlCost(manaString);
|
||||
this.addWatcher(new ProwlWatcher());
|
||||
this.addHint(ProwlHint.instance);
|
||||
}
|
||||
|
||||
public ProwlAbility(final ProwlAbility ability) {
|
||||
private ProwlAbility(final ProwlAbility ability) {
|
||||
super(ability);
|
||||
this.prowlCosts.addAll(ability.prowlCosts);
|
||||
this.reminderText = ability.reminderText;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -57,112 +42,8 @@ public class ProwlAbility extends StaticAbility implements AlternativeSourceCost
|
|||
return new ProwlAbility(this);
|
||||
}
|
||||
|
||||
public final AlternativeCost2 addProwlCost(String manaString) {
|
||||
AlternativeCost2 prowlCost = new AlternativeCost2Impl(PROWL_KEYWORD,
|
||||
reminderText, new ManaCostsImpl(manaString));
|
||||
prowlCosts.add(prowlCost);
|
||||
return prowlCost;
|
||||
}
|
||||
|
||||
public void resetProwl() {
|
||||
for (AlternativeCost2 cost : prowlCosts) {
|
||||
cost.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActivated(Ability ability, Game game) {
|
||||
for (AlternativeCost2 cost : prowlCosts) {
|
||||
if (cost.isActivated(game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(Ability source, Game game) {
|
||||
return ProwlCondition.instance.apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean askToActivateAlternativeCosts(Ability ability, Game game) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
if (ProwlCondition.instance.apply(game, ability)) {
|
||||
this.resetProwl();
|
||||
for (AlternativeCost2 prowlCost : prowlCosts) {
|
||||
if (prowlCost.canPay(ability, this, ability.getControllerId(), game)
|
||||
&& player.chooseUse(Outcome.Benefit, "Cast for "
|
||||
+ PROWL_KEYWORD + " cost " + prowlCost.getText(true)
|
||||
+ " ?", ability, game)) {
|
||||
prowlCost.activate();
|
||||
ability.getManaCostsToPay().clear();
|
||||
ability.getCosts().clear();
|
||||
for (Iterator it = ((Costs) prowlCost).iterator(); it.hasNext();) {
|
||||
Cost cost = (Cost) it.next();
|
||||
if (cost instanceof ManaCostsImpl) {
|
||||
ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy());
|
||||
} else {
|
||||
ability.getCosts().add(cost.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return isActivated(ability, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int numberCosts = 0;
|
||||
String remarkText = "";
|
||||
for (AlternativeCost2 prowlCost : prowlCosts) {
|
||||
if (numberCosts == 0) {
|
||||
sb.append(prowlCost.getText(false));
|
||||
remarkText = prowlCost.getReminderText();
|
||||
} else {
|
||||
sb.append(" and/or ").append(prowlCost.getText(true));
|
||||
}
|
||||
++numberCosts;
|
||||
}
|
||||
if (numberCosts == 1) {
|
||||
sb.append(' ').append(remarkText);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCastMessageSuffix(Game game) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int position = 0;
|
||||
for (AlternativeCost2 cost : prowlCosts) {
|
||||
if (cost.isActivated(game)) {
|
||||
sb.append(cost.getCastSuffixMessage(position));
|
||||
++position;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void setReminderText(Card card) {
|
||||
reminderText
|
||||
= "(You may cast this for its prowl cost if you dealt combat damage to a "
|
||||
+ "player this turn with a creature that shared a creature type with {this})";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Costs<Cost> getCosts() {
|
||||
Costs<Cost> alterCosts = new CostsImpl<>();
|
||||
for (AlternativeCost2 aCost : prowlCosts) {
|
||||
alterCosts.add(aCost.getCost());
|
||||
}
|
||||
return alterCosts;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue