mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Merge branch 'master' of https://github.com/magefree/mage
This commit is contained in:
commit
372fb4ec91
207 changed files with 1674 additions and 1281 deletions
|
@ -1046,8 +1046,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
// close & remove sideboarding or construction pane if open
|
||||
if (window instanceof DeckEditorPane) {
|
||||
DeckEditorPane deckEditorPane = (DeckEditorPane) window;
|
||||
if (deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.LIMITED_BUILDING)
|
||||
|| deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.SIDEBOARDING)) {
|
||||
if (deckEditorPane.getDeckEditorMode() == DeckEditorMode.LIMITED_BUILDING
|
||||
|| deckEditorPane.getDeckEditorMode() == DeckEditorMode.SIDEBOARDING) {
|
||||
deckEditorPane.removeFrame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class BigCard extends JComponent {
|
|||
image = TransformedImageCache.getResizedImage((BufferedImage)image, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
if (this.cardId == null || !enlargeMode.equals(this.enlargeMode) || !this.cardId.equals(cardId)) {
|
||||
if (this.cardId == null || enlargeMode != this.enlargeMode || !this.cardId.equals(cardId)) {
|
||||
if (this.panel != null) {
|
||||
remove(this.panel);
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
|||
}
|
||||
break;
|
||||
case RARITY:
|
||||
if (!cardImg.getOriginal().getRarity().equals(lastCard.getOriginal().getRarity())) {
|
||||
if (cardImg.getOriginal().getRarity() != lastCard.getOriginal().getRarity()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
|
|
|
@ -88,10 +88,10 @@ public class ChatPanelSeparated extends ChatPanelBasic {
|
|||
textColor = MESSAGE_COLOR;
|
||||
userSeparator = ": ";
|
||||
}
|
||||
if (color.equals(ChatMessage.MessageColor.ORANGE)) {
|
||||
if (color == ChatMessage.MessageColor.ORANGE) {
|
||||
textColor = "Orange";
|
||||
}
|
||||
if (color.equals(ChatMessage.MessageColor.YELLOW)) {
|
||||
if (color == ChatMessage.MessageColor.YELLOW) {
|
||||
textColor = "Yellow";
|
||||
}
|
||||
if (username != null && !username.isEmpty()) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class DialogContainer extends JPanel {
|
|||
|
||||
if (dialogType == DialogManager.MTGDialogs.MessageDialog) {
|
||||
//backgroundColor = new Color(0, 255, 255, 60);
|
||||
if (params.type.equals(MessageDlg.Types.Warning)) {
|
||||
if (params.type == MessageDlg.Types.Warning) {
|
||||
backgroundColor = new Color(255, 0, 0, 90);
|
||||
} else {
|
||||
backgroundColor = new Color(0, 0, 0, 90);
|
||||
|
|
|
@ -162,7 +162,7 @@ public class CardInfoWindowDialog extends MageDialog {
|
|||
|
||||
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, boolean revertOrder) {
|
||||
cards.loadCards(showCards, bigCard, gameId, revertOrder);
|
||||
if (showType.equals(ShowType.GRAVEYARD)) {
|
||||
if (showType == ShowType.GRAVEYARD) {
|
||||
int qty = qtyCardTypes(showCards);
|
||||
String titel = name + "'s Graveyard (" + showCards.size() + ") - " + qty + ((qty == 1) ? " Card Type" : " Card Types");
|
||||
setTitle(titel);
|
||||
|
@ -173,7 +173,7 @@ public class CardInfoWindowDialog extends MageDialog {
|
|||
|
||||
@Override
|
||||
public void show() {
|
||||
if (showType.equals(ShowType.EXILE)) {
|
||||
if (showType == ShowType.EXILE) {
|
||||
if (cards == null || cards.getNumberOfCards() == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -391,7 +391,7 @@ public class ConnectDialog extends MageDialog {
|
|||
connection.setUsername(this.txtUserName.getText().trim());
|
||||
connection.setPassword(this.txtPassword.getText().trim());
|
||||
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected());
|
||||
connection.setUserIdStr(System.getProperty("user.name") + ":" + MagePreferences.getUserNames());
|
||||
connection.setUserIdStr(System.getProperty("user.name") + ':' + MagePreferences.getUserNames());
|
||||
MageFrame.getPreferences().put(KEY_CONNECT_FLAG, ((CountryItemEditor) cbFlag.getEditor()).getImageItem());
|
||||
PreferencesDialog.setProxyInformation(connection);
|
||||
|
||||
|
|
|
@ -2958,7 +2958,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
connection.setProxyType(configProxyType);
|
||||
if (!configProxyType.equals(ProxyType.NONE)) {
|
||||
if (configProxyType != ProxyType.NONE) {
|
||||
String host = getCachedValue(KEY_PROXY_ADDRESS, "");
|
||||
String port = getCachedValue(KEY_PROXY_PORT, "");
|
||||
if (!host.isEmpty() && !port.isEmpty()) {
|
||||
|
|
|
@ -1144,7 +1144,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
PopUpMenuType popupMenuType = null;
|
||||
if (options != null) {
|
||||
if (options.containsKey("targetZone")) {
|
||||
if (Zone.HAND.equals(options.get("targetZone"))) { // mark selectable target cards in hand
|
||||
if (Zone.HAND == options.get("targetZone")) { // mark selectable target cards in hand
|
||||
List<UUID> choosen = null;
|
||||
if (options.containsKey("chosen")) {
|
||||
choosen = (List<UUID>) options.get("chosen");
|
||||
|
@ -1163,7 +1163,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (options.containsKey("queryType") && PlayerQueryEvent.QueryType.PICK_ABILITY.equals(options.get("queryType"))) {
|
||||
if (options.containsKey("queryType") && PlayerQueryEvent.QueryType.PICK_ABILITY == options.get("queryType")) {
|
||||
popupMenuType = PopUpMenuType.TRIGGER_ORDER;
|
||||
}
|
||||
}
|
||||
|
@ -1263,7 +1263,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
hideAll();
|
||||
ShowCardsDialog showCards = new ShowCardsDialog();
|
||||
JPopupMenu popupMenu = null;
|
||||
if (PopUpMenuType.TRIGGER_ORDER.equals(popupMenuType)) {
|
||||
if (PopUpMenuType.TRIGGER_ORDER == popupMenuType) {
|
||||
popupMenu = popupMenuTriggerOrder;
|
||||
}
|
||||
showCards.loadCards(title, cards, bigCard, gameId, required, options, popupMenu, getShowCardsEventListener(showCards));
|
||||
|
|
|
@ -145,7 +145,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
createChatStartMessage(panel);
|
||||
}
|
||||
// send the message to subchat if exists and it's not a game message
|
||||
if (!message.getMessageType().equals(MessageType.GAME) && panel.getConnectedChat() != null) {
|
||||
if (message.getMessageType() != MessageType.GAME && panel.getConnectedChat() != null) {
|
||||
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
|
||||
} else {
|
||||
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), message.getColor());
|
||||
|
@ -157,7 +157,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
case "serverMessage":
|
||||
if (callback.getData() != null) {
|
||||
ChatMessage message = (ChatMessage) callback.getData();
|
||||
if (message.getColor().equals(ChatMessage.MessageColor.RED)) {
|
||||
if (message.getColor() == ChatMessage.MessageColor.RED) {
|
||||
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.WARNING_MESSAGE);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.INFORMATION_MESSAGE);
|
||||
|
|
|
@ -24,7 +24,7 @@ public class DelayedViewerThread extends Thread {
|
|||
|
||||
public synchronized void show(Component component, long delay) {
|
||||
delayedViewers.put(component, System.currentTimeMillis() + delay);
|
||||
notify();
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
public synchronized void hide(Component component) {
|
||||
|
|
|
@ -147,7 +147,7 @@ public final class GuiDisplayUtil {
|
|||
for (String rule : card.getRules()) {
|
||||
textLines.basicTextLength += rule.length();
|
||||
}
|
||||
if (card.getMageObjectType().equals(MageObjectType.PERMANENT)) {
|
||||
if (card.getMageObjectType() == MageObjectType.PERMANENT) {
|
||||
if (card.getPairedCard() != null) {
|
||||
textLines.lines.add("<span color='green'><i>Paired with another creature</i></span>");
|
||||
textLines.basicTextLength += 30;
|
||||
|
|
|
@ -65,7 +65,7 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
if (a.getRarity() == null || b.getRarity() == null) {
|
||||
return false;
|
||||
}
|
||||
if (!a.getRarity().equals(b.getRarity())) {
|
||||
if (a.getRarity() != b.getRarity()) {
|
||||
return false;
|
||||
}
|
||||
if (a.getCardNumber() != null && !a.getCardNumber().equals(b.getCardNumber())) {
|
||||
|
|
|
@ -460,7 +460,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
continue;
|
||||
}
|
||||
// all attached permanents are grouped separately later
|
||||
if (!type.equals(RowType.attached) && RowType.attached.isType(permanent)) {
|
||||
if (type != RowType.attached && RowType.attached.isType(permanent)) {
|
||||
continue;
|
||||
}
|
||||
Stack stack = new Stack();
|
||||
|
|
|
@ -142,7 +142,7 @@ public class MythicspoilerComSource implements CardImageSource {
|
|||
|
||||
String urlDocument;
|
||||
Document doc;
|
||||
if (proxyType.equals(ProxyType.NONE)) {
|
||||
if (proxyType == ProxyType.NONE) {
|
||||
urlDocument = pageUrl;
|
||||
doc = Jsoup.connect(urlDocument).get();
|
||||
} else {
|
||||
|
|
|
@ -332,7 +332,7 @@ public class WizardCardsImageSource implements CardImageSource {
|
|||
Preferences prefs = MageFrame.getPreferences();
|
||||
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(prefs.get("proxyType", "None"));
|
||||
Document doc;
|
||||
if (proxyType.equals(ProxyType.NONE)) {
|
||||
if (proxyType == ProxyType.NONE) {
|
||||
doc = Jsoup.connect(urlString).get();
|
||||
} else {
|
||||
String proxyServer = prefs.get("proxyAddress", "");
|
||||
|
|
|
@ -216,7 +216,7 @@ public final class CardImageUtils {
|
|||
public static Proxy getProxyFromPreferences() {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(prefs.get("proxyType", "None"));
|
||||
if (!proxyType.equals(ProxyType.NONE)) {
|
||||
if (proxyType != ProxyType.NONE) {
|
||||
String proxyServer = prefs.get("proxyAddress", "");
|
||||
int proxyPort = Integer.parseInt(prefs.get("proxyPort", "0"));
|
||||
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyServer, proxyPort));
|
||||
|
|
|
@ -48,7 +48,7 @@ public class StartMultiGamesTest {
|
|||
synchronized (sync) {
|
||||
frame = new MageFrame();
|
||||
frame.setVisible(true);
|
||||
sync.notify();
|
||||
sync.notifyAll();
|
||||
}
|
||||
});
|
||||
synchronized (sync) {
|
||||
|
|
|
@ -167,7 +167,7 @@ class MomirEffect extends OneShotEffect {
|
|||
while (token.getName().isEmpty() && !options.isEmpty()) {
|
||||
int index = RandomUtil.nextInt(options.size());
|
||||
ExpansionSet expansionSet = Sets.findSet(options.get(index).getSetCode());
|
||||
if (expansionSet == null || expansionSet.getSetType().equals(SetType.CUSTOM_SET)) {
|
||||
if (expansionSet == null || expansionSet.getSetType() == SetType.CUSTOM_SET) {
|
||||
options.remove(index);
|
||||
} else {
|
||||
Card card = options.get(index).getCard();
|
||||
|
|
|
@ -1372,7 +1372,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
|||
|
||||
private boolean checkForRepeatedAction(Game sim, SimulationNode2 node, Ability action, UUID playerId) {
|
||||
// pass or casting two times a spell multiple times on hand is ok
|
||||
if (action instanceof PassAbility || action instanceof SpellAbility || action.getAbilityType().equals(AbilityType.MANA)) {
|
||||
if (action instanceof PassAbility || action instanceof SpellAbility || action.getAbilityType() == AbilityType.MANA) {
|
||||
return false;
|
||||
}
|
||||
int newVal = GameStateEvaluator2.evaluate(playerId, sim);
|
||||
|
|
|
@ -124,7 +124,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
|
|||
List<Ability> playables = game.getPlayer(playerId).getPlayable(game, isSimulatedPlayer);
|
||||
playables = filterAbilities(game, playables, suggested);
|
||||
for (Ability ability : playables) {
|
||||
if (ability.getAbilityType().equals(AbilityType.MANA)) {
|
||||
if (ability.getAbilityType() == AbilityType.MANA) {
|
||||
continue;
|
||||
}
|
||||
List<Ability> options = game.getPlayer(playerId).getPlayableOptions(ability, game);
|
||||
|
|
|
@ -91,7 +91,7 @@ public final class ArtificialScoringSystem {
|
|||
Outcome outcome = effect.getOutcome();
|
||||
if (outcome.isGood()) {
|
||||
enchantments++;
|
||||
} else if (!outcome.equals(Outcome.Detriment)) {
|
||||
} else if (outcome != Outcome.Detriment) {
|
||||
enchantments--;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class OutcomeOptimizer extends BaseTreeOptimizer {
|
|||
public void filter(Game game, List<Ability> actions) {
|
||||
for (Ability ability : actions) {
|
||||
for (Effect effect: ability.getEffects()) {
|
||||
if (effect.getOutcome().equals(Outcome.AIDontUseIt)) {
|
||||
if (effect.getOutcome() == Outcome.AIDontUseIt) {
|
||||
removeAbility(ability);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
|
||||
if (target.getOriginalTarget() instanceof TargetCardInHand
|
||||
|| (target.getZone().equals(Zone.HAND) && (target.getOriginalTarget() instanceof TargetCard))) {
|
||||
|| (target.getZone() == Zone.HAND && (target.getOriginalTarget() instanceof TargetCard))) {
|
||||
List<Card> cards = new ArrayList<>();
|
||||
for (UUID cardId : target.possibleTargets(sourceId, this.getId(), game)) {
|
||||
Card card = game.getCard(cardId);
|
||||
|
@ -759,7 +759,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
UUID opponentId = game.getOpponents(playerId).iterator().next();
|
||||
if (target.getOriginalTarget() instanceof TargetCreatureOrPlayerAmount) {
|
||||
if (outcome.equals(Outcome.Damage) && game.getPlayer(opponentId).getLife() <= target.getAmountRemaining()) {
|
||||
if (outcome == Outcome.Damage && game.getPlayer(opponentId).getLife() <= target.getAmountRemaining()) {
|
||||
target.addTarget(opponentId, target.getAmountRemaining(), source, game);
|
||||
return true;
|
||||
}
|
||||
|
@ -1265,7 +1265,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
// Be proactive! Always use abilities, the evaluation function will decide if it's good or not
|
||||
// Otherwise some abilities won't be used by AI like LoseTargetEffect that has "bad" outcome
|
||||
// but still is good when targets opponent
|
||||
return !outcome.equals(Outcome.AIDontUseIt); // Added for Desecration Demon sacrifice ability
|
||||
return outcome != Outcome.AIDontUseIt; // Added for Desecration Demon sacrifice ability
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1276,7 +1276,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
chooseCreatureType(outcome, choice, game);
|
||||
}
|
||||
// choose the correct color to pay a spell
|
||||
if (outcome.equals(Outcome.PutManaInPool) && choice instanceof ChoiceColor && currentUnpaidMana != null) {
|
||||
if (outcome == Outcome.PutManaInPool && choice instanceof ChoiceColor && currentUnpaidMana != null) {
|
||||
if (currentUnpaidMana.containsColor(ColoredManaSymbol.W) && choice.getChoices().contains("White")) {
|
||||
choice.setChoice("White");
|
||||
return true;
|
||||
|
@ -1319,7 +1319,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
|
||||
protected boolean chooseCreatureType(Outcome outcome, Choice choice, Game game) {
|
||||
if (outcome.equals(Outcome.Detriment)) {
|
||||
if (outcome == Outcome.Detriment) {
|
||||
// choose a creature type of opponent on battlefield or graveyard
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(this.getId(), game)) {
|
||||
if (game.getOpponents(this.getId()).contains(permanent.getControllerId())
|
||||
|
@ -1391,7 +1391,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
// We don't have any valid target to choose so stop choosing
|
||||
return target.getTargets().size() < target.getNumberOfTargets();
|
||||
}
|
||||
if (outcome.equals(Outcome.Neutral) && target.getTargets().size() > target.getNumberOfTargets() + (target.getMaxNumberOfTargets() - target.getNumberOfTargets()) / 2) {
|
||||
if (outcome == Outcome.Neutral && target.getTargets().size() > target.getNumberOfTargets() + (target.getMaxNumberOfTargets() - target.getNumberOfTargets()) / 2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
// We don't have any valid target to choose so stop choosing
|
||||
break;
|
||||
}
|
||||
if (outcome.equals(Outcome.Neutral) && target.getTargets().size() > target.getNumberOfTargets() + (target.getMaxNumberOfTargets() - target.getNumberOfTargets()) / 2) {
|
||||
if (outcome == Outcome.Neutral && target.getTargets().size() > target.getNumberOfTargets() + (target.getMaxNumberOfTargets() - target.getNumberOfTargets()) / 2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2076,7 +2076,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
for (Card card : this.playableInstant) {
|
||||
if (card.getSpellAbility().canActivate(playerId, game)) {
|
||||
for (Effect effect : card.getSpellAbility().getEffects()) {
|
||||
if (effect.getOutcome().equals(Outcome.DestroyPermanent) || effect.getOutcome().equals(Outcome.ReturnToHand)) {
|
||||
if (effect.getOutcome() == Outcome.DestroyPermanent || effect.getOutcome() == Outcome.ReturnToHand) {
|
||||
if (card.getSpellAbility().getTargets().get(0).canTarget(creatureId, card.getSpellAbility(), game)) {
|
||||
if (this.activateAbility(card.getSpellAbility(), game)) {
|
||||
return;
|
||||
|
|
|
@ -83,11 +83,11 @@ public final class RateCard {
|
|||
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect.getOutcome().equals(Outcome.Removal)) {
|
||||
if (effect.getOutcome() == Outcome.Removal) {
|
||||
log.debug("Found removal: " + card.getName());
|
||||
return 1;
|
||||
}
|
||||
if (effect.getOutcome().equals(Outcome.Damage)) {
|
||||
if (effect.getOutcome() == Outcome.Damage) {
|
||||
if (effect instanceof DamageTargetEffect) {
|
||||
DamageTargetEffect damageEffect = (DamageTargetEffect) effect;
|
||||
if (damageEffect.getAmount() > 1) {
|
||||
|
@ -100,7 +100,7 @@ public final class RateCard {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (effect.getOutcome().equals(Outcome.DestroyPermanent)) {
|
||||
if (effect.getOutcome() == Outcome.DestroyPermanent) {
|
||||
for (Target target : ability.getTargets()) {
|
||||
if (target instanceof TargetCreaturePermanent) {
|
||||
log.debug("Found destroyer: " + card.getName());
|
||||
|
|
|
@ -297,7 +297,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Choice choice, Game game) {
|
||||
if (Outcome.PutManaInPool.equals(outcome)) {
|
||||
if (Outcome.PutManaInPool == outcome) {
|
||||
if (currentlyUnpaidMana != null
|
||||
&& ManaUtil.tryToAutoSelectAManaColor(choice, currentlyUnpaidMana)) {
|
||||
return true;
|
||||
|
@ -593,12 +593,12 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
}
|
||||
if (getJustActivatedType() != null && !holdingPriority) {
|
||||
if (controllingPlayer.getUserData().isPassPriorityCast() && getJustActivatedType().equals(AbilityType.SPELL)) {
|
||||
if (controllingPlayer.getUserData().isPassPriorityCast() && getJustActivatedType() == AbilityType.SPELL) {
|
||||
setJustActivatedType(null);
|
||||
pass(game);
|
||||
return false;
|
||||
}
|
||||
if (controllingPlayer.getUserData().isPassPriorityActivation() && getJustActivatedType().equals(AbilityType.ACTIVATED)) {
|
||||
if (controllingPlayer.getUserData().isPassPriorityActivation() && getJustActivatedType() == AbilityType.ACTIVATED) {
|
||||
setJustActivatedType(null);
|
||||
pass(game);
|
||||
return false;
|
||||
|
@ -612,7 +612,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
if (passedUntilEndStepBeforeMyTurn) {
|
||||
|
||||
if (!game.getTurn().getStepType().equals(PhaseStep.END_TURN)) {
|
||||
if (game.getTurn().getStepType() != PhaseStep.END_TURN) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
}
|
||||
if (passedUntilNextMain) {
|
||||
if (game.getTurn().getStepType().equals(PhaseStep.POSTCOMBAT_MAIN) || game.getTurn().getStepType().equals(PhaseStep.PRECOMBAT_MAIN)) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.POSTCOMBAT_MAIN || game.getTurn().getStepType() == PhaseStep.PRECOMBAT_MAIN) {
|
||||
// it's a main phase
|
||||
if (!skippedAtLeastOnce || (!playerId.equals(game.getActivePlayerId()) && !this.getUserData().getUserSkipPrioritySteps().isStopOnAllMainPhases())) {
|
||||
skippedAtLeastOnce = true;
|
||||
|
@ -653,7 +653,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
}
|
||||
if (passedUntilEndOfTurn) {
|
||||
if (game.getTurn().getStepType().equals(PhaseStep.END_TURN)) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.END_TURN) {
|
||||
// It's end of turn phase
|
||||
if (!skippedAtLeastOnce || (playerId.equals(game.getActivePlayerId()) && !this.getUserData().getUserSkipPrioritySteps().isStopOnAllEndPhases())) {
|
||||
skippedAtLeastOnce = true;
|
||||
|
@ -1376,7 +1376,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!source.getAbilityType().equals(AbilityType.TRIGGERED)) {
|
||||
if (source.getAbilityType() != AbilityType.TRIGGERED) {
|
||||
done = true;
|
||||
}
|
||||
if (!canRespond()) {
|
||||
|
@ -1407,7 +1407,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public void setResponseString(String responseString) {
|
||||
synchronized (response) {
|
||||
response.setString(responseString);
|
||||
response.notify();
|
||||
response.notifyAll();
|
||||
logger.debug("Got response string from player: " + getId());
|
||||
}
|
||||
}
|
||||
|
@ -1417,7 +1417,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
synchronized (response) {
|
||||
response.setManaType(manaType);
|
||||
response.setResponseManaTypePlayerId(manaTypePlayerId);
|
||||
response.notify();
|
||||
response.notifyAll();
|
||||
logger.debug("Got response mana type from player: " + getId());
|
||||
}
|
||||
}
|
||||
|
@ -1426,7 +1426,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public void setResponseUUID(UUID responseUUID) {
|
||||
synchronized (response) {
|
||||
response.setUUID(responseUUID);
|
||||
response.notify();
|
||||
response.notifyAll();
|
||||
logger.debug("Got response UUID from player: " + getId());
|
||||
}
|
||||
}
|
||||
|
@ -1435,7 +1435,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public void setResponseBoolean(Boolean responseBoolean) {
|
||||
synchronized (response) {
|
||||
response.setBoolean(responseBoolean);
|
||||
response.notify();
|
||||
response.notifyAll();
|
||||
logger.debug("Got response boolean from player: " + getId());
|
||||
}
|
||||
}
|
||||
|
@ -1444,7 +1444,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public void setResponseInteger(Integer responseInteger) {
|
||||
synchronized (response) {
|
||||
response.setInteger(responseInteger);
|
||||
response.notify();
|
||||
response.notifyAll();
|
||||
logger.debug("Got response integer from player: " + getId());
|
||||
}
|
||||
}
|
||||
|
@ -1453,7 +1453,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public void abort() {
|
||||
abort = true;
|
||||
synchronized (response) {
|
||||
response.notify();
|
||||
response.notifyAll();
|
||||
logger.debug("Got cancel action from player: " + getId());
|
||||
}
|
||||
}
|
||||
|
@ -1462,7 +1462,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public void skip() {
|
||||
synchronized (response) {
|
||||
response.setInteger(0);
|
||||
response.notify();
|
||||
response.notifyAll();
|
||||
logger.debug("Got skip action from player: " + getId());
|
||||
}
|
||||
}
|
||||
|
@ -1516,7 +1516,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
private void setRequestAutoAnswer(PlayerAction playerAction, Game game, Object data) {
|
||||
if (playerAction.equals(REQUEST_AUTO_ANSWER_RESET_ALL)) {
|
||||
if (playerAction == REQUEST_AUTO_ANSWER_RESET_ALL) {
|
||||
requestAutoAnswerId.clear();
|
||||
requestAutoAnswerText.clear();
|
||||
return;
|
||||
|
@ -1541,7 +1541,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
private void setTriggerAutoOrder(PlayerAction playerAction, Game game, Object data) {
|
||||
if (playerAction.equals(TRIGGER_AUTO_ORDER_RESET_ALL)) {
|
||||
if (playerAction == TRIGGER_AUTO_ORDER_RESET_ALL) {
|
||||
triggerAutoOrderAbilityFirst.clear();
|
||||
triggerAutoOrderAbilityLast.clear();
|
||||
triggerAutoOrderNameFirst.clear();
|
||||
|
|
|
@ -106,19 +106,20 @@ public enum ChatManager {
|
|||
ChatSession chatSession = chatSessions.get(chatId);
|
||||
if (chatSession != null) {
|
||||
if (message.startsWith("\\") || message.startsWith("/")) {
|
||||
User user = UserManager.instance.getUserByName(userName);
|
||||
if (user != null) {
|
||||
if (!performUserCommand(user, message, chatId, false)) {
|
||||
performUserCommand(user, message, chatId, true);
|
||||
Optional<User> user = UserManager.instance.getUserByName(userName);
|
||||
if (user.isPresent()) {
|
||||
if (!performUserCommand(user.get(), message, chatId, false)) {
|
||||
performUserCommand(user.get(), message, chatId, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (messageType != MessageType.GAME) {
|
||||
User user = UserManager.instance.getUserByName(userName);
|
||||
if (message != null && userName != null && !userName.isEmpty()) {
|
||||
Optional<User> u = UserManager.instance.getUserByName(userName);
|
||||
if (u.isPresent()) {
|
||||
|
||||
User user = u.get();
|
||||
if (message.equals(userMessages.get(userName))) {
|
||||
// prevent identical messages
|
||||
String informUser = "Your message appears to be identical to your last message";
|
||||
|
@ -157,10 +158,9 @@ public enum ChatManager {
|
|||
}
|
||||
|
||||
userMessages.put(userName, message);
|
||||
}
|
||||
|
||||
if (messageType == MessageType.TALK) {
|
||||
if (user != null) {
|
||||
|
||||
if (messageType == MessageType.TALK) {
|
||||
if (user.getChatLockedUntil() != null) {
|
||||
if (user.getChatLockedUntil().compareTo(Calendar.getInstance().getTime()) > 0) {
|
||||
chatSessions.get(chatId).broadcastInfoToUser(user, "Your chat is muted until " + SystemUtil.dateFormat.format(user.getChatLockedUntil()));
|
||||
|
@ -169,11 +169,12 @@ public enum ChatManager {
|
|||
user.setChatLockedUntil(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay);
|
||||
}
|
||||
chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,9 +214,9 @@ public enum ChatManager {
|
|||
if (first > 1) {
|
||||
String userToName = rest.substring(0, first);
|
||||
rest = rest.substring(first + 1).trim();
|
||||
User userTo = UserManager.instance.getUserByName(userToName);
|
||||
if (userTo != null) {
|
||||
if (!chatSessions.get(chatId).broadcastWhisperToUser(user, userTo, rest)) {
|
||||
Optional<User> userTo = UserManager.instance.getUserByName(userToName);
|
||||
if (userTo.isPresent()) {
|
||||
if (!chatSessions.get(chatId).broadcastWhisperToUser(user, userTo.get(), rest)) {
|
||||
message += new StringBuilder("<br/>User ").append(userToName).append(" not found").toString();
|
||||
chatSessions.get(chatId).broadcastInfoToUser(user, message);
|
||||
}
|
||||
|
@ -244,7 +245,7 @@ public enum ChatManager {
|
|||
* @param color
|
||||
*/
|
||||
public void broadcast(UUID userId, String message, MessageColor color) throws UserNotFoundException {
|
||||
UserManager.instance.getUser(userId).ifPresent(user-> {
|
||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||
chatSessions.values()
|
||||
.stream()
|
||||
.filter(chat -> chat.hasUser(userId))
|
||||
|
|
|
@ -1071,12 +1071,11 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public void muteUser(final String sessionId, final String userName, final long durationMinutes) throws MageException {
|
||||
execute("muteUser", sessionId, () -> {
|
||||
User user = UserManager.instance.getUserByName(userName);
|
||||
if (user != null) {
|
||||
UserManager.instance.getUserByName(userName).ifPresent(user -> {
|
||||
Date muteUntil = new Date(Calendar.getInstance().getTimeInMillis() + (durationMinutes * Timer.ONE_MINUTE));
|
||||
user.showUserMessage("Admin info", "You were muted for chat messages until " + SystemUtil.dateFormat.format(muteUntil) + '.');
|
||||
user.setChatLockedUntil(muteUntil);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -1084,15 +1083,14 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public void lockUser(final String sessionId, final String userName, final long durationMinutes) throws MageException {
|
||||
execute("lockUser", sessionId, () -> {
|
||||
User user = UserManager.instance.getUserByName(userName);
|
||||
if (user != null) {
|
||||
UserManager.instance.getUserByName(userName).ifPresent(user -> {
|
||||
Date lockUntil = new Date(Calendar.getInstance().getTimeInMillis() + (durationMinutes * Timer.ONE_MINUTE));
|
||||
user.showUserMessage("Admin info", "Your user profile was locked until " + SystemUtil.dateFormat.format(lockUntil) + '.');
|
||||
user.setLockedUntil(lockUntil);
|
||||
if (user.isConnected()) {
|
||||
SessionManager.instance.disconnectUser(sessionId, user.getSessionId());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -1101,8 +1099,9 @@ public class MageServerImpl implements MageServer {
|
|||
public void setActivation(final String sessionId, final String userName, boolean active) throws MageException {
|
||||
execute("setActivation", sessionId, () -> {
|
||||
AuthorizedUser authorizedUser = AuthorizedUserRepository.instance.getByName(userName);
|
||||
User user = UserManager.instance.getUserByName(userName);
|
||||
if (user != null) {
|
||||
Optional<User> u = UserManager.instance.getUserByName(userName);
|
||||
if (u.isPresent()) {
|
||||
User user = u.get();
|
||||
user.setActive(active);
|
||||
if (!user.isActive() && user.isConnected()) {
|
||||
SessionManager.instance.disconnectUser(sessionId, user.getSessionId());
|
||||
|
@ -1117,16 +1116,14 @@ public class MageServerImpl implements MageServer {
|
|||
|
||||
@Override
|
||||
public void toggleActivation(final String sessionId, final String userName) throws MageException {
|
||||
execute("toggleActivation", sessionId, () -> {
|
||||
User user = UserManager.instance.getUserByName(userName);
|
||||
if (user != null) {
|
||||
user.setActive(!user.isActive());
|
||||
if (!user.isActive() && user.isConnected()) {
|
||||
SessionManager.instance.disconnectUser(sessionId, user.getSessionId());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
execute("toggleActivation", sessionId, () ->
|
||||
UserManager.instance.getUserByName(userName).ifPresent(user ->
|
||||
{
|
||||
user.setActive(!user.isActive());
|
||||
if (!user.isActive() && user.isConnected()) {
|
||||
SessionManager.instance.disconnectUser(sessionId, user.getSessionId());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1144,13 +1141,10 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public void removeTable(final String sessionId, final UUID tableId) throws MageException {
|
||||
execute("removeTable", sessionId, () -> {
|
||||
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||
if (!session.isPresent()) {
|
||||
logger.error("Session not found : " + sessionId);
|
||||
} else {
|
||||
UUID userId = session.get().getUserId();
|
||||
SessionManager.instance.getSession(sessionId).ifPresent(session -> {
|
||||
UUID userId = session.getUserId();
|
||||
TableManager.instance.removeTable(userId, tableId);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1162,15 +1156,12 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public void sendFeedbackMessage(final String sessionId, final String username, final String title, final String type, final String message, final String email) throws MageException {
|
||||
if (title != null && message != null) {
|
||||
execute("sendFeedbackMessage", sessionId, () -> {
|
||||
Optional<Session> session = SessionManager.instance.getSession(sessionId);
|
||||
if (!session.isPresent()) {
|
||||
logger.error(String.format("Session not found: %s", sessionId));
|
||||
} else {
|
||||
FeedbackServiceImpl.instance.feedback(username, title, type, message, email, session.get().getHost());
|
||||
execute("sendFeedbackMessage", sessionId, () ->
|
||||
SessionManager.instance.getSession(sessionId).ifPresent(
|
||||
session -> FeedbackServiceImpl.instance.feedback(username, title, type, message, email, session.getHost())
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -217,55 +217,59 @@ public class Session {
|
|||
if (authorizedUser.lockedUntil.compareTo(Calendar.getInstance().getTime()) > 0) {
|
||||
return "Your profile is deactivated until " + SystemUtil.dateFormat.format(authorizedUser.lockedUntil);
|
||||
} else {
|
||||
User user = UserManager.instance.createUser(userName, host, authorizedUser);
|
||||
if (user != null && authorizedUser.lockedUntil != null) {
|
||||
user.setLockedUntil(null);
|
||||
UserManager.instance.createUser(userName, host, authorizedUser).ifPresent(user ->
|
||||
user.setLockedUntil(null)
|
||||
);
|
||||
|
||||
}
|
||||
Optional<User> selectUser = UserManager.instance.createUser(userName, host, authorizedUser);
|
||||
boolean reconnect = false;
|
||||
if (!selectUser.isPresent()) { // user already exists
|
||||
selectUser = UserManager.instance.getUserByName(userName);
|
||||
if (selectUser.isPresent()) {
|
||||
User user = selectUser.get();
|
||||
// If authentication is not activated, check the identity using IP address.
|
||||
if (ConfigSettings.instance.isAuthenticationActivated() || user.getHost().equals(host)) {
|
||||
user.updateLastActivity(null); // minimizes possible expiration
|
||||
this.userId = user.getId();
|
||||
if (user.getSessionId().isEmpty()) {
|
||||
logger.info("Reconnecting session for " + userName);
|
||||
reconnect = true;
|
||||
} else {
|
||||
//disconnect previous session
|
||||
logger.info("Disconnecting another user instance: " + userName);
|
||||
SessionManager.instance.disconnect(user.getSessionId(), DisconnectReason.ConnectingOtherInstance);
|
||||
}
|
||||
} else {
|
||||
return "User name " + userName + " already in use (or your IP address changed)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
User user = UserManager.instance.createUser(userName, host, authorizedUser);
|
||||
boolean reconnect = false;
|
||||
if (user == null) { // user already exists
|
||||
user = UserManager.instance.getUserByName(userName);
|
||||
// If authentication is not activated, check the identity using IP address.
|
||||
if (ConfigSettings.instance.isAuthenticationActivated() || user.getHost().equals(host)) {
|
||||
user.updateLastActivity(null); // minimizes possible expiration
|
||||
this.userId = user.getId();
|
||||
if (user.getSessionId().isEmpty()) {
|
||||
logger.info("Reconnecting session for " + userName);
|
||||
reconnect = true;
|
||||
} else {
|
||||
//disconnect previous session
|
||||
logger.info("Disconnecting another user instance: " + userName);
|
||||
SessionManager.instance.disconnect(user.getSessionId(), DisconnectReason.ConnectingOtherInstance);
|
||||
User user = selectUser.get();
|
||||
if (!UserManager.instance.connectToSession(sessionId, user.getId())) {
|
||||
return "Error connecting " + userName;
|
||||
}
|
||||
this.userId = user.getId();
|
||||
if (reconnect) { // must be connected to receive the message
|
||||
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(GamesRoomManager.instance.getMainRoomId());
|
||||
if (!room.isPresent()) {
|
||||
logger.error("main room not found");
|
||||
return null;
|
||||
}
|
||||
ChatManager.instance.joinChat(room.get().getChatId(), userId);
|
||||
ChatManager.instance.sendReconnectMessage(userId);
|
||||
}
|
||||
} else {
|
||||
return "User name " + userName + " already in use (or your IP address changed)";
|
||||
}
|
||||
}
|
||||
if (!UserManager.instance.connectToSession(sessionId, user.getId())) {
|
||||
return "Error connecting " + userName;
|
||||
}
|
||||
this.userId = user.getId();
|
||||
if (reconnect) { // must be connected to receive the message
|
||||
Optional<GamesRoom> room = GamesRoomManager.instance.getRoom(GamesRoomManager.instance.getMainRoomId());
|
||||
if (!room.isPresent()) {
|
||||
logger.error("main room not found");
|
||||
return null;
|
||||
}
|
||||
ChatManager.instance.joinChat(room.get().getChatId(), userId);
|
||||
ChatManager.instance.sendReconnectMessage(userId);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void connectAdmin() {
|
||||
this.isAdmin = true;
|
||||
User user = UserManager.instance.createUser("Admin", host, null);
|
||||
if (user == null) {
|
||||
user = UserManager.instance.getUserByName("Admin");
|
||||
}
|
||||
User user = UserManager.instance.createUser("Admin", host, null).orElse(
|
||||
UserManager.instance.getUserByName("Admin").get());
|
||||
|
||||
UserData adminUserData = UserData.getDefaultUserDataView();
|
||||
adminUserData.setGroupId(UserGroup.ADMIN.getGroupId());
|
||||
user.setUserData(adminUserData);
|
||||
|
@ -276,8 +280,8 @@ public class Session {
|
|||
}
|
||||
|
||||
public boolean setUserData(String userName, UserData userData, String clientVersion, String userIdStr) {
|
||||
User user = UserManager.instance.getUserByName(userName);
|
||||
if (user != null) {
|
||||
Optional<User> _user = UserManager.instance.getUserByName(userName);
|
||||
_user.ifPresent(user -> {
|
||||
if (clientVersion != null) {
|
||||
user.setClientVersion(clientVersion);
|
||||
}
|
||||
|
@ -294,9 +298,8 @@ public class Session {
|
|||
if (user.getUserData().getAvatarId() == 11) {
|
||||
user.getUserData().setAvatarId(updateAvatar(user.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return _user.isPresent();
|
||||
}
|
||||
|
||||
private int updateAvatar(String userName) {
|
||||
|
|
|
@ -51,7 +51,11 @@ public enum SessionManager {
|
|||
|
||||
public Optional<Session> getSession(@Nonnull String sessionId) {
|
||||
Session session = sessions.get(sessionId);
|
||||
if (session != null && session.getUserId() != null && UserManager.instance.getUser(session.getUserId()) == null) {
|
||||
if(session == null){
|
||||
logger.error("Session with sessionId " + sessionId + " is not found");
|
||||
return Optional.empty();
|
||||
}
|
||||
if (session.getUserId() != null && UserManager.instance.getUser(session.getUserId()) == null) {
|
||||
logger.error("User for session " + sessionId + " with userId " + session.getUserId() + " is missing. Session removed.");
|
||||
// can happen if user from same host signs in multiple time with multiple clients, after he disconnects with one client
|
||||
disconnect(sessionId, DisconnectReason.ConnectingOtherInstance);
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.concurrent.*;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public enum UserManager {
|
||||
public enum UserManager {
|
||||
instance;
|
||||
|
||||
protected final ScheduledExecutorService expireExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||
|
@ -50,7 +50,6 @@ public enum UserManager {
|
|||
private static final Logger LOGGER = Logger.getLogger(UserManager.class);
|
||||
|
||||
private final ConcurrentHashMap<UUID, User> users = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, User> usersByName = new ConcurrentHashMap<>();
|
||||
|
||||
private static final ExecutorService USER_EXECUTOR = ThreadExecutor.getInstance().getCallExecutor();
|
||||
|
||||
|
@ -58,32 +57,36 @@ public enum UserManager {
|
|||
expireExecutor.scheduleAtFixedRate(this::checkExpired, 60, 60, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public User createUser(String userName, String host, AuthorizedUser authorizedUser) {
|
||||
if (getUserByName(userName) != null) {
|
||||
return null; //user already exists
|
||||
public Optional<User> createUser(String userName, String host, AuthorizedUser authorizedUser) {
|
||||
if (getUserByName(userName).isPresent()) {
|
||||
return Optional.empty(); //user already exists
|
||||
}
|
||||
User user = new User(userName, host, authorizedUser);
|
||||
users.put(user.getId(), user);
|
||||
usersByName.put(userName, user);
|
||||
return user;
|
||||
return Optional.of(user);
|
||||
}
|
||||
|
||||
public Optional<User> getUser(UUID userId) {
|
||||
if (users.get(userId) == null) {
|
||||
if (!users.containsKey(userId)) {
|
||||
LOGGER.error(String.format("User with id %s could not be found", userId));
|
||||
|
||||
return Optional.empty();
|
||||
} else {
|
||||
return Optional.of(users.get(userId));
|
||||
}
|
||||
/* if (userId != null) {
|
||||
return users.get(userId);
|
||||
}
|
||||
return null;
|
||||
*/
|
||||
}
|
||||
|
||||
public User getUserByName(String userName) {
|
||||
return usersByName.get(userName);
|
||||
public Optional<User> getUserByName(String userName) {
|
||||
Optional<User> u = users.values().stream().filter(user -> user.getName().equals(userName))
|
||||
.findFirst();
|
||||
if (u.isPresent()) {
|
||||
return u;
|
||||
} else {
|
||||
|
||||
LOGGER.error("User with name " + userName + " could not be found");
|
||||
return Optional.empty();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<User> getUsers() {
|
||||
|
@ -103,12 +106,9 @@ public enum UserManager {
|
|||
|
||||
public void disconnect(UUID userId, DisconnectReason reason) {
|
||||
if (userId != null) {
|
||||
User user = users.get(userId);
|
||||
if (user != null) {
|
||||
user.setSessionId(""); // Session will be set again with new id if user reconnects
|
||||
}
|
||||
ChatManager.instance.removeUser(userId, reason);
|
||||
getUser(userId).ifPresent(user -> user.setSessionId(""));// Session will be set again with new id if user reconnects
|
||||
}
|
||||
ChatManager.instance.removeUser(userId, reason);
|
||||
}
|
||||
|
||||
public boolean isAdmin(UUID userId) {
|
||||
|
@ -123,25 +123,21 @@ public enum UserManager {
|
|||
|
||||
public void removeUser(final UUID userId, final DisconnectReason reason) {
|
||||
if (userId != null) {
|
||||
final User user = users.get(userId);
|
||||
if (user != null) {
|
||||
USER_EXECUTOR.execute(
|
||||
() -> {
|
||||
try {
|
||||
LOGGER.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId + " [" + user.getGameInfo() + ']');
|
||||
user.remove(reason);
|
||||
LOGGER.debug("USER REMOVE END - " + user.getName());
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
} finally {
|
||||
users.remove(userId);
|
||||
usersByName.remove(user.getName());
|
||||
getUser(userId).ifPresent(user ->
|
||||
USER_EXECUTOR.execute(
|
||||
() -> {
|
||||
try {
|
||||
LOGGER.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId + " [" + user.getGameInfo() + ']');
|
||||
user.remove(reason);
|
||||
LOGGER.debug("USER REMOVE END - " + user.getName());
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
} finally {
|
||||
users.remove(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
LOGGER.warn("Trying to remove userId: " + userId + " - but it does not exist.");
|
||||
}
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,9 +179,9 @@ public enum UserManager {
|
|||
}
|
||||
|
||||
public String getUserHistory(String userName) {
|
||||
User user = getUserByName(userName);
|
||||
if (user != null) {
|
||||
return "History of user " + userName + " - " + user.getUserData().getHistory();
|
||||
Optional<User> user = getUserByName(userName);
|
||||
if (user.isPresent()) {
|
||||
return "History of user " + userName + " - " + user.get().getUserData().getHistory();
|
||||
}
|
||||
|
||||
UserStats userStats = UserStatsRepository.instance.getUser(userName);
|
||||
|
@ -199,10 +195,7 @@ public enum UserManager {
|
|||
public void updateUserHistory() {
|
||||
USER_EXECUTOR.execute(() -> {
|
||||
for (String updatedUser : UserStatsRepository.instance.updateUserStats()) {
|
||||
User user = getUserByName(updatedUser);
|
||||
if (user != null) {
|
||||
user.resetUserStats();
|
||||
}
|
||||
getUserByName(updatedUser).ifPresent(User::resetUserStats);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -80,42 +80,44 @@ public class AAT1 extends CardImpl {
|
|||
public AAT1 copy() {
|
||||
return new AAT1(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AAT1TriggeredAbility extends TriggeredAbilityImpl {
|
||||
private static class AAT1TriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public AAT1TriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
}
|
||||
|
||||
public AAT1TriggeredAbility(AAT1TriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (event.getPlayerId().equals(game.getControllerId(sourceId))
|
||||
&& card.isCreature()
|
||||
&& game.getState().getZone(card.getId()) == Zone.GRAVEYARD
|
||||
&& event.getData().equals("repair")) {
|
||||
return true;
|
||||
public AAT1TriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a repair counter is removed from a creature card in your graveyard " + super.getRule();
|
||||
}
|
||||
public AAT1TriggeredAbility(AAT1TriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AAT1TriggeredAbility copy() {
|
||||
return new AAT1TriggeredAbility(this);
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (event.getPlayerId().equals(game.getControllerId(sourceId))
|
||||
&& card.isCreature()
|
||||
&& game.getState().getZone(card.getId()) == Zone.GRAVEYARD
|
||||
&& event.getData().equals("repair")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a repair counter is removed from a creature card in your graveyard " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AAT1TriggeredAbility copy() {
|
||||
return new AAT1TriggeredAbility(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ class AlhammarretsArchiveEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.GAIN_LIFE);
|
||||
return event.getType() == GameEvent.EventType.GAIN_LIFE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,7 +100,7 @@ class CantBeBlockedByMoreThanOneAttachedEffect extends ContinuousEffectImpl {
|
|||
super(duration, Outcome.Benefit);
|
||||
this.amount = amount;
|
||||
this.attachmentType = attachmentType;
|
||||
staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted" : "Equipped") + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount==1 ?"":"s");
|
||||
staticText = (attachmentType == AttachmentType.AURA ? "Enchanted" : "Equipped") + " creature can't be blocked by more than " + CardUtil.numberToText(amount) + " creature" + (amount==1 ?"":"s");
|
||||
}
|
||||
|
||||
public CantBeBlockedByMoreThanOneAttachedEffect(final CantBeBlockedByMoreThanOneAttachedEffect effect) {
|
||||
|
|
|
@ -135,7 +135,7 @@ class AnafenzaTheForemostEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.ZONE_CHANGE);
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -96,7 +96,7 @@ class AnthemOfRakdosHellbentEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGE_CREATURE
|
||||
|| event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER);
|
||||
|| event.getType() == GameEvent.EventType.DAMAGE_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -117,7 +117,7 @@ class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (event.getType().equals(EventType.TURNFACEUP)) {
|
||||
if (event.getType() == EventType.TURNFACEUP) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ class AthreosGodOfPassageReturnEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (opponent == null || !paid) {
|
||||
if (game.getState().getZone(creature.getId()).equals(Zone.GRAVEYARD)) {
|
||||
if (game.getState().getZone(creature.getId()) == Zone.GRAVEYARD) {
|
||||
controller.moveCards(game.getCard(creatureId), Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ class AthreosDiesCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone().equals(Zone.BATTLEFIELD) && zEvent.getToZone().equals(Zone.GRAVEYARD)) {
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (permanent != null && filter.match(permanent, sourceId, controllerId, game)) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
|
|
141
Mage.Sets/src/mage/cards/a/AzoriusAEthermage.java
Normal file
141
Mage.Sets/src/mage/cards/a/AzoriusAEthermage.java
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DoIfCostPaid;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class AzoriusAEthermage extends CardImpl {
|
||||
|
||||
private static final String rule = "Whenever a permanent is returned to your hand, ";
|
||||
|
||||
public AzoriusAEthermage(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{U}");
|
||||
|
||||
this.subtype.add("Human");
|
||||
this.subtype.add("Wizard");
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Whenever a permanent is returned to your hand, you may pay {1}. If you do, draw a card.
|
||||
Effect effect = new DoIfCostPaid(new DrawCardSourceControllerEffect(1), new ManaCostsImpl("{1}"));
|
||||
this.addAbility(new AzoriusAEthermageAbility(Zone.BATTLEFIELD, Zone.BATTLEFIELD, Zone.HAND, effect, new FilterPermanent(), rule, true));
|
||||
}
|
||||
|
||||
public AzoriusAEthermage(final AzoriusAEthermage card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AzoriusAEthermage copy() {
|
||||
return new AzoriusAEthermage(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AzoriusAEthermageAbility extends TriggeredAbilityImpl {
|
||||
|
||||
protected FilterPermanent filter;
|
||||
protected Zone fromZone;
|
||||
protected Zone toZone;
|
||||
protected String rule;
|
||||
|
||||
public AzoriusAEthermageAbility(Zone zone, Zone fromZone, Zone toZone, Effect effect, FilterPermanent filter, String rule, boolean optional) {
|
||||
super(zone, effect, optional);
|
||||
this.fromZone = fromZone;
|
||||
this.toZone = toZone;
|
||||
this.rule = rule;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public AzoriusAEthermageAbility(final AzoriusAEthermageAbility ability) {
|
||||
super(ability);
|
||||
this.fromZone = ability.fromZone;
|
||||
this.toZone = ability.toZone;
|
||||
this.rule = ability.rule;
|
||||
this.filter = ability.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if ((fromZone == null || zEvent.getFromZone() == fromZone)
|
||||
&& (toZone == null || zEvent.getToZone() == toZone)) {
|
||||
Permanent permanentThatMoved = null;
|
||||
if (zEvent.getTarget() != null) {
|
||||
permanentThatMoved = zEvent.getTarget();
|
||||
}
|
||||
if (permanentThatMoved != null
|
||||
&& filter.match(permanentThatMoved, sourceId, controllerId, game)
|
||||
&& zEvent.getPlayerId() == controllerId) { //The controller's hand is where the permanent moved to.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return rule + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AzoriusAEthermageAbility copy() {
|
||||
return new AzoriusAEthermageAbility(this);
|
||||
}
|
||||
|
||||
public Zone getFromZone() {
|
||||
return fromZone;
|
||||
}
|
||||
|
||||
public Zone getToZone() {
|
||||
return toZone;
|
||||
}
|
||||
}
|
|
@ -83,7 +83,7 @@ class BurningVengeanceOnCastAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getPlayerId().equals(controllerId) && event.getZone().equals(Zone.GRAVEYARD);
|
||||
return event.getPlayerId().equals(controllerId) && event.getZone() == Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -273,7 +273,7 @@ class CelestialDawnSpendColorlessManaEffect extends AsThoughEffectImpl implement
|
|||
|
||||
@Override
|
||||
public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
|
||||
if (mana.getWhite() == 0 && !ManaType.COLORLESS.equals(manaType)) {
|
||||
if (mana.getWhite() == 0 && ManaType.COLORLESS != manaType) {
|
||||
return null;
|
||||
}
|
||||
return manaType;
|
||||
|
|
|
@ -115,7 +115,7 @@ class ChainsOfMephistophelesReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getPhase().getStep().getType().equals(PhaseStep.DRAW)) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getPhase().getStep().getType() == PhaseStep.DRAW) {
|
||||
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep");
|
||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
|
|
75
Mage.Sets/src/mage/cards/c/ChronomanticEscape.java
Normal file
75
Mage.Sets/src/mage/cards/c/ChronomanticEscape.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.combat.CantAttackYouAllEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
public class ChronomanticEscape extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures");
|
||||
|
||||
public ChronomanticEscape(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{W}{W}");
|
||||
|
||||
// Until your next turn, creatures can't attack you. Exile Chronomantic Escape with three time counters on it.
|
||||
getSpellAbility().addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, filter));
|
||||
getSpellAbility().addEffect(ExileSpellEffect.getInstance());
|
||||
Effect effect = new AddCountersSourceEffect(CounterType.TIME.createInstance(), new StaticValue(3), true, true);
|
||||
effect.setText("with 3 time counters on it");
|
||||
getSpellAbility().addEffect(effect);
|
||||
|
||||
// Suspend 3-{2}{W}
|
||||
this.addAbility(new SuspendAbility(3, new ManaCostsImpl("{2}{W}"), this));
|
||||
}
|
||||
|
||||
public ChronomanticEscape(final ChronomanticEscape card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChronomanticEscape copy() {
|
||||
return new ChronomanticEscape(this);
|
||||
}
|
||||
}
|
112
Mage.Sets/src/mage/cards/c/CitadelOfPain.java
Normal file
112
Mage.Sets/src/mage/cards/c/CitadelOfPain.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.OnEventTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.TappedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexsandr0x
|
||||
*/
|
||||
public class CitadelOfPain extends CardImpl {
|
||||
|
||||
public CitadelOfPain(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}");
|
||||
|
||||
TriggeredAbility triggered = new OnEventTriggeredAbility(GameEvent.EventType.END_TURN_STEP_PRE,
|
||||
"beginning of the end step", true,
|
||||
new CitadelOfPainEffect());
|
||||
// At the beginning of each player's end step, Citadel of Pain deals X damage to that player, where X is the number of untapped lands he or she controls.
|
||||
this.addAbility(triggered);
|
||||
}
|
||||
|
||||
public CitadelOfPain(final CitadelOfPain card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CitadelOfPain copy() {
|
||||
return new CitadelOfPain(this);
|
||||
}
|
||||
}
|
||||
|
||||
class CitadelOfPainEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterPermanent filter = new FilterControlledLandPermanent();
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "{this} deals X damage to that player, where X is the number of untapped lands he or she controls.";
|
||||
}
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(new TappedPredicate()));
|
||||
}
|
||||
|
||||
public CitadelOfPainEffect() {
|
||||
super(Outcome.Damage);
|
||||
}
|
||||
|
||||
public CitadelOfPainEffect(Outcome outcome) {
|
||||
super(outcome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(game.getActivePlayerId());
|
||||
if (player != null) {
|
||||
int damage = game.getBattlefield().countAll(filter, game.getActivePlayerId(), game);
|
||||
player.damage(damage, source.getSourceId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Effect copy() {
|
||||
return new CitadelOfPainEffect();
|
||||
}
|
||||
}
|
|
@ -138,11 +138,11 @@ class CoffinQueenDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (GameEvent.EventType.LOST_CONTROL.equals(event.getType())
|
||||
if (EventType.LOST_CONTROL == event.getType()
|
||||
&& event.getSourceId().equals(getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return GameEvent.EventType.UNTAPPED.equals(event.getType())
|
||||
return EventType.UNTAPPED == event.getType()
|
||||
&& event.getTargetId() != null && event.getTargetId().equals(getSourceId());
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ class DanceOfTheDeadAttachEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(source.getFirstTarget());
|
||||
if (card != null && game.getState().getZone(source.getFirstTarget()).equals(Zone.GRAVEYARD)) {
|
||||
if (card != null && game.getState().getZone(source.getFirstTarget()) == Zone.GRAVEYARD) {
|
||||
// Card have no attachedTo attribute yet so write ref only to enchantment now
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null) {
|
||||
|
|
|
@ -76,63 +76,65 @@ public class DiviningWitch extends CardImpl {
|
|||
public DiviningWitch copy() {
|
||||
return new DiviningWitch(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DiviningWitchEffect extends OneShotEffect {
|
||||
private static class DiviningWitchEffect extends OneShotEffect {
|
||||
|
||||
DiviningWitchEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Name a card. Exile the top six cards of your library. Reveal cards from the top of your library until you reveal the named card, then put that card into your hand. Exile all other cards revealed this way";
|
||||
}
|
||||
DiviningWitchEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Name a card. Exile the top six cards of your library. Reveal cards from the top of your library until you reveal the named card, then put that card into your hand. Exile all other cards revealed this way";
|
||||
}
|
||||
|
||||
DiviningWitchEffect(final DiviningWitchEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
DiviningWitchEffect(final DiviningWitchEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiviningWitchEffect copy() {
|
||||
return new DiviningWitchEffect(this);
|
||||
}
|
||||
@Override
|
||||
public DiviningWitchEffect copy() {
|
||||
return new DiviningWitchEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
// Name a card.
|
||||
Choice choice = new ChoiceImpl();
|
||||
choice.setChoices(CardRepository.instance.getNames());
|
||||
while (!controller.choose(Outcome.Benefit, choice, game)) {
|
||||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
String name = choice.getChoice();
|
||||
game.informPlayers("Card named: " + name);
|
||||
|
||||
// Exile the top six cards of your library,
|
||||
controller.moveCards(controller.getLibrary().getTopCards(game, 6), Zone.EXILED, source, game);
|
||||
|
||||
// then reveal cards from the top of your library until you reveal the named card.
|
||||
Cards cardsToReaveal = new CardsImpl();
|
||||
Card cardToHand = null;
|
||||
while (controller.getLibrary().hasCards()) {
|
||||
Card card = controller.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cardsToReaveal.add(card);
|
||||
// Put that card into your hand
|
||||
if (card.getName().equals(name)) {
|
||||
cardToHand = card;
|
||||
break;
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
// Name a card.
|
||||
Choice choice = new ChoiceImpl();
|
||||
choice.setChoices(CardRepository.instance.getNames());
|
||||
while (!controller.choose(Outcome.Benefit, choice, game)) {
|
||||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
String name = choice.getChoice();
|
||||
game.informPlayers("Card named: " + name);
|
||||
|
||||
// Exile the top six cards of your library,
|
||||
controller.moveCards(controller.getLibrary().getTopCards(game, 6), Zone.EXILED, source, game);
|
||||
|
||||
// then reveal cards from the top of your library until you reveal the named card.
|
||||
Cards cardsToReaveal = new CardsImpl();
|
||||
Card cardToHand = null;
|
||||
while (controller.getLibrary().hasCards()) {
|
||||
Card card = controller.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
cardsToReaveal.add(card);
|
||||
// Put that card into your hand
|
||||
if (card.getName().equals(name)) {
|
||||
cardToHand = card;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
controller.moveCards(cardToHand, Zone.HAND, source, game);
|
||||
controller.revealCards(sourceObject.getIdName(), cardsToReaveal, game);
|
||||
cardsToReaveal.remove(cardToHand);
|
||||
controller.moveCards(cardsToReaveal, Zone.EXILED, source, game);
|
||||
return true;
|
||||
}
|
||||
controller.moveCards(cardToHand, Zone.HAND, source, game);
|
||||
controller.revealCards(sourceObject.getIdName(), cardsToReaveal, game);
|
||||
cardsToReaveal.remove(cardToHand);
|
||||
controller.moveCards(cardsToReaveal, Zone.EXILED, source, game);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ class EliteArcanistCopyEffect extends OneShotEffect {
|
|||
}
|
||||
if (sourcePermanent != null && sourcePermanent.getImprinted() != null && !sourcePermanent.getImprinted().isEmpty()) {
|
||||
Card imprintedInstant = game.getCard(sourcePermanent.getImprinted().get(0));
|
||||
if (imprintedInstant != null && game.getState().getZone(imprintedInstant.getId()).equals(Zone.EXILED)) {
|
||||
if (imprintedInstant != null && game.getState().getZone(imprintedInstant.getId()) == Zone.EXILED) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card copiedCard = game.copyCard(imprintedInstant, source, source.getControllerId());
|
||||
|
|
|
@ -145,7 +145,7 @@ class EpiphanyAtTheDrownyardEffect extends OneShotEffect {
|
|||
pile2Zone = Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(sourceObject.getLogName() + ": Pile 1, going to ").append(pile1Zone.equals(Zone.HAND) ? "Hand" : "Graveyard").append(": ");
|
||||
StringBuilder sb = new StringBuilder(sourceObject.getLogName() + ": Pile 1, going to ").append(pile1Zone == Zone.HAND ? "Hand" : "Graveyard").append(": ");
|
||||
int i = 0;
|
||||
for (UUID cardUuid : pile1CardsIds) {
|
||||
i++;
|
||||
|
@ -160,7 +160,7 @@ class EpiphanyAtTheDrownyardEffect extends OneShotEffect {
|
|||
}
|
||||
game.informPlayers(sb.toString());
|
||||
|
||||
sb = new StringBuilder(sourceObject.getLogName() + ": Pile 2, going to ").append(pile2Zone.equals(Zone.HAND) ? "Hand" : "Graveyard").append(':');
|
||||
sb = new StringBuilder(sourceObject.getLogName() + ": Pile 2, going to ").append(pile2Zone == Zone.HAND ? "Hand" : "Graveyard").append(':');
|
||||
i = 0;
|
||||
for (UUID cardUuid : pile2CardsIds) {
|
||||
Card card = game.getCard(cardUuid);
|
||||
|
|
|
@ -125,7 +125,7 @@ class FactOrFictionEffect extends OneShotEffect {
|
|||
pile2Zone = Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder("Pile 1, going to ").append(pile1Zone.equals(Zone.HAND) ? "Hand" : "Graveyard").append(": ");
|
||||
StringBuilder sb = new StringBuilder("Pile 1, going to ").append(pile1Zone == Zone.HAND ? "Hand" : "Graveyard").append(": ");
|
||||
int i = 0;
|
||||
for (Card card : pile1) {
|
||||
i++;
|
||||
|
|
|
@ -89,7 +89,7 @@ class GeistOfSaintTraftEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
||||
if (controller != null && effect.apply(game, source)) {
|
||||
effect.exileTokensCreatedAtNextEndStep(game, source);
|
||||
effect.exileTokensCreatedAtEndOfCombat(game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -136,7 +136,7 @@ class GiftOfImmortalityReturnEnchantmentEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card aura = game.getCard(source.getSourceId());
|
||||
if (aura != null && game.getState().getZone(aura.getId()).equals(Zone.GRAVEYARD)) {
|
||||
if (aura != null && game.getState().getZone(aura.getId()) == Zone.GRAVEYARD) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (controller != null && creature != null) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.cards.g;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -35,9 +34,9 @@ import mage.abilities.costs.common.SacrificeTargetCost;
|
|||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
|
||||
/**
|
||||
|
@ -45,16 +44,16 @@ import mage.target.common.TargetCreatureOrPlayer;
|
|||
*/
|
||||
public class GoblinGrenade extends CardImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("a Goblin");
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("a Goblin");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Goblin"));
|
||||
}
|
||||
|
||||
public GoblinGrenade(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{R}");
|
||||
|
||||
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, filter, false)));
|
||||
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, filter, false)));
|
||||
this.getSpellAbility().addEffect(new DamageTargetEffect(5));
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ class GontiLordOfLuxuryLookEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId).equals(Zone.EXILED)) {
|
||||
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId) == Zone.EXILED) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
|
|
|
@ -165,7 +165,7 @@ class GracefulReprieveDelayedEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(permanent.getOwnerId());
|
||||
if (player != null) {
|
||||
Card card = game.getCard(target);
|
||||
if (card != null && game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
|
||||
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
|
||||
return card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), player.getId());
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -88,7 +88,7 @@ class GrafdiggersCageEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return EventType.ZONE_CHANGE.equals(event.getType());
|
||||
return EventType.ZONE_CHANGE == event.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,7 +82,7 @@ class GreaterHarvesterAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return EventType.DAMAGED_PLAYER.equals(event.getType());
|
||||
return EventType.DAMAGED_PLAYER == event.getType();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ class GrimoireThiefLookEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId).equals(Zone.EXILED)) {
|
||||
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId) == Zone.EXILED) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
|
|
|
@ -150,8 +150,8 @@ class GruesomeEncoreReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getTargetId().equals(source.getFirstTarget())
|
||||
&& ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)
|
||||
&& !((ZoneChangeEvent) event).getToZone().equals(Zone.EXILED);
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD
|
||||
&& ((ZoneChangeEvent) event).getToZone() != Zone.EXILED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -117,7 +117,7 @@ class HavengulLichPlayEffect extends AsThoughEffectImpl {
|
|||
if (targetId != null) {
|
||||
return targetId.equals(objectId)
|
||||
&& source.getControllerId().equals(affectedControllerId)
|
||||
&& Zone.GRAVEYARD.equals(game.getState().getZone(objectId));
|
||||
&& Zone.GRAVEYARD == game.getState().getZone(objectId);
|
||||
} else {
|
||||
// the target card has changed zone meanwhile, so the effect is no longer needed
|
||||
discard();
|
||||
|
|
|
@ -110,7 +110,7 @@ class HomuraReturnFlippedSourceEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (sourceCard != null && controller != null && game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) {
|
||||
if (sourceCard != null && controller != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
|
||||
ContinuousEffect effect = new ConditionalContinuousEffect(new CopyTokenEffect(flipToken), FlippedCondition.getInstance(), "");
|
||||
game.addEffect(effect, source);
|
||||
controller.moveCards(sourceCard, Zone.BATTLEFIELD, source, game);
|
||||
|
|
|
@ -95,7 +95,7 @@ class HumilityEffect extends ContinuousEffectImpl {
|
|||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer.equals(SubLayer.SetPT_7b)) {
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanent.getPower().setValue(1);
|
||||
permanent.getToughness().setValue(1);
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ class IntetTheDreamerCastEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId).equals(Zone.EXILED)) {
|
||||
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId) == Zone.EXILED) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
|
@ -200,7 +200,7 @@ class IntetTheDreamerLookEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId).equals(Zone.EXILED)) {
|
||||
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId) == Zone.EXILED) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
|
|
|
@ -97,7 +97,7 @@ class InvocationOfSaintTraftEffect extends OneShotEffect {
|
|||
CreateTokenEffect effect = new CreateTokenEffect(new AngelToken(), 1, true, true);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && (effect.apply(game, source))) {
|
||||
effect.exileTokensCreatedAtNextEndStep(game, source);
|
||||
effect.exileTokensCreatedAtEndOfCombat(game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -107,7 +107,7 @@ class IslandSanctuaryEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return source.getControllerId().equals(event.getPlayerId()) && game.getTurn().getStepType().equals(PhaseStep.DRAW);
|
||||
return source.getControllerId().equals(event.getPlayerId()) && game.getTurn().getStepType() == PhaseStep.DRAW;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -154,7 +154,7 @@ class IsochronScepterCopyEffect extends OneShotEffect {
|
|||
Permanent scepter = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (scepter != null && scepter.getImprinted() != null && !scepter.getImprinted().isEmpty()) {
|
||||
Card imprintedInstant = game.getCard(scepter.getImprinted().get(0));
|
||||
if (imprintedInstant != null && game.getState().getZone(imprintedInstant.getId()).equals(Zone.EXILED)) {
|
||||
if (imprintedInstant != null && game.getState().getZone(imprintedInstant.getId()) == Zone.EXILED) {
|
||||
if (controller.chooseUse(outcome, new StringBuilder("Create a copy of ").append(imprintedInstant.getName()).append('?').toString(), source, game)) {
|
||||
Card copiedCard = game.copyCard(imprintedInstant, source, source.getControllerId());
|
||||
if (copiedCard != null) {
|
||||
|
|
|
@ -141,7 +141,7 @@ class KalitasTraitorOfGhetEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.ZONE_CHANGE);
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -94,7 +94,7 @@ class KariZevSkyshipRaiderEffect extends OneShotEffect {
|
|||
CreateTokenEffect effect = new CreateTokenEffect(new RagavanToken(), 1, true, true);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && effect.apply(game, source)) {
|
||||
effect.exileTokensCreatedAtNextEndStep(game, source);
|
||||
effect.exileTokensCreatedAtEndOfCombat(game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -94,7 +94,7 @@ class KembasLegionEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && !permanent.getAttachments().isEmpty()) {
|
||||
if (layer.equals(Layer.RulesEffects)) {
|
||||
if (layer == Layer.RulesEffects) {
|
||||
// maxBlocks = 0 equals to "can block any number of creatures"
|
||||
if (permanent.getMaxBlocks() > 0) {
|
||||
List<UUID> attachments = permanent.getAttachments();
|
||||
|
|
|
@ -184,8 +184,8 @@ class KheruLichLordReplacementEffect extends ReplacementEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
|
||||
&& event.getTargetId().equals(getTargetPointer().getFirst(game, source))
|
||||
&& ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)
|
||||
&& !((ZoneChangeEvent) event).getToZone().equals(Zone.EXILED)) {
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD
|
||||
&& ((ZoneChangeEvent) event).getToZone() != Zone.EXILED) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -154,7 +154,7 @@ class LeoninArbiterCantSearchEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return EventType.SEARCH_LIBRARY.equals(event.getType());
|
||||
return EventType.SEARCH_LIBRARY == event.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -128,7 +128,7 @@ class LifeAndLimbEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer.equals(SubLayer.SetPT_7b)) {
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanent.getPower().setValue(1);
|
||||
permanent.getToughness().setValue(1);
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ class MeanderingTowershellReturnEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null && game.getState().getZone(source.getSourceId()).equals(Zone.EXILED)) {
|
||||
if (card != null && game.getState().getZone(source.getSourceId()) == Zone.EXILED) {
|
||||
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
|
||||
game.getCombat().addAttackingCreature(card.getId(), game);
|
||||
return true;
|
||||
|
|
|
@ -151,7 +151,7 @@ class MindreaverNamePredicate implements Predicate<MageObject> {
|
|||
// A split card has the chosen name if one of its two names matches the chosen name.
|
||||
if (input instanceof SplitCard) {
|
||||
return cardNames.contains(((SplitCard) input).getLeftHalfCard().getName()) || cardNames.contains(((SplitCard) input).getRightHalfCard().getName());
|
||||
} else if (input instanceof Spell && ((Spell) input).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
|
||||
} else if (input instanceof Spell && ((Spell) input).getSpellAbility().getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) {
|
||||
SplitCard card = (SplitCard) ((Spell) input).getCard();
|
||||
return cardNames.contains(card.getLeftHalfCard().getName()) || cardNames.contains(card.getRightHalfCard().getName());
|
||||
} else {
|
||||
|
|
|
@ -114,7 +114,7 @@ class NotionThiefReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getStep().getType().equals(PhaseStep.DRAW)) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getStep().getType() == PhaseStep.DRAW) {
|
||||
CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get("CardsDrawnDuringDrawStep");
|
||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
|
|
|
@ -176,7 +176,7 @@ class ObzedatGhostCouncilReturnEffect extends OneShotEffect {
|
|||
if (card != null) {
|
||||
Zone zone = game.getState().getZone(source.getSourceId());
|
||||
// return it from every public zone - http://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/513186-obzedat-gc-as-edh-commander
|
||||
if (!zone.equals(Zone.BATTLEFIELD) && !zone.equals(Zone.LIBRARY) && !zone.equals(Zone.HAND)) {
|
||||
if (zone != Zone.BATTLEFIELD && zone != Zone.LIBRARY && zone != Zone.HAND) {
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
owner.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
|
|
|
@ -169,7 +169,7 @@ class OtherworldlyJourneyEntersBattlefieldEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return EventType.ENTERS_THE_BATTLEFIELD.equals(event.getType());
|
||||
return EventType.ENTERS_THE_BATTLEFIELD == event.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -94,7 +94,7 @@ class PersonalSanctuaryEffect extends PreventionEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER)) {
|
||||
if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER) {
|
||||
if (event.getTargetId().equals(source.getControllerId()) && game.getActivePlayerId().equals(source.getControllerId()))
|
||||
return super.applies(event, source, game);
|
||||
}
|
||||
|
|
|
@ -27,35 +27,28 @@
|
|||
*/
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.PhantomPreventionEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class PhantomCentaur extends CardImpl {
|
||||
|
||||
public PhantomCentaur(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}");
|
||||
this.subtype.add("Centaur");
|
||||
this.subtype.add("Spirit");
|
||||
|
||||
|
@ -69,7 +62,7 @@ public class PhantomCentaur extends CardImpl {
|
|||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(3)), "with three +1/+1 counters on it"));
|
||||
|
||||
// If damage would be dealt to Phantom Centaur, prevent that damage. Remove a +1/+1 counter from Phantom Centaur.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomCentaurPreventionEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomPreventionEffect()));
|
||||
}
|
||||
|
||||
public PhantomCentaur(final PhantomCentaur card) {
|
||||
|
@ -81,71 +74,3 @@ public class PhantomCentaur extends CardImpl {
|
|||
return new PhantomCentaur(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhantomCentaurPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
// remember turn and phase step to check if counter in this step was already removed
|
||||
private int turn = 0;
|
||||
private Step combatPhaseStep = null;
|
||||
|
||||
public PhantomCentaurPreventionEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "If damage would be dealt to {this}, prevent that damage. Remove a +1/+1 counter from {this}";
|
||||
}
|
||||
|
||||
public PhantomCentaurPreventionEffect(final PhantomCentaurPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.turn = effect.turn;
|
||||
this.combatPhaseStep = effect.combatPhaseStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhantomCentaurPreventionEffect copy() {
|
||||
return new PhantomCentaurPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
preventDamageAction(event, source, game);
|
||||
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
boolean removeCounter = true;
|
||||
// check if in the same combat damage step already a counter was removed
|
||||
if (game.getTurn().getPhase().getStep().getType().equals(PhaseStep.COMBAT_DAMAGE)) {
|
||||
if (game.getTurnNum() == turn
|
||||
&& game.getTurn().getStep().equals(combatPhaseStep)) {
|
||||
removeCounter = false;
|
||||
} else {
|
||||
turn = game.getTurnNum();
|
||||
combatPhaseStep = game.getTurn().getStep();
|
||||
}
|
||||
}
|
||||
|
||||
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
|
||||
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
|
||||
sb.append("Removed a +1/+1 counter ");
|
||||
game.informPlayers(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,34 +27,27 @@
|
|||
*/
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.PhantomPreventionEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public class PhantomFlock extends CardImpl {
|
||||
|
||||
public PhantomFlock(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}");
|
||||
this.subtype.add("Bird");
|
||||
this.subtype.add("Soldier");
|
||||
this.subtype.add("Spirit");
|
||||
|
@ -68,7 +61,7 @@ public class PhantomFlock extends CardImpl {
|
|||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(3)), "with three +1/+1 counters on it"));
|
||||
|
||||
// If damage would be dealt to Phantom Flock, prevent that damage. Remove a +1/+1 counter from Phantom Flock.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomFlockPreventionEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomPreventionEffect()));
|
||||
}
|
||||
|
||||
public PhantomFlock(final PhantomFlock card) {
|
||||
|
@ -80,71 +73,3 @@ public class PhantomFlock extends CardImpl {
|
|||
return new PhantomFlock(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhantomFlockPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
// remember turn and phase step to check if counter in this step was already removed
|
||||
private int turn = 0;
|
||||
private Step combatPhaseStep = null;
|
||||
|
||||
PhantomFlockPreventionEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "If damage would be dealt to {this}, prevent that damage. Remove a +1/+1 counter from {this}";
|
||||
}
|
||||
|
||||
PhantomFlockPreventionEffect(final PhantomFlockPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.turn = effect.turn;
|
||||
this.combatPhaseStep = effect.combatPhaseStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhantomFlockPreventionEffect copy() {
|
||||
return new PhantomFlockPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
preventDamageAction(event, source, game);
|
||||
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
boolean removeCounter = true;
|
||||
// check if in the same combat damage step already a counter was removed
|
||||
if (game.getTurn().getPhase().getStep().getType().equals(PhaseStep.COMBAT_DAMAGE)) {
|
||||
if (game.getTurnNum() == turn
|
||||
&& game.getTurn().getStep().equals(combatPhaseStep)) {
|
||||
removeCounter = false;
|
||||
} else {
|
||||
turn = game.getTurnNum();
|
||||
combatPhaseStep = game.getTurn().getStep();
|
||||
}
|
||||
}
|
||||
|
||||
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
|
||||
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
|
||||
sb.append("Removed a +1/+1 counter ");
|
||||
game.informPlayers(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,27 +27,21 @@
|
|||
*/
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.PhantomPreventionEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -68,7 +62,7 @@ public class PhantomNantuko extends CardImpl {
|
|||
// Phantom Nantuko enters the battlefield with two +1/+1 counters on it.
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2), true), "with two +1/+1 counters on it"));
|
||||
// If damage would be dealt to Phantom Nantuko, prevent that damage. Remove a +1/+1 counter from Phantom Nantuko.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomNantukoPreventionEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomPreventionEffect()));
|
||||
// {tap}: Put a +1/+1 counter on Phantom Nantuko.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), new TapSourceCost()));
|
||||
}
|
||||
|
@ -83,70 +77,3 @@ public class PhantomNantuko extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class PhantomNantukoPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
// remember turn and phase step to check if counter in this step was already removed
|
||||
private int turn = 0;
|
||||
private Step combatPhaseStep = null;
|
||||
|
||||
public PhantomNantukoPreventionEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "If damage would be dealt to {this}, prevent that damage. Remove a +1/+1 counter from {this}";
|
||||
}
|
||||
|
||||
public PhantomNantukoPreventionEffect(final PhantomNantukoPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.turn = effect.turn;
|
||||
this.combatPhaseStep = effect.combatPhaseStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhantomNantukoPreventionEffect copy() {
|
||||
return new PhantomNantukoPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
preventDamageAction(event, source, game);
|
||||
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
boolean removeCounter = true;
|
||||
// check if in the same combat damage step already a counter was removed
|
||||
if (game.getTurn().getPhase().getStep().getType() == PhaseStep.COMBAT_DAMAGE) {
|
||||
if (game.getTurnNum() == turn
|
||||
&& game.getTurn().getStep().equals(combatPhaseStep)) {
|
||||
removeCounter = false;
|
||||
} else {
|
||||
turn = game.getTurnNum();
|
||||
combatPhaseStep = game.getTurn().getStep();
|
||||
}
|
||||
}
|
||||
|
||||
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
|
||||
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
|
||||
sb.append("Removed a +1/+1 counter ");
|
||||
game.informPlayers(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,35 +27,28 @@
|
|||
*/
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsDamageGainLifeSourceTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.PhantomPreventionEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public class PhantomNishoba extends CardImpl {
|
||||
|
||||
public PhantomNishoba(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{G}{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}{W}");
|
||||
this.subtype.add("Cat");
|
||||
this.subtype.add("Beast");
|
||||
this.subtype.add("Spirit");
|
||||
|
@ -72,7 +65,7 @@ public class PhantomNishoba extends CardImpl {
|
|||
this.addAbility(new DealsDamageGainLifeSourceTriggeredAbility());
|
||||
|
||||
// If damage would be dealt to Phantom Nishoba, prevent that damage. Remove a +1/+1 counter from Phantom Nishoba.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomNishobaPreventionEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomPreventionEffect()));
|
||||
}
|
||||
|
||||
public PhantomNishoba(final PhantomNishoba card) {
|
||||
|
@ -84,71 +77,3 @@ public class PhantomNishoba extends CardImpl {
|
|||
return new PhantomNishoba(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhantomNishobaPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
// remember turn and phase step to check if counter in this step was already removed
|
||||
private int turn = 0;
|
||||
private Step combatPhaseStep = null;
|
||||
|
||||
public PhantomNishobaPreventionEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "If damage would be dealt to {this}, prevent that damage. Remove a +1/+1 counter from {this}";
|
||||
}
|
||||
|
||||
public PhantomNishobaPreventionEffect(final PhantomNishobaPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.turn = effect.turn;
|
||||
this.combatPhaseStep = effect.combatPhaseStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhantomNishobaPreventionEffect copy() {
|
||||
return new PhantomNishobaPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
preventDamageAction(event, source, game);
|
||||
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
boolean removeCounter = true;
|
||||
// check if in the same combat damage step already a counter was removed
|
||||
if (game.getTurn().getPhase().getStep().getType().equals(PhaseStep.COMBAT_DAMAGE)) {
|
||||
if (game.getTurnNum() == turn
|
||||
&& game.getTurn().getStep().equals(combatPhaseStep)) {
|
||||
removeCounter = false;
|
||||
} else {
|
||||
turn = game.getTurnNum();
|
||||
combatPhaseStep = game.getTurn().getStep();
|
||||
}
|
||||
}
|
||||
|
||||
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
|
||||
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
|
||||
sb.append("Removed a +1/+1 counter ");
|
||||
game.informPlayers(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -27,24 +27,18 @@
|
|||
*/
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.PhantomPreventionEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -65,7 +59,7 @@ public class PhantomNomad extends CardImpl {
|
|||
"two +1/+1 counters on it"));
|
||||
|
||||
// If damage would be dealt to Phantom Nomad, prevent that damage. Remove a +1/+1 counter from Phantom Nomad.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomNomadPreventionEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomPreventionEffect()));
|
||||
|
||||
|
||||
}
|
||||
|
@ -79,71 +73,3 @@ public class PhantomNomad extends CardImpl {
|
|||
return new PhantomNomad(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhantomNomadPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
// remember turn and phase step to check if counter in this step was already removed
|
||||
private int turn = 0;
|
||||
private Step combatPhaseStep = null;
|
||||
|
||||
public PhantomNomadPreventionEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "If damage would be dealt to {this}, prevent that damage. Remove a +1/+1 counter from {this}";
|
||||
}
|
||||
|
||||
public PhantomNomadPreventionEffect(final PhantomNomadPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.turn = effect.turn;
|
||||
this.combatPhaseStep = effect.combatPhaseStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhantomNomadPreventionEffect copy() {
|
||||
return new PhantomNomadPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
preventDamageAction(event, source, game);
|
||||
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
boolean removeCounter = true;
|
||||
// check if in the same combat damage step already a counter was removed
|
||||
if (game.getTurn().getPhase().getStep().getType().equals(PhaseStep.COMBAT_DAMAGE)) {
|
||||
if (game.getTurnNum() == turn
|
||||
&& game.getTurn().getStep().equals(combatPhaseStep)) {
|
||||
removeCounter = false;
|
||||
} else {
|
||||
turn = game.getTurnNum();
|
||||
combatPhaseStep = game.getTurn().getStep();
|
||||
}
|
||||
}
|
||||
|
||||
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
|
||||
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
|
||||
sb.append("Removed a +1/+1 counter ");
|
||||
game.informPlayers(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,25 +27,18 @@
|
|||
*/
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.PhantomPreventionEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Temba
|
||||
|
@ -63,7 +56,7 @@ public class PhantomTiger extends CardImpl {
|
|||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)), "with two +1/+1 counters on it"));
|
||||
|
||||
// If damage would be dealt to Phantom Tiger, prevent that damage. Remove a +1/+1 counter from Phantom Tiger.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomTigerPreventionEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomPreventionEffect()));
|
||||
}
|
||||
|
||||
public PhantomTiger(final PhantomTiger card) {
|
||||
|
@ -75,71 +68,3 @@ public class PhantomTiger extends CardImpl {
|
|||
return new PhantomTiger(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhantomTigerPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
// remember turn and phase step to check if counter in this step was already removed
|
||||
private int turn = 0;
|
||||
private Step combatPhaseStep = null;
|
||||
|
||||
public PhantomTigerPreventionEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "If damage would be dealt to {this}, prevent that damage. Remove a +1/+1 counter from {this}";
|
||||
}
|
||||
|
||||
public PhantomTigerPreventionEffect(final PhantomTigerPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.turn = effect.turn;
|
||||
this.combatPhaseStep = effect.combatPhaseStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhantomTigerPreventionEffect copy() {
|
||||
return new PhantomTigerPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
preventDamageAction(event, source, game);
|
||||
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
boolean removeCounter = true;
|
||||
// check if in the same combat damage step already a counter was removed
|
||||
if (game.getTurn().getPhase().getStep().getType() == PhaseStep.COMBAT_DAMAGE) {
|
||||
if (game.getTurnNum() == turn
|
||||
&& game.getTurn().getStep().equals(combatPhaseStep)) {
|
||||
removeCounter = false;
|
||||
} else {
|
||||
turn = game.getTurnNum();
|
||||
combatPhaseStep = game.getTurn().getStep();
|
||||
}
|
||||
}
|
||||
|
||||
if (removeCounter && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
|
||||
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
|
||||
sb.append("Removed a +1/+1 counter ");
|
||||
game.informPlayers(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,24 +27,18 @@
|
|||
*/
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.PhantomPreventionEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -65,7 +59,7 @@ public class PhantomWurm extends CardImpl {
|
|||
"with four +1/+1 counters on it"));
|
||||
|
||||
// If damage would be dealt to Phantom Wurm, prevent that damage. Remove a +1/+1 counter from Phantom Wurm.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomWurmPreventionEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhantomPreventionEffect()));
|
||||
}
|
||||
|
||||
public PhantomWurm(final PhantomWurm card) {
|
||||
|
@ -77,71 +71,3 @@ public class PhantomWurm extends CardImpl {
|
|||
return new PhantomWurm(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PhantomWurmPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
// remember turn and phase step to check if counter in this step was already removed
|
||||
private int turn = 0;
|
||||
private Step combatPhaseStep = null;
|
||||
|
||||
public PhantomWurmPreventionEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "If damage would be dealt to {this}, prevent that damage. Remove a +1/+1 counter from {this}";
|
||||
}
|
||||
|
||||
public PhantomWurmPreventionEffect(final PhantomWurmPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.turn = effect.turn;
|
||||
this.combatPhaseStep = effect.combatPhaseStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhantomWurmPreventionEffect copy() {
|
||||
return new PhantomWurmPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
preventDamageAction(event, source, game);
|
||||
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
boolean removeCounter = true;
|
||||
// check if in the same combat damage step already a counter was removed
|
||||
if (game.getTurn().getPhase().getStep().getType() == PhaseStep.COMBAT_DAMAGE) {
|
||||
if (game.getTurnNum() == turn
|
||||
&& game.getTurn().getStep().equals(combatPhaseStep)) {
|
||||
removeCounter = false;
|
||||
} else {
|
||||
turn = game.getTurnNum();
|
||||
combatPhaseStep = game.getTurn().getStep();
|
||||
}
|
||||
}
|
||||
|
||||
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
|
||||
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
|
||||
sb.append("Removed a +1/+1 counter ");
|
||||
game.informPlayers(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class PharikaExileEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Card targetCard = game.getCard(source.getFirstTarget());
|
||||
if (targetCard != null) {
|
||||
if (game.getState().getZone(source.getFirstTarget()).equals(Zone.GRAVEYARD)) {
|
||||
if (game.getState().getZone(source.getFirstTarget()) == Zone.GRAVEYARD) {
|
||||
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true);
|
||||
}
|
||||
Player tokenController = game.getPlayer(targetCard.getOwnerId());
|
||||
|
|
|
@ -96,7 +96,7 @@ class PhyrexianDelverEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (creatureCard != null && controller != null) {
|
||||
boolean result = false;
|
||||
if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) {
|
||||
if (game.getState().getZone(creatureCard.getId()) == Zone.GRAVEYARD) {
|
||||
result = controller.moveCards(creatureCard, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
controller.loseLife(creatureCard.getConvertedManaCost(), game, false);
|
||||
|
|
|
@ -101,7 +101,7 @@ class PithingNeedleEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
MageObject object = game.getObject(event.getSourceId());
|
||||
Ability ability = game.getAbility(event.getTargetId(), event.getSourceId());
|
||||
if (ability != null && object != null) {
|
||||
if (!ability.getAbilityType().equals(AbilityType.MANA)
|
||||
if (ability.getAbilityType() != AbilityType.MANA
|
||||
&& object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY))) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class PostmortemLunge extends CardImpl {
|
|||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability.getAbilityType().equals(AbilityType.SPELL)) { // otherwise the target is also added to the delayed triggered ability
|
||||
if (ability.getAbilityType() == AbilityType.SPELL) { // otherwise the target is also added to the delayed triggered ability
|
||||
ability.getTargets().clear();
|
||||
int xValue = ability.getManaCostsToPay().getX();
|
||||
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less from your graveyard");
|
||||
|
|
187
Mage.Sets/src/mage/cards/q/QuicksilverFountain.java
Normal file
187
Mage.Sets/src/mage/cards/q/QuicksilverFountain.java
Normal file
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.cards.q;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.BecomesBasicLandTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetLandPermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class QuicksilverFountain extends CardImpl {
|
||||
|
||||
public QuicksilverFountain(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
|
||||
|
||||
// At the beginning of each player's upkeep, that player puts a flood counter on target non-Island land he or she controls of his or her choice. That land is an Island for as long as it has a flood counter on it.
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new QuicksilverFountainEffect(), TargetController.ANY, false, true));
|
||||
|
||||
// At the beginning of each end step, if all lands on the battlefield are Islands, remove all flood counters from them.
|
||||
Condition condition = new AllLandsAreSubtypeCondition("Island");
|
||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new QuicksilverFountainEffect2(), TargetController.ANY, condition, false));
|
||||
|
||||
}
|
||||
|
||||
public QuicksilverFountain(final QuicksilverFountain card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuicksilverFountain copy() {
|
||||
return new QuicksilverFountain(this);
|
||||
}
|
||||
}
|
||||
|
||||
class QuicksilverFountainEffect extends OneShotEffect {
|
||||
|
||||
static final private FilterLandPermanent filterNonIslandLand = new FilterLandPermanent("non-Island land");
|
||||
|
||||
static {
|
||||
filterNonIslandLand.add(Predicates.not(new SubtypePredicate("Island")));
|
||||
}
|
||||
|
||||
public QuicksilverFountainEffect() {
|
||||
super(Outcome.Neutral);
|
||||
staticText = "that player puts a flood counter on target non-Island land he or she controls of his or her choice. That land is an Island for as long as it has a flood counter on it";
|
||||
}
|
||||
|
||||
public QuicksilverFountainEffect(final QuicksilverFountainEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
Target targetNonIslandLand = new TargetLandPermanent(filterNonIslandLand);
|
||||
if (player != null) {
|
||||
if (player.choose(Outcome.Neutral, targetNonIslandLand, source.getId(), game)) {
|
||||
Permanent landChosen = game.getPermanent(targetNonIslandLand.getFirstTarget());
|
||||
landChosen.addCounters(CounterType.FLOOD.createInstance(), source, game);
|
||||
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new BecomesBasicLandTargetEffect(Duration.OneUse, "Island"), new LandHasFloodCounterCondition(this), staticText);
|
||||
this.setTargetPointer(new FixedTarget(landChosen, game));
|
||||
effect.setTargetPointer(new FixedTarget(landChosen, game));
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuicksilverFountainEffect copy() {
|
||||
return new QuicksilverFountainEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class QuicksilverFountainEffect2 extends OneShotEffect {
|
||||
|
||||
public QuicksilverFountainEffect2() {
|
||||
super(Outcome.Neutral);
|
||||
staticText = "remove all flood counters from them";
|
||||
}
|
||||
|
||||
public QuicksilverFountainEffect2(final QuicksilverFountainEffect2 effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent land : game.getBattlefield().getAllActivePermanents(CardType.LAND)) {
|
||||
land.removeCounters(CounterType.FLOOD.createInstance(land.getCounters(game).getCount(CounterType.FLOOD)), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuicksilverFountainEffect2 copy() {
|
||||
return new QuicksilverFountainEffect2(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AllLandsAreSubtypeCondition implements Condition {
|
||||
|
||||
private final String subtype;
|
||||
|
||||
public AllLandsAreSubtypeCondition(String subtype) {
|
||||
this.subtype = subtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FilterLandPermanent filterLand = new FilterLandPermanent();
|
||||
filterLand.add(new SubtypePredicate(subtype));
|
||||
int landCount = game.getBattlefield().getAllActivePermanents(CardType.LAND).size();
|
||||
return game.getBattlefield().getAllActivePermanents(filterLand, game).size() == landCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if all lands on the battlefield are " + subtype + "s";
|
||||
}
|
||||
}
|
||||
|
||||
class LandHasFloodCounterCondition implements Condition {
|
||||
|
||||
private final Effect effect;
|
||||
|
||||
public LandHasFloodCounterCondition(Effect effect) {
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(effect.getTargetPointer().getFirst(game, source));
|
||||
return permanent != null
|
||||
&& permanent.getCounters(game).getCount(CounterType.FLOOD) > 0;
|
||||
}
|
||||
}
|
|
@ -101,7 +101,7 @@ class RosheenMeandererManaCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (AbilityType.SPELL.equals(source.getAbilityType())) {
|
||||
if (AbilityType.SPELL == source.getAbilityType()) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
return object != null
|
||||
&& object.getManaCost().getText().contains("X");
|
||||
|
|
|
@ -88,7 +88,7 @@ class SacredGroundTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (game.getOpponents(this.getControllerId()).contains(game.getControllerId(event.getSourceId()))) {
|
||||
ZoneChangeEvent zce = (ZoneChangeEvent) event;
|
||||
if (Zone.BATTLEFIELD.equals(zce.getFromZone()) && Zone.GRAVEYARD.equals(zce.getToZone())) {
|
||||
if (Zone.BATTLEFIELD == zce.getFromZone() && Zone.GRAVEYARD == zce.getToZone()) {
|
||||
Permanent targetPermanent = zce.getTarget();
|
||||
if (targetPermanent.isLand() && targetPermanent.getControllerId().equals(getControllerId())) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(targetPermanent.getId(), game.getState().getZoneChangeCounter(targetPermanent.getId())));
|
||||
|
|
|
@ -127,7 +127,7 @@ class SerraAscendantEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return Layer.AbilityAddingRemovingEffects_6.equals(layer) || Layer.PTChangingEffects_7.equals(layer);
|
||||
return Layer.AbilityAddingRemovingEffects_6 == layer || Layer.PTChangingEffects_7 == layer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ class SharedFatePlayEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (game.getState().getZone(objectId).equals(Zone.EXILED)) {
|
||||
if (game.getState().getZone(objectId) == Zone.EXILED) {
|
||||
Player player = game.getPlayer(affectedControllerId);
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game);
|
||||
|
@ -192,7 +192,7 @@ class SharedFateLookEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (game.getState().getZone(objectId).equals(Zone.EXILED)) {
|
||||
if (game.getState().getZone(objectId) == Zone.EXILED) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game);
|
||||
if (exileId != null) {
|
||||
|
|
|
@ -169,8 +169,8 @@ class SithMagicReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getTargetId().equals(source.getFirstTarget())
|
||||
&& ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)
|
||||
&& !((ZoneChangeEvent) event).getToZone().equals(Zone.EXILED)) {
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD
|
||||
&& ((ZoneChangeEvent) event).getToZone() != Zone.EXILED) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -99,7 +99,7 @@ class ArtifactAbilityManaCondition extends ManaCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (source != null && source.getAbilityType().equals(AbilityType.ACTIVATED)) {
|
||||
if (source != null && source.getAbilityType() == AbilityType.ACTIVATED) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object != null && object.isArtifact()) {
|
||||
return true;
|
||||
|
|
|
@ -102,7 +102,7 @@ class SoulSeparatorEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (creatureCard != null && controller != null) {
|
||||
boolean result = false;
|
||||
if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) {
|
||||
if (game.getState().getZone(creatureCard.getId()) == Zone.GRAVEYARD) {
|
||||
result = controller.moveCardToExileWithInfo(creatureCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true);
|
||||
ZombieToken2 token = new ZombieToken2(creatureCard.getPower().getValue(), creatureCard.getToughness().getValue());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
|
|
|
@ -188,7 +188,7 @@ class SpellbinderCopyEffect extends OneShotEffect {
|
|||
Permanent spellbinder = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (spellbinder != null && spellbinder.getImprinted() != null && !spellbinder.getImprinted().isEmpty()) {
|
||||
Card imprintedInstant = game.getCard(spellbinder.getImprinted().get(0));
|
||||
if (imprintedInstant != null && game.getState().getZone(imprintedInstant.getId()).equals(Zone.EXILED)) {
|
||||
if (imprintedInstant != null && game.getState().getZone(imprintedInstant.getId()) == Zone.EXILED) {
|
||||
if (controller.chooseUse(outcome, new StringBuilder("Create a copy of ").append(imprintedInstant.getName()).append('?').toString(), source, game)) {
|
||||
Card copiedCard = game.copyCard(imprintedInstant, source, source.getControllerId());
|
||||
if (copiedCard != null) {
|
||||
|
|
|
@ -115,6 +115,7 @@ class SpellshiftEffect extends OneShotEffect {
|
|||
library.addAll(cards.getCards(game), game);
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -147,7 +147,7 @@ class SphinxOfUthuunEffect extends OneShotEffect {
|
|||
pile2Zone = Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(sourceObject.getLogName()).append(": Pile 1, going to ").append(pile1Zone.equals(Zone.HAND)?"Hand":"Graveyard").append (": ");
|
||||
StringBuilder sb = new StringBuilder(sourceObject.getLogName()).append(": Pile 1, going to ").append(pile1Zone == Zone.HAND ?"Hand":"Graveyard").append (": ");
|
||||
int i = 0;
|
||||
for (UUID cardUuid : pile1CardsIds) {
|
||||
i++;
|
||||
|
@ -162,7 +162,7 @@ class SphinxOfUthuunEffect extends OneShotEffect {
|
|||
}
|
||||
game.informPlayers(sb.toString());
|
||||
|
||||
sb = new StringBuilder(sourceObject.getLogName()).append(": Pile 2, going to ").append(pile2Zone.equals(Zone.HAND)?"Hand":"Graveyard").append (':');
|
||||
sb = new StringBuilder(sourceObject.getLogName()).append(": Pile 2, going to ").append(pile2Zone == Zone.HAND ?"Hand":"Graveyard").append (':');
|
||||
i = 0;
|
||||
for (UUID cardUuid : pile2CardsIds) {
|
||||
Card card = game.getCard(cardUuid);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue