Added league matches list to league results page.

This commit is contained in:
marcins78@gmail.com
2012-10-24 22:14:08 +00:00
parent 924a18048f
commit 3c29901fb6
5 changed files with 38 additions and 8 deletions

View File

@@ -11,6 +11,11 @@
<artifactId>gemp-lotr-common</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-collections</artifactId>
<version>r03</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>

View File

@@ -163,7 +163,7 @@ public class LeagueService {
_collectionsManager.addItemsToPlayerCollection(player, new CollectionType("permanent", "My cards"), prize.getAll().values());
}
private Collection<LeagueMatchResult> getPlayerMatchesInSerie(League league, LeagueSerieData serie, String player) {
public synchronized Collection<LeagueMatchResult> getPlayerMatchesInSerie(League league, LeagueSerieData serie, String player) {
final Collection<LeagueMatchResult> allMatches = _leagueMatchDao.getLeagueMatches(league.getType());
Set<LeagueMatchResult> result = new HashSet<LeagueMatchResult>();
for (LeagueMatchResult match : allMatches) {

View File

@@ -3,6 +3,7 @@ package com.gempukku.lotro.server;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.competitive.PlayerStanding;
import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.db.vo.LeagueMatchResult;
import com.gempukku.lotro.game.Player;
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
import com.gempukku.lotro.league.LeagueData;
@@ -22,6 +23,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.text.DecimalFormat;
import java.util.Collection;
import java.util.List;
@Singleton
@@ -127,6 +129,16 @@ public class LeagueResource extends AbstractResource {
serieElem.setAttribute("collection", serie.getCollectionType().getFullName());
serieElem.setAttribute("limited", String.valueOf(serie.isLimited()));
Element matchesElem = doc.createElement("matches");
Collection<LeagueMatchResult> playerMatches = _leagueService.getPlayerMatchesInSerie(league, serie, resourceOwner.getName());
for (LeagueMatchResult playerMatch : playerMatches) {
Element matchElem = doc.createElement("match");
matchElem.setAttribute("winner", playerMatch.getWinner());
matchElem.setAttribute("loser", playerMatch.getLoser());
matchesElem.appendChild(matchElem);
}
serieElem.appendChild(matchesElem);
final List<PlayerStanding> standings = _leagueService.getLeagueSerieStandings(league, serie);
for (PlayerStanding standing : standings) {
Element standingElem = doc.createElement("standing");

View File

@@ -102,7 +102,7 @@ var GempLotrCommunication = Class.extend({
url:this.url + "/tournament",
cache:false,
data:{
participanId:getUrlParam("participantId") },
participantId:getUrlParam("participantId") },
success:this.deliveryCheck(callback),
error:this.errorCheck(errorMap),
dataType:"xml"
@@ -115,7 +115,7 @@ var GempLotrCommunication = Class.extend({
url:this.url + "/tournament/history",
cache:false,
data:{
participanId:getUrlParam("participantId") },
participantId:getUrlParam("participantId") },
success:this.deliveryCheck(callback),
error:this.errorCheck(errorMap),
dataType:"xml"
@@ -128,7 +128,7 @@ var GempLotrCommunication = Class.extend({
url:this.url + "/tournament/" + tournamentId,
cache:false,
data:{
participanId:getUrlParam("participantId") },
participantId:getUrlParam("participantId") },
success:this.deliveryCheck(callback),
error:this.errorCheck(errorMap),
dataType:"xml"
@@ -141,7 +141,7 @@ var GempLotrCommunication = Class.extend({
url:this.url + "/league",
cache:false,
data:{
participanId:getUrlParam("participantId") },
participantId:getUrlParam("participantId") },
success:this.deliveryCheck(callback),
error:this.errorCheck(errorMap),
dataType:"xml"
@@ -154,7 +154,7 @@ var GempLotrCommunication = Class.extend({
url:this.url + "/league/" + type,
cache:false,
data:{
participanId:getUrlParam("participantId") },
participantId:getUrlParam("participantId") },
success:this.deliveryCheck(callback),
error:this.errorCheck(errorMap),
dataType:"xml"
@@ -167,7 +167,7 @@ var GempLotrCommunication = Class.extend({
url:this.url + "/league/" + code,
cache:false,
data:{
participanId:getUrlParam("participantId") },
participantId:getUrlParam("participantId") },
success:this.deliveryCheck(callback),
error:this.errorCheck(errorMap),
dataType:"xml"

View File

@@ -98,13 +98,26 @@ var LeagueResultsUI = Class.extend({
tabDiv.append(tabContent);
tabNavigation.append("<li><a href='#leagueoverall'>Overall results</a></li>");
tabNavigation.append("<li><a href='#leaguematches'>Your league matches</a></li>");
var matchResults = $("<div id='leaguematches'></div>");
tabDiv.append(matchResults);
var series = league.getElementsByTagName("serie");
for (var j = 0; j < series.length; j++) {
var serie = series[j];
matchResults.append("<div>Serie " + (j + 1) + "</div>");
var matchGroup = $("<table class='standings'><tr><th>Winner</th><th>Loser</th></tr></table>");
var matches = serie.getElementsByTagName("match");
for (var k = 0; k<matches.length; k++) {
var match = matches[k];
matchGroup.append("<tr><td>"+match.getAttribute("winner")+"</td><td>"+match.getAttribute("loser")+"</td></tr>");
}
matchResults.append(matchGroup);
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");