Deck builder.

This commit is contained in:
marcins78@gmail.com
2011-12-11 14:15:10 +00:00
parent a5426ae07a
commit a623300b2f
6 changed files with 73 additions and 8 deletions

View File

@@ -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();

View File

@@ -71,7 +71,7 @@ public class LeagueService {
public void gameFinished(String winnerPlayerId, String winReason, Map<String, String> 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);
}
});

View File

@@ -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);

View File

@@ -22,5 +22,16 @@
Packs: <textarea rows="5" cols="20" name="packCollection"></textarea><br/>
<input type="submit" value="Create">
</form>
<h2>Add season</h2>
<form method="POST" action="server/admin/addLeagueSeason">
League type: <input type="text" name="leagueType"><br/>
Season type: <input type="text" name="type"><br/>
Start: <input type="text" name="start"><br/>
End: <input type="text" name="end"><br/>
Max matches: <input type="text" name="maxMatches"><br/>
<input type="submit" value="Create">
</form>
</body>
</html>

View File

@@ -59,15 +59,17 @@
</li>
<li>Earning points:
<ol type="a">
<li>Each calendar day (in GMT+0 time-zone), every <b style="color:#009f9f">League</b> participant can play a
maximum of fixed (to
be announced) rated games.
<li>Each <b style="color:#009f9f">League serie</b>, every <b style="color:#009f9f">League</b> participant
can play a
maximum of fixed (to be announced) rated games.
</li>
<li>In addition to rated games, player can choose to play any number of non-rated games with other
<b style="color:#009f9f">League</b> players.
</li>
<li>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.
<li>Only first game played against the same opponent in the same <b style="color:#009f9f">League serie</b>
can be rated. Any subsequent games
against the same opponent in the same <b style="color:#009f9f">League serie</b> will be treated as
non-rated.
</li>
<li>Winner of each rated game in a <b style="color:#009f9f">League</b> gains 2 <b style="color:#009f9f">League
serie</b> points. Rated game loser

View File

@@ -51,7 +51,16 @@ var GempLotrHallUI = Class.extend({
buttonsDiv.append(editDeck);
buttonsDiv.append(" | ");
this.supportedFormatsSelect = $("<select></select>");
var editLeagueDeck = $("<button>League deck builder</button>");
editLeagueDeck.button().click(
function() {
location.href = 'deckBuild.html?collectionType=test_league';
});
buttonsDiv.append(editLeagueDeck);
buttonsDiv.append(" | ");
this.supportedFormatsSelect = $("<select style='width: 220px'></select>");
this.supportedFormatsSelect.hide();
this.createTableButton = $("<button>Create table</button>");
@@ -69,7 +78,7 @@ var GempLotrHallUI = Class.extend({
});
this.createTableButton.hide();
this.decksSelect = $("<select></select>");
this.decksSelect = $("<select style='width: 220px'></select>");
this.decksSelect.hide();
buttonsDiv.append(this.supportedFormatsSelect);