mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
reworked coin doubling again for some reason
This commit is contained in:
parent
191e9903ba
commit
837503d8f4
6 changed files with 34 additions and 52 deletions
|
@ -3,12 +3,16 @@ package mage.cards.k;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.game.events.FlipCoinEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -35,7 +39,7 @@ public final class KrarksThumb extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class KrarksThumbEffect extends ContinuousEffectImpl {
|
||||
class KrarksThumbEffect extends ReplacementEffectImpl {
|
||||
|
||||
KrarksThumbEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
|
@ -52,12 +56,20 @@ class KrarksThumbEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
controller.setExtraCoinFlips(2 * controller.getExtraCoinFlips());
|
||||
}
|
||||
return true;
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
FlipCoinEvent flipCoinEvent = (FlipCoinEvent) event;
|
||||
flipCoinEvent.setFlipCount(2 * flipCoinEvent.getFlipCount());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.FLIP_COIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return source.isControlledBy(event.getPlayerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2418,16 +2418,6 @@ public class TestPlayer implements Player {
|
|||
computerPlayer.setLoyaltyUsePerTurn(loyaltyUsePerTurn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExtraCoinFlips() {
|
||||
return computerPlayer.getExtraCoinFlips();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtraCoinFlips(int extraCoinFlips) {
|
||||
computerPlayer.setExtraCoinFlips(extraCoinFlips);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHandSize() {
|
||||
return computerPlayer.getMaxHandSize();
|
||||
|
|
|
@ -262,16 +262,6 @@ public class PlayerStub implements Player {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExtraCoinFlips() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtraCoinFlips(int extraCoinFlips) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHandSize() {
|
||||
return 0;
|
||||
|
|
|
@ -11,6 +11,7 @@ public class FlipCoinEvent extends GameEvent {
|
|||
private boolean result;
|
||||
private final boolean chosen;
|
||||
private final boolean winnable;
|
||||
private int flipCount = 1;
|
||||
|
||||
public FlipCoinEvent(UUID playerId, UUID sourceId, boolean result, boolean chosen, boolean winnable) {
|
||||
super(EventType.FLIP_COIN, playerId, sourceId, playerId);
|
||||
|
@ -43,6 +44,14 @@ public class FlipCoinEvent extends GameEvent {
|
|||
return winnable;
|
||||
}
|
||||
|
||||
public int getFlipCount() {
|
||||
return flipCount;
|
||||
}
|
||||
|
||||
public void setFlipCount(int flipCount) {
|
||||
this.flipCount = flipCount;
|
||||
}
|
||||
|
||||
public CoinFlippedEvent getFlippedEvent() {
|
||||
return new CoinFlippedEvent(playerId, sourceId, result, chosen, winnable);
|
||||
}
|
||||
|
|
|
@ -141,10 +141,6 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void setLoyaltyUsePerTurn(int loyaltyUsePerTurn);
|
||||
|
||||
int getExtraCoinFlips();
|
||||
|
||||
void setExtraCoinFlips(int getExtraCoinFlips);
|
||||
|
||||
int getMaxHandSize();
|
||||
|
||||
void setMaxHandSize(int maxHandSize);
|
||||
|
|
|
@ -98,7 +98,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
protected int landsPlayed;
|
||||
protected int landsPerTurn = 1;
|
||||
protected int loyaltyUsePerTurn = 1;
|
||||
protected int extraCoinFlips = 1;
|
||||
protected int maxHandSize = 7;
|
||||
protected int maxAttackedBy = Integer.MAX_VALUE;
|
||||
protected ManaPool manaPool;
|
||||
|
@ -224,7 +223,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.landsPlayed = player.landsPlayed;
|
||||
this.landsPerTurn = player.landsPerTurn;
|
||||
this.loyaltyUsePerTurn = player.loyaltyUsePerTurn;
|
||||
this.extraCoinFlips = player.extraCoinFlips;
|
||||
this.maxHandSize = player.maxHandSize;
|
||||
this.maxAttackedBy = player.maxAttackedBy;
|
||||
this.manaPool = player.manaPool.copy();
|
||||
|
@ -315,7 +313,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.landsPlayed = player.getLandsPlayed();
|
||||
this.landsPerTurn = player.getLandsPerTurn();
|
||||
this.loyaltyUsePerTurn = player.getLoyaltyUsePerTurn();
|
||||
this.extraCoinFlips = player.getExtraCoinFlips();
|
||||
this.maxHandSize = player.getMaxHandSize();
|
||||
this.maxAttackedBy = player.getMaxAttackedBy();
|
||||
this.manaPool = player.getManaPool().copy();
|
||||
|
@ -436,7 +433,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.abilities.clear();
|
||||
this.landsPerTurn = 1;
|
||||
this.loyaltyUsePerTurn = 1;
|
||||
this.extraCoinFlips = 1;
|
||||
this.maxHandSize = 7;
|
||||
this.maxAttackedBy = Integer.MAX_VALUE;
|
||||
this.canGainLife = true;
|
||||
|
@ -2083,16 +2079,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.loyaltyUsePerTurn = loyaltyUsePerTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExtraCoinFlips() {
|
||||
return extraCoinFlips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtraCoinFlips(int extraCoinFlips) {
|
||||
this.extraCoinFlips = extraCoinFlips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHandSize() {
|
||||
return maxHandSize;
|
||||
|
@ -2593,12 +2579,11 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
FlipCoinEvent event = new FlipCoinEvent(playerId, source.getSourceId(), result, chosen, winnable);
|
||||
event.addAppliedEffects(appliedEffects);
|
||||
game.replaceEvent(event);
|
||||
if (extraCoinFlips > 1) {
|
||||
if (event.getFlipCount() > 1) {
|
||||
boolean canChooseHeads = event.getResult();
|
||||
boolean canChooseTails = !event.getResult();
|
||||
boolean tempFlip;
|
||||
for (int i = 0; i < extraCoinFlips; i++) {
|
||||
tempFlip = RandomUtil.nextBoolean();
|
||||
for (int i = 1; i < event.getFlipCount(); i++) {
|
||||
boolean tempFlip = RandomUtil.nextBoolean();
|
||||
canChooseHeads = canChooseHeads || tempFlip;
|
||||
canChooseTails = canChooseTails || !tempFlip;
|
||||
game.informPlayers(getLogName() + " flipped " + CardUtil.booleanToFlipName(tempFlip));
|
||||
|
|
Loading…
Reference in a new issue