mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
Implement Giant Albatross
This commit is contained in:
parent
083d4cee6d
commit
ca8721e4f9
3 changed files with 176 additions and 0 deletions
110
Mage.Sets/src/mage/cards/g/GiantAlbatross.java
Normal file
110
Mage.Sets/src/mage/cards/g/GiantAlbatross.java
Normal file
|
@ -0,0 +1,110 @@
|
|||
package mage.cards.g;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.PayLifeCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DoIfCostPaid;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.DealtDamageToWatcher;
|
||||
import mage.watchers.common.PlayerDamagedBySourceWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public final class GiantAlbatross extends CardImpl {
|
||||
|
||||
public GiantAlbatross(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
|
||||
|
||||
this.subtype.add(SubType.BIRD);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// When Giant Albatross dies, you may pay {1}{U}. If you do, for each creature that dealt damage to Giant Albatross this turn, destroy that creature unless its controller pays 2 life. A creature destroyed this way can't be regenerated.
|
||||
Ability ability = new DiesTriggeredAbility(new DoIfCostPaid(new GiantAlbatrossEffect(), new ManaCostsImpl("{1}{U}")));
|
||||
DealtDamageToWatcher watcher = new DealtDamageToWatcher();
|
||||
watcher.setSourceId(this.objectId);
|
||||
ability.addWatcher(watcher);
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public GiantAlbatross(final GiantAlbatross card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GiantAlbatross copy() {
|
||||
return new GiantAlbatross(this);
|
||||
}
|
||||
}
|
||||
|
||||
class GiantAlbatrossEffect extends OneShotEffect {
|
||||
|
||||
public GiantAlbatrossEffect() {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = "for each creature that dealt damage to {this} this turn, destroy that creature unless its controller pays 2 life. A creature destroyed this way can’t be regenerated";
|
||||
}
|
||||
|
||||
public GiantAlbatrossEffect(final GiantAlbatrossEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GiantAlbatrossEffect copy() {
|
||||
return new GiantAlbatrossEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
DealtDamageToWatcher watcher = (DealtDamageToWatcher) game.getState().getWatchers().get(DealtDamageToWatcher.class.getSimpleName(), source.getSourceId());
|
||||
System.out.println("Dealt damage: "+watcher.dealtDamageToSource);
|
||||
for (MageObjectReference mageObjectReference : watcher.dealtDamageToSource){
|
||||
System.out.println(mageObjectReference.getCard(game).getName());
|
||||
System.out.println(mageObjectReference.getCard(game).getLogName());
|
||||
}
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game);
|
||||
|
||||
Cost cost = new PayLifeCost(2);
|
||||
for (Permanent creature : creatures) {
|
||||
if (watcher.didDamage(creature, game)) {
|
||||
final StringBuilder sb = new StringBuilder("Pay 2 life? (Otherwise ").append(creature.getName()).append(" will be destroyed)");
|
||||
if (cost.canPay(source, creature.getControllerId(), creature.getControllerId(), game) && player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
|
||||
cost.pay(source, game, creature.getControllerId(), creature.getControllerId(), true, null);
|
||||
}
|
||||
if (!cost.isPaid()) {
|
||||
creature.destroy(source.getSourceId(), game, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -103,6 +103,8 @@ public final class Homelands extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Forget", 26, Rarity.RARE, mage.cards.f.Forget.class));
|
||||
cards.add(new SetCardInfo("Funeral March", 48, Rarity.UNCOMMON, mage.cards.f.FuneralMarch.class));
|
||||
cards.add(new SetCardInfo("Ghost Hounds", 49, Rarity.UNCOMMON, mage.cards.g.GhostHounds.class));
|
||||
cards.add(new SetCardInfo("Giant Albatross", "34a", Rarity.COMMON, mage.cards.g.GiantAlbatross.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Giant Albatross", "34b", Rarity.COMMON, mage.cards.g.GiantAlbatross.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Grandmother Sengir", 50, Rarity.RARE, mage.cards.g.GrandmotherSengir.class));
|
||||
cards.add(new SetCardInfo("Greater Werewolf", 51, Rarity.UNCOMMON, mage.cards.g.GreaterWerewolf.class));
|
||||
cards.add(new SetCardInfo("Hazduhr the Abbot", 8, Rarity.RARE, mage.cards.h.HazduhrTheAbbot.class));
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DealtDamageToWatcher extends Watcher {
|
||||
|
||||
public final Set<MageObjectReference> dealtDamageToSource = new HashSet<>();
|
||||
|
||||
public DealtDamageToWatcher() {
|
||||
super(DealtDamageToWatcher.class.getSimpleName(), WatcherScope.CARD);
|
||||
}
|
||||
|
||||
public DealtDamageToWatcher(final DealtDamageToWatcher watcher) {
|
||||
super(watcher);
|
||||
this.dealtDamageToSource.addAll(watcher.dealtDamageToSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealtDamageToWatcher copy() {
|
||||
return new DealtDamageToWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
boolean eventHasAppropriateType = event.getType() == GameEvent.EventType.DAMAGED_CREATURE ||
|
||||
event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER;
|
||||
if (eventHasAppropriateType && sourceId.equals(event.getTargetId())) {
|
||||
MageObjectReference mor = new MageObjectReference(event.getSourceId(), game);
|
||||
dealtDamageToSource.add(mor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
dealtDamageToSource.clear();
|
||||
}
|
||||
|
||||
public boolean didDamage(UUID sourceId, Game game) {
|
||||
MageObject mageObject = game.getObject(sourceId);
|
||||
if (mageObject != null) {
|
||||
return didDamage(new MageObjectReference(mageObject, game));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean didDamage(MageObjectReference objectReference) {
|
||||
return dealtDamageToSource.contains(objectReference);
|
||||
}
|
||||
|
||||
public boolean didDamage(Permanent permanent, Game game) {
|
||||
return dealtDamageToSource.contains(new MageObjectReference(permanent, game));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue