forked from External/mage
64 lines
2 KiB
Java
64 lines
2 KiB
Java
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
package mage.abilities.effects.common;
|
|
|
|
import mage.Mana;
|
|
import mage.abilities.Ability;
|
|
import mage.abilities.effects.OneShotEffect;
|
|
import mage.constants.Outcome;
|
|
import mage.game.Game;
|
|
import mage.players.Player;
|
|
|
|
/**
|
|
*
|
|
* @author LevelX2
|
|
*/
|
|
|
|
public class AddManaToManaPoolEffect extends OneShotEffect {
|
|
|
|
protected Mana mana;
|
|
protected boolean emptyOnlyOnTurnsEnd;
|
|
|
|
public AddManaToManaPoolEffect(Mana mana, String textManaPoolOwner) {
|
|
this(mana, textManaPoolOwner, false);
|
|
}
|
|
/**
|
|
* Adds mana to the mana pool of target pointer player
|
|
*
|
|
* @param mana mana that will be added to the pool
|
|
* @param textManaPoolOwner text that references to the mana pool owner (e.g. "damaged player's")
|
|
* @param emptyOnTurnsEnd if set, the mana will empty only on end of turnstep
|
|
*
|
|
*/
|
|
public AddManaToManaPoolEffect(Mana mana, String textManaPoolOwner, boolean emptyOnTurnsEnd) {
|
|
super(Outcome.PutManaInPool);
|
|
this.mana = mana;
|
|
this.emptyOnlyOnTurnsEnd = emptyOnTurnsEnd;
|
|
this.staticText = "add " + mana.toString() + " to " + textManaPoolOwner + " mana pool";
|
|
}
|
|
|
|
public AddManaToManaPoolEffect(final AddManaToManaPoolEffect effect) {
|
|
super(effect);
|
|
this.mana = effect.mana;
|
|
this.emptyOnlyOnTurnsEnd = effect.emptyOnlyOnTurnsEnd;
|
|
}
|
|
|
|
@Override
|
|
public AddManaToManaPoolEffect copy() {
|
|
return new AddManaToManaPoolEffect(this);
|
|
}
|
|
|
|
@Override
|
|
public boolean apply(Game game, Ability source) {
|
|
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
|
if (player != null) {
|
|
player.getManaPool().addMana(mana, game, source, emptyOnlyOnTurnsEnd);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|