use of mage.abilities.effects.common.continuous.GainAbilitySourceEffect in project mage by magefree.
the class IllusionaryPresenceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
SubType landTypeChoice = SubType.byDescription((String) game.getState().getValue(mageObject.getId().toString() + "BasicLandType"));
if (landTypeChoice != null) {
switch(landTypeChoice) {
case PLAINS:
gainedAbility = new PlainswalkAbility();
break;
case FOREST:
gainedAbility = new ForestwalkAbility();
break;
case SWAMP:
gainedAbility = new SwampwalkAbility();
break;
case ISLAND:
gainedAbility = new IslandwalkAbility();
break;
case MOUNTAIN:
gainedAbility = new MountainwalkAbility();
break;
}
if (gainedAbility != null) {
GainAbilitySourceEffect effect = new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
}
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilitySourceEffect in project mage by magefree.
the class ButcherOfTheHordeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Choice abilityChoice = new ChoiceImpl();
abilityChoice.setMessage("Choose an ability to add");
Set<String> abilities = new HashSet<>();
abilities.add(VigilanceAbility.getInstance().getRule());
abilities.add(LifelinkAbility.getInstance().getRule());
abilities.add(HasteAbility.getInstance().getRule());
abilityChoice.setChoices(abilities);
controller.choose(Outcome.AddAbility, abilityChoice, game);
if (!abilityChoice.isChosen()) {
return false;
}
String chosen = abilityChoice.getChoice();
Ability ability = null;
if (VigilanceAbility.getInstance().getRule().equals(chosen)) {
ability = VigilanceAbility.getInstance();
} else if (LifelinkAbility.getInstance().getRule().equals(chosen)) {
ability = LifelinkAbility.getInstance();
} else if (HasteAbility.getInstance().getRule().equals(chosen)) {
ability = HasteAbility.getInstance();
}
if (ability != null) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen: " + chosen);
ContinuousEffect effect = new GainAbilitySourceEffect(ability, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilitySourceEffect in project mage by magefree.
the class CouncilGuardianVote method apply.
@Override
public boolean apply(Game game, Ability source) {
CouncilGuardianVote vote = new CouncilGuardianVote();
vote.doVotes(source, game);
for (String color : vote.getMostVoted()) {
if (color == null) {
continue;
}
game.addEffect(new GainAbilitySourceEffect(ProtectionAbility.from(ChoiceColor.getColorFromString(color)), Duration.Custom), source);
}
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilitySourceEffect in project mage by magefree.
the class RiotReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) {
if (controller.chooseUse(outcome, "Have " + creature.getLogName() + " enter the battlefield with a +1/+1 counter on it or with haste?", null, "+1/+1 counter", "Haste", source, game)) {
game.informPlayers(controller.getLogName() + " choose to put a +1/+1 counter on " + creature.getName());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
} else {
game.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.Custom), source);
}
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilitySourceEffect in project mage by magefree.
the class JodahsAvengerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (sourceObject != null) {
sourceObject.addPower(-1);
sourceObject.addToughness(-1);
game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn), source);
return true;
}
return false;
}
Aggregations