Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[don't merge - see #11841 instead] [WHO] Implement Donna Noble #11833

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions Mage.Sets/src/mage/cards/d/DonnaNoble.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
package mage.cards.d;

import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.constants.*;
import mage.abilities.keyword.SoulbondAbility;
import mage.abilities.keyword.DoctorsCompanionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.game.Game;
import mage.game.events.DamagedBatchForPermanentsEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetOpponent;

/**
*
* @author jimga150
*/
public final class DonnaNoble extends CardImpl {

public DonnaNoble(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}");

this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.power = new MageInt(2);
this.toughness = new MageInt(4);

// Soulbond
this.addAbility(new SoulbondAbility());

// Whenever Donna or a creature it's paired with is dealt damage, Donna deals that much damage to target opponent.
Ability ability = new DonnaNobleTriggeredAbility();
this.addAbility(ability);

// Doctor's companion
this.addAbility(DoctorsCompanionAbility.getInstance());

}

private DonnaNoble(final DonnaNoble card) {
super(card);
}

@Override
public DonnaNoble copy() {
return new DonnaNoble(this);
}
}

// Based on DealtDamageToSourceTriggeredAbility
class DonnaNobleTriggeredAbility extends TriggeredAbilityImpl {

DonnaNobleTriggeredAbility() {
super(Zone.BATTLEFIELD, new DonnaNobleEffect());
}

private DonnaNobleTriggeredAbility(final DonnaNobleTriggeredAbility ability) {
super(ability);
}

@Override
public DonnaNobleTriggeredAbility copy() {
return new DonnaNobleTriggeredAbility(this);
}

@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DAMAGED_BATCH_FOR_PERMANENTS;
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
this.getTargets().clear();
DamagedBatchForPermanentsEvent dEvent = (DamagedBatchForPermanentsEvent) event;
return checkTriggerThis(dEvent) | checkTriggerPaired(dEvent, game);
}

boolean checkTriggerThis(DamagedBatchForPermanentsEvent dEvent) {
this.getEffects().setValue("damageToThis", null);
int damage = dEvent
.getEvents()
.stream()
.filter(damagedEvent -> getSourceId().equals(damagedEvent.getTargetId()))
.mapToInt(GameEvent::getAmount)
.sum();
if (damage < 1) {
return false;
}
this.getEffects().setValue("damageToThis", damage);
this.addTarget(new TargetOpponent());
return true;
}

boolean checkTriggerPaired(DamagedBatchForPermanentsEvent dEvent, Game game) {

this.getEffects().setValue("damageToPaired", null);

Permanent paired;
Permanent permanent = game.getPermanent(getSourceId());
if (permanent != null && permanent.getPairedCard() != null) {
paired = permanent.getPairedCard().getPermanent(game);
if (paired == null || paired.getPairedCard() == null || !paired.getPairedCard().equals(new MageObjectReference(permanent, game))) {
return false;
}
} else {
return false;
}

int damage = dEvent
.getEvents()
.stream()
.filter(damagedEvent -> paired.getId().equals(damagedEvent.getTargetId()))
.mapToInt(GameEvent::getAmount)
.sum();
if (damage < 1) {
return false;
}
this.getEffects().setValue("damageToPaired", damage);
this.addTarget(new TargetOpponent());
return true;
}

@Override
public String getRule() {
return "Whenever {this} or a creature it's paired with is dealt damage, " +
"{this} deals that much damage to target opponent.";
}
}

//Based on WrathfulRaptorsEffect
class DonnaNobleEffect extends OneShotEffect {

DonnaNobleEffect() {
super(Outcome.Benefit);
}

private DonnaNobleEffect(final DonnaNobleEffect effect) {
super(effect);
}

@Override
public DonnaNobleEffect copy() {
return new DonnaNobleEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {

// Only resolve the targets we need.
int targetIdx = 0;
boolean damageApplied = false;

Integer[] damages = {
(Integer) getValue("damageToThis"),
(Integer) getValue("damageToPaired")
};

for (Integer damage : damages){
if (damage == null) {
continue;
}
UUID targetId = source.getTargets().get(targetIdx++).getFirstTarget();
Player player = game.getPlayer(targetId);
UUID sourceId = source.getSourcePermanentOrLKI(game).getId();
if (player != null && sourceId != null) {
damageApplied |= player.damage(damage, sourceId, source, game) > 0;
}
}

return damageApplied;
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/DoctorWho.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private DoctorWho() {
cards.add(new SetCardInfo("Desolate Lighthouse", 271, Rarity.RARE, mage.cards.d.DesolateLighthouse.class));
cards.add(new SetCardInfo("Dinosaurs on a Spaceship", 122, Rarity.RARE, mage.cards.d.DinosaursOnASpaceship.class));
cards.add(new SetCardInfo("Displaced Dinosaurs", 100, Rarity.UNCOMMON, mage.cards.d.DisplacedDinosaurs.class));
cards.add(new SetCardInfo("Donna Noble", 82, Rarity.RARE, mage.cards.d.DonnaNoble.class));
cards.add(new SetCardInfo("Dragonskull Summit", 272, Rarity.RARE, mage.cards.d.DragonskullSummit.class));
cards.add(new SetCardInfo("Dreamroot Cascade", 273, Rarity.RARE, mage.cards.d.DreamrootCascade.class));
cards.add(new SetCardInfo("Drowned Catacomb", 274, Rarity.RARE, mage.cards.d.DrownedCatacomb.class));
Expand Down