use of mage.abilities.Ability in project mage by magefree.
the class StoryweaveWatcher method makeAbility.
public static Ability makeAbility() {
// for testing purposes
Ability ability = new SimpleActivatedAbility(new StoryweaveReplacementEffect(), new GenericManaCost(0));
ability.addWatcher(new StoryweaveWatcher());
return ability;
}
use of mage.abilities.Ability in project mage by magefree.
the class TorporOrbEffect method getInfoMessage.
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject enteringObject = game.getObject(event.getSourceId());
MageObject sourceObject = game.getObject(source.getSourceId());
Ability ability = (Ability) getValue("targetAbility");
if (enteringObject != null && sourceObject != null && ability != null) {
MageObject abilitObject = game.getObject(ability.getSourceId());
if (abilitObject != null) {
return sourceObject.getLogName() + " prevented ability of " + abilitObject.getLogName() + " to trigger for " + enteringObject.getLogName() + " entering the battlefield.";
}
}
return null;
}
use of mage.abilities.Ability in project mage by magefree.
the class VolrathTheShapestealerCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new SimpleActivatedAbility(new VolrathTheShapestealerEffect(), new GenericManaCost(1));
ability.addTarget(new TargetPermanent(VolrathTheShapestealer.filter));
blueprint.getAbilities().add(ability);
blueprint.removePTCDA();
blueprint.getPower().modifyBaseValue(7);
blueprint.getToughness().modifyBaseValue(5);
return true;
}
use of mage.abilities.Ability in project mage by magefree.
the class VodalianWarMachineWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
if (event.getSourceId() != null) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (sourcePermanent != null) {
StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
if (stackAbility != null) {
Ability ability = stackAbility.getStackAbility();
if (ability != null) {
for (Cost cost : ability.getCosts()) {
if (cost instanceof TapTargetCost && cost.isPaid()) {
TapTargetCost tapCost = (TapTargetCost) cost;
if (tapCost.getTarget().isChosen()) {
MageObjectReference mor = new MageObjectReference(sourcePermanent.getId(), sourcePermanent.getZoneChangeCounter(game), game);
Set<MageObjectReference> toAdd;
if (tappedMerfolkIds.get(mor) == null) {
toAdd = new HashSet<>();
} else {
toAdd = tappedMerfolkIds.get(mor);
}
for (UUID targetId : tapCost.getTarget().getTargets()) {
toAdd.add(new MageObjectReference(targetId, game));
}
tappedMerfolkIds.put(mor, toAdd);
break;
}
}
}
}
}
}
}
}
}
use of mage.abilities.Ability in project mage by magefree.
the class PoisonousTest method assertMultipleInstancesOfAbility.
public void assertMultipleInstancesOfAbility(Player player, String cardName, Ability ability, int count) throws AssertionError {
int permanentCount = 0;
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
if (permanent.getName().equals(cardName)) {
found = permanent;
permanentCount++;
}
}
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName() + ", cardName=" + cardName, found);
Assert.assertTrue("There is more than one such permanent under player's control, player=" + player.getName() + ", cardName=" + cardName, permanentCount == 1);
int abilityCount = 0;
for (Ability existingAbility : found.getAbilities()) {
if (existingAbility.getRule().equals(ability.getRule())) {
abilityCount++;
}
}
Assert.assertEquals("Ability count mismatch (" + ability.getRule() + "). Expected " + count + ", got " + abilityCount, count, abilityCount);
}
Aggregations