Merge origin/master

This commit is contained in:
fireshoes 2015-06-22 18:47:51 -05:00
commit cda11b280c
14 changed files with 384 additions and 105 deletions

View file

@ -34,20 +34,31 @@
package mage.client.cards;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil;
import mage.client.util.Config;
import mage.view.*;
import mage.view.CardView;
import mage.view.CardsView;
import mage.view.PermanentView;
import mage.view.SimpleCardsView;
import mage.view.StackAbilityView;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardPanel;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.util.*;
import java.util.Map.Entry;
/**
*
* @author BetaSteward_at_googlemail.com
@ -58,7 +69,7 @@ public class Cards extends javax.swing.JPanel {
private final Map<UUID, MageCard> cards = new LinkedHashMap<>();
private boolean dontDisplayTapped = false;
private static final int GAP_X = 5;
private static final int GAP_X = 0;
private String zone;
private static final Border emptyBorder = new EmptyBorder(0,0,0,0);

View file

@ -20,7 +20,7 @@ import java.util.UUID;
public class DialogManager extends JComponent implements MouseListener,
MouseMotionListener {
private final static Map<UUID, DialogManager> dialogManagers = new HashMap<UUID, DialogManager>();
private final static Map<UUID, DialogManager> dialogManagers = new HashMap<>();
public static DialogManager getManager(UUID gameId) {
if (!dialogManagers.containsKey(gameId)) {

View file

@ -23,7 +23,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cards" alignment="1" pref="418" max="32767" attributes="0"/>
<Component id="cards" alignment="1" pref="239" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">

View file

@ -34,16 +34,19 @@
package mage.client.dialog;
import static com.sun.java.accessibility.util.AWTEventMonitor.addWindowListener;
import java.awt.Point;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyVetoException;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
import mage.client.cards.BigCard;
import mage.client.util.Config;
import mage.client.util.ImageHelper;
import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
import mage.view.CardsView;
@ -57,17 +60,19 @@ import org.mage.plugins.card.utils.impl.ImageManagerImpl;
*/
public class CardInfoWindowDialog extends MageDialog {
public static enum ShowType { REVEAL, LOOKED_AT, EXILE, OTHER };
public static enum ShowType { REVEAL, LOOKED_AT, EXILE, GRAVEYARD, OTHER };
private ShowType showType;
private boolean positioned;
private String name;
public CardInfoWindowDialog(ShowType showType, String name) {
this.name = name;
this.title = name;
this.showType = showType;
this.positioned = false;
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
this.setModal(false);
switch(this.showType) {
case LOOKED_AT:
@ -78,6 +83,18 @@ public class CardInfoWindowDialog extends MageDialog {
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getRevealedImage()));
this.setClosable(true);
break;
case GRAVEYARD:
this.setFrameIcon(new ImageIcon(ImageHelper.getImageFromResources("/info/grave.png")));
this.setIconifiable(false);
this.setClosable(true);
this.setDefaultCloseOperation(HIDE_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
CardInfoWindowDialog.this.hideDialog();
}
});
break;
case EXILE:
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getExileImage()));
break;
@ -92,71 +109,37 @@ public class CardInfoWindowDialog extends MageDialog {
}
public void loadCards(SimpleCardsView showCards, BigCard bigCard, UUID gameId) {
boolean changed = cards.loadCards(showCards, bigCard, gameId);
if (showCards.size() > 0) {
show();
if (changed) {
try {
if (!positioned) {
this.setIcon(false);
firstWindowPosition();
}
} catch (PropertyVetoException ex) {
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
else {
this.hideDialog();
}
cards.loadCards(showCards, bigCard, gameId);
showAndPositionWindow();
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
boolean changed = cards.loadCards(showCards, bigCard, gameId, null);
if (showCards.size() > 0) {
show();
if (changed) {
try {
if (!positioned) {
this.setIcon(false);
firstWindowPosition();
} else {
}
} catch (PropertyVetoException ex) {
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
cards.loadCards(showCards, bigCard, gameId, null);
if (showType.equals(ShowType.GRAVEYARD)) {
setTitle(name + "'s Graveyard (" + showCards.size() + ")");
this.setTitelBarToolTip(name);
}
showAndPositionWindow();
}
}
else {
this.hideDialog();
}
}
private void firstWindowPosition() {
private void showAndPositionWindow() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!positioned) {
int width = CardInfoWindowDialog.this.getWidth();
int height = CardInfoWindowDialog.this.getHeight();
if (width > 0 && height > 0) {
positioned = true;
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
if (!positioned) {
positioned = true;
int xPos = centered.x / 2;
int yPos = centered.y / 2;
CardInfoWindowDialog.this.setLocation(xPos, yPos);
show();
}
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, CardInfoWindowDialog.this);
CardInfoWindowDialog.this.show();
}
}
// ShowCardsDialog.this.setVisible(true);
}
});
}
@ -197,7 +180,7 @@ public class CardInfoWindowDialog extends MageDialog {
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cards, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
.addComponent(cards, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

View file

@ -148,6 +148,8 @@ public final class GamePanel extends javax.swing.JPanel {
private final Map<UUID, CardInfoWindowDialog> exiles = new HashMap<>();
private final Map<String, CardInfoWindowDialog> revealed = new HashMap<>();
private final Map<String, CardInfoWindowDialog> lookedAt = new HashMap<>();
private final Map<String, CardInfoWindowDialog> graveyardWindows = new HashMap<>();
private final Map<String, CardsView> graveyards = new HashMap<>();
private final ArrayList<ShowCardsDialog> pickTarget = new ArrayList<>();
private UUID gameId;
private UUID playerId; // playerId of the player
@ -261,6 +263,10 @@ public final class GamePanel extends javax.swing.JPanel {
exileDialog.cleanUp();
exileDialog.removeDialog();
}
for (CardInfoWindowDialog graveyardDialog: graveyardWindows.values()) {
graveyardDialog.cleanUp();
graveyardDialog.removeDialog();
}
for (CardInfoWindowDialog revealDialog: revealed.values()) {
revealDialog.cleanUp();
revealDialog.removeDialog();
@ -650,6 +656,17 @@ public final class GamePanel extends javax.swing.JPanel {
if (player.getPlayerId().equals(playerId)) {
updateSkipButtons(player.isPassedTurn(), player.isPassedUntilEndOfTurn(), player.isPassedUntilNextMain(), player.isPassedAllTurns(), player.isPassedUntilStackResolved());
}
// update open or remove closed graveyard windows
graveyards.put(player.getName(), player.getGraveyard());
if (graveyardWindows.containsKey(player.getName())) {
CardInfoWindowDialog cardInfoWindowDialog = graveyardWindows.get(player.getName());
if (cardInfoWindowDialog.isClosed()) {
graveyardWindows.remove(player.getName());
} else {
cardInfoWindowDialog.loadCards(player.getGraveyard(), bigCard, gameId);
}
}
} else {
logger.warn("Couldn't find player.");
logger.warn(" uuid:" + player.getPlayerId());
@ -691,6 +708,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
exiles.get(exile.getId()).loadCards(exile, bigCard, gameId);
}
showRevealed(game);
showLookedAt(game);
if (game.getCombat().size() > 0) {
@ -808,6 +826,24 @@ public final class GamePanel extends javax.swing.JPanel {
}
}
public void openGraveyardWindow(String playerName) {
if(graveyardWindows.containsKey(playerName)) {
CardInfoWindowDialog cardInfoWindowDialog = graveyardWindows.get(playerName);
if (cardInfoWindowDialog.isVisible()) {
cardInfoWindowDialog.hideDialog();
} else {
cardInfoWindowDialog.show();
}
// if (!cardInfoWindowDialog.isClosed()) {
return;
// }
}
CardInfoWindowDialog newGraveyard = new CardInfoWindowDialog(ShowType.GRAVEYARD, playerName);
graveyardWindows.put(playerName, newGraveyard);
MageFrame.getDesktop().add(newGraveyard, JLayeredPane.MODAL_LAYER);
newGraveyard.loadCards(graveyards.get(playerName), bigCard, gameId);
}
private void showRevealed(GameView game) {
for (RevealedView revealView: game.getRevealed()) {
handleGameInfoWindow(revealed, ShowType.REVEAL, revealView.getName(), revealView.getCards());

View file

@ -226,7 +226,7 @@ public class HelperPanel extends JPanel {
if (message.length() < this.getWidth() / 10) {
message = getSmallText(message);
} else {
message = "Use ability?" + getSmallText(message.substring(this.getWidth() / 10));
message = "Use ability?" + getSmallText(message.substring(0, this.getWidth() / 10));
}
}
textArea.setText(message);

View file

@ -34,6 +34,28 @@
package mage.client.game;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import mage.MageException;
import mage.cards.MageCard;
import mage.cards.action.ActionCallback;
@ -60,20 +82,6 @@ import mage.view.ManaPoolView;
import mage.view.PlayerView;
import org.mage.card.arcane.ManaSymbols;
import javax.swing.*;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
/**
* Enhanced player pane.
*
@ -787,11 +795,12 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
MageFrame.getGame(gameId).openGraveyardWindow(player.getName());
/*if (graveyard == null) {
graveyard = new ShowCardsDialog();
}*/
//graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false);
DialogManager.getManager(gameId).showGraveyardDialog(player.getGraveyard(), bigCard, gameId);
// DialogManager.getManager(gameId).showGraveyardDialog(player.getGraveyard(), bigCard, gameId);
}
private void btnCommandZoneActionPerformed(java.awt.event.ActionEvent evt) {

View file

@ -0,0 +1,68 @@
/*
* 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.sets.apocalypse;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.GreenManaAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
/**
*
* @author EvilGeek
*/
public class UrborgElf extends CardImpl {
public UrborgElf(UUID ownerId) {
super(ownerId, 90, "Urborg Elf", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{G}");
this.expansionSetCode = "APC";
this.subtype.add("Elf");
this.subtype.add("Druid");
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// {tap}: Add {G}, {U}, or {B} to your mana pool.
this.addAbility(new GreenManaAbility());
this.addAbility(new BlueManaAbility());
this.addAbility(new BlackManaAbility());
}
public UrborgElf(final UrborgElf card) {
super(card);
}
@Override
public UrborgElf copy() {
return new UrborgElf(this);
}
}

View file

@ -28,22 +28,17 @@
package mage.sets.judgment;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.common.DiscardTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInHand;
/**
*
@ -55,7 +50,6 @@ public class Browbeat extends CardImpl {
super(ownerId, 82, "Browbeat", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{R}");
this.expansionSetCode = "JUD";
// Any player may have Browbeat deal 5 damage to him or her. If no one does, target player draws three cards.
this.getSpellAbility().addEffect(new BrowbeatDrawEffect());
this.getSpellAbility().addTarget(new TargetPlayer());
@ -75,6 +69,7 @@ class BrowbeatDrawEffect extends OneShotEffect {
public BrowbeatDrawEffect() {
super(Outcome.DrawCard);
staticText = "Any player may have {source} deal 5 damage to him or her. If no one does, target player draws three cards.";
}
public BrowbeatDrawEffect(final BrowbeatDrawEffect effect) {
@ -88,6 +83,10 @@ class BrowbeatDrawEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
StackObject spell = null;
for(StackObject object : game.getStack()){
if(object instanceof Spell && object.getSourceId().equals(source.getSourceId())){
@ -96,12 +95,12 @@ class BrowbeatDrawEffect extends OneShotEffect {
}
if(spell != null){
boolean drawCards = true;
for(UUID uuid : game.getPlayerList()){
Player player = game.getPlayer(uuid);
if(player != null && player.chooseUse(Outcome.Detriment, "Have " + spell.getName() + " deal 5 damage to you?", game)){
for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)){
Player player = game.getPlayer(playerId);
if (player != null && player.chooseUse(Outcome.Detriment, "Have " + spell.getLogName() + " deal 5 damage to you?", game)){
drawCards = false;
player.damage(5, source.getSourceId(), game, false, true);
game.informPlayers(player.getLogName() + " has " + spell.getName() + " deal 5 to him or her");
game.informPlayers(player.getLogName() + " has " + spell.getLogName() + " deal 5 to him or her");
}
}
if (drawCards) {
@ -116,11 +115,4 @@ class BrowbeatDrawEffect extends OneShotEffect {
return false;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return "Any player may have {source} deal 5 damage to him or her. If no one does, target player draws three cards.";
}
}

View file

@ -0,0 +1,85 @@
/*
* 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.sets.magicorigins;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.keyword.ReachAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AttackingPredicate;
/**
*
* @author emerald000
*/
public class DwynenGiltLeafDaen extends CardImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Elf", "attacking Elf you control");
static {
filter.add(new AttackingPredicate());
}
public DwynenGiltLeafDaen(UUID ownerId) {
super(ownerId, 172, "Dwynen, Gilt-Leaf Daen", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{G}{G}");
this.expansionSetCode = "ORI";
this.supertype.add("Legendary");
this.subtype.add("Elf");
this.subtype.add("Warrior");
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// Reach
this.addAbility(ReachAbility.getInstance());
// Other Elf creatures you control get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, new FilterCreaturePermanent("Elf", "Elf creatures"), true)));
// Whenever Dwynen, Gilt-Leaf Daen attacks, you gain 1 life for each attacking Elf you control.
this.addAbility(new AttacksTriggeredAbility(new GainLifeEffect(new PermanentsOnBattlefieldCount(filter)), false));
}
public DwynenGiltLeafDaen(final DwynenGiltLeafDaen card) {
super(card);
}
@Override
public DwynenGiltLeafDaen copy() {
return new DwynenGiltLeafDaen(this);
}
}

View file

@ -0,0 +1,68 @@
/*
* 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.sets.magicorigins;
import java.util.UUID;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.Filter.ComparisonType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
/**
*
* @author emerald000
*/
public class ElementalBond extends CardImpl {
private static final FilterPermanent filter = new FilterControlledCreaturePermanent("creature with power 3 or greater");
static {
filter.add(new PowerPredicate(ComparisonType.GreaterThan, 2));
}
public ElementalBond(UUID ownerId) {
super(ownerId, 174, "Elemental Bond", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}");
this.expansionSetCode = "ORI";
// Whenever a creature with power 3 or greater enters the battlefield under your control, draw a card.
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(new DrawCardSourceControllerEffect(1), filter));
}
public ElementalBond(final ElementalBond card) {
super(card);
}
@Override
public ElementalBond copy() {
return new ElementalBond(this);
}
}

View file

@ -33,6 +33,7 @@ import mage.cards.Card;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
/**
@ -58,10 +59,13 @@ public class ReturnToLibrarySpellEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) {
controller.moveCardToLibraryWithInfo(spellCard, source.getSourceId(), game, Zone.STACK, toTop, true);
}
}
return true;
}
return false;

View file

@ -141,7 +141,9 @@ public class KickerAbility extends StaticAbility implements OptionalAdditionalSo
return kickerCost;
}
public void resetKicker() {
public void resetKicker(Game game, Ability source) {
String key = getActivationKey(source, "", game);
activations.remove(key);
for (OptionalAdditionalCost cost: kickerCosts) {
cost.reset();
}
@ -196,13 +198,13 @@ public class KickerAbility extends StaticAbility implements OptionalAdditionalSo
if (ability instanceof SpellAbility) {
Player player = game.getPlayer(controllerId);
if (player != null) {
this.resetKicker();
this.resetKicker(game, ability);
for (OptionalAdditionalCost kickerCost: kickerCosts) {
boolean again = true;
while (player.isInGame() && again) {
String times = "";
if (kickerCost.isRepeatable()) {
int activatedCount = kickerCost.getActivateCount();
int activatedCount = getKickedCounter(game, ability);
times = Integer.toString(activatedCount + 1) + (activatedCount == 0 ? " time ":" times ");
}
if (kickerCost.canPay(ability, sourceId, controllerId, game) &&

View file

@ -585,6 +585,27 @@ public class GameState implements Serializable, Copyable<GameState> {
newPlayerList.setCurrent(playerId);
return newPlayerList;
}
/**
* Returns a list of all active players of the game in range of playerId,
* also setting the playerId to the current player of the list.
*
* @param playerId
* @param game
* @return playerList
*/
public PlayerList getPlayersInRange(UUID playerId, Game game) {
PlayerList newPlayerList = new PlayerList();
Player currentPlayer = game.getPlayer(playerId);
if (currentPlayer != null) {
for (Player player: players.values()) {
if (!player.hasLeft()&& !player.hasLost() && currentPlayer.getInRange().contains(player.getId())) {
newPlayerList.add(player.getId());
}
}
newPlayerList.setCurrent(playerId);
}
return newPlayerList;
}
public Permanent getPermanent(UUID permanentId) {
if (permanentId != null && battlefield.containsPermanent(permanentId)) {