diff --git a/.gitignore b/.gitignore index ca85c840055..5b29a556792 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ Mage.Server.Plugins/Mage.Deck.Limited/target Mage.Server.Plugins/Mage.Game.CommanderDuel/target Mage.Server.Plugins/Mage.Game.CommanderFreeForAll/target/ Mage.Server.Plugins/Mage.Game.FreeForAll/target +Mage.Server.Plugins/Mage.Game.MomirDuel/target Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/target Mage.Server.Plugins/Mage.Game.TwoPlayerDuel/target Mage.Server.Plugins/Mage.Player.AI.DraftBot/target diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index ff350409715..71224880943 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -802,7 +802,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { } private void btnCommandZoneActionPerformed(java.awt.event.ActionEvent evt) { - DialogManager.getManager(gameId).showEmblemsDialog(CardsViewUtil.convertCommandObject(player.getCommadObjectList()), bigCard, gameId); + DialogManager.getManager(gameId).showEmblemsDialog(CardsViewUtil.convertCommandObject(player.getCommandObjectList()), bigCard, gameId); } private void btnExileZoneActionPerformed(java.awt.event.ActionEvent evt) { diff --git a/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java b/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java index 733a87391cb..3bb8d409810 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java +++ b/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java @@ -30,7 +30,6 @@ import net.xeoh.plugins.base.PluginManager; import net.xeoh.plugins.base.impl.PluginManagerFactory; import org.apache.log4j.Logger; import org.mage.plugins.card.CardPluginImpl; -import org.mage.plugins.theme.ThemePluginImpl; public class Plugins implements MagePlugins { @@ -58,8 +57,7 @@ public class Plugins implements MagePlugins { pm.addPluginsFrom(new File(PLUGINS_DIRECTORY).toURI()); this.cardPlugin = new CardPluginImpl(); this.counterPlugin = pm.getPlugin(CounterPlugin.class); - //this.themePlugin = pm.getPlugin(ThemePlugin.class); - this.themePlugin = new ThemePluginImpl(); + this.themePlugin = pm.getPlugin(ThemePlugin.class); logger.info("Done."); } diff --git a/Mage.Common/src/mage/view/EmblemView.java b/Mage.Common/src/mage/view/EmblemView.java index e4971d5cecb..1681f05de90 100644 --- a/Mage.Common/src/mage/view/EmblemView.java +++ b/Mage.Common/src/mage/view/EmblemView.java @@ -28,6 +28,13 @@ public class EmblemView implements CommandObjectView, Serializable { rules = emblem.getAbilities().getRules(sourceCard.getName()); } + public EmblemView(Emblem emblem) { + id = emblem.getId(); + name = emblem.getName(); + expansionSetCode = emblem.getExpansionSetCodeForImage(); + rules = emblem.getAbilities().getRules(emblem.getName()); + } + @Override public String getExpansionSetCode() { return expansionSetCode; diff --git a/Mage.Common/src/mage/view/GameView.java b/Mage.Common/src/mage/view/GameView.java index 15731967b2c..ad27715f417 100644 --- a/Mage.Common/src/mage/view/GameView.java +++ b/Mage.Common/src/mage/view/GameView.java @@ -123,6 +123,7 @@ public class GameView implements Serializable { checkPaid(stackObject.getId(), (StackAbility) stackObject); } else if (object instanceof Emblem) { Card sourceCard = game.getCard(((Emblem) object).getSourceId()); + CardView cardView; if (sourceCard != null) { if (!sourceCard.getCardType().contains(CardType.PLANESWALKER)) { if (sourceCard.getSecondCardFace() != null) { @@ -131,11 +132,12 @@ public class GameView implements Serializable { } ((StackAbility) stackObject).setName("Emblem " + sourceCard.getName()); ((StackAbility) stackObject).setExpansionSetCode(sourceCard.getExpansionSetCode()); + cardView = new CardView(new EmblemView(((Emblem) object), sourceCard)); } else { - throw new IllegalArgumentException("Source card for emblem not found."); + cardView = new CardView(new EmblemView((Emblem) object)); } stack.put(stackObject.getId(), - new StackAbilityView(game, (StackAbility) stackObject, object.getName(), new CardView(new EmblemView(((Emblem) object), sourceCard)))); + new StackAbilityView(game, (StackAbility) stackObject, object.getName(), cardView)); checkPaid(stackObject.getId(), ((StackAbility) stackObject)); } else { if (object instanceof StackAbility) { diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index ce66a5ffbe0..51b49dc4182 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -132,6 +132,8 @@ public class PlayerView implements Serializable { } } commandList.add(new EmblemView(emblem, sourceCard)); + } else { + commandList.add(new EmblemView(emblem)); } } } else if (commandObject instanceof Commander) { @@ -229,7 +231,7 @@ public class PlayerView implements Serializable { return this.userData; } - public List getCommadObjectList() { + public List getCommandObjectList() { return commandList; } diff --git a/Mage.Plugins/Mage.Theme.Plugin/pom.xml b/Mage.Plugins/Mage.Theme.Plugin/pom.xml deleted file mode 100644 index f58f45d1d6d..00000000000 --- a/Mage.Plugins/Mage.Theme.Plugin/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - 4.0.0 - - - org.mage - mage-plugins - 1.4.4 - - - mage-theme-plugin - jar - 0.5 - Mage Theme Plugin - Contains resources for drawing background - - - - ${project.groupId} - mage-common - ${mage-version} - - - log4j - log4j - provided - - - ${project.groupId} - mage-client - 1.4.4 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - - - - - mage-theme-plugin - - diff --git a/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java b/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java deleted file mode 100644 index f2a10884a10..00000000000 --- a/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java +++ /dev/null @@ -1,210 +0,0 @@ -package org.mage.plugins.theme; - -import mage.components.ImagePanel; -import mage.interfaces.plugin.ThemePlugin; -import mage.client.dialog.PreferencesDialog; -import net.xeoh.plugins.base.annotations.PluginImplementation; -import net.xeoh.plugins.base.annotations.events.Init; -import net.xeoh.plugins.base.annotations.events.PluginLoaded; -import net.xeoh.plugins.base.annotations.meta.Author; -import org.apache.log4j.Logger; - -import javax.imageio.ImageIO; -import javax.swing.*; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.*; -import java.io.InputStream; -import java.util.Map; - -@PluginImplementation -@Author(name = "nantuko") -public class ThemePluginImpl implements ThemePlugin { - - private static final Logger log = Logger.getLogger(ThemePluginImpl.class); - private static BufferedImage background; - private List flist = new List(); - private String BackgroundDir = "plugins" + File.separator + "plugin.data" + File.separator - + "background" + File.separator; - @Init - public void init() { - } - - @PluginLoaded - public void newPlugin(ThemePlugin plugin) { - log.info(plugin.toString() + " has been loaded."); - } - - public String toString() { - return "[Theme plugin, version 0.5]"; - } - - public boolean loadimages(){ - File filedir = new File(BackgroundDir); - File[] filelist = filedir.listFiles(); - if(filelist == null) return false; - if(filelist.length == 0) return false; - for(File f:filelist){ - String filename = f.getName().toLowerCase(); - if(filename != null && (filename.endsWith(".png") || filename.endsWith(".jpg") - || filename.endsWith(".bmp"))){ - flist.add(filename); - } - } - if(flist.getItemCount() == 0) return false; - return true; - } - - public void applyInGame(Map ui) { - BufferedImage background; - try { - - if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE_DEFAULT, - "true").equals("true")){ - - background = loadbuffer_default(); - - }else if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE_RANDOM, - "true").equals("true")){ - - background = loadbuffer_random(); - - }else if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE, "") != null){ - - background = loadbuffer_selected(); - - }else{ - background = loadbuffer_default(); - } - - - - /* - if(loadimages()){ - int it = (int)Math.abs(Math.random()*(flist.getItemCount())); - filename = BackgroundDir + flist.getItem(it); - background = ImageIO.read(new File(filename)); - }else{ - filename = "/dragon.png"; - InputStream is = this.getClass().getResourceAsStream(filename); - if (is == null) - throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - background = ImageIO.read(is); - } - */ - if (background == null) { - throw new FileNotFoundException("Couldn't find background file in resources."); - } - - if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) { - ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED); - - unsetOpaque(ui.get("jSplitPane1")); - unsetOpaque(ui.get("pnlBattlefield")); - unsetOpaque(ui.get("jPanel3")); - unsetOpaque(ui.get("hand")); - unsetOpaque(ui.get("gameChatPanel")); - unsetOpaque(ui.get("userChatPanel")); - - ui.get("gamePanel").remove(ui.get("jLayeredPane")); - bgPanel.add(ui.get("jLayeredPane")); - ui.get("gamePanel").add(bgPanel); - } else { - log.error("error: no components"); - } - } catch (Exception e) { - log.error(e.getMessage(), e); - return; - } - } - - - private BufferedImage loadbuffer_default() throws IOException{ - String filename = "/dragon.png"; - BufferedImage res; - InputStream is = this.getClass().getResourceAsStream(filename); - res = ImageIO.read(is); - return res; - } - - private BufferedImage loadbuffer_random() throws IOException{ - BufferedImage res; - if(loadimages()){ - int it = (int)Math.abs(Math.random()*(flist.getItemCount())); - String filename = BackgroundDir + flist.getItem(it); - res = ImageIO.read(new File(filename)); - return res; - } - return null; - } - - private BufferedImage loadbuffer_selected() throws IOException{ - BufferedImage res; - String path = PreferencesDialog.getCachedValue(PreferencesDialog. - KEY_BATTLEFIELD_IMAGE, ""); - if(path != null){ - res = ImageIO.read(new File(path)); - return res; - } - return null; - } - - - public JComponent updateTable(Map ui) { - ImagePanel bgPanel = createImagePanelInstance(); - - unsetOpaque(ui.get("jScrollPane1")); - unsetOpaque(ui.get("jPanel1")); - unsetOpaque(ui.get("tablesPanel")); - JComponent viewport = ui.get("jScrollPane1ViewPort"); - if (viewport != null) { - viewport.setBackground(new Color(255,255,255,50)); - } - return bgPanel; - } - - private ImagePanel createImagePanelInstance() { - if (background == null) { - synchronized (ThemePluginImpl.class) { - if (background == null) { - String filename = "/background.png"; - try { - if(PreferencesDialog.getCachedValue(PreferencesDialog. - KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")){ - InputStream is = this.getClass().getResourceAsStream(filename); - if (is == null) - throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - background = ImageIO.read(is); - }else if(PreferencesDialog.getCachedValue(PreferencesDialog. - KEY_BACKGROUND_IMAGE, "") != null){ - String path = PreferencesDialog.getCachedValue(PreferencesDialog. - KEY_BATTLEFIELD_IMAGE, ""); - if(path != null){ - background = ImageIO.read(new File(path)); - }else{ - InputStream is = this.getClass().getResourceAsStream(filename); - if (is == null) - throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - background = ImageIO.read(is); - } - } - - if (background == null) - throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - } catch (Exception e) { - log.error(e.getMessage(), e); - return null; - } - } - } - } - return new ImagePanel(background, ImagePanel.SCALED); - } - - private void unsetOpaque(JComponent c) { - if (c != null) { - c.setOpaque(false); - } - } -} diff --git a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/background.png b/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/background.png deleted file mode 100644 index 01acc151f2c..00000000000 Binary files a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/background.png and /dev/null differ diff --git a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/dk_gray.jpg b/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/dk_gray.jpg deleted file mode 100644 index 2e0776d6068..00000000000 Binary files a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/dk_gray.jpg and /dev/null differ diff --git a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/dragon.png b/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/dragon.png deleted file mode 100644 index 634f56c21c8..00000000000 Binary files a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/dragon.png and /dev/null differ diff --git a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/green.jpg b/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/green.jpg deleted file mode 100644 index f5705253297..00000000000 Binary files a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/green.jpg and /dev/null differ diff --git a/Mage.Plugins/pom.xml b/Mage.Plugins/pom.xml index e1a1ba632b5..62bbc48c9c2 100644 --- a/Mage.Plugins/pom.xml +++ b/Mage.Plugins/pom.xml @@ -16,7 +16,6 @@ Mage Plugins POM - Mage.Theme.Plugin Mage.Counter.Plugin diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Momir.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Momir.java new file mode 100644 index 00000000000..48a05c3c81e --- /dev/null +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Momir.java @@ -0,0 +1,70 @@ +/* + * 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.deck; + +import mage.cards.Card; +import mage.cards.decks.Deck; +import mage.cards.decks.DeckValidator; + +import java.util.*; + +/** + * + * @author nigelzor + */ +public class Momir extends DeckValidator { + + public Momir() { + this("Momir Basic"); + } + + public Momir(String name) { + super(name); + } + + @Override + public boolean validate(Deck deck) { + boolean valid = true; + + if (deck.getCards().size() != 60) { + invalid.put("Deck", "Must contain 60 cards: has " + deck.getCards().size() + " cards"); + valid = false; + } + + List basicLandNames = new ArrayList<>(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains")); + for (Card card : deck.getCards()) { + if (!basicLandNames.contains(card.getName())) { + invalid.put(card.getName(), "Only basic lands are allowed"); + valid = false; + } + } + + return valid; + } + +} diff --git a/Mage.Server.Plugins/Mage.Game.MomirDuel/pom.xml b/Mage.Server.Plugins/Mage.Game.MomirDuel/pom.xml new file mode 100644 index 00000000000..295da532669 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.MomirDuel/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + + org.mage + mage-server-plugins + 1.4.4 + + + mage-game-momirduel + jar + Mage Game Momir Basic Two Player + + + + ${project.groupId} + mage + ${project.version} + + + + + src + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + maven-resources-plugin + + UTF-8 + + + + + + mage-game-momirduel + + + + + diff --git a/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuel.java b/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuel.java new file mode 100644 index 00000000000..e34dd81d2a9 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuel.java @@ -0,0 +1,159 @@ +/* + * 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.game; + +import mage.abilities.Ability; +import mage.abilities.common.LimitedTimesPerTurnActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.DiscardCardCost; +import mage.abilities.costs.mana.VariableManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.InfoEffect; +import mage.cards.Card; +import mage.cards.repository.CardCriteria; +import mage.cards.repository.CardInfo; +import mage.cards.repository.CardRepository; +import mage.constants.*; +import mage.game.command.Emblem; +import mage.game.match.MatchType; +import mage.game.permanent.token.EmptyToken; +import mage.game.turn.TurnMod; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.*; + +/** + * + * @author nigelzor + */ +public class MomirDuel extends GameImpl { + + public MomirDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) { + super(attackOption, range, freeMulligans, startLife); + } + + public MomirDuel(final MomirDuel game) { + super(game); + } + + @Override + public MatchType getGameType() { + return new MomirDuelType(); + } + + @Override + public int getNumPlayers() { + return 2; + } + + @Override + protected void init(UUID choosingPlayerId) { + Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Vanguard effects")); + for (UUID playerId : state.getPlayerList(startingPlayerId)) { + Player player = getPlayer(playerId); + if (player != null) { + addEmblem(new MomirEmblem(), ability, playerId); + } + } + getState().addAbility(ability, null); + super.init(choosingPlayerId); + state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW)); + } + + @Override + public Set getOpponents(UUID playerId) { + Set opponents = new HashSet<>(); + for (UUID opponentId: this.getPlayer(playerId).getInRange()) { + if (!opponentId.equals(playerId)) { + opponents.add(opponentId); + } + } + return opponents; + } + + @Override + public boolean isOpponent(Player player, UUID playerToCheck) { + return !player.getId().equals(playerToCheck); + } + + @Override + public MomirDuel copy() { + return new MomirDuel(this); + } + +} + +// faking Vanguard as an Emblem; need to come back to this and add a new type of CommandObject +class MomirEmblem extends Emblem { + + public MomirEmblem() { + setName("Momir Vig, Simic Visionary"); + + // {X}, Discard a card: Put a token into play as a copy of a random creature card with converted mana cost X. Play this ability only any time you could play a sorcery and only once each turn. + LimitedTimesPerTurnActivatedAbility ability = new LimitedTimesPerTurnActivatedAbility(Zone.COMMAND, new MomirEffect(), new VariableManaCost()); + ability.addCost(new DiscardCardCost()); + ability.setTiming(TimingRule.SORCERY); + this.getAbilities().add(ability); + + } +} + +class MomirEffect extends OneShotEffect { + + private static final Random rnd = new Random(); + + public MomirEffect() { + super(Outcome.PutCreatureInPlay); + } + + public MomirEffect(MomirEffect effect) { + super(effect); + staticText = "Put a token into play as a copy of a random creature card with converted mana cost X"; + } + + @Override + public MomirEffect copy() { + return new MomirEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int value = source.getManaCostsToPay().getX(); + // should this be random across card names, or card printings? + CardCriteria criteria = new CardCriteria().types(CardType.CREATURE).convertedManaCost(value); + List options = CardRepository.instance.findCards(criteria); + if (options != null && !options.isEmpty()) { + Card card = options.get(rnd.nextInt(options.size())).getCard(); + EmptyToken token = new EmptyToken(); + CardUtil.copyTo(token).from(card); + token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false); + } + return true; + } +} \ No newline at end of file diff --git a/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuelMatch.java b/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuelMatch.java new file mode 100644 index 00000000000..9f91e749f05 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuelMatch.java @@ -0,0 +1,55 @@ +/* + * 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.game; + +import mage.game.match.MatchImpl; +import mage.game.match.MatchOptions; + +/** + * + * @author nigelzor + */ +public class MomirDuelMatch extends MatchImpl { + + public MomirDuelMatch(MatchOptions options) { + super(options); + } + + @Override + public void startGame() throws GameException { + // Momir Vig, Simic Visionary gives +4 starting life + int startLife = 24; + + MomirDuel game = new MomirDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife); + game.setStartMessage(this.createGameStartMessage()); + + this.initGame(game); + games.add(game); + } + +} diff --git a/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuelType.java b/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuelType.java new file mode 100644 index 00000000000..4ec7925477f --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.MomirDuel/src/mage/game/MomirDuelType.java @@ -0,0 +1,57 @@ +/* + * 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.game; + +import mage.game.match.MatchType; + +/** + * + * @author nigelzor + */ +public class MomirDuelType extends MatchType { + + public MomirDuelType() { + this.name = "Momir Basic Two Player Duel"; + this.maxPlayers = 2; + this.minPlayers = 2; + this.numTeams = 0; + this.useAttackOption = false; + this.useRange = false; + this.sideboardingAllowed = true; + } + + protected MomirDuelType(final MomirDuelType matchType){ + super(matchType); + } + + @Override + public MomirDuelType copy() { + return new MomirDuelType(this); + } + +} diff --git a/Mage.Server.Plugins/pom.xml b/Mage.Server.Plugins/pom.xml index 590c8fbc00d..c7d32cb1d32 100644 --- a/Mage.Server.Plugins/pom.xml +++ b/Mage.Server.Plugins/pom.xml @@ -17,9 +17,10 @@ Mage.Deck.Constructed Mage.Deck.Limited - Mage.Game.CommanderDuel + Mage.Game.CommanderDuel Mage.Game.CommanderFreeForAll Mage.Game.FreeForAll + Mage.Game.MomirDuel Mage.Game.TinyLeadersDuel Mage.Game.TwoPlayerDuel Mage.Player.AI diff --git a/Mage.Server/config/config.xml b/Mage.Server/config/config.xml index ea32d103198..eb2c57ef452 100644 --- a/Mage.Server/config/config.xml +++ b/Mage.Server/config/config.xml @@ -49,6 +49,7 @@ + @@ -94,6 +95,7 @@ + diff --git a/Mage.Server/pom.xml b/Mage.Server/pom.xml index 7490945b1e7..d91918733b3 100644 --- a/Mage.Server/pom.xml +++ b/Mage.Server/pom.xml @@ -142,6 +142,12 @@ ${project.version} runtime + + ${project.groupId} + mage-game-momirduel + ${project.version} + runtime + diff --git a/Mage.Server/release/config/config.xml b/Mage.Server/release/config/config.xml index b4b7bfe6c78..77ff19bb4bf 100644 --- a/Mage.Server/release/config/config.xml +++ b/Mage.Server/release/config/config.xml @@ -28,6 +28,7 @@ + @@ -73,6 +74,7 @@ + diff --git a/Mage.Server/src/main/java/mage/server/Main.java b/Mage.Server/src/main/java/mage/server/Main.java index d9f8aec6c2b..7e83044274d 100644 --- a/Mage.Server/src/main/java/mage/server/Main.java +++ b/Mage.Server/src/main/java/mage/server/Main.java @@ -166,12 +166,9 @@ public class Main { else { logger.fatal("Unable to start MAGE server - another server is already started"); } - } catch (IOException ex) { - logger.fatal("Failed to start server - " + connection.toString(), ex); } catch (Exception ex) { logger.fatal("Failed to start server - " + connection.toString(), ex); } - } static void initStatistics() { diff --git a/Mage/src/mage/abilities/common/LimitedTimesPerTurnActivatedAbility.java b/Mage/src/mage/abilities/common/LimitedTimesPerTurnActivatedAbility.java index 53d40539031..a415bb19a18 100644 --- a/Mage/src/mage/abilities/common/LimitedTimesPerTurnActivatedAbility.java +++ b/Mage/src/mage/abilities/common/LimitedTimesPerTurnActivatedAbility.java @@ -71,16 +71,17 @@ public class LimitedTimesPerTurnActivatedAbility extends ActivatedAbilityImpl { @Override public boolean canActivate(UUID playerId, Game game) { - if (super.canActivate(playerId, game)) { - ActivationInfo activationInfo = getActivationInfo(game); - return activationInfo == null || activationInfo.turnNum != game.getTurnNum() || activationInfo.activationCounter < maxActivationsPerTurn; - } - return false; + return super.canActivate(playerId, game) && hasMoreActivationsThisTurn(game); + } + + private boolean hasMoreActivationsThisTurn(Game game) { + ActivationInfo activationInfo = getActivationInfo(game); + return activationInfo == null || activationInfo.turnNum != game.getTurnNum() || activationInfo.activationCounter < maxActivationsPerTurn; } @Override public boolean activate(Game game, boolean noMana) { - if (canActivate(this.controllerId, game)) { + if (hasMoreActivationsThisTurn(game)) { if (super.activate(game, noMana)) { ActivationInfo activationInfo = getActivationInfo(game); if (activationInfo == null) { diff --git a/Mage/src/mage/cards/repository/CardCriteria.java b/Mage/src/mage/cards/repository/CardCriteria.java index 3f33e19da69..38e25425db6 100644 --- a/Mage/src/mage/cards/repository/CardCriteria.java +++ b/Mage/src/mage/cards/repository/CardCriteria.java @@ -59,6 +59,7 @@ public class CardCriteria { private boolean red; private boolean white; private boolean colorless; + private Integer convertedManaCost; private String sortBy; private Long start; private Long count; @@ -173,6 +174,11 @@ public class CardCriteria { return this; } + public CardCriteria convertedManaCost(Integer convertedManaCost) { + this.convertedManaCost = convertedManaCost; + return this; + } + public CardCriteria maxCardNumber(int maxCardNumber) { this.maxCardNumber = maxCardNumber; return this; @@ -248,6 +254,11 @@ public class CardCriteria { clausesCount++; } + if (convertedManaCost != null) { + where.eq("convertedManaCost", convertedManaCost); + clausesCount++; + } + if (!black || !blue || !green || !red || !white || !colorless) { int colorClauses = 0; if (black) {