Merge branch 'grand-card-rework' into v2-cards
This commit is contained in:
@@ -254,6 +254,7 @@ public class CollectionRequestHandler extends LotroServerRequestHandler implemen
|
|||||||
Element collectionElem = doc.createElement("collection");
|
Element collectionElem = doc.createElement("collection");
|
||||||
collectionElem.setAttribute("type", collectionType.getCode());
|
collectionElem.setAttribute("type", collectionType.getCode());
|
||||||
collectionElem.setAttribute("name", collectionType.getFullName());
|
collectionElem.setAttribute("name", collectionType.getFullName());
|
||||||
|
collectionElem.setAttribute("format", serie.getFormat().getCode());
|
||||||
collectionsElem.appendChild(collectionElem);
|
collectionsElem.appendChild(collectionElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,6 +267,7 @@ public class CollectionRequestHandler extends LotroServerRequestHandler implemen
|
|||||||
Element collectionElem = doc.createElement("collection");
|
Element collectionElem = doc.createElement("collection");
|
||||||
collectionElem.setAttribute("type", collectionType.getCode());
|
collectionElem.setAttribute("type", collectionType.getCode());
|
||||||
collectionElem.setAttribute("name", collectionType.getFullName());
|
collectionElem.setAttribute("name", collectionType.getFullName());
|
||||||
|
collectionElem.setAttribute("format", tourney.getFormatCode());
|
||||||
collectionsElem.appendChild(collectionElem);
|
collectionsElem.appendChild(collectionElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ public class DeckRequestHandler extends LotroServerRequestHandler implements Uri
|
|||||||
if(format == null || targetFormat == null)
|
if(format == null || targetFormat == null)
|
||||||
{
|
{
|
||||||
responseWriter.writeHtmlResponse("Invalid format: " + targetFormat);
|
responseWriter.writeHtmlResponse("Invalid format: " + targetFormat);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> validation = format.validateDeck(deck);
|
List<String> validation = format.validateDeck(deck);
|
||||||
|
|||||||
@@ -393,6 +393,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
|||||||
for (var i = 0; i < collections.length; i++) {
|
for (var i = 0; i < collections.length; i++) {
|
||||||
var collection = collections[i];
|
var collection = collections[i];
|
||||||
$("#collectionSelect").append("<option value='" + collection.getAttribute("type") + "'>" + collection.getAttribute("name") + "</option>");
|
$("#collectionSelect").append("<option value='" + collection.getAttribute("type") + "'>" + collection.getAttribute("name") + "</option>");
|
||||||
|
$("#formatSelect").append("<option value='" + collection.getAttribute("format") + "'>" + collection.getAttribute("name") + "</option>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ var GempLotrHallUI = Class.extend({
|
|||||||
if (joined == "true") {
|
if (joined == "true") {
|
||||||
that.inTournament = true;
|
that.inTournament = true;
|
||||||
debugger;
|
debugger;
|
||||||
if(type === "sealed" && (stage === "deck-building" || stage === "registering decks")) {
|
if(type === "sealed" && (stage === "deck-building" || stage === "registering decks" || stage === "awaiting kickoff" || stage === "paused between rounds")) {
|
||||||
var but = $("<button>Register Deck</button>");
|
var but = $("<button>Register Deck</button>");
|
||||||
$(but).button().click((
|
$(but).button().click((
|
||||||
function(tourneyInfo) {
|
function(tourneyInfo) {
|
||||||
|
|||||||
@@ -38,7 +38,14 @@ public class DateUtils {
|
|||||||
public static boolean IsToday(ZonedDateTime date) { return DaysSince(date) == 0; }
|
public static boolean IsToday(ZonedDateTime date) { return DaysSince(date) == 0; }
|
||||||
public static boolean IsAtLeastDayAfter(ZonedDateTime a, ZonedDateTime b) { return DaysBetween(b, a) >= 1; }
|
public static boolean IsAtLeastDayAfter(ZonedDateTime a, ZonedDateTime b) { return DaysBetween(b, a) >= 1; }
|
||||||
public static boolean IsAfterStart(ZonedDateTime date, ZonedDateTime start) { return date.isEqual(start) || date.isAfter(start); }
|
public static boolean IsAfterStart(ZonedDateTime date, ZonedDateTime start) { return date.isEqual(start) || date.isAfter(start); }
|
||||||
public static boolean IsBeforeEnd(ZonedDateTime date, ZonedDateTime end) { return DaysBetween(end, date) < 0; }
|
public static boolean IsBeforeEnd(ZonedDateTime date, ZonedDateTime end) {
|
||||||
|
if(IsSameDay(date, end)) {
|
||||||
|
return date.isBefore(end.plusDays(1));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return date.isBefore(end);
|
||||||
|
}
|
||||||
|
}
|
||||||
public static boolean IsSameDay(ZonedDateTime a, ZonedDateTime b) { return DaysBetween(a, b) == 0; }
|
public static boolean IsSameDay(ZonedDateTime a, ZonedDateTime b) { return DaysBetween(a, b) == 0; }
|
||||||
public static long DaysBetween(ZonedDateTime a, ZonedDateTime b) { return Duration.between(a, b).toDays(); }
|
public static long DaysBetween(ZonedDateTime a, ZonedDateTime b) { return Duration.between(a, b).toDays(); }
|
||||||
public static long DaysSince(ZonedDateTime date) { return DaysBetween(date, Now()); }
|
public static long DaysSince(ZonedDateTime date) { return DaysBetween(date, Now()); }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.gempukku.lotro.common.SitesBlock;
|
|||||||
import com.gempukku.lotro.game.*;
|
import com.gempukku.lotro.game.*;
|
||||||
import com.gempukku.lotro.logic.GameUtils;
|
import com.gempukku.lotro.logic.GameUtils;
|
||||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -715,8 +716,13 @@ public class DefaultLotroFormat implements LotroFormat {
|
|||||||
sites.add(new PhysicalCardImpl(0, bp, "", _library.getLotroCardBlueprint(bp)));
|
sites.add(new PhysicalCardImpl(0, bp, "", _library.getLotroCardBlueprint(bp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
var rb = new PhysicalCardImpl(0, deck.getRingBearer(), "", _library.getLotroCardBlueprint(deck.getRingBearer()));
|
PhysicalCardImpl rb = null, ring = null;
|
||||||
var ring = new PhysicalCardImpl(0, deck.getRing(), "", _library.getLotroCardBlueprint(deck.getRing()));
|
if(!StringUtils.isEmpty(deck.getRingBearer())) {
|
||||||
|
rb = new PhysicalCardImpl(0, deck.getRingBearer(), "", _library.getLotroCardBlueprint(deck.getRingBearer()));
|
||||||
|
}
|
||||||
|
if(!StringUtils.isEmpty(deck.getRing())) {
|
||||||
|
ring = new PhysicalCardImpl(0, deck.getRing(), "", _library.getLotroCardBlueprint(deck.getRing()));
|
||||||
|
}
|
||||||
|
|
||||||
var result = map.validatePreGameDeckCheck(freeps, shadow, sites, rb, ring, new PhysicalCardImpl(0, mapBP, "", map));
|
var result = map.validatePreGameDeckCheck(freeps, shadow, sites, rb, ring, new PhysicalCardImpl(0, mapBP, "", map));
|
||||||
if(!result.success())
|
if(!result.success())
|
||||||
|
|||||||
@@ -528,19 +528,26 @@ public class HallServer extends AbstractServer {
|
|||||||
String result = "";
|
String result = "";
|
||||||
var tournament = _tournamentService.getTournamentById(tournamentId);
|
var tournament = _tournamentService.getTournamentById(tournamentId);
|
||||||
if (tournament != null) {
|
if (tournament != null) {
|
||||||
var stage = tournament.getInfo().Stage;
|
LotroDeck lotroDeck = validateUserAndDeck(_formatLibrary.getFormat(tournament.getFormatCode()), player, deckName, tournament.getCollectionType());
|
||||||
if(stage == Tournament.Stage.STARTING || stage == Tournament.Stage.DECK_BUILDING ||
|
var submitted = tournament.playerSubmittedDeck(player.getName(), lotroDeck);
|
||||||
stage == Tournament.Stage.PAUSED || stage == Tournament.Stage.AWAITING_KICKOFF) {
|
|
||||||
LotroDeck lotroDeck = validateUserAndDeck(_formatLibrary.getFormat(tournament.getFormatCode()), player, deckName, tournament.getCollectionType());
|
|
||||||
|
|
||||||
tournament.playerSubmittedDeck(player.getName(), lotroDeck);
|
if(submitted) {
|
||||||
|
result = "Registered deck '" + deckName + "' with tournament <b>" + tournament.getTournamentName() + "</b> successfully."
|
||||||
|
+ "<br/><br/>If you make an update to your deck, you will need to register it here again for any changes to take effect.";
|
||||||
|
_log.trace("Player '" + player.getName() + "' registered deck '" + deckName + "' for tournament '" + tournament.getTournamentName() + "' successfully.");
|
||||||
}
|
}
|
||||||
result = "Registered deck '" + deckName + "' with tournament <b>" + tournament.getTournamentName() + "</b> successfully."
|
else {
|
||||||
+ "<br/><br/>If you make an update to your deck, you will need to register it here again for any changes to take effect.";
|
result = "Could not register deck with tournament <b>" + tournament.getTournamentName() + "</b>."
|
||||||
|
+ "<br/><br/>Please contact an administrator if you think this was in error.";
|
||||||
|
|
||||||
|
_log.trace("Player '" + player.getName() + "' failed to register deck '" + deckName + "' for tournament '" + tournament.getTournamentName() + "'.");
|
||||||
|
}
|
||||||
|
|
||||||
hallChanged();
|
hallChanged();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = "Registration for that tournament has already closed.";
|
result = "Registration for that tournament has already closed.";
|
||||||
|
_log.trace("Player '" + player.getName() + "' attempted to register deck '" + deckName + "' for tournament '" + tournament.getTournamentName() + "' after registration closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class LeagueService {
|
|||||||
var currentDate = DateUtils.Now();
|
var currentDate = DateUtils.Now();
|
||||||
|
|
||||||
for (LeagueSerieInfo leagueSerieInfo : league.getLeagueData(_productLibrary, _formatLibrary, _soloDraftDefinitions).getSeries()) {
|
for (LeagueSerieInfo leagueSerieInfo : league.getLeagueData(_productLibrary, _formatLibrary, _soloDraftDefinitions).getSeries()) {
|
||||||
if (currentDate.isAfter( leagueSerieInfo.getStart()) && currentDate.isBefore(leagueSerieInfo.getEnd()))
|
if (currentDate.isAfter( leagueSerieInfo.getStart()) && DateUtils.IsBeforeEnd(currentDate, leagueSerieInfo.getEnd()))
|
||||||
return leagueSerieInfo;
|
return leagueSerieInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ public class ConstructedTournament extends BaseTournament implements Tournament
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playerSubmittedDeck(String player, LotroDeck deck) {
|
public boolean playerSubmittedDeck(String player, LotroDeck deck) {
|
||||||
//Constructed has all decks submitted upon signup, so nothing to do here
|
//Constructed has all decks submitted upon signup, so nothing to do here
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,13 +37,18 @@ public class SealedTournament extends BaseTournament implements Tournament {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playerSubmittedDeck(String player, LotroDeck deck) {
|
public boolean playerSubmittedDeck(String player, LotroDeck deck) {
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try {
|
try {
|
||||||
if (getTournamentStage() == Stage.DECK_BUILDING && _players.contains(player)) {
|
var stage = getTournamentStage();
|
||||||
|
if ((stage == Stage.DECK_BUILDING || stage == Stage.DECK_REGISTRATION ||
|
||||||
|
stage == Tournament.Stage.PAUSED || stage == Tournament.Stage.AWAITING_KICKOFF)
|
||||||
|
&& _players.contains(player)) {
|
||||||
_tournamentService.updateRecordedPlayerDeck(_tournamentId, player, deck);
|
_tournamentService.updateRecordedPlayerDeck(_tournamentId, player, deck);
|
||||||
_playerDecks.put(player, deck);
|
_playerDecks.put(player, deck);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
writeLock.unlock();
|
writeLock.unlock();
|
||||||
}
|
}
|
||||||
@@ -150,7 +155,7 @@ public class SealedTournament extends BaseTournament implements Tournament {
|
|||||||
+ "<br/><br/>Remember to return to the game hall and register your deck before " + DateUtils.FormatTime(_sealedInfo.RegistrationDeadline) + "."));
|
+ "<br/><br/>Remember to return to the game hall and register your deck before " + DateUtils.FormatTime(_sealedInfo.RegistrationDeadline) + "."));
|
||||||
}
|
}
|
||||||
else if (getTournamentStage() == Stage.DECK_BUILDING) {
|
else if (getTournamentStage() == Stage.DECK_BUILDING) {
|
||||||
if (DateUtils.Now().isAfter(_sealedInfo.DeckbuildingDeadline) && _playerDecks.values().stream().anyMatch(x -> StringUtils.isEmpty(x.getDeckName()))) {
|
if (DateUtils.Now().isAfter(_sealedInfo.DeckbuildingDeadline)) {
|
||||||
_tournamentInfo.Stage = Stage.DECK_REGISTRATION;
|
_tournamentInfo.Stage = Stage.DECK_REGISTRATION;
|
||||||
_tournamentService.recordTournamentStage(_tournamentId, getTournamentStage());
|
_tournamentService.recordTournamentStage(_tournamentId, getTournamentStage());
|
||||||
|
|
||||||
@@ -158,16 +163,12 @@ public class SealedTournament extends BaseTournament implements Tournament {
|
|||||||
result.add(new BroadcastAction("Deck building in tournament <b>" + getTournamentName() + "</b> has finished. Players now have "
|
result.add(new BroadcastAction("Deck building in tournament <b>" + getTournamentName() + "</b> has finished. Players now have "
|
||||||
+ duration + " to finish registering their decks. Any player who has not turned in their deck by the deadline at "
|
+ duration + " to finish registering their decks. Any player who has not turned in their deck by the deadline at "
|
||||||
+ DateUtils.FormatTime(_sealedInfo.RegistrationDeadline) + " will be auto-disqualified."
|
+ DateUtils.FormatTime(_sealedInfo.RegistrationDeadline) + " will be auto-disqualified."
|
||||||
+ "<br/><br/>Once all players have turned in decks or the deadline has passed, the tournament will begin."));
|
+ "<br/><br/>Once the deadline has passed, the tournament will begin."));
|
||||||
}
|
|
||||||
else if (DateUtils.Now().isAfter(_sealedInfo.DeckbuildingDeadline) && _playerDecks.values().stream().noneMatch(x -> StringUtils.isEmpty(x.getDeckName()))) {
|
|
||||||
_tournamentInfo.Stage = _sealedInfo.PostRegistrationStage();
|
|
||||||
_tournamentService.recordTournamentStage(_tournamentId, getTournamentStage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTournamentStage() == Stage.DECK_REGISTRATION) {
|
if (getTournamentStage() == Stage.DECK_REGISTRATION) {
|
||||||
if (DateUtils.Now().isAfter(_sealedInfo.RegistrationDeadline) || _playerDecks.values().stream().noneMatch(x -> StringUtils.isEmpty(x.getDeckName()))) {
|
if (DateUtils.Now().isAfter(_sealedInfo.RegistrationDeadline)) {
|
||||||
disqualifyUnregisteredPlayers();
|
disqualifyUnregisteredPlayers();
|
||||||
|
|
||||||
_tournamentInfo.Stage = _sealedInfo.PostRegistrationStage();
|
_tournamentInfo.Stage = _sealedInfo.PostRegistrationStage();
|
||||||
|
|||||||
@@ -35,13 +35,18 @@ public class SoloDraftTournament extends BaseTournament implements Tournament {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playerSubmittedDeck(String player, LotroDeck deck) {
|
public boolean playerSubmittedDeck(String player, LotroDeck deck) {
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try {
|
try {
|
||||||
if (getTournamentStage() == Stage.DECK_BUILDING && _players.contains(player)) {
|
var stage = getTournamentStage();
|
||||||
|
if ((stage == Tournament.Stage.DECK_BUILDING || stage == Tournament.Stage.DECK_REGISTRATION ||
|
||||||
|
stage == Tournament.Stage.PAUSED || stage == Tournament.Stage.AWAITING_KICKOFF)
|
||||||
|
&& _players.contains(player)) {
|
||||||
_tournamentService.updateRecordedPlayerDeck(_tournamentId, player, deck);
|
_tournamentService.updateRecordedPlayerDeck(_tournamentId, player, deck);
|
||||||
_playerDecks.put(player, deck);
|
_playerDecks.put(player, deck);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
writeLock.unlock();
|
writeLock.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public interface Tournament {
|
|||||||
void reportGameFinished(String winner, String loser);
|
void reportGameFinished(String winner, String loser);
|
||||||
|
|
||||||
void playerChosenCard(String playerName, String cardId);
|
void playerChosenCard(String playerName, String cardId);
|
||||||
void playerSubmittedDeck(String player, LotroDeck deck);
|
boolean playerSubmittedDeck(String player, LotroDeck deck);
|
||||||
void issuePlayerMaterial(String player);
|
void issuePlayerMaterial(String player);
|
||||||
LotroDeck getPlayerDeck(String player);
|
LotroDeck getPlayerDeck(String player);
|
||||||
String dropPlayer(String player);
|
String dropPlayer(String player);
|
||||||
|
|||||||
Reference in New Issue
Block a user