forked from External/mage
Cost reduction effects - refactor, removed redundant custom effects, added card hints;
This commit is contained in:
parent
e4ebf50d42
commit
cf3feff76a
35 changed files with 506 additions and 643 deletions
|
|
@ -1,38 +1,60 @@
|
|||
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AttackingCreatureCount implements DynamicValue {
|
||||
|
||||
private String message;
|
||||
private FilterCreaturePermanent filter;
|
||||
|
||||
public AttackingCreatureCount() {
|
||||
this("attacking creature");
|
||||
}
|
||||
|
||||
public AttackingCreatureCount(FilterCreaturePermanent filter) {
|
||||
this(filter, "attacking " + filter.getMessage());
|
||||
}
|
||||
|
||||
public AttackingCreatureCount(String message) {
|
||||
this(null, message);
|
||||
}
|
||||
|
||||
public AttackingCreatureCount(FilterCreaturePermanent filter, String message) {
|
||||
this.message = message;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public AttackingCreatureCount(final AttackingCreatureCount dynamicValue) {
|
||||
super();
|
||||
this.message = dynamicValue.message;
|
||||
this.filter = dynamicValue.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int count = 0;
|
||||
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
|
||||
count += combatGroup.getAttackers().size();
|
||||
for (UUID permId : combatGroup.getAttackers()) {
|
||||
if (filter != null) {
|
||||
Permanent attacker = game.getPermanent(permId);
|
||||
if (attacker != null && filter.match(attacker, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game)) {
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue