mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
* Added card hints to Avatar of Might, Avatar of Will, Avatar of Woe, Dusk Feaster, Rekindled Flame;
* Refactor: removed custom spell cost reduction effects;
This commit is contained in:
parent
c46e5d2399
commit
2252648f01
13 changed files with 167 additions and 411 deletions
|
|
@ -0,0 +1,36 @@
|
|||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
|
||||
public enum OpponentHasNoCardsInHandCondition implements Condition {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
for (UUID playerId : game.getOpponents(source.getControllerId())) {
|
||||
Player opponent = game.getPlayer(playerId);
|
||||
if (opponent != null && opponent.getHand().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "an opponent has no cards in hand";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||
|
|
@ -9,9 +8,10 @@ import mage.constants.Duration;
|
|||
import mage.constants.Outcome;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
public class AffinityEffect extends CostModificationEffectImpl {
|
||||
|
||||
|
||||
private final FilterControlledPermanent filter;
|
||||
|
||||
public AffinityEffect(FilterControlledPermanent affinityFilter) {
|
||||
|
|
@ -27,20 +27,12 @@ public class AffinityEffect extends CostModificationEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
SpellAbility spellAbility = (SpellAbility)abilityToModify;
|
||||
Mana mana = spellAbility.getManaCostsToPay().getMana();
|
||||
if (mana.getGeneric() > 0) {
|
||||
// the following works with Sen Triplets and in multiplayer games
|
||||
int count = game.getBattlefield().getActivePermanents(filter, abilityToModify.getControllerId(), source.getId(), game).size();
|
||||
int newCount = mana.getGeneric() - count;
|
||||
if (newCount < 0) {
|
||||
newCount = 0;
|
||||
}
|
||||
mana.setGeneric(newCount);
|
||||
spellAbility.getManaCostsToPay().load(mana.toString());
|
||||
return true;
|
||||
// abilityToModify.getControllerId() works with Sen Triplets and in multiplayer games, see https://github.com/magefree/mage/issues/5931
|
||||
int count = game.getBattlefield().getActivePermanents(filter, abilityToModify.getControllerId(), source.getId(), game).size();
|
||||
if (count > 0) {
|
||||
CardUtil.reduceCost(abilityToModify, count);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import mage.abilities.SpellAbility;
|
|||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
|
|
@ -16,7 +18,7 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class SpellCostReductionSourceEffect extends CostModificationEffectImpl {
|
||||
|
||||
private final int amount;
|
||||
private final DynamicValue amount;
|
||||
private ManaCosts<ManaCost> manaCostsToReduce = null;
|
||||
private Condition condition;
|
||||
|
||||
|
|
@ -26,7 +28,7 @@ public class SpellCostReductionSourceEffect extends CostModificationEffectImpl {
|
|||
|
||||
public SpellCostReductionSourceEffect(ManaCosts<ManaCost> manaCostsToReduce, Condition condition) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
this.amount = 0;
|
||||
this.amount = StaticValue.get(0);
|
||||
this.manaCostsToReduce = manaCostsToReduce;
|
||||
this.condition = condition;
|
||||
|
||||
|
|
@ -44,19 +46,30 @@ public class SpellCostReductionSourceEffect extends CostModificationEffectImpl {
|
|||
}
|
||||
|
||||
public SpellCostReductionSourceEffect(int amount) {
|
||||
this(StaticValue.get(amount), null);
|
||||
}
|
||||
|
||||
public SpellCostReductionSourceEffect(DynamicValue amount) {
|
||||
this(amount, null);
|
||||
}
|
||||
|
||||
public SpellCostReductionSourceEffect(int amount, Condition condition) {
|
||||
this(StaticValue.get(amount), condition);
|
||||
}
|
||||
|
||||
public SpellCostReductionSourceEffect(DynamicValue amount, Condition condition) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
this.amount = amount;
|
||||
this.condition = condition;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("this spell costs {").append(amount).append("} less to cast");
|
||||
sb.append("this spell costs {").append(this.amount).append("} less to cast");
|
||||
if (this.condition != null) {
|
||||
sb.append(" ").append(this.condition.toString().startsWith("if ") ? "" : "if ");
|
||||
sb.append(this.condition.toString());
|
||||
}
|
||||
if (this.amount.toString().equals("X")) {
|
||||
sb.append(", where {X} is ").append(this.amount.getMessage());
|
||||
}
|
||||
this.staticText = sb.toString();
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +85,7 @@ public class SpellCostReductionSourceEffect extends CostModificationEffectImpl {
|
|||
if (manaCostsToReduce != null) {
|
||||
CardUtil.adjustCost((SpellAbility) abilityToModify, manaCostsToReduce, false);
|
||||
} else {
|
||||
CardUtil.reduceCost(abilityToModify, this.amount);
|
||||
CardUtil.reduceCost(abilityToModify, this.amount.calculate(game, source, this));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
public class SpellCostReductionSourceForOpponentsEffect extends CostModificationEffectImpl {
|
||||
|
||||
|
|
@ -25,19 +25,11 @@ public class SpellCostReductionSourceForOpponentsEffect extends CostModification
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
SpellAbility spellAbility = (SpellAbility) abilityToModify;
|
||||
Mana mana = spellAbility.getManaCostsToPay().getMana();
|
||||
if (mana.getGeneric() > 0) {
|
||||
int count = game.getOpponents(source.getControllerId()).size();
|
||||
int newCount = mana.getGeneric() - count;
|
||||
if (newCount < 0) {
|
||||
newCount = 0;
|
||||
}
|
||||
mana.setGeneric(newCount);
|
||||
spellAbility.getManaCostsToPay().load(mana.toString());
|
||||
return true;
|
||||
int count = game.getOpponents(source.getControllerId()).size();
|
||||
if (count > 0) {
|
||||
CardUtil.reduceCost(abilityToModify, count);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue