- You can't create a League table, if you played maximum number of games in league serie. You can't join a league table
if you played maximum games in league serie, or if you played against that opponent in this league series already.
This commit is contained in:
@@ -115,6 +115,9 @@ public class HallServer extends AbstractServer {
|
||||
leagueSerie = _leagueService.getCurrentLeagueSerie(league);
|
||||
if (leagueSerie == null)
|
||||
throw new HallException("There is no ongoing serie for that league");
|
||||
|
||||
if (!_leagueService.canPlayRankedGame(league, leagueSerie, player.getName()))
|
||||
throw new HallException("You have already played max games in league");
|
||||
format = _supportedFormats.get(leagueSerie.getFormat());
|
||||
collectionType = league.getCollectionType();
|
||||
}
|
||||
@@ -305,7 +308,15 @@ public class HallServer extends AbstractServer {
|
||||
_awaitingTables.remove(tableId);
|
||||
}
|
||||
|
||||
private void joinTableInternal(String tableId, String playerId, AwaitingTable awaitingTable, String deckName, LotroDeck lotroDeck) {
|
||||
private void joinTableInternal(String tableId, String playerId, AwaitingTable awaitingTable, String deckName, LotroDeck lotroDeck) throws HallException {
|
||||
League league = awaitingTable.getLeague();
|
||||
if (league != null) {
|
||||
LeagueSerie leagueSerie = awaitingTable.getLeagueSerie();
|
||||
if (!_leagueService.canPlayRankedGame(league, leagueSerie, playerId))
|
||||
throw new HallException("You have already played max games in league");
|
||||
if (!_leagueService.canPlayRankedGame(league, leagueSerie, awaitingTable.getPlayerNames().iterator().next(), playerId))
|
||||
throw new HallException("You have already played ranked league game against this player in that series");
|
||||
}
|
||||
boolean tableFull = awaitingTable.addPlayer(new LotroGameParticipant(playerId, deckName, lotroDeck));
|
||||
if (tableFull)
|
||||
createGame(tableId, awaitingTable);
|
||||
|
||||
@@ -61,6 +61,23 @@ public class LeagueService {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPlayRankedGame(League league, LeagueSerie season, String player) {
|
||||
int maxMatches = season.getMaxMatches();
|
||||
Collection<LeagueMatch> playedInSeason = _leagueMatchDao.getPlayerMatchesPlayedOn(league, season, player);
|
||||
if (playedInSeason.size() >= maxMatches)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canPlayRankedGame(League league, LeagueSerie season, String playerOne, String playerTwo) {
|
||||
Collection<LeagueMatch> playedInSeason = _leagueMatchDao.getPlayerMatchesPlayedOn(league, season, playerOne);
|
||||
for (LeagueMatch leagueMatch : playedInSeason) {
|
||||
if (playerTwo.equals(leagueMatch.getWinner()) && playerTwo.equals(leagueMatch.getLoser()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getCurrentDate() {
|
||||
Calendar date = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
|
||||
return date.get(Calendar.YEAR) * 10000 + (date.get(Calendar.MONTH) + 1) * 100 + date.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<pre style="font-size:80%">
|
||||
<b>23 Jan. 2012</b>
|
||||
- You can't create a League table, if you played maximum number of games in league serie. You can't join a league table
|
||||
if you played maximum games in league serie, or if you played against that opponent in this league series already.
|
||||
|
||||
<b>22 Jan. 2012</b>
|
||||
- Added resistance to card detail information window.
|
||||
- If an effect makes you exert a character X times, and you can't find a character able to be exerted X times, you can
|
||||
|
||||
Reference in New Issue
Block a user