Adding leagues via league-admin page.
This commit is contained in:
@@ -48,33 +48,32 @@ public class LotroServer extends AbstractServer {
|
||||
|
||||
// Hunters have 1-194 normal cards, 9 "O" cards, and 3 extra to cover the different culture versions of 15_60
|
||||
|
||||
final int[] cardCounts = new int[]{129, 365, 122, 122, 365, 128, 128, 365, 122, 52, 122, 266, 203, 203, 15, 207, 6, 157, 149, 40};
|
||||
Thread thr = new Thread() {
|
||||
public void run() {
|
||||
final int[] cardCounts = new int[]{129, 365, 122, 122, 365, 128, 128, 365, 122, 52, 122, 266, 203, 203, 15, 207, 6, 157, 149, 40};
|
||||
|
||||
for (int i = 0; i <= 19; i++) {
|
||||
System.out.println("Loading set " + i);
|
||||
for (int j = 1; j <= cardCounts[i]; j++) {
|
||||
String blueprintId = i + "_" + j;
|
||||
try {
|
||||
if (_lotroCardBlueprintLibrary.getBaseBlueprintId(blueprintId).equals(blueprintId)) {
|
||||
LotroCardBlueprint cardBlueprint = _lotroCardBlueprintLibrary.getLotroCardBlueprint(blueprintId);
|
||||
CardType cardType = cardBlueprint.getCardType();
|
||||
if (cardType == CardType.SITE || cardType == CardType.THE_ONE_RING)
|
||||
_defaultCollection.addItem(blueprintId, 1);
|
||||
else
|
||||
_defaultCollection.addItem(blueprintId, 4);
|
||||
for (int i = 0; i <= 19; i++) {
|
||||
System.out.println("Loading set " + i);
|
||||
for (int j = 1; j <= cardCounts[i]; j++) {
|
||||
String blueprintId = i + "_" + j;
|
||||
try {
|
||||
if (_lotroCardBlueprintLibrary.getBaseBlueprintId(blueprintId).equals(blueprintId)) {
|
||||
LotroCardBlueprint cardBlueprint = _lotroCardBlueprintLibrary.getLotroCardBlueprint(blueprintId);
|
||||
CardType cardType = cardBlueprint.getCardType();
|
||||
if (cardType == CardType.SITE || cardType == CardType.THE_ONE_RING)
|
||||
_defaultCollection.addItem(blueprintId, 1);
|
||||
else
|
||||
_defaultCollection.addItem(blueprintId, 4);
|
||||
}
|
||||
} catch (IllegalArgumentException exp) {
|
||||
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException exp) {
|
||||
|
||||
}
|
||||
_collectionReadyLatch.countDown();
|
||||
}
|
||||
try {
|
||||
// Slow it down, as it chockes the poor Amazon
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException exp) {
|
||||
|
||||
}
|
||||
}
|
||||
_collectionReadyLatch.countDown();
|
||||
};
|
||||
thr.start();
|
||||
|
||||
_gameRecorder = new GameRecorder(_gameHistoryService);
|
||||
}
|
||||
|
||||
@@ -178,16 +178,16 @@ public class AdminResource extends AbstractResource {
|
||||
@FormParam("start") String start,
|
||||
@FormParam("prizeMultiplier") float prizeMultiplier,
|
||||
@FormParam("collectionType") String collectionType,
|
||||
@FormParam("format") String[] formats,
|
||||
@FormParam("serieDuration") int[] serieDurations,
|
||||
@FormParam("maxMatches") int[] maxMatches,
|
||||
@FormParam("format") List<String> formats,
|
||||
@FormParam("serieDuration") List<Integer> serieDurations,
|
||||
@FormParam("maxMatches") List<Integer> maxMatches,
|
||||
@Context HttpServletRequest request) throws Exception {
|
||||
validateLeagueAdmin(request);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + formats.length);
|
||||
for (int i = 0; i < formats.length; i++)
|
||||
sb.append("," + formats[i] + "," + serieDurations[i] + "," + maxMatches[i]);
|
||||
sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + formats.size());
|
||||
for (int i = 0; i < formats.size(); i++)
|
||||
sb.append("," + formats.get(i) + "," + serieDurations.get(i) + "," + maxMatches.get(i));
|
||||
|
||||
String parameters = sb.toString();
|
||||
LeagueData leagueData = new NewConstructedLeagueData(parameters);
|
||||
@@ -234,18 +234,18 @@ public class AdminResource extends AbstractResource {
|
||||
@FormParam("start") String start,
|
||||
@FormParam("prizeMultiplier") float prizeMultiplier,
|
||||
@FormParam("collectionType") String collectionType,
|
||||
@FormParam("format") String[] formats,
|
||||
@FormParam("serieDuration") int[] serieDurations,
|
||||
@FormParam("maxMatches") int[] maxMatches,
|
||||
@FormParam("format") List<String> formats,
|
||||
@FormParam("serieDuration") List<Integer> serieDurations,
|
||||
@FormParam("maxMatches") List<Integer> maxMatches,
|
||||
@Context HttpServletRequest request) throws Exception {
|
||||
validateLeagueAdmin(request);
|
||||
|
||||
String code = String.valueOf(System.currentTimeMillis());
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + formats.length);
|
||||
for (int i = 0; i < formats.length; i++)
|
||||
sb.append("," + formats[i] + "," + serieDurations[i] + "," + maxMatches[i]);
|
||||
sb.append(start + "," + collectionType + "," + prizeMultiplier + "," + formats.size());
|
||||
for (int i = 0; i < formats.size(); i++)
|
||||
sb.append("," + formats.get(i) + "," + serieDurations.get(i) + "," + maxMatches.get(i));
|
||||
|
||||
String parameters = sb.toString();
|
||||
LeagueData leagueData = new NewConstructedLeagueData(parameters);
|
||||
|
||||
@@ -15,3 +15,7 @@ function formatPrice(price) {
|
||||
var silver = (price % 100);
|
||||
return Math.floor(price / 100) + "<img src='images/gold.png'/> " + ((silver < 10) ? ("0" + silver) : silver) + "<img src='images/silver.png'/>";
|
||||
}
|
||||
|
||||
function getDateString(date) {
|
||||
return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8);
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ var LeagueResultsUI = Class.extend({
|
||||
|
||||
this.questionDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
title: "League operation"
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
title: "League operation"
|
||||
});
|
||||
|
||||
this.loadResults();
|
||||
},
|
||||
@@ -27,10 +27,6 @@ var LeagueResultsUI = Class.extend({
|
||||
});
|
||||
},
|
||||
|
||||
getDateString: function(date) {
|
||||
return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8);
|
||||
},
|
||||
|
||||
loadedLeague: function(xml) {
|
||||
var that = this;
|
||||
log(xml);
|
||||
@@ -107,7 +103,7 @@ var LeagueResultsUI = Class.extend({
|
||||
var collection = serie.getAttribute("collection");
|
||||
var limited = serie.getAttribute("limited");
|
||||
|
||||
var serieText = serieName + " - " + this.getDateString(serieStart) + " to " + this.getDateString(serieEnd);
|
||||
var serieText = serieName + " - " + getDateString(serieStart) + " to " + getDateString(serieEnd);
|
||||
$("#leagueExtraInfo").append("<div class='serieName'>" + serieText + "</div>");
|
||||
|
||||
$("#leagueExtraInfo").append("<div><b>Format:</b> " + ((limited == "true") ? "Limited" : "Constructed") + " " + format + "</div>");
|
||||
@@ -146,7 +142,7 @@ var LeagueResultsUI = Class.extend({
|
||||
|
||||
$("#leagueResults").append("<div class='leagueName'>" + leagueName + "</div>");
|
||||
|
||||
var duration = this.getDateString(start) + " to " + this.getDateString(end);
|
||||
var duration = getDateString(start) + " to " + getDateString(end);
|
||||
$("#leagueResults").append("<div class='leagueDuration'><b>Duration (GMT+0):</b> " + duration + "</div>");
|
||||
|
||||
var detailsBut = $("<button>See details</button>").button();
|
||||
|
||||
@@ -6,6 +6,24 @@
|
||||
<meta http-equiv="Cache-Control" content="no-cache"/>
|
||||
<meta http-equiv="Expires" content="-1">
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-size: 12px;
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.leagueName {
|
||||
font-size: 150%;
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
.serieName {
|
||||
font-size: 120%;
|
||||
font-weight: bolder;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="css/dark-hive/jquery-ui-1.8.16.custom.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/jquery.contextMenu.css">
|
||||
<link rel="stylesheet" type="text/css" href="js/jquery/styles/jquery.spinnercontrol.css">
|
||||
@@ -28,31 +46,31 @@
|
||||
function submitFormToAddress(url, formElem, success, error) {
|
||||
var data = {};
|
||||
|
||||
var inputs = $("input[type='text'], option:selected", formElem);
|
||||
var input;
|
||||
for (input in inputs) {
|
||||
var name = null;
|
||||
var value = null;
|
||||
if (input.tagName == "INPUT") {
|
||||
name = input.getAttribute("name");
|
||||
value = input.val();
|
||||
|
||||
} else if (input.tagName == "OPTION") {
|
||||
name = input.parents("select").eq(0).getAttribute("name");
|
||||
value = input.prop("value");
|
||||
}
|
||||
if (name != null && value != null) {
|
||||
if (data[name] == null)
|
||||
data[name] = new Array();
|
||||
data[name].push(value);
|
||||
}
|
||||
}
|
||||
var inputs = $("input[type='text'], option:selected", formElem).each(
|
||||
function() {
|
||||
var input = $(this);
|
||||
var name = null;
|
||||
var value = null;
|
||||
if (input.prop("tagName") == "INPUT") {
|
||||
name = input.attr("name");
|
||||
value = input.val();
|
||||
} else if (input.prop("tagName") == "OPTION") {
|
||||
name = input.parents("select").attr("name");
|
||||
value = input.attr("value");
|
||||
}
|
||||
if (name != null && value != null) {
|
||||
if (data[name] == null)
|
||||
data[name] = new Array();
|
||||
data[name].push(value);
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
cache: false,
|
||||
data: data,
|
||||
traditional: true,
|
||||
success: success,
|
||||
error: error,
|
||||
dataType: "xml"
|
||||
@@ -63,62 +81,76 @@
|
||||
function () {
|
||||
var previewDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: true,
|
||||
modal: true,
|
||||
title: "Preview window"
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: true,
|
||||
modal: true,
|
||||
title: "Preview window"
|
||||
});
|
||||
|
||||
var displayPreview = function(xml) {
|
||||
var root = xml.documentElement;
|
||||
if (root.tagName == 'league') {
|
||||
var league = root;
|
||||
|
||||
var leagueName = league.getAttribute("name");
|
||||
var cost = parseInt(league.getAttribute("cost"));
|
||||
var start = league.getAttribute("start");
|
||||
var end = league.getAttribute("end");
|
||||
|
||||
previewDialog.append("<div class='leagueName'>" + leagueName + "</div>");
|
||||
|
||||
var costStr = formatPrice(cost);
|
||||
previewDialog.append("<div class='leagueCost'><b>Cost:</b> " + costStr + "</div>");
|
||||
|
||||
var series = league.getElementsByTagName("serie");
|
||||
for (var j = 0; j < series.length; j++) {
|
||||
|
||||
var tabContent = $("<div id='leagueserie" + j + "'></div>");
|
||||
|
||||
var serie = series[j];
|
||||
var serieName = serie.getAttribute("type");
|
||||
var serieStart = serie.getAttribute("start");
|
||||
var serieEnd = serie.getAttribute("end");
|
||||
var maxMatches = serie.getAttribute("maxMatches");
|
||||
var format = serie.getAttribute("format");
|
||||
var collection = serie.getAttribute("collection");
|
||||
var limited = serie.getAttribute("limited");
|
||||
|
||||
var serieText = serieName + " - " + getDateString(serieStart) + " to " + getDateString(serieEnd);
|
||||
previewDialog.append("<div class='serieName'>" + serieText + "</div>");
|
||||
|
||||
previewDialog.append("<div><b>Format:</b> " + ((limited == "true") ? "Limited" : "Constructed") + " " + format + "</div>");
|
||||
previewDialog.append("<div><b>Collection:</b> " + collection + "</div>");
|
||||
|
||||
previewDialog.append("<div>Maximum ranked matches in serie: " + maxMatches + "</div>");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var previewError = function() {
|
||||
previewDialog.dialog("close");
|
||||
alert("Invalid parameters specified");
|
||||
};
|
||||
|
||||
$("#previewSealed").click(
|
||||
function() {
|
||||
submitFormToAddress("/gemp-lotr-server/admin/previewSealedLeague", $("#addSealedForm").eq(0),
|
||||
function(xml) {
|
||||
var root = xml.documentElement;
|
||||
if (root.tagName == 'league') {
|
||||
var league = root;
|
||||
|
||||
var leagueName = league.getAttribute("name");
|
||||
var cost = parseInt(league.getAttribute("cost"));
|
||||
var start = league.getAttribute("start");
|
||||
var end = league.getAttribute("end");
|
||||
|
||||
previewDialog.append("<div class='leagueName'>" + leagueName + "</div>");
|
||||
|
||||
var costStr = formatPrice(cost);
|
||||
previewDialog.append("<div class='leagueCost'><b>Cost:</b> " + costStr + "</div>");
|
||||
|
||||
var series = league.getElementsByTagName("serie");
|
||||
for (var j = 0; j < series.length; j++) {
|
||||
|
||||
var tabContent = $("<div id='leagueserie" + j + "'></div>");
|
||||
|
||||
var serie = series[j];
|
||||
var serieName = serie.getAttribute("type");
|
||||
var serieStart = serie.getAttribute("start");
|
||||
var serieEnd = serie.getAttribute("end");
|
||||
var maxMatches = serie.getAttribute("maxMatches");
|
||||
var format = serie.getAttribute("format");
|
||||
var collection = serie.getAttribute("collection");
|
||||
var limited = serie.getAttribute("limited");
|
||||
|
||||
var serieText = serieName + " - " + this.getDateString(serieStart) + " to " + this.getDateString(serieEnd);
|
||||
previewDialog.append("<div class='serieName'>" + serieText + "</div>");
|
||||
|
||||
previewDialog.append("<div><b>Format:</b> " + ((limited == "true") ? "Limited" : "Constructed") + " " + format + "</div>");
|
||||
previewDialog.append("<div><b>Collection:</b> " + collection + "</div>");
|
||||
|
||||
previewDialog.append("<div>Maximum ranked matches in serie: " + maxMatches + "</div>");
|
||||
}
|
||||
}
|
||||
},
|
||||
function() {
|
||||
previewDialog.dialog("close");
|
||||
alert("Invalid parameters specified");
|
||||
});
|
||||
submitFormToAddress("/gemp-lotr-server/admin/previewSealedLeague", $("#addSealedForm").eq(0), displayPreview, previewError);
|
||||
previewDialog.html("");
|
||||
previewDialog.dialog("open");
|
||||
});
|
||||
|
||||
$("#previewConstructed").click(
|
||||
function() {
|
||||
submitFormToAddress("/gemp-lotr-server/admin/previewConstructedLeague", $("#addConstructedForm").eq(0), displayPreview, previewError);
|
||||
previewDialog.html("");
|
||||
previewDialog.dialog("open");
|
||||
});
|
||||
|
||||
$("#addConstructedSerie").click(
|
||||
function() {
|
||||
$(".serieData").last().clone().appendTo(".series");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
@@ -130,17 +162,59 @@
|
||||
<form id="addSealedForm" method="POST" action="/gemp-lotr-server/admin/addSealedLeague">
|
||||
Name: <input type="text" name="name"><br/>
|
||||
Cost (in silver): <input type="text" name="cost"><br/>
|
||||
Start (YYYYMMDD): <input type="text" name="start"><br/>
|
||||
Format:
|
||||
<select name="format">
|
||||
<option value="fotr_block">Fellowship block</option>
|
||||
<option value="ttt_block">Towers block</option>
|
||||
</select><br/>
|
||||
Start (YYYYMMDD): <input type="text" name="start"><br/>
|
||||
Serie duration in days: <input type="text" name="serieDuration"><br/>
|
||||
Maximum matches in serie: <input type="text" name="maxMatches"><br/>
|
||||
<input id="previewSealed" type="button" value="Preview sealed league">
|
||||
<input type="submit" value="Add sealed league">
|
||||
</form>
|
||||
|
||||
<h2>Add constructed league</h2>
|
||||
|
||||
<form id="addConstructedForm" method="POST" action="/gemp-lotr-server/admin/addConstructedLeague">
|
||||
Name: <input type="text" name="name"><br/>
|
||||
Cost (in silver): <input type="text" name="cost"><br/>
|
||||
Start (YYYYMMDD): <input type="text" name="start"><br/>
|
||||
Prize multiplier (e.g. 0.7): <input type="text" name="prizeMultiplier"><br/>
|
||||
Collection:
|
||||
<select name="collectionType">
|
||||
<option value="default">All cards</option>
|
||||
<option value="permanent">My cards</option>
|
||||
</select><br/>
|
||||
|
||||
<div class="series">
|
||||
<div class="serieData">
|
||||
<b>Serie definition:</b><br/>
|
||||
Format:
|
||||
<select name="format">
|
||||
<option value="fotr_block">Fellowship block</option>
|
||||
<option value="fotr1_block">Fellowship block - Set 1</option>
|
||||
<option value="fotr2_block">Fellowship block - Set 1&2</option>
|
||||
<option value="ttt_block">Towers block</option>
|
||||
<option value="ttt1_block">Towers block - Set 4</option>
|
||||
<option value="ttt2_block">Towers block - Set 4&5</option>
|
||||
<option value="towers_standard">Towers standard</option>
|
||||
<option value="king_block">King block</option>
|
||||
<option value="movie">Movie block</option>
|
||||
<option value="war_block">War of the Ring block</option>
|
||||
<option value="war_standard">War of the Ring standard</option>
|
||||
<option value="standard">Standard</option>
|
||||
<option value="open">Open</option>
|
||||
<option value="expanded">Expanded</option>
|
||||
</select><br/>
|
||||
Serie duration in days: <input type="text" name="serieDuration"><br/>
|
||||
Maximum matches in serie: <input type="text" name="maxMatches"><br/>
|
||||
</div>
|
||||
</div>
|
||||
<input id="addConstructedSerie" type="button" value="Add another serie">
|
||||
<input id="previewConstructed" type="button" value="Preview constructed league">
|
||||
<input type="submit" value="Add constructed league">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user