[BLB] Implement forage mechanic (#12569)

* [BLB] Implement Corpseberry Cultivator

* [BLB] Implement Thornvault Forager

* fix verify failure
This commit is contained in:
Evan Kranzler 2024-07-10 22:57:22 -04:00 committed by GitHub
parent 39e254c914
commit 43e95fd0cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 208 additions and 0 deletions

View file

@ -0,0 +1,41 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
* @author TheElk801
*/
public class ForageTriggeredAbility extends TriggeredAbilityImpl {
public ForageTriggeredAbility(Effect effect) {
this(Zone.BATTLEFIELD, effect, false);
}
public ForageTriggeredAbility(Zone zone, Effect effect, boolean optional) {
super(zone, effect, optional);
setTriggerPhrase("Whenever you forage, ");
}
private ForageTriggeredAbility(final ForageTriggeredAbility ability) {
super(ability);
}
@Override
public ForageTriggeredAbility copy() {
return new ForageTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.FORAGED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return isControlledBy(event.getPlayerId());
}
}

View file

@ -0,0 +1,43 @@
package mage.abilities.costs.common;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.OrCost;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID;
/**
* @author TheElk801
*/
public class ForageCost extends OrCost {
public ForageCost() {
super(
"forage",
new ExileFromGraveCost(new TargetCardInYourGraveyard(3)),
new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_FOOD)
);
}
private ForageCost(final ForageCost cost) {
super(cost);
}
@Override
public ForageCost copy() {
return new ForageCost(this);
}
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
if (!super.pay(ability, game, source, controllerId, noMana, costToPay)) {
return false;
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.FORAGED, source.getSourceId(), source, controllerId));
return true;
}
}

View file

@ -662,6 +662,12 @@ public class GameEvent implements Serializable {
playerId owner of the plotted card (the one able to cast the card)
*/
BECOME_PLOTTED,
/* the player foraged
targetId same as sourceId
sourceId of the ability
playerId player who foraged
*/
FORAGED,
//custom events
CUSTOM_EVENT
}