diff --git a/.gitignore b/.gitignore index 53ce9bb177..e98869c519 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,7 @@ 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 +*.txt +Mage.Client/serverlist.txt \ 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 0000000000..1680d0cf4b --- /dev/null +++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/TinyLeaders.java @@ -0,0 +1,209 @@ +/* + * 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<String> banned = new ArrayList<>(); + protected List<String> 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<String> 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<String, Integer> counts = new HashMap<>(); + countCards(counts, deck.getCards()); + countCards(counts, deck.getSideboard()); + for (Map.Entry<String, Integer> 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() <= 11) { + Card commander = null; + + for (Card card : deck.getSideboard()) { + if (card.getName().equalsIgnoreCase(deck.getName())) { + commander = card; + } + } + + /** + * 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) { + if (commander == null) invalid.put("Leader", "Please be sure to set your leader in the NAME field in the DECK EDITOR"); + if (commander != null && commander.getManaCost().convertedManaCost() > 3) invalid.put("Leader", "Commander CMC is Greater than 3"); + 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 0000000000..ccf6b733a0 --- /dev/null +++ b/Mage.Server.Plugins/Mage.Game.TinyLeadersDuel/pom.xml @@ -0,0 +1,50 @@ + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.mage</groupId> + <artifactId>mage-server-plugins</artifactId> + <version>1.3.0</version> + </parent> + + <artifactId>mage-game-tinyleadersduel</artifactId> + <packaging>jar</packaging> + <name>Mage Game Tiny Leaders Two Player</name> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>mage</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <sourceDirectory>src</sourceDirectory> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <configuration> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + + </plugins> + + <finalName>mage-game-tinyleadersduel</finalName> + </build> + + <properties/> + +</project> 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 0000000000..b8e05f7607 --- /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 0000000000..6349384e7c --- /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 0000000000..7936d4e890 --- /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 + */ +public 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 = true; + } + + 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 42835c4d18..5235f4a7a1 100644 --- a/Mage.Server.Plugins/pom.xml +++ b/Mage.Server.Plugins/pom.xml @@ -17,19 +17,12 @@ <modules> <module>Mage.Deck.Constructed</module> <module>Mage.Deck.Limited</module> - <module>Mage.Game.CommanderDuel</module> + <module>Mage.Game.CommanderDuel</module> <module>Mage.Game.CommanderFreeForAll</module> <module>Mage.Game.FreeForAll</module> <module>Mage.Game.TwoPlayerDuel</module> - <module>Mage.Player.AI</module> - <module>Mage.Player.AIMinimax</module> - <module>Mage.Player.AI.MA</module> - <module>Mage.Player.AIMCTS</module> - <module>Mage.Player.AI.DraftBot</module> <module>Mage.Player.Human</module> - <module>Mage.Tournament.BoosterDraft</module> - <module>Mage.Tournament.Constructed</module> - <module>Mage.Tournament.Sealed</module> - </modules> + <module>Mage.Game.TinyLeadersDuel</module> + </modules> </project> \ No newline at end of file diff --git a/Mage.Server/config/config.xml b/Mage.Server/config/config.xml index 81bf9f2ea4..c1aff2d008 100644 --- a/Mage.Server/config/config.xml +++ b/Mage.Server/config/config.xml @@ -41,13 +41,14 @@ <!--<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>--> <playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer7"/> <!--<playerType name="Computer - monte carlo" jar="mage-player-aimcts.jar" className="mage.player.ai.ComputerPlayerMCTS"/>--> - <playerType name="Computer - draftbot" jar="mage-player-ai-draft-bot.jar" className="mage.player.ai.ComputerDraftPlayer"/> + <playerType name="Computer - draftbot" jar="mage-player-ai-draft-bot.jar" className="mage.player.ai.ComputerDraftPlayer"/> </playerTypes> <gameTypes> <gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/> <gameType name="Free For All" jar="mage-game-freeforall.jar" className="mage.game.FreeForAllMatch" typeName="mage.game.FreeForAllType"/> <gameType name="Commander Two Player Duel" jar="mage-game-commanderduel.jar" className="mage.game.CommanderDuelMatch" typeName="mage.game.CommanderDuelType"/> <gameType name="Commander Free For All" jar="mage-game-commanderfreeforall.jar" className="mage.game.CommanderFreeForAllMatch" typeName="mage.game.CommanderFreeForAllType"/> + <gameType name="Tiny Leaders Two Player Duel" jar="mage-game-tinyleadersduel.jar" className="mage.game.TinyLeadersDuelMatch" typeName="mage.game.TinyLeadersDuelType"/> </gameTypes> <tournamentTypes> <tournamentType name="Constructed Elimination" jar="mage-tournament-constructed.jar" className="mage.tournament.ConstructedEliminationTournament" typeName="mage.tournament.ConstructedEliminationTournamentType"/> @@ -91,6 +92,7 @@ <deckType name="Block Constructed - Zendikar" jar="mage-deck-constructed.jar" className="mage.deck.ZendikarBlock"/> <deckType name="Variant Magic - Commander" jar="mage-deck-constructed.jar" className="mage.deck.Commander"/> <deckType name="Variant Magic - Duel Commander" jar="mage-deck-constructed.jar" className="mage.deck.DuelCommander"/> + <deckType name="Variant Magic - Tiny Leaders" jar="mage-deck-constructed.jar" className="mage.deck.TinyLeaders"/> <deckType name="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/> </deckTypes> </config> diff --git a/Mage.Server/pom.xml b/Mage.Server/pom.xml index 461172aaab..f9f5951f3d 100644 --- a/Mage.Server/pom.xml +++ b/Mage.Server/pom.xml @@ -133,6 +133,12 @@ <version>${project.version}</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>mage-game-tinyleadersduel</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> </dependencies> <build> diff --git a/Mage/src/mage/game/GameTinyLeadersImpl.java b/Mage/src/mage/game/GameTinyLeadersImpl.java new file mode 100644 index 0000000000..1094ef3cf7 --- /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 JRHerlehy + */ +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<UUID> getOpponents(UUID playerId) { + Set<UUID> 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 f024001d95..bc9933a845 100644 --- a/pom.xml +++ b/pom.xml @@ -50,17 +50,16 @@ </plugins> </build> <modules> - <module>Mage</module> <module>Mage.Common</module> - <module>Mage.Server</module> - <module>Mage.Sets</module> <module>Mage.Client</module> <module>Mage.Plugins</module> + <module>Mage</module> + <module>Mage.Server</module> + <module>Mage.Sets</module> <module>Mage.Server.Plugins</module> <module>Mage.Server.Console</module> <module>Mage.Tests</module> <module>Mage.Updater</module> - <module>Mage.Stats</module> </modules> <repositories>