mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
61 lines
1.6 KiB
Java
61 lines
1.6 KiB
Java
package mage.abilities.dynamicvalue.common;
|
|
|
|
import mage.abilities.Ability;
|
|
import mage.abilities.dynamicvalue.DynamicValue;
|
|
import mage.abilities.effects.Effect;
|
|
import mage.filter.FilterCard;
|
|
import mage.filter.StaticFilters;
|
|
import mage.game.Game;
|
|
import mage.players.Player;
|
|
|
|
/**
|
|
*
|
|
* @author North
|
|
*/
|
|
public class CardsInControllerGraveyardCount implements DynamicValue {
|
|
|
|
private FilterCard filter;
|
|
private Integer amount;
|
|
|
|
public CardsInControllerGraveyardCount() {
|
|
this(StaticFilters.FILTER_CARD, 1);
|
|
}
|
|
|
|
public CardsInControllerGraveyardCount(FilterCard filter) {
|
|
this(filter, 1);
|
|
}
|
|
|
|
public CardsInControllerGraveyardCount(FilterCard filter, Integer amount) {
|
|
this.filter = filter;
|
|
this.amount = amount;
|
|
}
|
|
|
|
public CardsInControllerGraveyardCount(final CardsInControllerGraveyardCount dynamicValue) {
|
|
this.filter = dynamicValue.filter;
|
|
this.amount = dynamicValue.amount;
|
|
}
|
|
|
|
@Override
|
|
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
|
Player player = game.getPlayer(sourceAbility.getControllerId());
|
|
if (player != null) {
|
|
return amount * player.getGraveyard().count(filter, game);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public CardsInControllerGraveyardCount copy() {
|
|
return new CardsInControllerGraveyardCount(this);
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return amount.toString();
|
|
}
|
|
|
|
@Override
|
|
public String getMessage() {
|
|
return filter.getMessage() + " in your graveyard";
|
|
}
|
|
}
|