mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 11:49:56 -08:00
[TLA] Implement Fire Nation Attacks
This commit is contained in:
parent
b552c850f4
commit
e93d95d7a0
7 changed files with 180 additions and 7 deletions
|
|
@ -0,0 +1,91 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class FirebendingAbility extends AttacksTriggeredAbility {
|
||||
|
||||
private final DynamicValue amount;
|
||||
|
||||
public FirebendingAbility(int amount) {
|
||||
this(StaticValue.get(amount));
|
||||
}
|
||||
|
||||
public FirebendingAbility(DynamicValue amount) {
|
||||
super(new FirebendingAbilityEffect(amount));
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
private FirebendingAbility(final FirebendingAbility ability) {
|
||||
super(ability);
|
||||
this.amount = ability.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirebendingAbility copy() {
|
||||
return new FirebendingAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
if (amount instanceof StaticValue) {
|
||||
return "firebending " + amount +
|
||||
" <i>(Whenever this creature attacks, add " +
|
||||
String.join("", Collections.nCopies(((StaticValue) amount).getValue(), "{R}")) +
|
||||
". This mana lasts until end of combat.)</i>";
|
||||
}
|
||||
return "firebending X, where X is " + amount.getMessage() +
|
||||
". <i>(Whenever this creature attacks, add X {R}. This mana lasts until end of combat.)</i>";
|
||||
}
|
||||
}
|
||||
|
||||
class FirebendingAbilityEffect extends OneShotEffect {
|
||||
|
||||
private final DynamicValue amount;
|
||||
|
||||
FirebendingAbilityEffect(DynamicValue amount) {
|
||||
super(Outcome.Benefit);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
private FirebendingAbilityEffect(final FirebendingAbilityEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirebendingAbilityEffect copy() {
|
||||
return new FirebendingAbilityEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
int amount = Math.max(this.amount.calculate(game, source, this), 0);
|
||||
if (amount > 0) {
|
||||
player.getManaPool().addMana(Mana.RedMana(amount), game, source, Duration.EndOfCombat);
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(
|
||||
GameEvent.EventType.FIREBENDED, source.getSourceId(),
|
||||
source, source.getControllerId(), amount
|
||||
));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -696,6 +696,7 @@ public class GameEvent implements Serializable {
|
|||
*/
|
||||
PAY_SACRIFICE_COST,
|
||||
EARTHBENDED,
|
||||
FIREBENDED,
|
||||
// custom events - must store some unique data to track
|
||||
CUSTOM_EVENT;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.keyword.FirebendingAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class SoldierFirebendingToken extends TokenImpl {
|
||||
|
||||
public SoldierFirebendingToken() {
|
||||
super("Soldier Token", "2/2 red Soldier creature token with firebending 1");
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setRed(true);
|
||||
subtype.add(SubType.SOLDIER);
|
||||
power = new MageInt(2);
|
||||
toughness = new MageInt(2);
|
||||
this.addAbility(new FirebendingAbility(1));
|
||||
}
|
||||
|
||||
private SoldierFirebendingToken(final SoldierFirebendingToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
public SoldierFirebendingToken copy() {
|
||||
return new SoldierFirebendingToken(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import mage.abilities.costs.Cost;
|
|||
import mage.abilities.effects.mana.ManaEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterMana;
|
||||
|
|
@ -302,9 +303,17 @@ public class ManaPool implements Serializable {
|
|||
}
|
||||
|
||||
private int emptyItem(ManaPoolItem item, Emptiable toEmpty, Game game, ManaType manaType) {
|
||||
if (item.getDuration() == Duration.EndOfTurn
|
||||
&& game.getTurnPhaseType() != TurnPhase.END) {
|
||||
return 0;
|
||||
switch (item.getDuration()) {
|
||||
case EndOfTurn:
|
||||
if (game.getTurnPhaseType() != TurnPhase.END) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case EndOfCombat:
|
||||
if (game.getTurnPhaseType() != TurnPhase.COMBAT
|
||||
|| game.getTurnStepType() != PhaseStep.END_COMBAT) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (manaBecomesBlack) {
|
||||
int amount = toEmpty.get(manaType);
|
||||
|
|
@ -366,6 +375,10 @@ public class ManaPool implements Serializable {
|
|||
}
|
||||
|
||||
public void addMana(Mana manaToAdd, Game game, Ability source, boolean dontLoseUntilEOT) {
|
||||
addMana(manaToAdd, game, source, dontLoseUntilEOT ? Duration.EndOfTurn : null);
|
||||
}
|
||||
|
||||
public void addMana(Mana manaToAdd, Game game, Ability source, Duration duration) {
|
||||
if (manaToAdd != null) {
|
||||
Mana mana = manaToAdd.copy();
|
||||
if (!game.replaceEvent(new ManaEvent(EventType.ADD_MANA, source.getId(), source, playerId, mana))) {
|
||||
|
|
@ -376,8 +389,8 @@ public class ManaPool implements Serializable {
|
|||
source.getSourceObject(game),
|
||||
conditionalMana.getManaProducerOriginalId() != null ? conditionalMana.getManaProducerOriginalId() : source.getOriginalId()
|
||||
);
|
||||
if (dontLoseUntilEOT) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
if (duration != null) {
|
||||
item.setDuration(duration);
|
||||
}
|
||||
this.manaItems.add(item);
|
||||
} else {
|
||||
|
|
@ -392,8 +405,8 @@ public class ManaPool implements Serializable {
|
|||
source.getOriginalId(),
|
||||
mana.getFlag()
|
||||
);
|
||||
if (dontLoseUntilEOT) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
if (duration != null) {
|
||||
item.setDuration(duration);
|
||||
}
|
||||
this.manaItems.add(item);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue