This commit is contained in:
igoudt 2017-09-01 22:49:50 +02:00
commit 43bb541876
24 changed files with 864 additions and 255 deletions

View file

@ -27,6 +27,10 @@
*/
package mage.client.remote;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.UUID;
import javax.swing.*;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
import mage.client.SessionHandler;
@ -48,11 +52,6 @@ import mage.view.*;
import mage.view.ChatMessage.MessageType;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -325,11 +324,11 @@ public class CallbackClientImpl implements CallbackClient {
break;
}
case VIEW_LIMITED_DECK: {
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
viewLimitedDeck(deck, message.getTableId(), message.getTime());
break;
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
viewLimitedDeck(deck, message.getTableId(), message.getTime());
break;
}
case CONSTRUCT: {
TableClientMessage message = (TableClientMessage) callback.getData();
@ -356,14 +355,6 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case DRAFT_INFORM: // if (callback.getMessageId() > messageId) {
{
DraftClientMessage message = (DraftClientMessage) callback.getData();
}
// } else {
// logger.warn("message out of sequence - ignoring");
// }
break;
case DRAFT_INIT: {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());

View file

@ -30,18 +30,27 @@ public enum ClientCallbackMethod {
GAME_UPDATE("gameUpdate"),
DRAFT_OVER("draftOver"),
REPLAY_DONE("replayDone"),
USER_REQUEST_DIALOG("userRequestDialog"),
USER_REQUEST_DIALOG("userRequestDialog"),
REPLAY_UPDATE("replayUpdate"),
REPLAY_INIT("replayInit"),
END_GAME_INFO("endGameInfo"),
GAME_TARGET("gameTarget"),
GAME_CHOOSE_ABILITY("gameChooseAbility"),
GAME_CHOOSE_ABILITY("gameChooseAbility"),
GAME_CHOOSE_PILE("gameChoosePile"),
GAME_CHOOSE_CHOICE("gameChooseChoice"), GAME_ASK("gameAsk"), GAME_SELECT("gameSelect"), GAME_PLAY_MANA("gamePlayMana"), GAME_PLAY_XMANA("gamePlayXMana"), GAME_GET_AMOUNT("gameSelectAmount"), DRAFT_INIT("draftInit"), DRAFT_INFORM("draftInform"), DRAFT_PICK("draftPick"), DRAFT_UPDATE("draftUpdate");
GAME_CHOOSE_CHOICE("gameChooseChoice"),
GAME_ASK("gameAsk"),
GAME_SELECT("gameSelect"),
GAME_PLAY_MANA("gamePlayMana"),
GAME_PLAY_XMANA("gamePlayXMana"),
GAME_GET_AMOUNT("gameSelectAmount"),
DRAFT_INIT("draftInit"),
// DRAFT_INFORM("draftInform"),
DRAFT_PICK("draftPick"),
DRAFT_UPDATE("draftUpdate");
String value;
ClientCallbackMethod(String value){
ClientCallbackMethod(String value) {
this.value = value;
}
}

View file

@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
import javax.swing.*;
import mage.MageException;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.InvalidDeckException;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.cards.repository.ExpansionInfo;
@ -691,8 +690,6 @@ public class SessionImpl implements Session {
}
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
}
} catch (InvalidDeckException iex) {
handleInvalidDeckException(iex);
} catch (GameException ex) {
handleGameException(ex);
} catch (MageException ex) {
@ -1547,11 +1544,6 @@ public class SessionImpl implements Session {
client.showError(ex.getMessage());
}
private void handleInvalidDeckException(InvalidDeckException iex) {
logger.warn(iex.getMessage() + '\n' + iex.getInvalid());
client.showError(iex.getMessage() + '\n' + iex.getInvalid());
}
private void handleGameException(GameException ex) {
logger.warn(ex.getMessage());
client.showError(ex.getMessage());

View file

@ -38,7 +38,6 @@ import java.util.concurrent.TimeUnit;
import mage.MageException;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.InvalidDeckException;
import mage.constants.RangeOfInfluence;
import mage.constants.TableState;
import mage.game.*;
@ -414,7 +413,17 @@ public class TableController {
}
}
if (!Main.isTestMode() && !table.getValidator().validate(deck)) {
throw new InvalidDeckException("Invalid deck for this format", table.getValidator().getInvalid());
Optional<User> _user = UserManager.instance.getUser(userId);
if (!_user.isPresent()) {
return false;
}
StringBuilder sb = new StringBuilder("Invalid deck for the selected ").append(table.getValidator().getName()).append(" format. \n\n");
for (Map.Entry<String, String> entry : table.getValidator().getInvalid().entrySet()) {
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append('\n');
}
sb.append("\n\nAdd enough cards and try again!");
_user.get().showUserMessage("Submit deck", sb.toString());
return false;
}
submitDeck(userId, playerId, deck);
return true;

View file

@ -35,6 +35,9 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import mage.MageException;
import mage.cards.decks.DeckCardLists;
import mage.constants.TableState;
@ -66,7 +69,10 @@ public enum TableManager {
private static final DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
private final ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<>();
private final ReadWriteLock controllersLock = new ReentrantReadWriteLock();
private final ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<>();
private final ReadWriteLock tablesLock = new ReentrantReadWriteLock();
/**
* Defines how often checking process should be run on server.
@ -88,25 +94,45 @@ public enum TableManager {
public Table createTable(UUID roomId, UUID userId, MatchOptions options) {
TableController tableController = new TableController(roomId, userId, options);
controllers.put(tableController.getTable().getId(), tableController);
tables.put(tableController.getTable().getId(), tableController.getTable());
putControllers(tableController.getTable().getId(), tableController);
putTables(tableController.getTable().getId(), tableController.getTable());
return tableController.getTable();
}
public Table createTable(UUID roomId, MatchOptions options) {
TableController tableController = new TableController(roomId, null, options);
controllers.put(tableController.getTable().getId(), tableController);
tables.put(tableController.getTable().getId(), tableController.getTable());
putControllers(tableController.getTable().getId(), tableController);
putTables(tableController.getTable().getId(), tableController.getTable());
return tableController.getTable();
}
public Table createTournamentTable(UUID roomId, UUID userId, TournamentOptions options) {
TableController tableController = new TableController(roomId, userId, options);
controllers.put(tableController.getTable().getId(), tableController);
tables.put(tableController.getTable().getId(), tableController.getTable());
putControllers(tableController.getTable().getId(), tableController);
putTables(tableController.getTable().getId(), tableController.getTable());
return tableController.getTable();
}
private void putTables(UUID tableId, Table table) {
final Lock w = tablesLock.writeLock();
w.lock();
try {
tables.put(tableId, table);
} finally {
w.unlock();
}
}
private void putControllers(UUID controllerId, TableController tableController) {
final Lock w = controllersLock.writeLock();
w.lock();
try {
controllers.put(controllerId, tableController);
} finally {
w.unlock();
}
}
public Table getTable(UUID tableId) {
return tables.get(tableId);
}
@ -119,7 +145,27 @@ public enum TableManager {
}
public Collection<Table> getTables() {
return tables.values();
Collection<Table> newTables = new ArrayList<>();
final Lock r = tablesLock.readLock();
r.lock();
try {
newTables.addAll(tables.values());
} finally {
r.unlock();
}
return newTables;
}
public Collection<TableController> getControllers() {
Collection<TableController> newControllers = new ArrayList<>();
final Lock r = controllersLock.readLock();
r.lock();
try {
newControllers.addAll(controllers.values());
} finally {
r.unlock();
}
return newControllers;
}
public Optional<TableController> getController(UUID tableId) {
@ -164,7 +210,7 @@ public enum TableManager {
// removeUserFromAllTablesAndChat user from all tournament sub tables
public void userQuitTournamentSubTables(UUID userId) {
for (TableController controller : controllers.values()) {
for (TableController controller : getControllers()) {
if (controller.getTable() != null) {
if (controller.getTable().isTournamentSubTable()) {
controller.leaveTable(userId);
@ -177,7 +223,7 @@ public enum TableManager {
// removeUserFromAllTablesAndChat user from all sub tables of a tournament
public void userQuitTournamentSubTables(UUID tournamentId, UUID userId) {
for (TableController controller : controllers.values()) {
for (TableController controller : getControllers()) {
if (controller.getTable().isTournamentSubTable() && controller.getTable().getTournament().getId().equals(tournamentId)) {
if (controller.hasPlayer(userId)) {
controller.leaveTable(userId);
@ -268,12 +314,6 @@ public enum TableManager {
return false;
}
// public boolean replayTable(UUID userId, UUID tableId) {
// if (controllers.containsKey(tableId)) {
// return controllers.get(tableId).replayTable(userId);
// }
// return false;
// }
public void endGame(UUID tableId) {
if (controllers.containsKey(tableId)) {
if (controllers.get(tableId).endGameAndStartNextGame()) {
@ -321,11 +361,24 @@ public enum TableManager {
public void removeTable(UUID tableId) {
TableController tableController = controllers.get(tableId);
if (tableController != null) {
controllers.remove(tableId);
Lock w = controllersLock.writeLock();
w.lock();
try {
controllers.remove(tableId);
} finally {
w.unlock();
}
tableController.cleanUp(); // deletes the table chat and references to users
Table table = tables.get(tableId);
tables.remove(tableId);
w = tablesLock.writeLock();
w.lock();
try {
tables.remove(tableId);
} finally {
w.unlock();
}
Match match = table.getMatch();
Game game = null;
if (match != null) {
@ -383,8 +436,7 @@ public enum TableManager {
debugServerState();
}
logger.debug("TABLE HEALTH CHECK");
List<Table> tableCopy = new ArrayList<>(tables.values());
for (Table table : tableCopy) {
for (Table table : getTables()) {
try {
if (table.getState() != TableState.FINISHED
&& ((System.currentTimeMillis() - table.getStartTime().getTime()) / 1000) > 30) { // removeUserFromAllTablesAndChat only if table started longer than 30 seconds ago

View file

@ -24,10 +24,16 @@
* 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.server.draft;
import java.rmi.RemoteException;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import mage.game.draft.Draft;
import mage.interfaces.callback.ClientCallback;
import mage.interfaces.callback.ClientCallbackMethod;
@ -39,14 +45,6 @@ import mage.view.DraftPickView;
import mage.view.DraftView;
import org.apache.log4j.Logger;
import java.rmi.RemoteException;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -89,21 +87,10 @@ public class DraftSession {
UserManager.instance
.getUser(userId).
ifPresent(user -> user.fireCallback(
new ClientCallback(ClientCallbackMethod.DRAFT_UPDATE, draft.getId(), getDraftView())));
new ClientCallback(ClientCallbackMethod.DRAFT_UPDATE, draft.getId(), getDraftView())));
}
}
// not used
//
public void inform(final String message) {
if (!killed) {
UserManager.instance
.getUser(userId)
.ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_INFORM, draft.getId(), new DraftClientMessage(getDraftView(), message))));
}
}
public void draftOver() {
if (!killed) {
UserManager.instance

View file

@ -0,0 +1,73 @@
/*
* 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.b;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetOpponent;
/**
*
* @author TheElk801
*/
public class BurningSunsAvatar extends CardImpl {
public BurningSunsAvatar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{R}{R}");
this.subtype.add("Dinosaur");
this.subtype.add("Avatar");
this.power = new MageInt(6);
this.toughness = new MageInt(6);
// When Burning Sun's Avatar enters the battlefield, it deals 3 damage to target opponent and 3 damage to up to one target creature.
Effect effect = new DamageTargetEffect(3);
effect.setText("it deals 3 damage to target opponent and 3 damage to up to one target creature");
Ability ability = new EntersBattlefieldTriggeredAbility(effect, false);
ability.addTarget(new TargetOpponent());
ability.addTarget(new TargetCreaturePermanent(0, 1));
this.addAbility(ability);
}
public BurningSunsAvatar(final BurningSunsAvatar card) {
super(card);
}
@Override
public BurningSunsAvatar copy() {
return new BurningSunsAvatar(this);
}
}

View file

@ -0,0 +1,78 @@
/*
* 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.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author TheElk801
*/
public class EntrancingMelody extends CardImpl {
public EntrancingMelody(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}{U}");
// Gain control of target creature with converted mana cost X.
this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.Custom, true));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature with converted mana cost X")));
}
public EntrancingMelody(final EntrancingMelody card) {
super(card);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with converted mana cost X or less");
filter.add(Predicates.not(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue)));
ability.addTarget(new TargetCreaturePermanent(filter));
}
}
@Override
public EntrancingMelody copy() {
return new EntrancingMelody(this);
}
}

View file

@ -0,0 +1,149 @@
/*
* 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.g;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
* @author TheElk801
*/
public class GishathSunsAvatar extends CardImpl {
public GishathSunsAvatar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}{G}{W}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add("Dinosaur");
this.subtype.add("Avatar");
this.power = new MageInt(7);
this.toughness = new MageInt(6);
// Trample
this.addAbility(TrampleAbility.getInstance());
// Vigilance
this.addAbility(VigilanceAbility.getInstance());
// Haste
this.addAbility(HasteAbility.getInstance());
// Whenever Gishath, Sun's Avatar deals combat damage to a player, reveal that many cards from the top of your library. Put any number of Dinosaur creature cards from among them onto the battlefield and the rest on the bottom of your library in a random order.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new GishathSunsAvatarEffect(), false, true));
}
public GishathSunsAvatar(final GishathSunsAvatar card) {
super(card);
}
@Override
public GishathSunsAvatar copy() {
return new GishathSunsAvatar(this);
}
}
class GishathSunsAvatarEffect extends OneShotEffect {
private static final FilterCreatureCard filter = new FilterCreatureCard("Dinosaur creature cards");
static {
filter.add(new SubtypePredicate(SubType.DINOSAUR));
}
GishathSunsAvatarEffect() {
super(Outcome.Benefit);
this.staticText = "reveal that many cards from the top of your library. Put any number of Dinosaur creature cards from among them onto the battlefield and the rest on the bottom of your library in a random order";
}
GishathSunsAvatarEffect(final GishathSunsAvatarEffect effect) {
super(effect);
}
@Override
public GishathSunsAvatarEffect copy() {
return new GishathSunsAvatarEffect(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) {
return false;
}
Cards cards = new CardsImpl();
int xValue = (Integer) getValue("damage");
int numberCards = Math.min(controller.getLibrary().size(), xValue);
for (int i = 0; i < numberCards; i++) {
Card card = controller.getLibrary().removeFromTop(game);
cards.add(card);
}
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
target1.setRequired(false);
controller.choose(Outcome.PutCardInPlay, cards, target1, game);
Set<Card> toBattlefield = new LinkedHashSet<>();
for (UUID cardId : target1.getTargets()) {
Card card = cards.get(cardId, game);
if (card != null) {
cards.remove(card);
toBattlefield.add(card);
}
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, false, null);
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
}
return true;
}
}

View file

@ -55,7 +55,7 @@ import mage.target.TargetPermanent;
public class MistOfStagnation extends CardImpl {
public MistOfStagnation(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}");
// Permanents don't untap during their controllers' untap steps.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DontUntapInControllersUntapStepAllEffect(Duration.WhileOnBattlefield, TargetController.ANY, new FilterPermanent("permanents"))));

View file

@ -52,7 +52,7 @@ import mage.watchers.Watcher;
public class MoltenPsyche extends CardImpl {
public MoltenPsyche(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{R}{R}");
// Each player shuffles the cards from his or her hand into his or her library, then draws that many cards.
// Metalcraft - If you control three or more artifacts, Molten Psyche deals damage to each opponent equal to the number of cards that player has drawn this turn.
@ -106,10 +106,6 @@ class MoltenPsycheEffect extends OneShotEffect {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(cardsToDraw.get(playerId), game);
if (MetalcraftCondition.instance.apply(game, source) && !playerId.equals(source.getControllerId())) {
MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get(MoltenPsycheWatcher.class.getSimpleName());
player.damage(watcher.getDraws(playerId), source.getSourceId(), game, false, true);
}
}
}
if (MetalcraftCondition.instance.apply(game, source)) {

View 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.o;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterLandCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
/**
*
* @author TheElk801
*/
public class OldGrowthDryads extends CardImpl {
public OldGrowthDryads(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}");
this.subtype.add("Dryad");
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// When Old-Growth Dryads enters the battlefield, each opponent may search his or her library for a basic land card, put it onto the battlefield tapped, then shuffle his or her library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new OldGrowthDryadsEffect()));
}
public OldGrowthDryads(final OldGrowthDryads card) {
super(card);
}
@Override
public OldGrowthDryads copy() {
return new OldGrowthDryads(this);
}
}
class OldGrowthDryadsEffect extends OneShotEffect {
OldGrowthDryadsEffect() {
super(Outcome.Detriment);
this.staticText = "each opponent may search his or her library for a basic land card, put it onto the battlefield tapped, then shuffle his or her library";
}
OldGrowthDryadsEffect(final OldGrowthDryadsEffect effect) {
super(effect);
}
@Override
public OldGrowthDryadsEffect copy() {
return new OldGrowthDryadsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Set<Player> playersThatSearched = new HashSet<>(1);
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null && opponent.chooseUse(Outcome.PutCreatureInPlay, "Search your library for a creature card and put it onto the battlefield?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(new FilterLandCard());
if (opponent.searchLibrary(target, game)) {
Card targetCard = opponent.getLibrary().getCard(target.getFirstTarget(), game);
if (targetCard != null) {
opponent.moveCards(targetCard, Zone.BATTLEFIELD, source, game, true, false, false, null);
playersThatSearched.add(opponent);
}
}
}
}
for (Player opponent : playersThatSearched) {
opponent.shuffleLibrary(source, game);
}
return true;
}
}

View file

@ -34,7 +34,6 @@ import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.Zone;
@ -52,8 +51,7 @@ public class RipjawRaptor extends CardImpl {
this.toughness = new MageInt(5);
// <i>Enrage</i> &mdash; Whenever Ripjaw Raptor is dealt damage, draw a card.
Ability ability = new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), false);
ability.setAbilityWord(AbilityWord.ENRAGE);
Ability ability = new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), false, true);
this.addAbility(ability);
}

View file

@ -34,7 +34,6 @@ import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.target.common.TargetOpponent;
@ -47,15 +46,14 @@ public class SunCrownedHunters extends CardImpl {
public SunCrownedHunters(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}");
this.subtype.add("Dinosaur");
this.power = new MageInt(5);
this.toughness = new MageInt(4);
// <i>Enrage</i> &mdash; Whenever Sun-Crowned Hunters is dealt damage, it deals 3 damage to target opponent.
Ability ability = new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3), false);
Ability ability = new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3), false, true);
ability.addTarget(new TargetOpponent());
ability.setAbilityWord(AbilityWord.ENRAGE);
this.addAbility(ability);
}

View file

@ -27,6 +27,8 @@
*/
package mage.cards.t;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
@ -46,17 +48,16 @@ import mage.constants.Zone;
import mage.counters.Counter;
import mage.counters.Counters;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.common.FilterEnchantmentPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
/**
*
@ -64,14 +65,12 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class TawnossCoffin extends CardImpl {
public Counters godHelpMe = null;
public TawnossCoffin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
// You may choose not to untap Tawnos's Coffin during your untap step.
this.addAbility(new SkipUntapOptionalAbility());
// {3}, {tap}: Exile target creature and all Auras attached to it. Note the number and kind of counters that were on that creature.
// {3}, {T}: Exile target creature and all Auras attached to it. Note the number and kind of counters that were on that creature.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new TawnossCoffinEffect(), new TapSourceCost());
ability.addCost(new ManaCostsImpl("{3}"));
ability.addTarget(new TargetCreaturePermanent());
@ -114,7 +113,7 @@ class TawnossCoffinTriggeredAbility extends LeavesBattlefieldTriggeredAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.UNTAPPED) {
return event.getTargetId().equals(sourceId);
return event.getTargetId().equals(getSourceId());
} else {
return super.checkTrigger(event, game);
}
@ -151,40 +150,25 @@ class TawnossCoffinEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
// Exile enchanted creature and all Auras attached to it.
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment == null) {
enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
UUID targetId = source.getFirstTarget();
if (targetId == null) {
return false; // if previous scan somehow failed, simply quit
}
if (enchantment != null) { //back to code (mostly) copied from Flickerform
Permanent enchantedCreature = game.getPermanent(targetId);
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && sourceObject != null) {
Permanent enchantedCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (enchantedCreature != null) {
UUID exileZoneId = source.getSourceId();
enchantedCreature.moveToExile(exileZoneId, enchantment.getName(), source.getSourceId(), game);
UUID exileZoneId = CardUtil.getCardExileZoneId(game, source);
Set<Card> toExile = new HashSet<>();
toExile.add(enchantedCreature);
for (UUID attachementId : enchantedCreature.getAttachments()) {
Permanent attachment = game.getPermanent(attachementId);
if (attachment != null && filter.match(attachment, game)) {
attachment.moveToExile(exileZoneId, enchantment.getName(), source.getSourceId(), game);
if (attachment != null && attachment.hasSubtype(SubType.AURA, game)) {
toExile.add(attachment);
}
}
//((TawnossCoffin)enchantment.getMainCard()).godHelpMe = enchantedCreature.getCounters(game); //why doesn't work? should return the same card, no?
((TawnossCoffin) game.getCard(source.getSourceId())).godHelpMe = enchantedCreature.getCounters(game).copy();
if (!(enchantedCreature instanceof Token)) {
// If you do, return the other cards exiled this way to the battlefield under their owners' control attached to that creature
/*LeavesBattlefieldTriggeredAbility triggeredAbility = new LeavesBattlefieldTriggeredAbility(
new TawnossCoffinReturnEffect(), false);
enchantment.addAbility(triggeredAbility, source.getSourceId(), game);
*/
}
return true;
controller.moveCardsToExile(toExile, source, game, true, exileZoneId, sourceObject.getIdName());
game.getState().setValue(exileZoneId.toString() + "NotedCounters", enchantedCreature.getCounters(game).copy());
game.getState().setValue(exileZoneId.toString() + "EnchantedCreature", enchantedCreature.getId());
}
return true;
}
return false;
@ -193,17 +177,9 @@ class TawnossCoffinEffect extends OneShotEffect {
class TawnossCoffinReturnEffect extends OneShotEffect {
private static final FilterCard filterAura = new FilterCard();
static {
filterAura.add(new CardTypePredicate(CardType.ENCHANTMENT));
filterAura.add(new SubtypePredicate(SubType.AURA));
}
public TawnossCoffinReturnEffect() {
super(Outcome.Benefit);
this.staticText = "return the exiled card to the battlefield under its owner's control tapped with the noted number and kind of counters on it. If you do, return the exiled Aura cards to the battlefield under their owner's control attached to that permanent";
}
public TawnossCoffinReturnEffect(final TawnossCoffinReturnEffect effect) {
@ -217,57 +193,66 @@ class TawnossCoffinReturnEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
ExileZone exileZone = game.getExile().getExileZone(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
UUID exileZoneId = CardUtil.getCardExileZoneId(game, source);
ExileZone exileZone = game.getExile().getExileZone(exileZoneId);
if (exileZone == null) {
return true;
}
FilterCard filter = new FilterCard();
filter.add(new CardTypePredicate(CardType.CREATURE));
//There should be only 1 there, but the for each loop seems the most practical to get to it
for (Card enchantedCard : exileZone.getCards(filter, game)) {
if (enchantedCard == null) {
continue;
}
enchantedCard.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), enchantedCard.getOwnerId());
Permanent newPermanent = game.getPermanent(enchantedCard.getId());
if (newPermanent != null) {
newPermanent.tap(game);
for (Card enchantment : exileZone.getCards(game)) {
if (filterAura.match(enchantment, game)) {
boolean canTarget = false;
for (Target target : enchantment.getSpellAbility().getTargets()) {
Filter filter2 = target.getFilter();
if (filter2.match(newPermanent, game)) {
canTarget = true;
break;
}
}
if (!canTarget) {
// Aura stays exiled
continue;
}
game.getState().setValue("attachTo:" + enchantment.getId(), newPermanent);
}
if (enchantment.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), enchantment.getOwnerId())) {
if (filterAura.match(enchantment, game)) {
newPermanent.addAttachment(enchantment.getId(), game);
}
}
}
Card oubliette = game.getCard(source.getSourceId());
if (oubliette == null) {
return false;//1st stab at getting those counters back
}
for (Counter c : ((TawnossCoffin) oubliette).godHelpMe.values()) { //would be nice if could just use that copy function to set the whole field
UUID enchantedCreatureId = (UUID) game.getState().getValue(exileZoneId.toString() + "EnchantedCreature");
if (enchantedCreatureId == null) {
return false;
}
if (!exileZone.contains(enchantedCreatureId)) {
return true; // Card was removed from exile meanwhile, other card sstay in exile
}
Card enchantedCreature = game.getCard(enchantedCreatureId);
if (enchantedCreature == null) {
return false;
}
controller.moveCards(enchantedCreature, Zone.BATTLEFIELD, source, game, true, false, true, null);
Permanent newPermanent = game.getPermanent(enchantedCreature.getId());
if (newPermanent != null) {
// Add the noted counters
Counters notedCounters = (Counters) game.getState().getValue(exileZoneId.toString() + "NotedCounters");
if (notedCounters != null) {
for (Counter c : notedCounters.values()) { //would be nice if could just use that copy function to set the whole field
if (c != null) {
newPermanent.getCounters(game).addCounter(c);
}
}
}
return true;
// Return the exiled auras
Set<Card> returningAuras = new HashSet<>();
for (Card enchantment : exileZone.getCards(game)) {
if (enchantment.hasSubtype(SubType.AURA, game)) {
boolean canTarget = false;
for (Target target : enchantment.getSpellAbility().getTargets()) {
Filter filter2 = target.getFilter();
if (filter2.match(newPermanent, game)) {
canTarget = true;
break;
}
}
if (!canTarget) {
// Aura stays exiled
continue;
}
returningAuras.add(enchantment);
game.getState().setValue("attachTo:" + enchantment.getId(), newPermanent);
}
}
controller.moveCards(returningAuras, Zone.BATTLEFIELD, source, game, false, false, true, null);
for (Card enchantment : returningAuras) {
Permanent permanent = game.getPermanent(enchantment.getId());
if (permanent != null) {
newPermanent.addAttachment(permanent.getId(), game);
}
}
}
return false;
return true;
}
}

View file

@ -66,7 +66,7 @@ public class TemporalDistortion extends CardImpl {
}
public TemporalDistortion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}");
// Whenever a creature or land becomes tapped, put an hourglass counter on it.
Effect effect = new AddCountersTargetEffect(CounterType.HOURGLASS.createInstance());

View file

@ -0,0 +1,84 @@
/*
* 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.t;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CardsInControllerHandCount;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
/**
*
* @author spjspj
*/
public class TishanaVoiceOfThunder extends CardImpl {
public TishanaVoiceOfThunder(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}{U}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add("Merfolk");
this.subtype.add("Shaman");
this.power = new MageInt(0);
this.toughness = new MageInt(0);
// Tishana, Voice of Thunder's power and toughness are each equal to the number of cards in your hand.
DynamicValue xValue = new CardsInControllerHandCount();
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(xValue, Duration.EndOfGame)));
// You have no maximum hand size.
Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.WhileOnBattlefield, MaximumHandSizeControllerEffect.HandSizeModification.SET);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
// When Tishana enters the battlefield, draw a card for each creature you control.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(new FilterControlledCreaturePermanent()))));
}
public TishanaVoiceOfThunder(final TishanaVoiceOfThunder card) {
super(card);
}
@Override
public TishanaVoiceOfThunder copy() {
return new TishanaVoiceOfThunder(this);
}
}

View file

@ -32,6 +32,7 @@ public class Ixalan extends ExpansionSet {
this.numBoosterRare = 1;
this.ratioBoosterMythic = 8;
cards.add(new SetCardInfo("Bloodcrazed Paladin", 93, Rarity.RARE, mage.cards.b.BloodcrazedPaladin.class));
cards.add(new SetCardInfo("Burning Sun's Avatar", 135, Rarity.RARE, mage.cards.b.BurningSunsAvatar.class));
cards.add(new SetCardInfo("Captain Lannery Storm", 136, Rarity.RARE, mage.cards.c.CaptainLanneryStorm.class));
cards.add(new SetCardInfo("Carnage Tyrant", 179, Rarity.MYTHIC, mage.cards.c.CarnageTyrant.class));
cards.add(new SetCardInfo("Deadeye Tormentor", 98, Rarity.COMMON, mage.cards.d.DeadeyeTormentor.class));
@ -41,8 +42,11 @@ public class Ixalan extends ExpansionSet {
cards.add(new SetCardInfo("Dreamcaller Siren", 54, Rarity.RARE, mage.cards.d.DreamcallerSiren.class));
cards.add(new SetCardInfo("Drowned Catacomb", 253, Rarity.RARE, mage.cards.d.DrownedCatacomb.class));
cards.add(new SetCardInfo("Emperor's Vanguard", 189, Rarity.RARE, mage.cards.e.EmperorsVanguard.class));
cards.add(new SetCardInfo("Entrancing Melody", 55, Rarity.RARE, mage.cards.e.EntrancingMelody.class));
cards.add(new SetCardInfo("Gishath, Sun's Avatar", 222, Rarity.MYTHIC, mage.cards.g.GishathSunsAvatar.class));
cards.add(new SetCardInfo("Glacial Fortress", 255, Rarity.RARE, mage.cards.g.GlacialFortress.class));
cards.add(new SetCardInfo("Herald of Secret Streams", 59, Rarity.RARE, mage.cards.h.HeraldOfSecretStreams.class));
cards.add(new SetCardInfo("Old-Growth Dryads", 199, Rarity.RARE, mage.cards.o.OldGrowthDryads.class));
cards.add(new SetCardInfo("Prosperous Pirates", 69, Rarity.COMMON, mage.cards.p.ProsperousPirates.class));
cards.add(new SetCardInfo("Queen's Bay Soldier", 115, Rarity.COMMON, mage.cards.q.QueensBaySoldier.class));
cards.add(new SetCardInfo("Revel in Riches", 117, Rarity.RARE, mage.cards.r.RevelInRiches.class));
@ -56,6 +60,7 @@ public class Ixalan extends ExpansionSet {
cards.add(new SetCardInfo("Sun-Crowned Hunters", 164, Rarity.COMMON, mage.cards.s.SunCrownedHunters.class));
cards.add(new SetCardInfo("Sunpetal Grove", 257, Rarity.RARE, mage.cards.s.SunpetalGrove.class));
cards.add(new SetCardInfo("Tishana's Wayfinder", 211, Rarity.COMMON, mage.cards.t.TishanasWayfinder.class));
cards.add(new SetCardInfo("Tishana, Voice of Thunder", 230, Rarity.MYTHIC, mage.cards.t.TishanaVoiceOfThunder.class));
cards.add(new SetCardInfo("Tocatli Honor Guard", 42, Rarity.RARE, mage.cards.t.TocatliHonorGuard.class));
cards.add(new SetCardInfo("Treasure Cove", 1250, Rarity.RARE, mage.cards.t.TreasureCove.class));
cards.add(new SetCardInfo("Treasure Map", 250, Rarity.RARE, mage.cards.t.TreasureMap.class));

View file

@ -68,6 +68,7 @@ public class MediaInserts extends ExpansionSet {
cards.add(new SetCardInfo("Breath of Malfegor", 58, Rarity.COMMON, mage.cards.b.BreathOfMalfegor.class));
cards.add(new SetCardInfo("Brion Stoutarm", 17, Rarity.RARE, mage.cards.b.BrionStoutarm.class));
cards.add(new SetCardInfo("Broodmate Dragon", 19, Rarity.RARE, mage.cards.b.BroodmateDragon.class));
cards.add(new SetCardInfo("Burning Sun's Avatar", 183, Rarity.RARE, mage.cards.b.BurningSunsAvatar.class));
cards.add(new SetCardInfo("Canopy Vista", 167, Rarity.RARE, mage.cards.c.CanopyVista.class));
cards.add(new SetCardInfo("Cathedral of War", 51, Rarity.RARE, mage.cards.c.CathedralOfWar.class));
cards.add(new SetCardInfo("Celestial Colonnade", 23, Rarity.SPECIAL, mage.cards.c.CelestialColonnade.class));

View file

@ -0,0 +1,145 @@
/*
* 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 org.mage.test.cards.abilities.oneshot.exile;
import mage.abilities.keyword.ReachAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class ExileAndReturnTest extends CardTestPlayerBase {
@Test
public void testExileAndReturn() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 7);
// You may choose not to untap Tawnos's Coffin during your untap step.
// {3}, {T}: Exile target creature and all Auras attached to it. Note the number and kind of counters that were on that creature.
// When Tawnos's Coffin leaves the battlefield or becomes untapped, return the exiled card to the battlefield under
// its owner's control tapped with the noted number and kind of counters on it, and if you do, return the exiled Aura
// cards to the battlefield under their owner's control attached to that permanent.
addCard(Zone.HAND, playerA, "Tawnos's Coffin"); // Artifact {4}
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Tawnos's Coffin");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{3},{T}", "Silvercoat Lion");
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, "Tawnos's Coffin", 1);
assertTapped("Tawnos's Coffin", false);
assertPermanentCount(playerB, "Silvercoat Lion", 1);
}
@Test
public void testExileAndReturnWithCounters() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 7);
// You may choose not to untap Tawnos's Coffin during your untap step.
// {3}, {T}: Exile target creature and all Auras attached to it. Note the number and kind of counters that were on that creature.
// When Tawnos's Coffin leaves the battlefield or becomes untapped, return the exiled card to the battlefield under
// its owner's control tapped with the noted number and kind of counters on it, and if you do, return the exiled Aura
// cards to the battlefield under their owner's control attached to that permanent.
addCard(Zone.HAND, playerA, "Tawnos's Coffin"); // Artifact {4}
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
// Put a +1/+1 counter on target creature.
addCard(Zone.BATTLEFIELD, playerB, "Forest", 1);
addCard(Zone.HAND, playerB, "Battlegrowth"); // Instant {G}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Tawnos's Coffin");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Battlegrowth", "Silvercoat Lion");
activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerA, "{3},{T}", "Silvercoat Lion");
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, "Tawnos's Coffin", 1);
assertTapped("Tawnos's Coffin", false);
assertGraveyardCount(playerB, "Battlegrowth", 1);
assertPermanentCount(playerB, "Silvercoat Lion", 1);
assertPowerToughness(playerB, "Silvercoat Lion", 3, 3);
}
@Test
public void testExileAndReturnWithCountersAndAuras() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 7);
// You may choose not to untap Tawnos's Coffin during your untap step.
// {3}, {T}: Exile target creature and all Auras attached to it. Note the number and kind of counters that were on that creature.
// When Tawnos's Coffin leaves the battlefield or becomes untapped, return the exiled card to the battlefield under
// its owner's control tapped with the noted number and kind of counters on it, and if you do, return the exiled Aura
// cards to the battlefield under their owner's control attached to that permanent.
addCard(Zone.HAND, playerA, "Tawnos's Coffin"); // Artifact {4}
// Whenever an Aura becomes attached to Bramble Elemental, put two 1/1 green Saproling creature tokens onto the battlefield.
addCard(Zone.BATTLEFIELD, playerB, "Bramble Elemental"); // Creature 4/4
// Put a +1/+1 counter on target creature.
addCard(Zone.BATTLEFIELD, playerB, "Forest", 5);
addCard(Zone.HAND, playerB, "Battlegrowth"); // Instant {G}
// Enchant creature (Target a creature as you cast this. This card enters the battlefield attached to that creature.)
// Enchanted creature gets +1/+1 for each Forest you control.
addCard(Zone.HAND, playerB, "Blanchwood Armor"); // Enchantment Aura {2}{G}
// Enchant creature
// When Frog Tongue enters the battlefield, draw a card.
// Enchanted creature has reach. (It can block creatures with flying.)
addCard(Zone.HAND, playerB, "Frog Tongue"); // Enchantment Aura {G}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Tawnos's Coffin");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Battlegrowth", "Bramble Elemental");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Blanchwood Armor", "Bramble Elemental");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Frog Tongue", "Bramble Elemental");
activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerA, "{3},{T}", "Bramble Elemental");
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPermanentCount(playerA, "Tawnos's Coffin", 1);
assertTapped("Tawnos's Coffin", false);
assertGraveyardCount(playerB, "Battlegrowth", 1);
assertPermanentCount(playerB, "Bramble Elemental", 1);
assertGraveyardCount(playerB, "Blanchwood Armor", 0);
assertPermanentCount(playerB, "Blanchwood Armor", 1);
assertGraveyardCount(playerB, "Frog Tongue", 0);
assertPermanentCount(playerB, "Frog Tongue", 1);
assertPermanentCount(playerB, "Saproling", 8);
assertPowerToughness(playerB, "Bramble Elemental", 10, 10);
assertAbility(playerB, "Bramble Elemental", ReachAbility.getInstance(), true);
assertHandCount(playerB, 3); // 1 from Turn 2 and 2 from Frog Tongue
}
}

View file

@ -1,4 +1,4 @@
/*
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
@ -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.abilities.common;
import mage.constants.Zone;
@ -38,15 +37,22 @@ import mage.game.events.GameEvent;
*
* @author LevelX2
*/
public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
private boolean enrage;
public DealtDamageToSourceTriggeredAbility(Zone zone, Effect effect, boolean optional) {
this(zone, effect, optional, false);
}
public DealtDamageToSourceTriggeredAbility(Zone zone, Effect effect, boolean optional, boolean enrage) {
super(zone, effect, optional);
this.enrage = enrage;
}
public DealtDamageToSourceTriggeredAbility(final DealtDamageToSourceTriggeredAbility ability) {
super(ability);
this.enrage = ability.enrage;
}
@Override
@ -63,7 +69,7 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(getSourceId())) {
for (Effect effect : this.getEffects()) {
effect.setValue("damage", event.getAmount());
effect.setValue("damage", event.getAmount());
}
return true;
}
@ -72,6 +78,6 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return "Whenever {this} is dealt damage, " + super.getRule();
return (enrage ? "<i>Enrage</i> - " : "") + "Whenever {this} is dealt damage, " + super.getRule();
}
}

View file

@ -1,61 +0,0 @@
/*
* Copyright 2011 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.decks;
import java.util.Map;
import java.util.Map.Entry;
import mage.game.GameException;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class InvalidDeckException extends GameException {
Map<String, String> invalid;
public InvalidDeckException (String message, Map<String, String> invalid) {
super(message);
this.invalid = invalid;
}
public Map<String, String> getInvalid() {
return invalid;
}
@Override
public String getMessage() {
StringBuilder sb = new StringBuilder();
sb.append(super.getMessage()).append('\n');
for (Entry<String, String> entry: invalid.entrySet()) {
sb.append(entry.getKey()).append(' ').append(entry.getValue()).append('\n');
}
return sb.toString();
}
}

View file

@ -69,22 +69,22 @@ public final class StaticFilters {
public static final FilterPermanent FILTER_ATTACKING_CREATURES = new FilterCreaturePermanent("attacking creatures");
public static final FilterPermanent FILTER_AURA = new FilterPermanent();
public static final FilterPermanent FILTER_EQUIPMENT = new FilterPermanent();
public static final FilterPermanent FILTER_FORTIFICATION = new FilterPermanent();
public static final FilterPermanent FILTER_LEGENDARY = new FilterPermanent();
public static final FilterPermanent FILTER_PERMANENT_AURA = new FilterPermanent();
public static final FilterPermanent FILTER_PERMANENT_EQUIPMENT = new FilterPermanent();
public static final FilterPermanent FILTER_PERMANENT_FORTIFICATION = new FilterPermanent();
public static final FilterPermanent FILTER_PERMANENT_LEGENDARY = new FilterPermanent();
static {
FILTER_AURA.add(new CardTypePredicate(CardType.ENCHANTMENT));
FILTER_AURA.add(new SubtypePredicate(SubType.AURA));
FILTER_PERMANENT_AURA.add(new CardTypePredicate(CardType.ENCHANTMENT));
FILTER_PERMANENT_AURA.add(new SubtypePredicate(SubType.AURA));
FILTER_EQUIPMENT.add(new CardTypePredicate(CardType.ARTIFACT));
FILTER_EQUIPMENT.add(new SubtypePredicate(SubType.EQUIPMENT));
FILTER_PERMANENT_EQUIPMENT.add(new CardTypePredicate(CardType.ARTIFACT));
FILTER_PERMANENT_EQUIPMENT.add(new SubtypePredicate(SubType.EQUIPMENT));
FILTER_FORTIFICATION.add(new CardTypePredicate(CardType.ARTIFACT));
FILTER_FORTIFICATION.add(new SubtypePredicate(SubType.FORTIFICATION));
FILTER_PERMANENT_FORTIFICATION.add(new CardTypePredicate(CardType.ARTIFACT));
FILTER_PERMANENT_FORTIFICATION.add(new SubtypePredicate(SubType.FORTIFICATION));
FILTER_LEGENDARY.add(new SupertypePredicate(SuperType.LEGENDARY));
FILTER_PERMANENT_LEGENDARY.add(new SupertypePredicate(SuperType.LEGENDARY));
}
static {

View file

@ -1774,7 +1774,7 @@ public abstract class GameImpl implements Game, Serializable {
if (perm.isWorld()) {
worldEnchantment.add(perm);
}
if (StaticFilters.FILTER_AURA.match(perm, this)) {
if (StaticFilters.FILTER_PERMANENT_AURA.match(perm, this)) {
//20091005 - 704.5n, 702.14c
if (perm.getAttachedTo() == null) {
Card card = this.getCard(perm.getId());
@ -1852,10 +1852,10 @@ public abstract class GameImpl implements Game, Serializable {
}
}
}
if (this.getState().isLegendaryRuleActive() && StaticFilters.FILTER_LEGENDARY.match(perm, this)) {
if (this.getState().isLegendaryRuleActive() && StaticFilters.FILTER_PERMANENT_LEGENDARY.match(perm, this)) {
legendary.add(perm);
}
if (StaticFilters.FILTER_EQUIPMENT.match(perm, this)) {
if (StaticFilters.FILTER_PERMANENT_EQUIPMENT.match(perm, this)) {
//20091005 - 704.5p, 702.14d
if (perm.getAttachedTo() != null) {
Permanent attachedTo = getPermanent(perm.getAttachedTo());
@ -1880,7 +1880,7 @@ public abstract class GameImpl implements Game, Serializable {
}
}
}
if (StaticFilters.FILTER_FORTIFICATION.match(perm, this)) {
if (StaticFilters.FILTER_PERMANENT_FORTIFICATION.match(perm, this)) {
if (perm.getAttachedTo() != null) {
Permanent land = getPermanent(perm.getAttachedTo());
if (land == null || !land.getAttachments().contains(perm.getId())) {