package game.model;
/** This abstract base class can be used for command cards. Monster cards and some spell
* cards are command cards. Use of this base class is not required, however.
*
* The class provides the following default behaviour:
* - in the {@link Phase#STANDBY} and {@link Phase#RECOVER} phases the card can be executed.
*
- Execution means that the card is taken from the player's hand and placed on the table.
*
*/
public abstract class AbstractCommandCard extends AbstractCard implements Card, Command {
/** Constructor.
* @param t The card type.
* @param nm The name of the card.
* @param desc The description on the card.
*/
protected AbstractCommandCard(CardType t, String nm, String desc) {
super(t, nm, desc);
}
public boolean execute(Game game) {
switch (game.getPhase()) {
case STANDBY:
case RECOVER:
if (game.getPlayer().getHand().remove(this)) {
game.getPlayer().getTable().add(this);
printBoth(game, game.getPlayer().getName() + " places " + this + " on the table.");
return true;
}
}
game.getPlayer().getUI().print("You cannot play this card at this time.");
return false;
}
public Condition[] conditions() {
return new Condition [] {
new Condition(Phase.STANDBY),
new Condition(Phase.RECOVER)
};
}
}