mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
* Added "Duel Commander" format (fixes #436).
This commit is contained in:
parent
6f8de373ac
commit
d7f100b24b
21 changed files with 280 additions and 167 deletions
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
|
@ -33,7 +32,6 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckValidator;
|
||||
|
|
@ -44,155 +42,157 @@ import mage.filter.FilterMana;
|
|||
*
|
||||
* @author Plopman
|
||||
*/
|
||||
|
||||
|
||||
public class Commander extends DeckValidator {
|
||||
|
||||
protected List<String> banned = new ArrayList<>();
|
||||
|
||||
protected List<String> banned = new ArrayList<>();
|
||||
protected List<String> bannedCommander = new ArrayList<>();
|
||||
|
||||
private static final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
|
||||
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";
|
||||
private static final String regexRed = ".*\\x7b.{0,2}R.{0,2}\\x7d.*";
|
||||
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";
|
||||
private static final String regexRed = ".*\\x7b.{0,2}R.{0,2}\\x7d.*";
|
||||
private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*";
|
||||
private static final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*";
|
||||
|
||||
public Commander(){
|
||||
super("Commander");
|
||||
|
||||
banned.add("Ancestral Recall");
|
||||
banned.add("Balance");
|
||||
banned.add("Biorhythm");
|
||||
banned.add("Black Lotus");
|
||||
banned.add("Braids, Cabal Minion");
|
||||
banned.add("Channel");
|
||||
banned.add("Coalition Victory");
|
||||
banned.add("Emrakul, the Aeons Torn");
|
||||
banned.add("Erayo, Soratami Ascendant");
|
||||
banned.add("Fastbond");
|
||||
banned.add("Gifts Ungiven");
|
||||
banned.add("Griselbrand");
|
||||
banned.add("Karakas");
|
||||
banned.add("Library of Alexandria");
|
||||
banned.add("Limited Resources");
|
||||
banned.add("Mox Emerald");
|
||||
banned.add("Mox Jet");
|
||||
banned.add("Mox Pearl");
|
||||
banned.add("Mox Ruby");
|
||||
banned.add("Mox Sapphire");
|
||||
banned.add("Painter's Servant");
|
||||
banned.add("Panoptic Mirror");
|
||||
banned.add("Primeval Titan");
|
||||
banned.add("Protean Hulk");
|
||||
banned.add("Recurring Nightmare");
|
||||
banned.add("Rofellos, Llanowar Emissary");
|
||||
banned.add("Sundering Titan");
|
||||
banned.add("Sway of the Stars");
|
||||
banned.add("Sylvan Primordial");
|
||||
banned.add("Time Vault");
|
||||
banned.add("Time Walk");
|
||||
banned.add("Tinker");
|
||||
banned.add("Tolarian Academy");
|
||||
banned.add("Trade Secrets");
|
||||
banned.add("Upheaval");
|
||||
banned.add("Worldfire");
|
||||
banned.add("Yawgmoth's Bargain");
|
||||
|
||||
public Commander() {
|
||||
this("Commander");
|
||||
banned.add("Ancestral Recall");
|
||||
banned.add("Balance");
|
||||
banned.add("Biorhythm");
|
||||
banned.add("Black Lotus");
|
||||
banned.add("Braids, Cabal Minion");
|
||||
banned.add("Channel");
|
||||
banned.add("Coalition Victory");
|
||||
banned.add("Emrakul, the Aeons Torn");
|
||||
banned.add("Erayo, Soratami Ascendant");
|
||||
banned.add("Fastbond");
|
||||
banned.add("Gifts Ungiven");
|
||||
banned.add("Griselbrand");
|
||||
banned.add("Karakas");
|
||||
banned.add("Library of Alexandria");
|
||||
banned.add("Limited Resources");
|
||||
banned.add("Mox Emerald");
|
||||
banned.add("Mox Jet");
|
||||
banned.add("Mox Pearl");
|
||||
banned.add("Mox Ruby");
|
||||
banned.add("Mox Sapphire");
|
||||
banned.add("Painter's Servant");
|
||||
banned.add("Panoptic Mirror");
|
||||
banned.add("Primeval Titan");
|
||||
banned.add("Protean Hulk");
|
||||
banned.add("Recurring Nightmare");
|
||||
banned.add("Rofellos, Llanowar Emissary");
|
||||
banned.add("Sundering Titan");
|
||||
banned.add("Sway of the Stars");
|
||||
banned.add("Sylvan Primordial");
|
||||
banned.add("Time Vault");
|
||||
banned.add("Time Walk");
|
||||
banned.add("Tinker");
|
||||
banned.add("Tolarian Academy");
|
||||
banned.add("Trade Secrets");
|
||||
banned.add("Upheaval");
|
||||
banned.add("Worldfire");
|
||||
banned.add("Yawgmoth's Bargain");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Commander(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(Deck deck) {
|
||||
boolean valid = true;
|
||||
|
||||
|
||||
if (deck.getCards().size() != 99) {
|
||||
invalid.put("Deck", "Must contain 99 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"));
|
||||
"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()) {
|
||||
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")) {
|
||||
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) {
|
||||
|
||||
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];
|
||||
if(commander != null && commander.getCardType().contains(CardType.CREATURE) && commander.getSupertype().contains("Legendary")){
|
||||
FilterMana color = getColorIdentity(commander);
|
||||
for(Card card : deck.getCards()){
|
||||
if(!cardHasValideColor(color, card)){
|
||||
invalid.put(card.getName(), "Invalid color");
|
||||
valid = false;
|
||||
|
||||
if (deck.getSideboard().size() == 1) {
|
||||
Card commander = (Card) deck.getSideboard().toArray()[0];
|
||||
if (commander != null && commander.getCardType().contains(CardType.CREATURE) && commander.getSupertype().contains("Legendary")) {
|
||||
if (!bannedCommander.contains(commander.getName())) {
|
||||
FilterMana color = getColorIdentity(commander);
|
||||
for (Card card : deck.getCards()) {
|
||||
if (!cardHasValideColor(color, card)) {
|
||||
invalid.put(card.getName(), "Invalid color");
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
invalid.put("Commander", "Commander banned");
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
invalid.put("Commander", "Commander invalide");
|
||||
valid = false;
|
||||
}
|
||||
} else {
|
||||
invalid.put("Commander", "Sideboard must contain only the commander");
|
||||
}
|
||||
else{
|
||||
invalid.put("Commander", "Sideboard must contain only the commander");
|
||||
}
|
||||
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public FilterMana getColorIdentity(Card card){
|
||||
|
||||
public FilterMana getColorIdentity(Card card) {
|
||||
FilterMana mana = new FilterMana();
|
||||
mana.setBlack(card.getManaCost().getText().matches(regexBlack));
|
||||
mana.setBlue(card.getManaCost().getText().matches(regexBlue));
|
||||
mana.setGreen(card.getManaCost().getText().matches(regexGreen));
|
||||
mana.setRed(card.getManaCost().getText().matches(regexRed));
|
||||
mana.setWhite(card.getManaCost().getText().matches(regexWhite));
|
||||
|
||||
for(String rule : card.getRules()){
|
||||
|
||||
for (String rule : card.getRules()) {
|
||||
rule = rule.replaceAll("(?i)<i.*?</i>", ""); // Ignoring reminder text in italic
|
||||
if(rule.matches(regexBlack)){
|
||||
if (rule.matches(regexBlack)) {
|
||||
mana.setBlack(true);
|
||||
}
|
||||
if(rule.matches(regexBlue)){
|
||||
if (rule.matches(regexBlue)) {
|
||||
mana.setBlue(true);
|
||||
}
|
||||
if(rule.matches(regexGreen)){
|
||||
if (rule.matches(regexGreen)) {
|
||||
mana.setGreen(true);
|
||||
}
|
||||
if(rule.matches(regexRed)){
|
||||
if (rule.matches(regexRed)) {
|
||||
mana.setRed(true);
|
||||
}
|
||||
if(rule.matches(regexWhite)){
|
||||
if (rule.matches(regexWhite)) {
|
||||
mana.setWhite(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
|
||||
public boolean cardHasValideColor(FilterMana commander, Card card){
|
||||
|
||||
public boolean cardHasValideColor(FilterMana commander, Card card) {
|
||||
FilterMana cardColor = getColorIdentity(card);
|
||||
if(cardColor.isBlack() && !commander.isBlack()
|
||||
|| cardColor.isBlue() && !commander.isBlue()
|
||||
|| cardColor.isGreen() && !commander.isGreen()
|
||||
|| cardColor.isRed() && !commander.isRed()
|
||||
|| cardColor.isWhite() && !commander.isWhite()){
|
||||
if (cardColor.isBlack() && !commander.isBlack()
|
||||
|| cardColor.isBlue() && !commander.isBlue()
|
||||
|| cardColor.isGreen() && !commander.isGreen()
|
||||
|| cardColor.isRed() && !commander.isRed()
|
||||
|| cardColor.isWhite() && !commander.isWhite()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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.deck;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class DuelCommander extends Commander {
|
||||
|
||||
public DuelCommander() {
|
||||
super("Duel Commander");
|
||||
banned.add("Ancestral Recall");
|
||||
banned.add("Ancient Tomb");
|
||||
banned.add("Balance");
|
||||
banned.add("Back to Basics");
|
||||
banned.add("Black Lotus");
|
||||
banned.add("Cataclysm");
|
||||
banned.add("Channel");
|
||||
banned.add("Crucible of Worlds");
|
||||
banned.add("Gifts Ungiven");
|
||||
banned.add("Grim Monolith");
|
||||
banned.add("Grindstone");
|
||||
banned.add("Hermit Druid");
|
||||
banned.add("Humility");
|
||||
banned.add("Imperial Seal");
|
||||
banned.add("Karakas");
|
||||
banned.add("Library of Alexandria");
|
||||
banned.add("Loyal Retainers");
|
||||
banned.add("Mana Crypt");
|
||||
banned.add("Mana Drain");
|
||||
banned.add("Mana Vault");
|
||||
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("Natural Order");
|
||||
banned.add("Necropotence");
|
||||
banned.add("Oath of Druids");
|
||||
banned.add("Protean Hulk");
|
||||
banned.add("Sensei’s Divining Top");
|
||||
banned.add("Serra Ascendant");
|
||||
banned.add("Shahrazad");
|
||||
banned.add("Sol Ring");
|
||||
banned.add("Strip Mine");
|
||||
banned.add("The Tabernacle at Pendrell Vale");
|
||||
banned.add("Time Vault");
|
||||
banned.add("Time Walk");
|
||||
banned.add("Tinker");
|
||||
banned.add("Tolarian Academy");
|
||||
banned.add("Vampiric Tutor");
|
||||
banned.add("Winter Orb");
|
||||
banned.add("Yawgmoth’s Bargain");
|
||||
|
||||
bannedCommander.add("Braids, Cabal Minion");
|
||||
bannedCommander.add("Derevi, Empyrial Tactician");
|
||||
bannedCommander.add("Edric, Spymaster of Trest");
|
||||
bannedCommander.add("Erayo, Soratami Ascendant");
|
||||
bannedCommander.add("Oloro, Ageless Ascetic");
|
||||
bannedCommander.add("Rofellos, Llanowar Emissary");
|
||||
bannedCommander.add("Zur the Enchanter");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -34,8 +34,8 @@ import mage.game.match.MatchType;
|
|||
|
||||
public class CommanderDuel extends GameCommanderImpl {
|
||||
|
||||
public CommanderDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
|
||||
super(attackOption, range, freeMulligans);
|
||||
public CommanderDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) {
|
||||
super(attackOption, range, freeMulligans, startLife);
|
||||
}
|
||||
|
||||
public CommanderDuel(final CommanderDuel game) {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,16 @@ public class CommanderDuelMatch extends MatchImpl {
|
|||
|
||||
@Override
|
||||
public void startGame() throws GameException {
|
||||
CommanderDuel game = new CommanderDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans());
|
||||
int startLife = 40;
|
||||
boolean alsoLibrary = false;
|
||||
// Don't like it to compare but seems like it's complicated to do it in another way
|
||||
if (options.getDeckType().equals("Variant Magic - Duel Commander")) {
|
||||
startLife = 30;
|
||||
alsoLibrary = true;
|
||||
}
|
||||
CommanderDuel game = new CommanderDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife);
|
||||
game.setStartMessage(this.createGameStartMessage());
|
||||
game.setAlsoLibrary(alsoLibrary);
|
||||
initGame(game);
|
||||
games.add(game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ public class CommanderFreeForAll extends GameCommanderImpl {
|
|||
|
||||
private int numPlayers;
|
||||
|
||||
public CommanderFreeForAll(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
|
||||
super(attackOption, range, freeMulligans);
|
||||
public CommanderFreeForAll(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) {
|
||||
super(attackOption, range, freeMulligans, startLife);
|
||||
}
|
||||
|
||||
public CommanderFreeForAll(final CommanderFreeForAll game) {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,15 @@ public class CommanderFreeForAllMatch extends MatchImpl {
|
|||
|
||||
@Override
|
||||
public void startGame() throws GameException {
|
||||
CommanderFreeForAll game = new CommanderFreeForAll(options.getAttackOption(), options.getRange(), options.getFreeMulligans());
|
||||
int startLife = 40;
|
||||
boolean alsoLibrary = false;
|
||||
if (options.getDeckType().equals("Duel Commander")) {
|
||||
startLife = 30;
|
||||
alsoLibrary = true;
|
||||
}
|
||||
CommanderFreeForAll game = new CommanderFreeForAll(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife);
|
||||
game.setStartMessage(this.createGameStartMessage());
|
||||
game.setAlsoLibrary(alsoLibrary);
|
||||
initGame(game);
|
||||
games.add(game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ public class FreeForAll extends GameImpl {
|
|||
|
||||
private int numPlayers;
|
||||
|
||||
public FreeForAll(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
|
||||
super(attackOption, range, freeMulligans);
|
||||
public FreeForAll(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) {
|
||||
super(attackOption, range, freeMulligans, startLife);
|
||||
}
|
||||
|
||||
public FreeForAll(final FreeForAll game) {
|
||||
|
|
@ -67,11 +67,6 @@ public class FreeForAll extends GameImpl {
|
|||
this.numPlayers = numPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLife() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> getOpponents(UUID playerId) {
|
||||
Set<UUID> opponents = new HashSet<>();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class FreeForAllMatch extends MatchImpl {
|
|||
|
||||
@Override
|
||||
public void startGame() throws GameException {
|
||||
FreeForAll game = new FreeForAll(options.getAttackOption(), options.getRange(), options.getFreeMulligans());
|
||||
FreeForAll game = new FreeForAll(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), 20);
|
||||
game.setStartMessage(this.createGameStartMessage());
|
||||
initGame(game);
|
||||
games.add(game);
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ import mage.players.Player;
|
|||
|
||||
public class TwoPlayerDuel extends GameImpl {
|
||||
|
||||
public TwoPlayerDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
|
||||
super(attackOption, range, freeMulligans);
|
||||
public TwoPlayerDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) {
|
||||
super(attackOption, range, freeMulligans, startLife);
|
||||
}
|
||||
|
||||
public TwoPlayerDuel(final TwoPlayerDuel game) {
|
||||
|
|
@ -58,11 +58,6 @@ public class TwoPlayerDuel extends GameImpl {
|
|||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLife() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init(UUID choosingPlayerId, GameOptions gameOptions) {
|
||||
super.init(choosingPlayerId, gameOptions);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class TwoPlayerMatch extends MatchImpl {
|
|||
|
||||
@Override
|
||||
public void startGame() throws GameException {
|
||||
TwoPlayerDuel game = new TwoPlayerDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans());
|
||||
TwoPlayerDuel game = new TwoPlayerDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(),20);
|
||||
// Sets a start message about the match score
|
||||
game.setStartMessage(this.createGameStartMessage());
|
||||
initGame(game);
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@
|
|||
<deckType name="Block Constructed - Theros" jar="mage-deck-constructed.jar" className="mage.deck.TherosBlock"/>
|
||||
<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="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/>
|
||||
</deckTypes>
|
||||
</config>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@
|
|||
<deckType name="Block Constructed - Shards of Alara" jar="mage-deck-constructed-${project.version}.jar" className="mage.deck.ShardsOfAlaraBlock"/>
|
||||
<deckType name="Block Constructed - Theros" jar="mage-deck-constructed.jar" className="mage.deck.TherosBlock"/>
|
||||
<deckType name="Block Constructed - Zendikar" jar="mage-deck-constructed-${project.version}.jar" className="mage.deck.ZendikarBlock"/>
|
||||
<deckType name="Variant Magic - Commander" jar="mage-deck-constructed.jar" className="mage.deck.Commander"/>
|
||||
<deckType name="Variant Magic - Commander" jar="mage-deck-constructed-${project.version}.jar" className="mage.deck.Commander"/>
|
||||
<deckType name="Variant Magic - Duel Commander" jar="mage-deck-constructed-${project.version}.jar" className="mage.deck.DuelCommander"/>
|
||||
<deckType name="Limited" jar="mage-deck-limited-${project.version}.jar" className="mage.deck.Limited"/>
|
||||
</deckTypes>
|
||||
</config>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class PlayGameTest extends MageTestBase {
|
|||
@Ignore
|
||||
@Test
|
||||
public void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException {
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0);
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0, 20);
|
||||
|
||||
Player computerA = createPlayer("ComputerA", "Computer - minimax hybrid");
|
||||
// Player playerA = createPlayer("ComputerA", "Computer - mad");
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class TestPlayRandomGame extends MageTestBase {
|
|||
}
|
||||
|
||||
private void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException {
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0);
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0, 20);
|
||||
|
||||
Player computerA = createRandomPlayer("ComputerA");
|
||||
Deck deck = generateRandomDeck();
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public abstract class CardTestMultiPlayerBase extends CardTestPlayerAPIImpl {
|
|||
System.gc();
|
||||
}
|
||||
|
||||
Game game = new FreeForAll(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, 0);
|
||||
Game game = new FreeForAll(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, 0, 20);
|
||||
|
||||
playerA = createPlayer(game, playerA, "PlayerA");
|
||||
playerB = createPlayer(game, playerB, "PlayerB");
|
||||
|
|
@ -86,7 +86,7 @@ public abstract class CardTestMultiPlayerBase extends CardTestPlayerAPIImpl {
|
|||
System.gc();
|
||||
}
|
||||
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0);
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0, 20);
|
||||
|
||||
playerA = createNewPlayer("ComputerA");
|
||||
playerA.setTestMode(true);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
|
|||
System.gc();
|
||||
}
|
||||
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, 0);
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, 0, 20);
|
||||
|
||||
playerA = createNewPlayer("PlayerA");
|
||||
playerA.setTestMode(true);
|
||||
|
|
@ -110,7 +110,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
|
|||
System.gc();
|
||||
}
|
||||
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0);
|
||||
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ALL, 0, 20);
|
||||
|
||||
playerA = createNewPlayer("ComputerA");
|
||||
playerA.setTestMode(true);
|
||||
|
|
|
|||
|
|
@ -54,17 +54,20 @@ import mage.players.Player;
|
|||
public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
private final UUID commanderId;
|
||||
private final boolean alsoLibrary;
|
||||
|
||||
public CommanderReplacementEffect(UUID commanderId) {
|
||||
public CommanderReplacementEffect(UUID commanderId, boolean alsoLibrary) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "If a commander would be put into its owner’s graveyard from anywhere, that player may put it into the command zone instead. If a commander would be put into the exile zone from anywhere, its owner may put it into the command zone instead.";
|
||||
this.commanderId = commanderId;
|
||||
this.duration = Duration.EndOfGame;
|
||||
this.alsoLibrary = alsoLibrary;
|
||||
}
|
||||
|
||||
public CommanderReplacementEffect(final CommanderReplacementEffect effect) {
|
||||
super(effect);
|
||||
this.commanderId = effect.commanderId;
|
||||
this.alsoLibrary = effect.alsoLibrary;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -112,7 +115,11 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && (((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD || ((ZoneChangeEvent)event).getToZone() == Zone.EXILED)) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && (
|
||||
((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD ||
|
||||
((ZoneChangeEvent)event).getToZone() == Zone.EXILED ||
|
||||
(alsoLibrary && ((ZoneChangeEvent)event).getToZone() == Zone.LIBRARY))
|
||||
) {
|
||||
if (commanderId != null) {
|
||||
if (((ZoneChangeEvent)event).getFromZone().equals(Zone.STACK)) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public abstract class DeckValidator implements Serializable {
|
|||
|
||||
protected String name;
|
||||
|
||||
protected Map<String, String> invalid = new HashMap<String, String>();
|
||||
protected Map<String, String> invalid = new HashMap<>();
|
||||
|
||||
public DeckValidator(String name) {
|
||||
this.name = name;
|
||||
|
|
|
|||
|
|
@ -57,23 +57,17 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
|
||||
private final Map<UUID, Cards> mulliganedCards = new HashMap<>();
|
||||
private final Set<CommanderCombatDamageWatcher> commanderCombatWatcher = new HashSet<>();
|
||||
|
||||
protected boolean alsoLibrary; // replace also commander going to library
|
||||
|
||||
public GameCommanderImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
|
||||
super(attackOption, range, freeMulligans);
|
||||
public GameCommanderImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) {
|
||||
super(attackOption, range, freeMulligans, startLife);
|
||||
}
|
||||
|
||||
public GameCommanderImpl(final GameCommanderImpl game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
// MTG Rules 20121001
|
||||
// 903.7. Once the starting player has been determined, each player sets his or her life total to 40 and
|
||||
// draws a hand of seven cards.
|
||||
@Override
|
||||
public int getLife() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init(UUID choosingPlayerId, GameOptions gameOptions) {
|
||||
super.init(choosingPlayerId, gameOptions);
|
||||
|
|
@ -87,10 +81,10 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
if (commander != null) {
|
||||
player.setCommanderId(commander.getId());
|
||||
commander.moveToZone(Zone.COMMAND, null, this, true);
|
||||
ability.addEffect(new CommanderReplacementEffect(commander.getId()));
|
||||
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoLibrary));
|
||||
ability.addEffect(new CommanderCostModification(commander.getId()));
|
||||
ability.addEffect(new CommanderManaReplacementEffect(player.getId(), commander.getSpellAbility().getManaCosts().getMana()));
|
||||
getState().setValue(commander.getId() + "_castCount", new Integer(0));
|
||||
getState().setValue(commander.getId() + "_castCount", 0);
|
||||
CommanderCombatDamageWatcher watcher = new CommanderCombatDamageWatcher(commander.getId());
|
||||
getState().getWatchers().add(watcher);
|
||||
this.commanderCombatWatcher.add(watcher);
|
||||
|
|
@ -135,16 +129,16 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
int deduction = 1;
|
||||
if (freeMulligans > 0) {
|
||||
if (usedFreeMulligans != null && usedFreeMulligans.containsKey(player.getId())) {
|
||||
int used = usedFreeMulligans.get(player.getId()).intValue();
|
||||
int used = usedFreeMulligans.get(player.getId());
|
||||
if (used < freeMulligans ) {
|
||||
deduction = 0;
|
||||
usedFreeMulligans.put(player.getId(), new Integer(used+1));
|
||||
usedFreeMulligans.put(player.getId(), used+1);
|
||||
}
|
||||
} else {
|
||||
deduction = 0;{
|
||||
|
||||
}
|
||||
usedFreeMulligans.put(player.getId(), new Integer(1));
|
||||
usedFreeMulligans.put(player.getId(), 1);
|
||||
}
|
||||
}
|
||||
player.drawCards(numCards - deduction, this);
|
||||
|
|
@ -210,4 +204,9 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
public boolean isOpponent(Player player, UUID playerToCheck) {
|
||||
return !player.getId().equals(playerToCheck);
|
||||
}
|
||||
|
||||
public void setAlsoLibrary(boolean alsoLibrary) {
|
||||
this.alsoLibrary = alsoLibrary;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,12 +194,15 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
private boolean saveGame = false;
|
||||
private int priorityTime;
|
||||
|
||||
public GameImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
|
||||
private final int startLife;
|
||||
|
||||
public GameImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) {
|
||||
this.id = UUID.randomUUID();
|
||||
this.range = range;
|
||||
this.freeMulligans = freeMulligans;
|
||||
this.attackOption = attackOption;
|
||||
this.state = new GameState();
|
||||
this.startLife = startLife;
|
||||
// this.actions = new LinkedList<MageAction>();
|
||||
}
|
||||
|
||||
|
|
@ -235,6 +238,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
this.scopeRelevant = game.scopeRelevant;
|
||||
this.priorityTime = game.priorityTime;
|
||||
this.saveGame = game.saveGame;
|
||||
this.startLife = game.startLife;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2525,5 +2529,10 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
public UUID getStartingPlayerId() {
|
||||
return startingPlayerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLife() {
|
||||
return startLife;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ import mage.game.events.TableEvent;
|
|||
import mage.game.events.TableEvent.EventType;
|
||||
import mage.game.events.TableEventSource;
|
||||
import mage.players.Player;
|
||||
import mage.players.PlayerList;
|
||||
import mage.util.DateFormat;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue