mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
updated Krark's Thumb, still doesn't work in multiples
This commit is contained in:
parent
57a362ae29
commit
c34f611279
5 changed files with 51 additions and 18 deletions
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
package mage.cards.k;
|
package mage.cards.k;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
|
@ -9,25 +8,28 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.FlipCoinEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.util.CardUtil;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class KrarksThumb extends CardImpl {
|
public final class KrarksThumb extends CardImpl {
|
||||||
|
|
||||||
public KrarksThumb(UUID ownerId, CardSetInfo setInfo) {
|
public KrarksThumb(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||||
addSuperType(SuperType.LEGENDARY);
|
addSuperType(SuperType.LEGENDARY);
|
||||||
|
|
||||||
// If you would flip a coin, instead flip two coins and ignore one.
|
// If you would flip a coin, instead flip two coins and ignore one.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KrarksThumbEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KrarksThumbEffect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KrarksThumb(final KrarksThumb card) {
|
private KrarksThumb(final KrarksThumb card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,26 +46,30 @@ class KrarksThumbEffect extends ReplacementEffectImpl {
|
||||||
staticText = "If you would flip a coin, instead flip two coins and ignore one";
|
staticText = "If you would flip a coin, instead flip two coins and ignore one";
|
||||||
}
|
}
|
||||||
|
|
||||||
KrarksThumbEffect(final KrarksThumbEffect effect) {
|
private KrarksThumbEffect(final KrarksThumbEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
Player player = game.getPlayer(event.getPlayerId());
|
Player player = game.getPlayer(event.getPlayerId());
|
||||||
if (player != null) {
|
if (player == null || !player.getId().equals(source.getControllerId())) {
|
||||||
// because second flip is ignored it may not be done by the player method
|
return false;
|
||||||
boolean secondCoinFlip = RandomUtil.nextBoolean();
|
|
||||||
if (!game.isSimulation()) {
|
|
||||||
game.informPlayers("[Flip a coin] " + player.getLogName() + (secondCoinFlip ? " won (head)." : " lost (tail)."));
|
|
||||||
}
|
|
||||||
if (player.chooseUse(outcome, "Ignore the first coin flip?", source, game)) {
|
|
||||||
event.setFlag(secondCoinFlip);
|
|
||||||
game.informPlayers(player.getLogName() + " ignores the first coin flip.");
|
|
||||||
} else {
|
|
||||||
game.informPlayers(player.getLogName() + " ignores the second coin flip.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
FlipCoinEvent flipEvent = (FlipCoinEvent) event;
|
||||||
|
boolean secondFlip = RandomUtil.nextBoolean();
|
||||||
|
game.informPlayers(player.getLogName() + " flipped a " + flipEvent.getResultName()
|
||||||
|
+ " and a " + CardUtil.booleanToFlipName(secondFlip)
|
||||||
|
);
|
||||||
|
boolean chosenFlip = player.chooseUse(
|
||||||
|
Outcome.Benefit, "Choose which coin you want",
|
||||||
|
"(You chose " + flipEvent.getChosenName() + ")",
|
||||||
|
flipEvent.getResultName(), CardUtil.booleanToFlipName(secondFlip), source, game
|
||||||
|
);
|
||||||
|
if (!chosenFlip) {
|
||||||
|
flipEvent.setResult(secondFlip);
|
||||||
|
}
|
||||||
|
game.informPlayers(player.getLogName() + " chooses to keep " + flipEvent.getResultName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,10 +23,18 @@ public class CoinFlippedEvent extends GameEvent {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getResultName() {
|
||||||
|
return CardUtil.booleanToFlipName(result);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getChosen() {
|
public boolean getChosen() {
|
||||||
return chosen;
|
return chosen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getChosenName() {
|
||||||
|
return CardUtil.booleanToFlipName(chosen);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isWinnable() {
|
public boolean isWinnable() {
|
||||||
return winnable;
|
return winnable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +23,10 @@ public class FlipCoinEvent extends GameEvent {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getResultName() {
|
||||||
|
return CardUtil.booleanToFlipName(result);
|
||||||
|
}
|
||||||
|
|
||||||
public void setResult(boolean result) {
|
public void setResult(boolean result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +35,10 @@ public class FlipCoinEvent extends GameEvent {
|
||||||
return chosen;
|
return chosen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getChosenName() {
|
||||||
|
return CardUtil.booleanToFlipName(chosen);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isWinnable() {
|
public boolean isWinnable() {
|
||||||
return winnable;
|
return winnable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2558,7 +2558,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean flipCoin(Ability source, Game game, boolean winnable) {
|
public boolean flipCoin(Ability source, Game game, boolean winnable) {
|
||||||
return this.flipCoin(source, game, true, null);
|
return this.flipCoin(source, game, winnable, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -354,6 +354,13 @@ public final class CardUtil {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String booleanToFlipName(boolean flip) {
|
||||||
|
if (flip) {
|
||||||
|
return "Heads";
|
||||||
|
}
|
||||||
|
return "Tails";
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean checkNumeric(String s) {
|
public static boolean checkNumeric(String s) {
|
||||||
return s.chars().allMatch(Character::isDigit);
|
return s.chars().allMatch(Character::isDigit);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue