forked from External/mage
76 lines
1.5 KiB
Java
76 lines
1.5 KiB
Java
package mage.actions.impl;
|
|
|
|
import mage.abilities.Ability;
|
|
import mage.game.Game;
|
|
import mage.players.Player;
|
|
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* Base class for mage actions.
|
|
*
|
|
* @author ayratn
|
|
*/
|
|
public abstract class MageAction {
|
|
|
|
/**
|
|
* {@link Player} we count score for.
|
|
*/
|
|
private Player scorePlayer;
|
|
|
|
/**
|
|
* Current game score for the player.
|
|
*/
|
|
private int score = 0;
|
|
|
|
/**
|
|
* Set or change action score.
|
|
*
|
|
* @param scorePlayer Set player.
|
|
* @param score Set score value.
|
|
*/
|
|
protected void setScore(Player scorePlayer, int score) {
|
|
this.scorePlayer = scorePlayer;
|
|
this.score = score;
|
|
}
|
|
|
|
/**
|
|
* Get game score for the {@link Player}. Value depends on the owner of this
|
|
* action. In case player and owner differ, negative value is returned.
|
|
*
|
|
* @param player
|
|
* @return
|
|
*/
|
|
public int getScore(final Player player) {
|
|
if (player == null || scorePlayer == null) {
|
|
return 0;
|
|
}
|
|
if (player.getId().equals(scorePlayer.getId())) {
|
|
return score;
|
|
} else {
|
|
return -score;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Execute action.
|
|
*
|
|
*
|
|
* @param source
|
|
* @param game Game context.
|
|
* @return
|
|
*/
|
|
public abstract int doAction(Ability source, final Game game);
|
|
|
|
/**
|
|
* Undo action.
|
|
*
|
|
* @param game Game context
|
|
*/
|
|
public abstract void undoAction(final Game game);
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "";
|
|
}
|
|
}
|