mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 14:02:05 -08:00
[BLB] Implement Eluge the Shoreless Sea; expand SpellsCostReductionControllerEffect (#12607)
* Implement Eluge, the Shoreless Sea (missing mana cost reduction clause) * implement ability to convert colored to generic costs in SpellsCostReductionControllerEffect * fix text generation on SpellsCostReductionControllerEffect * remove unnecessary setText() calls on SpellsCostReductionControllerEffect * make logfile from master run * Fix plurality detection * Eliminate unnecessary setText() calls in other cards * Delete logfile * remove redundant type cast * Add parameter documentation
This commit is contained in:
parent
5043430481
commit
32042687fb
22 changed files with 284 additions and 64 deletions
|
|
@ -6,6 +6,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -28,19 +29,40 @@ import java.util.Set;
|
|||
*/
|
||||
public class SpellsCostReductionControllerEffect extends CostModificationEffectImpl {
|
||||
|
||||
// Which spells to apply cost reduction to
|
||||
private final FilterCard filter;
|
||||
|
||||
// Number of times to apply cost reduction
|
||||
// When just reducing colorless mana, (constructors without a ManaCosts<ManaCost> argument)
|
||||
// this is the amount of colorless mana to reduce by
|
||||
private final DynamicValue amount;
|
||||
|
||||
// adds "up to" sliding scale for mana reduction (only available for generic mana cost reduction)
|
||||
private final boolean upTo;
|
||||
|
||||
private ManaCosts<ManaCost> manaCostsToReduce = null;
|
||||
|
||||
// true when colored mana can also reduce generic mana if no more mana of that color remains in the cost
|
||||
// See CardUtil.adjustCost
|
||||
private final boolean convertToGeneric;
|
||||
|
||||
public SpellsCostReductionControllerEffect(FilterCard filter, ManaCosts<ManaCost> manaCostsToReduce) {
|
||||
this(filter, manaCostsToReduce, StaticValue.get(1));
|
||||
}
|
||||
|
||||
public SpellsCostReductionControllerEffect(FilterCard filter, ManaCosts<ManaCost> manaCostsToReduce, DynamicValue amount) {
|
||||
this(filter, manaCostsToReduce, amount, false);
|
||||
}
|
||||
|
||||
public SpellsCostReductionControllerEffect(FilterCard filter, ManaCosts<ManaCost> manaCostsToReduce, DynamicValue amount, boolean convertToGeneric) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
this.filter = filter;
|
||||
this.amount = StaticValue.get(0);
|
||||
this.amount = amount;
|
||||
this.manaCostsToReduce = manaCostsToReduce;
|
||||
this.upTo = false;
|
||||
this.staticText = filter.getMessage() + " you cast cost " + manaCostsToReduce.getText() +
|
||||
" less to cast. This effect reduces only the amount of colored mana you pay.";
|
||||
this.convertToGeneric = convertToGeneric;
|
||||
|
||||
createStaticText();
|
||||
}
|
||||
|
||||
public SpellsCostReductionControllerEffect(FilterCard filter, int amount) {
|
||||
|
|
@ -60,9 +82,9 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI
|
|||
this.filter = filter;
|
||||
this.amount = amount;
|
||||
this.upTo = upTo;
|
||||
this.staticText = (filter.getMessage().contains("you cast") ? filter.getMessage()
|
||||
: filter.getMessage() + " you cast")
|
||||
+ " cost " + (upTo ? "up to " : "") + '{' + amount + "} less to cast";
|
||||
this.convertToGeneric = false;
|
||||
|
||||
createStaticText();
|
||||
}
|
||||
|
||||
protected SpellsCostReductionControllerEffect(final SpellsCostReductionControllerEffect effect) {
|
||||
|
|
@ -71,14 +93,20 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI
|
|||
this.amount = effect.amount;
|
||||
this.manaCostsToReduce = effect.manaCostsToReduce;
|
||||
this.upTo = effect.upTo;
|
||||
this.convertToGeneric = effect.convertToGeneric;
|
||||
this.staticText = effect.staticText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
int reductionAmount = this.amount.calculate(game, source, this);
|
||||
if (manaCostsToReduce != null) {
|
||||
CardUtil.adjustCost((SpellAbility) abilityToModify, manaCostsToReduce, false);
|
||||
ManaCosts<ManaCost> calculatedManaCostsToReduce = new ManaCostsImpl<>();;
|
||||
for (int i = 0; i < reductionAmount; i++) {
|
||||
calculatedManaCostsToReduce.add(this.manaCostsToReduce.copy());
|
||||
}
|
||||
CardUtil.adjustCost(abilityToModify, calculatedManaCostsToReduce, convertToGeneric);
|
||||
} else {
|
||||
int reductionAmount = this.amount.calculate(game, source, this);
|
||||
if (upTo) {
|
||||
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
||||
int reduceMax = mana.getGeneric();
|
||||
|
|
@ -131,6 +159,37 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI
|
|||
return false;
|
||||
}
|
||||
|
||||
private void createStaticText(){
|
||||
StringBuilder sb = new StringBuilder(filter.getMessage());
|
||||
if (!sb.toString().contains("you cast")){
|
||||
sb.append(" you cast");
|
||||
}
|
||||
if (sb.toString().toLowerCase().contains("spells")){
|
||||
sb.append(" cost ");
|
||||
} else {
|
||||
sb.append(" costs ");
|
||||
}
|
||||
if (upTo){
|
||||
sb.append("up to ");
|
||||
}
|
||||
if (manaCostsToReduce != null) {
|
||||
sb.append(manaCostsToReduce.getText());
|
||||
if (convertToGeneric){
|
||||
sb.append(" (<i>or {1}</i>)");
|
||||
}
|
||||
} else {
|
||||
sb.append("{").append(amount).append("}");
|
||||
}
|
||||
sb.append(" less to cast");
|
||||
if (!(amount instanceof StaticValue)){
|
||||
sb.append(" for each ").append(amount.getMessage());
|
||||
}
|
||||
if (!convertToGeneric && manaCostsToReduce != null){
|
||||
sb.append(". This effect reduces only the amount of colored mana you pay");
|
||||
}
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellsCostReductionControllerEffect copy() {
|
||||
return new SpellsCostReductionControllerEffect(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue