diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/pom.xml b/Mage.Server.Plugins/Mage.Deck.Constructed/pom.xml
index 654c87c6797..883d7615545 100644
--- a/Mage.Server.Plugins/Mage.Deck.Constructed/pom.xml
+++ b/Mage.Server.Plugins/Mage.Deck.Constructed/pom.xml
@@ -20,6 +20,11 @@
Mage
${project.version}
+
+ ${project.groupId}
+ Mage-Sets
+ ${project.version}
+
diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Extended.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Extended.java
new file mode 100644
index 00000000000..1a814d53153
--- /dev/null
+++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Extended.java
@@ -0,0 +1,60 @@
+/*
+* 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.Calendar;
+import java.util.GregorianCalendar;
+import mage.Constants.SetType;
+import mage.cards.ExpansionSet;
+import mage.cards.decks.Constructed;
+import mage.sets.Sets;
+
+/**
+ *
+ * @author BetaSteward_at_googlemail.com
+ */
+public class Extended extends Constructed {
+
+ public Extended() {
+ super("Constructed - Extended");
+ GregorianCalendar current = new GregorianCalendar();
+ GregorianCalendar cutoff;
+ if (current.get(Calendar.MONTH) > 9) {
+ cutoff = new GregorianCalendar(current.get(Calendar.YEAR) - 3, Calendar.SEPTEMBER, 1);
+ }
+ else {
+ cutoff = new GregorianCalendar(current.get(Calendar.YEAR) - 4, Calendar.SEPTEMBER, 1);
+ }
+ for (ExpansionSet set: Sets.getInstance().values()) {
+ if (set.getReleaseDate().after(cutoff.getTime()) && set.getSetType() != SetType.REPRINT) {
+ setCodes.add(set.getCode());
+ }
+ }
+ }
+}
diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ScarsOfMirrodinBlock.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ScarsOfMirrodinBlock.java
new file mode 100644
index 00000000000..5df864adb9f
--- /dev/null
+++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ScarsOfMirrodinBlock.java
@@ -0,0 +1,46 @@
+/*
+* 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.decks.Constructed;
+
+/**
+ *
+ * @author BetaSteward_at_googlemail.com
+ */
+public class ScarsOfMirrodinBlock extends Constructed {
+
+ public ScarsOfMirrodinBlock() {
+ super("Constructed - Scars of Mirrodin Block");
+ setCodes.add("SOM");
+ setCodes.add("MBS");
+ setCodes.add("NPH");
+ }
+
+}
diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShardsOfAlaraBlock.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShardsOfAlaraBlock.java
new file mode 100644
index 00000000000..570f7bf7212
--- /dev/null
+++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ShardsOfAlaraBlock.java
@@ -0,0 +1,46 @@
+/*
+* 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.decks.Constructed;
+
+/**
+ *
+ * @author BetaSteward_at_googlemail.com
+ */
+public class ShardsOfAlaraBlock extends Constructed {
+
+ public ShardsOfAlaraBlock() {
+ super("Constructed - Shards Of Alara Block");
+ setCodes.add("ALA");
+ setCodes.add("CON");
+ setCodes.add("ARB");
+ }
+
+}
diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Standard.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Standard.java
new file mode 100644
index 00000000000..f15c6e5dc23
--- /dev/null
+++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Standard.java
@@ -0,0 +1,60 @@
+/*
+* 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.Calendar;
+import java.util.GregorianCalendar;
+import mage.Constants.SetType;
+import mage.cards.ExpansionSet;
+import mage.cards.decks.Constructed;
+import mage.sets.Sets;
+
+/**
+ *
+ * @author BetaSteward_at_googlemail.com
+ */
+public class Standard extends Constructed {
+
+ public Standard() {
+ super("Constructed - Standard");
+ GregorianCalendar current = new GregorianCalendar();
+ GregorianCalendar cutoff;
+ if (current.get(Calendar.MONTH) > 9) {
+ cutoff = new GregorianCalendar(current.get(Calendar.YEAR) - 1, Calendar.SEPTEMBER, 1);
+ }
+ else {
+ cutoff = new GregorianCalendar(current.get(Calendar.YEAR) - 2, Calendar.SEPTEMBER, 1);
+ }
+ for (ExpansionSet set: Sets.getInstance().values()) {
+ if (set.getReleaseDate().after(cutoff.getTime()) && set.getSetType() != SetType.REPRINT) {
+ setCodes.add(set.getCode());
+ }
+ }
+ }
+}
diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Vintage.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Vintage.java
new file mode 100644
index 00000000000..134d4b87708
--- /dev/null
+++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Vintage.java
@@ -0,0 +1,42 @@
+/*
+* 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.decks.Constructed;
+
+/**
+ *
+ * @author BetaSteward_at_googlemail.com
+ */
+public class Vintage extends Constructed {
+
+ public Vintage() {
+ super("Constructed - Vintage");
+ }
+}
diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ZendikarBlock.java b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ZendikarBlock.java
new file mode 100644
index 00000000000..e1e67df5a2c
--- /dev/null
+++ b/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/ZendikarBlock.java
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package mage.deck;
+
+import mage.cards.decks.Constructed;
+
+/**
+ *
+ * @author BetaSteward_at_googlemail.com
+ */
+public class ZendikarBlock extends Constructed {
+
+ public ZendikarBlock() {
+ super("Constructed - Zendikar Block");
+ setCodes.add("ZEN");
+ setCodes.add("WWK");
+ setCodes.add("ROE");
+ }
+
+}
diff --git a/Mage.Server/config/config.xml b/Mage.Server/config/config.xml
index 00f586ba5a9..0af9337b3ab 100644
--- a/Mage.Server/config/config.xml
+++ b/Mage.Server/config/config.xml
@@ -16,7 +16,12 @@
-
+
+
+
+
+
+
diff --git a/Mage.Server/plugins/mage-deck-constructed.jar b/Mage.Server/plugins/mage-deck-constructed.jar
index 3647989d7d0..7a164e1ad62 100644
Binary files a/Mage.Server/plugins/mage-deck-constructed.jar and b/Mage.Server/plugins/mage-deck-constructed.jar differ
diff --git a/Mage.Sets/src/mage/sets/Sets.java b/Mage.Sets/src/mage/sets/Sets.java
index d8f72c2b1c2..8a3fad9dbae 100644
--- a/Mage.Sets/src/mage/sets/Sets.java
+++ b/Mage.Sets/src/mage/sets/Sets.java
@@ -232,10 +232,8 @@ public class Sets extends HashMap {
public static ExpansionSet findSet(String code) {
- for (ExpansionSet set: fINSTANCE.values()) {
- if (set.getCode().equals(code))
- return set;
- }
+ if (fINSTANCE.containsKey(code))
+ return fINSTANCE.get(code);
return null;
}
diff --git a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Constructed.java b/Mage/src/mage/cards/decks/Constructed.java
similarity index 59%
rename from Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Constructed.java
rename to Mage/src/mage/cards/decks/Constructed.java
index b76db08d3bd..1b62d39a7d5 100644
--- a/Mage.Server.Plugins/Mage.Deck.Constructed/src/mage/deck/Constructed.java
+++ b/Mage/src/mage/cards/decks/Constructed.java
@@ -26,7 +26,7 @@
* or implied, of BetaSteward_at_googlemail.com.
*/
-package mage.deck;
+package mage.cards.decks;
import java.util.ArrayList;
import java.util.Arrays;
@@ -34,8 +34,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import mage.cards.decks.Deck;
-import mage.cards.decks.DeckValidatorImpl;
+import mage.cards.Card;
/**
*
@@ -43,18 +42,31 @@ import mage.cards.decks.DeckValidatorImpl;
*/
public class Constructed extends DeckValidatorImpl {
+ protected List banned = new ArrayList();
+ protected List restricted = new ArrayList();
+ protected List setCodes = new ArrayList();
+
public Constructed() {
super("Constructed");
}
+ protected Constructed(String name) {
+ super(name);
+ }
+
@Override
public boolean validate(Deck deck) {
+ boolean valid = true;
//20091005 - 100.2a
- if (deck.getCards().size() < 60)
- return false;
+ if (deck.getCards().size() < 60) {
+ invalid.put("Deck", "Must contain at least 60 cards: " + deck.getCards().size());
+ valid = false;
+ }
//20091005 - 100.4a
- if (deck.getSideboard().size() != 0 && deck.getSideboard().size() != 15)
- return false;
+ if (!deck.getSideboard().isEmpty() && deck.getSideboard().size() != 15) {
+ invalid.put("Sideboard", "Must have 0 or 15 cards: " + deck.getSideboard().size());
+ valid = false;
+ }
List basicLandNames = new ArrayList(Arrays.asList("Forest", "Island", "Mountain", "Swamp", "Plains"));
Map counts = new HashMap();
@@ -63,12 +75,47 @@ public class Constructed extends DeckValidatorImpl {
for (Entry entry: counts.entrySet()) {
if (entry.getValue() > 4) {
if (!basicLandNames.contains(entry.getKey()) && !entry.getKey().equals("Relentless Rats")) {
- return false;
+ invalid.put(entry.getKey(), "Too many: " + entry.getValue());
+ valid = false;
+ }
+ }
+ }
+ for (String bannedCard: banned) {
+ if (counts.containsKey(bannedCard)) {
+ invalid.put(bannedCard, "Banned");
+ valid = false;
+ }
+ }
+
+ for (String restrictedCard: restricted) {
+ if (counts.containsKey(restrictedCard)) {
+ int count = counts.get(restrictedCard);
+ if (count > 1) {
+ invalid.put(restrictedCard, "Restricted: " + count);
+ valid = false;
+ }
+ }
+ }
+ if (!setCodes.isEmpty()) {
+ for (Card card: deck.getCards()) {
+ if (!setCodes.contains(card.getExpansionSetCode())) {
+ if (!invalid.containsKey(card.getName())) {
+ invalid.put(card.getName(), "Invalid set: " + card.getExpansionSetCode());
+ valid = false;
+ }
+ }
+ }
+ for (Card card: deck.getSideboard()) {
+ if (!setCodes.contains(card.getExpansionSetCode())) {
+ if (!invalid.containsKey(card.getName())) {
+ invalid.put(card.getName(), "Invalid set: " + card.getExpansionSetCode());
+ valid = false;
+ }
}
}
}
- return true;
+ return valid;
}
}
diff --git a/Mage/src/mage/cards/decks/DeckValidator.java b/Mage/src/mage/cards/decks/DeckValidator.java
index f0c0bb656fa..c450583f412 100644
--- a/Mage/src/mage/cards/decks/DeckValidator.java
+++ b/Mage/src/mage/cards/decks/DeckValidator.java
@@ -29,6 +29,7 @@
package mage.cards.decks;
import java.io.Serializable;
+import java.util.Map;
/**
*
@@ -38,5 +39,6 @@ public interface DeckValidator extends Serializable {
public String getName();
public boolean validate(Deck deck);
+ public Map getInvalid();
}
diff --git a/Mage/src/mage/cards/decks/DeckValidatorImpl.java b/Mage/src/mage/cards/decks/DeckValidatorImpl.java
index 16fa9e8bb09..76d31d32b7d 100644
--- a/Mage/src/mage/cards/decks/DeckValidatorImpl.java
+++ b/Mage/src/mage/cards/decks/DeckValidatorImpl.java
@@ -29,6 +29,7 @@
package mage.cards.decks;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import mage.cards.Card;
@@ -40,6 +41,8 @@ public abstract class DeckValidatorImpl implements DeckValidator {
protected String name;
+ protected Map invalid = new HashMap();
+
public DeckValidatorImpl(String name) {
this.name = name;
}
@@ -59,4 +62,9 @@ public abstract class DeckValidatorImpl implements DeckValidator {
}
}
}
+
+ @Override
+ public Map getInvalid() {
+ return invalid;
+ }
}