mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
[AER] Heart of Kiran
Fixed the Alternate Crew Cost to push the correct game events for crewing a vehicle and the vehicle being crewed.
This commit is contained in:
parent
91a3d9a6a2
commit
4ef339d521
1 changed files with 61 additions and 4 deletions
|
@ -31,7 +31,7 @@ import mage.MageInt;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.RemoveCounterCost;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.effects.common.continuous.AddCardTypeSourceEffect;
|
||||
import mage.abilities.keyword.CrewAbility;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
|
@ -40,9 +40,14 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterControlledPlaneswalkerPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -52,8 +57,6 @@ import java.util.UUID;
|
|||
*/
|
||||
public class HeartOfKiran extends CardImpl {
|
||||
|
||||
private static final FilterControlledPlaneswalkerPermanent filter = new FilterControlledPlaneswalkerPermanent("planeswalker you control");
|
||||
|
||||
public HeartOfKiran(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||
|
||||
|
@ -72,7 +75,7 @@ public class HeartOfKiran extends CardImpl {
|
|||
this.addAbility(new CrewAbility(3));
|
||||
|
||||
// You may remove a loyalty counter from a planeswalker you control rather than pay Heart of Kiran's crew cost.
|
||||
Cost cost = new RemoveCounterCost(new TargetControlledPermanent(filter), CounterType.LOYALTY, 1);
|
||||
Cost cost = new HeartOfKiranAlternateCrewCost(CounterType.LOYALTY, 1);
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCardTypeSourceEffect(CardType.CREATURE, Duration.EndOfTurn), cost) {
|
||||
@Override
|
||||
public String getRule() {
|
||||
|
@ -91,3 +94,57 @@ public class HeartOfKiran extends CardImpl {
|
|||
return new HeartOfKiran(this);
|
||||
}
|
||||
}
|
||||
|
||||
class HeartOfKiranAlternateCrewCost extends CostImpl {
|
||||
|
||||
private CounterType counterTypeToRemove;
|
||||
private int countersToRemove;
|
||||
|
||||
private static final FilterControlledPlaneswalkerPermanent filter = new FilterControlledPlaneswalkerPermanent("planeswalker you control");
|
||||
|
||||
public HeartOfKiranAlternateCrewCost(CounterType counterTypeToRemove, int countersToRemove) {
|
||||
this.counterTypeToRemove = counterTypeToRemove;
|
||||
this.countersToRemove = countersToRemove;
|
||||
}
|
||||
|
||||
public HeartOfKiranAlternateCrewCost(final HeartOfKiranAlternateCrewCost cost) {
|
||||
super(cost);
|
||||
this.counterTypeToRemove = cost.counterTypeToRemove;
|
||||
this.countersToRemove = cost.countersToRemove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
paid = false;
|
||||
|
||||
Target target = new TargetControlledPermanent(1, 1, filter, true);
|
||||
|
||||
if (target.choose(Outcome.Benefit, controllerId, sourceId, game)) {
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
int originalLoyalty = permanent.getCounters(game).getCount(counterTypeToRemove);
|
||||
|
||||
GameEvent event = new GameEvent(GameEvent.EventType.CREW_VEHICLE, target.getFirstTarget(), sourceId, controllerId);
|
||||
if (!game.replaceEvent(event)) {
|
||||
permanent.removeCounters(counterTypeToRemove.createInstance(), game);
|
||||
}
|
||||
|
||||
paid = permanent.getCounters(game).getCount(counterTypeToRemove) < originalLoyalty;
|
||||
|
||||
if (paid) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CREWED_VEHICLE, target.getFirstTarget(), sourceId, controllerId));
|
||||
}
|
||||
}
|
||||
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return game.getBattlefield().getAllActivePermanents(filter, game).size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeartOfKiranAlternateCrewCost copy() {
|
||||
return new HeartOfKiranAlternateCrewCost(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue