mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
updated abilities which trigger off of a coin flip
This commit is contained in:
parent
2e1c4a054e
commit
57a362ae29
6 changed files with 69 additions and 54 deletions
|
@ -1,7 +1,6 @@
|
|||
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
|
@ -16,27 +15,29 @@ import mage.constants.TargetController;
|
|||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.CoinFlippedEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class ChanceEncounter extends CardImpl {
|
||||
|
||||
public ChanceEncounter(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{R}{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}");
|
||||
|
||||
// Whenever you win a coin flip, put a luck counter on Chance Encounter.
|
||||
this.addAbility(new ChanceEncounterTriggeredAbility());
|
||||
|
||||
|
||||
// At the beginning of your upkeep, if Chance Encounter has ten or more luck counters on it, you win the game.
|
||||
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new WinGameSourceControllerEffect(), TargetController.YOU, false);
|
||||
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new WinGameSourceControllerEffect(), TargetController.YOU, false);
|
||||
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new SourceHasCounterCondition(CounterType.LUCK, 10, Integer.MAX_VALUE),
|
||||
"At the beginning of your upkeep, if {this} has ten or more luck counters on it, you win the game"));
|
||||
}
|
||||
|
||||
public ChanceEncounter(final ChanceEncounter card) {
|
||||
private ChanceEncounter(final ChanceEncounter card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
@ -47,30 +48,33 @@ public final class ChanceEncounter extends CardImpl {
|
|||
}
|
||||
|
||||
class ChanceEncounterTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public ChanceEncounterTriggeredAbility() {
|
||||
|
||||
ChanceEncounterTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.LUCK.createInstance()), false);
|
||||
}
|
||||
|
||||
public ChanceEncounterTriggeredAbility(final ChanceEncounterTriggeredAbility ability) {
|
||||
|
||||
private ChanceEncounterTriggeredAbility(final ChanceEncounterTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ChanceEncounterTriggeredAbility copy() {
|
||||
return new ChanceEncounterTriggeredAbility(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.COIN_FLIPPED;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return this.isControlledBy(event.getPlayerId()) && event.getFlag();
|
||||
CoinFlippedEvent flipEvent = (CoinFlippedEvent) event;
|
||||
return flipEvent.getPlayerId().equals(controllerId)
|
||||
&& flipEvent.isWinnable()
|
||||
&& (flipEvent.getChosen() == flipEvent.getResult());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you win a coin flip, " + super.getRule();
|
||||
|
|
|
@ -15,6 +15,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.CoinFlippedEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
|
@ -56,30 +57,6 @@ public final class KarplusanMinotaur extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
enum KarplusanMinotaurAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
Player controller = game.getPlayer(ability.getControllerId());
|
||||
if (controller == null) {
|
||||
return;
|
||||
}
|
||||
UUID opponentId = null;
|
||||
if (game.getOpponents(controller.getId()).size() > 1) {
|
||||
Target target = new TargetOpponent(true);
|
||||
if (controller.chooseTarget(Outcome.Neutral, target, ability, game)) {
|
||||
opponentId = target.getFirstTarget();
|
||||
}
|
||||
} else {
|
||||
opponentId = game.getOpponents(controller.getId()).iterator().next();
|
||||
}
|
||||
if (opponentId != null) {
|
||||
ability.getTargets().get(0).setTargetController(opponentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KarplusanMinotaurFlipWinTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public KarplusanMinotaurFlipWinTriggeredAbility() {
|
||||
|
@ -103,7 +80,10 @@ class KarplusanMinotaurFlipWinTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return this.isControlledBy(event.getPlayerId()) && event.getFlag();
|
||||
CoinFlippedEvent flipEvent = (CoinFlippedEvent) event;
|
||||
return flipEvent.getPlayerId().equals(controllerId)
|
||||
&& flipEvent.isWinnable()
|
||||
&& (flipEvent.getChosen() == flipEvent.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,7 +116,10 @@ class KarplusanMinotaurFlipLoseTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return this.isControlledBy(event.getPlayerId()) && !event.getFlag();
|
||||
CoinFlippedEvent flipEvent = (CoinFlippedEvent) event;
|
||||
return flipEvent.getPlayerId().equals(controllerId)
|
||||
&& flipEvent.isWinnable()
|
||||
&& (flipEvent.getChosen() != flipEvent.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,7 +138,7 @@ class KarplusanMinotaurCost extends CostImpl {
|
|||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
controller.flipCoin(source, game, true);
|
||||
controller.flipCoin(ability, game, true);
|
||||
this.paid = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -178,3 +161,27 @@ class KarplusanMinotaurCost extends CostImpl {
|
|||
return new KarplusanMinotaurCost();
|
||||
}
|
||||
}
|
||||
|
||||
enum KarplusanMinotaurAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
Player controller = game.getPlayer(ability.getControllerId());
|
||||
if (controller == null) {
|
||||
return;
|
||||
}
|
||||
UUID opponentId = null;
|
||||
if (game.getOpponents(controller.getId()).size() > 1) {
|
||||
Target target = new TargetOpponent(true);
|
||||
if (controller.chooseTarget(Outcome.Neutral, target, ability, game)) {
|
||||
opponentId = target.getFirstTarget();
|
||||
}
|
||||
} else {
|
||||
opponentId = game.getOpponents(controller.getId()).iterator().next();
|
||||
}
|
||||
if (opponentId != null) {
|
||||
ability.getTargets().get(0).setTargetController(opponentId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
package mage.cards.o;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
|
||||
import mage.abilities.common.WinsCoinFlipTriggeredAbility;
|
||||
|
@ -13,18 +12,18 @@ import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
|||
import mage.abilities.keyword.PartnerWithAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class OkaunEyeOfChaos extends CardImpl {
|
||||
|
||||
private static final DynamicValue sourcePower = new SourcePermanentPowerCount();
|
||||
private static final DynamicValue sourceToughness = new SourcePermanentToughnessValue();
|
||||
|
||||
public OkaunEyeOfChaos(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}");
|
||||
|
||||
|
@ -41,8 +40,6 @@ public final class OkaunEyeOfChaos extends CardImpl {
|
|||
this.addAbility(new BeginningOfCombatTriggeredAbility(new FlipUntilLoseEffect(), TargetController.YOU, false));
|
||||
|
||||
// Whenever a player wins a coin flip, double Okaun's power and toughness until end of turn.
|
||||
DynamicValue sourcePower = new SourcePermanentPowerCount();
|
||||
DynamicValue sourceToughness = new SourcePermanentToughnessValue();
|
||||
this.addAbility(new WinsCoinFlipTriggeredAbility(
|
||||
new BoostSourceEffect(
|
||||
sourcePower,
|
||||
|
|
|
@ -5,10 +5,10 @@ import mage.abilities.TriggeredAbilityImpl;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.CoinFlippedEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class WinsCoinFlipTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
@ -33,7 +33,8 @@ public class WinsCoinFlipTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getFlag();
|
||||
CoinFlippedEvent flipEvent = (CoinFlippedEvent) event;
|
||||
return flipEvent.isWinnable() && (flipEvent.getChosen() == flipEvent.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,13 +2,16 @@ package mage.game.events;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
**/
|
||||
public class CoinFlippedEvent extends GameEvent {
|
||||
private final boolean result;
|
||||
private final boolean chosen;
|
||||
private final boolean winnable;
|
||||
|
||||
CoinFlippedEvent(UUID playerId, UUID sourceId, boolean result, boolean chosen, boolean winnable) {
|
||||
super(EventType.FLIP_COIN, playerId, sourceId, playerId);
|
||||
super(EventType.COIN_FLIPPED, playerId, sourceId, playerId);
|
||||
this.result = result;
|
||||
this.chosen = chosen;
|
||||
this.winnable = winnable;
|
||||
|
|
|
@ -2,6 +2,9 @@ package mage.game.events;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
**/
|
||||
public class FlipCoinEvent extends GameEvent {
|
||||
private boolean result;
|
||||
private final boolean chosen;
|
||||
|
|
Loading…
Reference in a new issue