- Added Standard format and format result are generated.

This commit is contained in:
marcins78@gmail.com
2012-04-02 08:49:02 +00:00
parent c841260ba3
commit bb851f6c57
6 changed files with 113 additions and 12 deletions

View File

@@ -1,5 +1,15 @@
package com.gempukku.lotro.common;
public enum Block {
FELLOWSHIP, TWO_TOWERS, KING, SHADOWS
FELLOWSHIP("Fellowship"), TWO_TOWERS("Towers"), KING("King"), SHADOWS("Shadows");
private String _humanReadable;
private Block(String humanReadable) {
_humanReadable = humanReadable;
}
public String getHumanReadable() {
return _humanReadable;
}
}

View File

@@ -1,7 +1,10 @@
package com.gempukku.lotro.game;
import com.gempukku.lotro.common.Block;
import com.gempukku.lotro.logic.vo.LotroDeck;
import java.util.List;
public interface LotroFormat {
public boolean isOrderedSites();
@@ -12,4 +15,12 @@ public interface LotroFormat {
public String getName();
public void validateDeck(Player player, LotroDeck deck) throws DeckInvalidException;
public List<Integer> getValidSets();
public List<String> getBannedCards();
public List<String> getRestrictedCards();
public Block getSiteBlock();
}

View File

@@ -8,10 +8,7 @@ import com.gempukku.lotro.game.*;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.vo.LotroDeck;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
public class DefaultLotroFormat implements LotroFormat {
private LotroCardBlueprintLibrary _library;
@@ -22,9 +19,9 @@ public class DefaultLotroFormat implements LotroFormat {
private boolean _mulliganRule;
private boolean _canCancelRingBearerSkirmish;
private int _minimumDeckSize = 60;
private Set<String> _bannedCards = new HashSet<String>();
private Set<String> _restrictedCards = new HashSet<String>();
private Set<Integer> _validSets = new HashSet<Integer>();
private List<String> _bannedCards = new ArrayList<String>();
private List<String> _restrictedCards = new ArrayList<String>();
private List<Integer> _validSets = new ArrayList<Integer>();
public DefaultLotroFormat(LotroCardBlueprintLibrary library, String name, Block siteBlock, boolean validateShadowFPCount, int minimumDeckSize, int maximumSameName, boolean mulliganRule, boolean canCancelRingBearerSkirmish) {
_library = library;
@@ -57,12 +54,48 @@ public class DefaultLotroFormat implements LotroFormat {
return _canCancelRingBearerSkirmish;
}
@Override
public List<Integer> getValidSets() {
return Collections.unmodifiableList(_validSets);
}
@Override
public List<String> getBannedCards() {
return Collections.unmodifiableList(_bannedCards);
}
@Override
public List<String> getRestrictedCards() {
return Collections.unmodifiableList(_restrictedCards);
}
@Override
public Block getSiteBlock() {
return _siteBlock;
}
protected void addBannedCard(String baseBlueprintId) {
_bannedCards.add(baseBlueprintId);
if (baseBlueprintId.contains("-")) {
String[] parts = baseBlueprintId.split("_");
String set = parts[0];
int from = Integer.parseInt(parts[1].split("-")[0]);
int to = Integer.parseInt(parts[1].split("-")[1]);
for (int i = from; i <= to; i++)
_bannedCards.add(set + "_" + i);
} else
_bannedCards.add(baseBlueprintId);
}
protected void addRestrictedCard(String baseBlueprintId) {
_restrictedCards.add(baseBlueprintId);
if (baseBlueprintId.contains("-")) {
String[] parts = baseBlueprintId.split("_");
String set = parts[0];
int from = Integer.parseInt(parts[1].split("-")[0]);
int to = Integer.parseInt(parts[1].split("-")[1]);
for (int i = from; i <= to; i++)
_restrictedCards.add(set + "_" + i);
} else
_restrictedCards.add(baseBlueprintId);
}
protected void addValidSet(int setNo) {

View File

@@ -89,7 +89,7 @@
"name": "Standard",
"code": "standard",
"sites": "SHADOWS",
"banned": ["0_62","0_63","0_64","0_65","0_66","0_67","8_1","13_188","11_114","11_31","10_11","15_64","10_2","10_91","11_132","7_49","11_100"],
"banned": ["0_1-19","0_21","0_22","0_30-47","0_62-67","8_1","13_188","11_114","11_31","10_11","15_64","10_2","10_91","11_132","7_49","11_100"],
"set": [0,7,8,9,10,11,12,13,14,15,16,17,18,19]
},
{

View File

@@ -1,13 +1,16 @@
package com.gempukku.lotro.server;
import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.game.LotroFormat;
import com.gempukku.lotro.game.Player;
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
import com.gempukku.lotro.hall.HallException;
import com.gempukku.lotro.hall.HallInfoVisitor;
import com.gempukku.lotro.hall.HallServer;
import com.gempukku.lotro.league.LeagueSerieData;
import com.gempukku.lotro.league.LeagueService;
import com.gempukku.lotro.logic.GameUtils;
import com.sun.jersey.spi.resource.Singleton;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -30,6 +33,50 @@ public class HallResource extends AbstractResource {
private HallServer _hallServer;
@Context
private LeagueService _leagueService;
@Context
private LotroFormatLibrary _formatLibrary;
@Context
private LotroCardBlueprintLibrary _library;
@Path("/formats/html")
@GET
@Produces(MediaType.TEXT_HTML)
public String getFormats(
@Context HttpServletResponse response) {
response.setCharacterEncoding("UTF-8");
StringBuilder result = new StringBuilder();
for (LotroFormat lotroFormat : _formatLibrary.getHallFormats().values()) {
result.append("<b>" + lotroFormat.getName() + "</b>");
result.append("<ul>");
result.append("<li>valid sets: ");
for (Integer integer : lotroFormat.getValidSets())
result.append(integer + ", ");
result.append("</li>");
result.append("<li>sites from block: " + lotroFormat.getSiteBlock().getHumanReadable() + "</li>");
result.append("<li>Ring-bearer skirmish can be cancelled: " + (lotroFormat.canCancelRingBearerSkirmish() ? "yes" : "no") + "</li>");
result.append("<li>X-listed: ");
for (String blueprintId : lotroFormat.getBannedCards()) {
String fullName = GameUtils.getFullName(_library.getLotroCardBlueprint(blueprintId));
result.append("<i>" + fullName + "</i>, ");
}
if (lotroFormat.getBannedCards().size() == 0)
result.append("none,");
result.append("</li>");
result.append("<li>R-listed: ");
for (String blueprintId : lotroFormat.getRestrictedCards()) {
String fullName = GameUtils.getFullName(_library.getLotroCardBlueprint(blueprintId));
result.append("<i>" + fullName + "</i>, ");
}
if (lotroFormat.getRestrictedCards().size() == 0)
result.append("none,");
result.append("</li>");
result.append("</ul>");
}
return result.toString();
}
@GET
@Produces(MediaType.APPLICATION_XML)

View File

@@ -229,7 +229,7 @@
<li><a href="includes/leagueResults.html">Leagues</a></li>
<li><a href="includes/leagueRules.html">League Rules (updated)</a></li>
<li><a href="includes/instruction.html">Manual</a></li>
<li><a href="includes/formatRules.html">Format Rules</a></li>
<li><a href="/gemp-lotr/server/hall/formats/html">Format Rules</a></li>
<li><a href="includes/contribute.html">Contribute</a></li>
<script type="text/javascript">
document.write('<li><a href="includes/changeLog.html?_=' + (new Date().getTime()) + '">Change Log</a></li>');