From d87ec679659cb0b843849412e28ac2338293be7a Mon Sep 17 00:00:00 2001 From: Justin Herlehy Date: Sat, 28 Feb 2015 19:55:32 -0800 Subject: [PATCH 1/2] Implementation of Tiny Leaders for XMage Initial Implementation of Tiny Leaders --- .gitignore | 4 +- .../src/mage/deck/TinyLeaders.java | 202 ++++++++++++++++++ .../Mage.Game.TinyLeadersDuel/pom.xml | 50 +++++ .../src/mage/game/TinyLeadersDuel.java | 64 ++++++ .../src/mage/game/TinyLeadersDuelMatch.java | 58 +++++ .../src/mage/game/TinyLeadersDuelType.java | 58 +++++ Mage.Server.Plugins/pom.xml | 11 +- Mage/src/mage/game/GameTinyLeadersImpl.java | 116 ++++++++++ pom.xml | 7 +- 9 files changed, 556 insertions(+), 14 deletions(-) create mode 100644 Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java create mode 100644 Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/pom.xml create mode 100644 Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuel.java create mode 100644 Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuelMatch.java create mode 100644 Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuelType.java create mode 100644 Mage/src/mage/game/GameTinyLeadersImpl.java diff --git a/.gitignore b/.gitignore index 53ce9bb177c..25ca0b875c2 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.FreeForAll/target Mage.Server.Plugins/Mage.Game.TwoPlayerDuel/target +Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/target Mage.Server.Plugins/Mage.Player.AI/target Mage.Server.Plugins/Mage.Player.AIMinimax/target Mage.Server.Plugins/Mage.Player.AI.MA/target @@ -82,4 +83,5 @@ Mage.Server.Plugins/Mage.Draft.8PlayerBooster/target /Mage.Server/config/ai.please.cast.this.txt /Mage.Stats/target/ -/Utils/*_unimplemented.txt \ No newline at end of file +/Utils/*_unimplemented.txt +*.netbeans_automatic_build \ No newline at end of file diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java new file mode 100644 index 00000000000..620160c0874 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java @@ -0,0 +1,202 @@ +/* + * 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 java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import mage.abilities.common.CanBeYourCommanderAbility; +import mage.cards.Card; +import mage.cards.decks.Deck; +import mage.cards.decks.DeckValidator; +import mage.constants.CardType; +import mage.filter.FilterMana; +import mage.util.CardUtil; + +/** + * + * @author JRHerlehy + */ +public class TinyLeaders extends DeckValidator { + + protected List banned = new ArrayList<>(); + protected List bannedCommander = new ArrayList<>(); + + public TinyLeaders() { + this("Tiny Leaders"); + //Banned list from tinyleaders.blodspot.ca/p/ban-list.html + //Ban list updated as of 11/08/14 + banned.add("Ancestral Recall"); + banned.add("Balance"); + banned.add("Black Lotus"); + banned.add("Channel"); + banned.add("Counterbalance"); + banned.add("Demonic Tutor"); + banned.add("Earthcraft"); + banned.add("Edric, Spymaster of Trest"); + banned.add("Fastbond"); + banned.add("Goblin Recruiter"); + banned.add("Hermit Druid"); + banned.add("Imperial Seal"); + banned.add("Library of Alexandria"); + banned.add("Karakas"); + banned.add("Mana Crypt"); + banned.add("Mana Drain"); + banned.add("Mana Vault"); + banned.add("metalworker"); + banned.add("Mind Twist"); + banned.add("Mishra's Workshop"); + banned.add("Mox Emerald"); + banned.add("Mox Jet"); + banned.add("Mox Pearl"); + banned.add("Mox Ruby"); + banned.add("Mox Sapphire"); + banned.add("Necropotence"); + banned.add("Painter's Servant"); + banned.add("Shahrazad"); + banned.add("Skullclamp"); + banned.add("Sol Ring"); + banned.add("Strip Mine"); + banned.add("Survival of the Fittest"); + banned.add("Sword of Body and Mind"); + banned.add("Time Vault"); + banned.add("Time Walk"); + banned.add("Timetwister"); + banned.add("Tolarian Academy"); + banned.add("Umezawa's Jitte"); + banned.add("Vampiric Tutor"); + banned.add("Yawgmoth's Will"); + + //Additionally, these Legendary creatures cannot be used as Commanders + bannedCommander.add("Erayo, Soratami Ascendant"); + bannedCommander.add("Rofellos, Llanowar Emissary"); + bannedCommander.add("Derevi, Empyrical Tactician"); + } + + public TinyLeaders(String name) { + super(name); + } + + /** + * + * @param deck + * @return - True if deck is valid + */ + @Override + public boolean validate(Deck deck) { + boolean valid = true; + + if (deck.getCards().size() != 49) { + invalid.put("Deck", "Must contain 49 cards: has " + deck.getCards().size() + " cards"); + valid = false; + } + + List basicLandNames = new ArrayList<>(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains", + "Snow-Covered Forest", "Snow-Covered Island", "Snow-Covered Mountain", "Snow-Covered Swamp", "Snow-Covered Plains")); + Map counts = new HashMap<>(); + countCards(counts, deck.getCards()); + countCards(counts, deck.getSideboard()); + for (Map.Entry entry : counts.entrySet()) { + if (entry.getValue() > 1) { + if (!basicLandNames.contains(entry.getKey()) && !entry.getKey().equals("Relentless Rats") && !entry.getKey().equals("Shadowborn Apostle")) { + invalid.put(entry.getKey(), "Too many: " + entry.getValue()); + valid = false; + } + } + } + + for (String bannedCard : banned) { + if (counts.containsKey(bannedCard)) { + invalid.put(bannedCard, "Banned"); + valid = false; + } + } + + if (deck.getSideboard().size() == 1) { + Card commander = (Card) deck.getSideboard().toArray()[0]; + + /** + * 905.5b - Each card must have a converted mana cost of three of less. + * Cards with {X} in their mana cost count X as zero. + * Split and double-face cards are legal only if both of their halves would be legal independently. + */ + + if (commander == null || commander.getManaCost().convertedManaCost() > 3) { + invalid.put("Commander", "Commander invalide "); + return false; + } + if ((commander.getCardType().contains(CardType.CREATURE) && commander.getSupertype().contains("Legendary")) + || (commander.getCardType().contains(CardType.PLANESWALKER) && commander.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) { + if (!bannedCommander.contains(commander.getName())) { + FilterMana color = CardUtil.getColorIdentity(commander); + for (Card card : deck.getCards()) { + if (!cardHasValideColor(color, card)) { + invalid.put(card.getName(), "Invalid color (" + commander.getName() + ")"); + valid = false; + } + + //905.5b - Converted mana cost must be 3 or less + if (card.getManaCost().convertedManaCost() > 3) { + invalid.put(card.getName(), "Invalid cost (" + card.getManaCost().convertedManaCost() + ")"); + valid = false; + } + } + } else { + invalid.put("Commander", "Commander banned (" + commander.getName() + ")"); + valid = false; + } + } else { + invalid.put("Commander", "Commander invalide (" + commander.getName() + ")"); + valid = false; + } + } else { + invalid.put("Commander", "Sideboard must contain only the commander"); + valid = false; + } + + return valid; + } + + /** + * + * @param commander FilterMana object with Color Identity of Commander set + * @param card Card to validate + * @return True if card has a valid color identity + */ + public boolean cardHasValideColor(FilterMana commander, Card card) { + FilterMana cardColor = CardUtil.getColorIdentity(card); + return !(cardColor.isBlack() && !commander.isBlack() + || cardColor.isBlue() && !commander.isBlue() + || cardColor.isGreen() && !commander.isGreen() + || cardColor.isRed() && !commander.isRed() + || cardColor.isWhite() && !commander.isWhite()); + } + +} diff --git a/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/pom.xml b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/pom.xml new file mode 100644 index 00000000000..1d6f0d0a37f --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + + org.mage + mage-server-plugins + 1.3.0 + + + mage-game-tinyleadersduel + jar + Mage Game Tiny Leaders Two Player + + + + ${project.groupId} + mage + 1.3.0 + + + + + src + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + maven-resources-plugin + + UTF-8 + + + + + + mage-game-tinyleadersduel + + + + + diff --git a/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuel.java b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuel.java new file mode 100644 index 00000000000..b8e05f76073 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuel.java @@ -0,0 +1,64 @@ +/* + * 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.constants.MultiplayerAttackOption; +import mage.constants.RangeOfInfluence; +import mage.game.match.MatchType; + +/** + * + * @author JRHerlehy + */ +public class TinyLeadersDuel extends GameTinyLeadersImpl { + + public TinyLeadersDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) { + super(attackOption, range, freeMulligans, startLife); + } + + public TinyLeadersDuel(final TinyLeadersDuel game) { + super(game); + } + + @Override + public MatchType getGameType() { + return new TinyLeadersDuelType(); + } + + @Override + public int getNumPlayers() { + return 2; + } + + @Override + public TinyLeadersDuel copy() { + return new TinyLeadersDuel(this); + } + +} diff --git a/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuelMatch.java b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuelMatch.java new file mode 100644 index 00000000000..d5b9ada2d5a --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuelMatch.java @@ -0,0 +1,58 @@ +/* + * 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 JRHerlehy + */ +public class TinyLeadersDuelMatch extends MatchImpl { + + public TinyLeadersDuelMatch(MatchOptions options) { + super(options); + } + + @Override + public void startGame() throws GameException { + //Tiny Leaders Play Rule 13: Players begin the game with 25 life. + int startLife = 25; + + TinyLeadersDuel game = new TinyLeadersDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife); + game.setStartMessage(this.createGameStartMessage()); + + //"Tucking a Tiny Leader is legal + game.setAlsoLibrary(false); + this.initGame(game); + games.add(game); + } + +} diff --git a/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuelType.java b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuelType.java new file mode 100644 index 00000000000..4c8055c8fb7 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/src/mage/game/TinyLeadersDuelType.java @@ -0,0 +1,58 @@ +/* + * 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 JRHerlehy + */ +class TinyLeadersDuelType extends MatchType { + + public TinyLeadersDuelType() { + this.name = "Tiny Leaders Two Player Duel"; + this.maxPlayers = 2; + this.minPlayers = 2; + this.numTeams = 0; + this.useAttackOption = false; + this.useRange = false; + this.sideboardingAllowed = false; + } + + protected TinyLeadersDuelType(final TinyLeadersDuelType matchType){ + super(matchType); + } + + @Override + public TinyLeadersDuelType copy() { + return new TinyLeadersDuelType(this); + } + +} diff --git a/Mage.Server.Plugins/pom.xml b/Mage.Server.Plugins/pom.xml index 42835c4d180..eb8c3742aaf 100644 --- a/Mage.Server.Plugins/pom.xml +++ b/Mage.Server.Plugins/pom.xml @@ -21,15 +21,8 @@ Mage.Game.CommanderFreeForAll Mage.Game.FreeForAll Mage.Game.TwoPlayerDuel - Mage.Player.AI - Mage.Player.AIMinimax - Mage.Player.AI.MA - Mage.Player.AIMCTS - Mage.Player.AI.DraftBot Mage.Player.Human - Mage.Tournament.BoosterDraft - Mage.Tournament.Constructed - Mage.Tournament.Sealed - + Mage.Game.TinyLeadersDuel + \ No newline at end of file diff --git a/Mage/src/mage/game/GameTinyLeadersImpl.java b/Mage/src/mage/game/GameTinyLeadersImpl.java new file mode 100644 index 00000000000..8b421f21d7a --- /dev/null +++ b/Mage/src/mage/game/GameTinyLeadersImpl.java @@ -0,0 +1,116 @@ +/* + * 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 java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.EmptyEffect; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.continious.CommanderManaReplacementEffect; +import mage.abilities.effects.common.continious.CommanderReplacementEffect; +import mage.abilities.effects.common.cost.CommanderCostModification; +import mage.cards.Card; +import mage.constants.MultiplayerAttackOption; +import mage.constants.PhaseStep; +import mage.constants.RangeOfInfluence; +import mage.constants.Zone; +import mage.game.turn.TurnMod; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * + * @author Justin + */ +public abstract class GameTinyLeadersImpl extends GameImpl{ + + protected boolean alsoLibrary; // replace also commander going to library + protected boolean startingPlayerSkipsDraw = true; + + public GameTinyLeadersImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) { + super(attackOption, range, freeMulligans, startLife); + } + + public GameTinyLeadersImpl(final GameTinyLeadersImpl game) { + super(game); + this.alsoLibrary = game.alsoLibrary; + this.startingPlayerSkipsDraw = game.startingPlayerSkipsDraw; + } + + @Override + protected void init(UUID choosingPlayerId, GameOptions gameOptions) { + Ability ability = new SimpleStaticAbility(Zone.COMMAND, new EmptyEffect("Commander effects")); + //Move tiny leader to command zone + for (UUID playerId: state.getPlayerList(startingPlayerId)) { + Player player = getPlayer(playerId); + if (player != null){ + if (player.getSideboard().size() > 0){ + Card commander = getCard((UUID)player.getSideboard().toArray()[0]); + if (commander != null) { + player.setCommanderId(commander.getId()); + commander.moveToZone(Zone.COMMAND, null, this, true); + ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoLibrary)); + ability.addEffect(new CommanderCostModification(commander.getId())); + ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander))); + getState().setValue(commander.getId() + "_castCount", 0); + } + } + } + + } + this.getState().addAbility(ability, null); + super.init(choosingPlayerId, gameOptions); + if (startingPlayerSkipsDraw) { + 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); + } + + public void setAlsoLibrary(boolean alsoLibrary) { + this.alsoLibrary = alsoLibrary; + } + +} diff --git a/pom.xml b/pom.xml index f024001d95b..bc9933a845f 100644 --- a/pom.xml +++ b/pom.xml @@ -50,17 +50,16 @@ - Mage Mage.Common - Mage.Server - Mage.Sets Mage.Client Mage.Plugins + Mage + Mage.Server + Mage.Sets Mage.Server.Plugins Mage.Server.Console Mage.Tests Mage.Updater - Mage.Stats From 3544060ada6d57b726b8aff1a7f4d6f4b68c5730 Mon Sep 17 00:00:00 2001 From: Justin Herlehy Date: Sat, 28 Feb 2015 22:03:14 -0800 Subject: [PATCH 2/2] Server Project file Configuration Changed to the Server pom file to include the Tiny Leaders Duel Format --- Mage.Server/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Mage.Server/pom.xml b/Mage.Server/pom.xml index 461172aaab3..f9f5951f3da 100644 --- a/Mage.Server/pom.xml +++ b/Mage.Server/pom.xml @@ -133,6 +133,12 @@ ${project.version} runtime + + ${project.groupId} + mage-game-tinyleadersduel + ${project.version} + runtime +