use of mage.counters.Counter in project mage by magefree.
the class GameStateEvaluator method evaluatePermanent.
public static int evaluatePermanent(Permanent permanent, Game game, boolean ignoreTapped) {
int value = 0;
if (ignoreTapped) {
value = 5;
} else {
value = permanent.isTapped() ? 4 : 5;
}
if (permanent.getCardType(game).contains(CardType.CREATURE)) {
value += evaluateCreature(permanent, game) * CREATURE_FACTOR;
}
value += permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD).size();
for (ActivatedAbility ability : permanent.getAbilities().getActivatedAbilities(Zone.BATTLEFIELD)) {
if (!(ability instanceof ActivatedManaAbilityImpl) && ability.canActivate(ability.getControllerId(), game).canActivate()) {
value += ability.getEffects().size();
}
}
for (Counter counter : permanent.getCounters(game).values()) {
if (!(counter instanceof BoostCounter)) {
value += counter.getCount();
}
}
value += permanent.getAbilities().getStaticAbilities(Zone.BATTLEFIELD).size();
value += permanent.getAbilities().getTriggeredAbilities(Zone.BATTLEFIELD).size();
value += permanent.getManaCost().manaValue();
// TODO: add a difficulty to calculation to ManaCost - sort permanents by difficulty for casting when evaluating game states
return value;
}
use of mage.counters.Counter in project mage by magefree.
the class DeepglowSkateEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean didOne = false;
for (Target target : source.getTargets()) {
for (UUID targetID : target.getTargets()) {
Permanent permanent = game.getPermanent(targetID);
if (permanent != null) {
for (Counter counter : permanent.getCounters(game).values()) {
Counter newCounter = new Counter(counter.getName(), counter.getCount());
permanent.addCounters(newCounter, source.getControllerId(), source, game);
didOne = true;
}
}
}
}
return didOne;
}
use of mage.counters.Counter in project mage by magefree.
the class MaulfistRevolutionaryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null) {
Counters counters = player.getCounters().copy();
for (Counter counter : counters.values()) {
CounterType counterType = CounterType.findByName(counter.getName());
Counter counterToAdd;
if (counterType != null) {
counterToAdd = counterType.createInstance();
} else {
counterToAdd = new Counter(counter.getName());
}
player.addCounters(counterToAdd, source.getControllerId(), source, game);
}
return true;
}
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
CounterType counterType = CounterType.findByName(counter.getName());
Counter counterToAdd;
if (counterType != null) {
counterToAdd = counterType.createInstance();
} else {
counterToAdd = new Counter(counter.getName());
}
permanent.addCounters(counterToAdd, source.getControllerId(), source, game);
}
}
return true;
}
return false;
}
use of mage.counters.Counter in project mage by magefree.
the class SkyshipPlundererEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null) {
Counters counters = player.getCounters().copy();
for (Counter counter : counters.values()) {
CounterType counterType = CounterType.findByName(counter.getName());
Counter counterToAdd;
if (counterType != null) {
counterToAdd = counterType.createInstance();
} else {
counterToAdd = new Counter(counter.getName());
}
player.addCounters(counterToAdd, source.getControllerId(), source, game);
}
return true;
}
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
CounterType counterType = CounterType.findByName(counter.getName());
Counter counterToAdd;
if (counterType != null) {
counterToAdd = counterType.createInstance();
} else {
counterToAdd = new Counter(counter.getName());
}
permanent.addCounters(counterToAdd, source.getControllerId(), source, game);
}
}
return true;
}
return false;
}
use of mage.counters.Counter in project mage by magefree.
the class SuncleanserPreventCountersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
for (Counter counter : permanent.getCounters(game).copy().values()) {
// copy to prevent ConcurrentModificationException
permanent.removeCounters(counter, source, game);
}
return true;
}
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null) {
for (Counter counter : player.getCounters().copy().values()) {
// copy to prevent ConcurrentModificationException
player.removeCounters(counter.getName(), counter.getCount(), source, game);
}
return true;
}
return false;
}
Aggregations