From a623300b2ff30cffeb6a0ee080dacb57de969831 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Sun, 11 Dec 2011 14:15:10 +0000 Subject: [PATCH] Deck builder. --- .../gempukku/lotro/db/LeagueSeasonDAO.java | 23 +++++++++++++++++++ .../gempukku/lotro/league/LeagueService.java | 2 +- .../gempukku/lotro/server/AdminResource.java | 20 ++++++++++++++++ .../gemp-lotr-web/src/main/webapp/admin.html | 11 +++++++++ .../src/main/webapp/includes/leagueRules.html | 12 ++++++---- .../src/main/webapp/js/hallUi.js | 13 +++++++++-- 6 files changed, 73 insertions(+), 8 deletions(-) diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/LeagueSeasonDAO.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/LeagueSeasonDAO.java index 57463dc85..1437e71b7 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/LeagueSeasonDAO.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/LeagueSeasonDAO.java @@ -15,6 +15,29 @@ public class LeagueSeasonDAO { _dbAccess = dbAccess; } + public void addSeason(String leagueType, String seasonType, int start, int end, int maxMatches) { + try { + Connection conn = _dbAccess.getDataSource().getConnection(); + try { + PreparedStatement statement = conn.prepareStatement("insert into league_season (league_type, season_type, start, end, max_matches) values (?, ?, ?, ?, ?)"); + try { + statement.setString(1, leagueType); + statement.setString(2, seasonType); + statement.setInt(3, start); + statement.setInt(4, end); + statement.setInt(5, maxMatches); + statement.execute(); + } finally { + statement.close(); + } + } finally { + conn.close(); + } + } catch (SQLException exp) { + throw new RuntimeException(exp); + } + } + public LeagueSeason getSeasonForLeague(League league, int inTime) { try { Connection conn = _dbAccess.getDataSource().getConnection(); diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeagueService.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeagueService.java index 8ca2142f5..c38368356 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeagueService.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/league/LeagueService.java @@ -71,7 +71,7 @@ public class LeagueService { public void gameFinished(String winnerPlayerId, String winReason, Map loserPlayerIdsWithReasons) { String loser = loserPlayerIdsWithReasons.keySet().iterator().next(); _leagueMatchDao.addPlayedMatch(league, season, winnerPlayerId, loser); - _leaguePointsDao.addPoints(league, season, winnerPlayerId, 3); + _leaguePointsDao.addPoints(league, season, winnerPlayerId, 2); _leaguePointsDao.addPoints(league, season, loser, 1); } }); diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/AdminResource.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/AdminResource.java index c505ad979..53010883e 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/AdminResource.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/AdminResource.java @@ -3,6 +3,7 @@ package com.gempukku.lotro.server; import com.gempukku.lotro.db.CollectionDAO; import com.gempukku.lotro.db.DeckDAO; import com.gempukku.lotro.db.LeagueDAO; +import com.gempukku.lotro.db.LeagueSeasonDAO; import com.gempukku.lotro.game.DefaultCardCollection; import com.gempukku.lotro.game.LotroCardBlueprintLibrary; import com.gempukku.lotro.game.Player; @@ -27,6 +28,8 @@ public class AdminResource extends AbstractResource { @Context private LeagueDAO _leagueDao; @Context + private LeagueSeasonDAO _leagueSeasonDao; + @Context private LotroCardBlueprintLibrary _library; @Context private HallServer _hallServer; @@ -78,6 +81,23 @@ public class AdminResource extends AbstractResource { return "OK"; } + + @Path("/addLeagueSeason") + @POST + public String addLeagueSeason( + @FormParam("leagueType") String leagueType, + @FormParam("type") String type, + @FormParam("start") int start, + @FormParam("end") int end, + @FormParam("maxMatches") int maxMatches, + @Context HttpServletRequest request) throws Exception { + validateAdmin(request); + + _leagueSeasonDao.addSeason(leagueType, type, start, end, maxMatches); + + return "OK"; + } + private void validateAdmin(HttpServletRequest request) { Player player = getResourceOwnerSafely(request, null); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/admin.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/admin.html index 9873e71e0..af6d9eb33 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/admin.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/admin.html @@ -22,5 +22,16 @@ Packs:
+ +

Add season

+ +
+ League type:
+ Season type:
+ Start:
+ End:
+ Max matches:
+ +
\ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/leagueRules.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/leagueRules.html index a7ec47fb6..d8830ea87 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/leagueRules.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/leagueRules.html @@ -59,15 +59,17 @@
  • Earning points:
      -
    1. Each calendar day (in GMT+0 time-zone), every League participant can play a - maximum of fixed (to - be announced) rated games. +
    2. Each League serie, every League participant + can play a + maximum of fixed (to be announced) rated games.
    3. In addition to rated games, player can choose to play any number of non-rated games with other League players.
    4. -
    5. Only first game played against the same opponent on the same day can be rated. Any subsequent games - against the same opponent on the same day will be treated as non-rated. +
    6. Only first game played against the same opponent in the same League serie + can be rated. Any subsequent games + against the same opponent in the same League serie will be treated as + non-rated.
    7. Winner of each rated game in a League gains 2 League serie points. Rated game loser diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js index f5d6e033b..10aafa40f 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js @@ -51,7 +51,16 @@ var GempLotrHallUI = Class.extend({ buttonsDiv.append(editDeck); buttonsDiv.append(" | "); - this.supportedFormatsSelect = $(""); + var editLeagueDeck = $(""); + editLeagueDeck.button().click( + function() { + location.href = 'deckBuild.html?collectionType=test_league'; + }); + + buttonsDiv.append(editLeagueDeck); + buttonsDiv.append(" | "); + + this.supportedFormatsSelect = $(""); this.supportedFormatsSelect.hide(); this.createTableButton = $(""); @@ -69,7 +78,7 @@ var GempLotrHallUI = Class.extend({ }); this.createTableButton.hide(); - this.decksSelect = $(""); + this.decksSelect = $(""); this.decksSelect.hide(); buttonsDiv.append(this.supportedFormatsSelect);