mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
* Added check if the deck was modified during sideboarding.
This commit is contained in:
parent
3c6ede7407
commit
0fd72c3010
12 changed files with 166 additions and 112 deletions
|
|
@ -421,12 +421,16 @@ public class TableController {
|
|||
}
|
||||
|
||||
public void updateDeck(UUID userId, DeckCardLists deckList) throws MageException {
|
||||
boolean validDeck;
|
||||
UUID playerId = userPlayerMap.get(userId);
|
||||
if (table.getState() != TableState.SIDEBOARDING && table.getState() != TableState.CONSTRUCTING) {
|
||||
return;
|
||||
}
|
||||
Deck deck = Deck.load(deckList, false, false);
|
||||
updateDeck(userId, playerId, deck);
|
||||
validDeck = updateDeck(userId, playerId, deck);
|
||||
if (!validDeck) {
|
||||
logger.warn(" userId: " + userId + " - Modified deck card list!");
|
||||
}
|
||||
}
|
||||
|
||||
private void submitDeck(UUID userId, UUID playerId, Deck deck) {
|
||||
|
|
@ -439,18 +443,20 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateDeck(UUID userId, UUID playerId, Deck deck) {
|
||||
private boolean updateDeck(UUID userId, UUID playerId, Deck deck) {
|
||||
boolean validDeck = true;
|
||||
if (table.isTournament()) {
|
||||
if (tournament != null) {
|
||||
TournamentManager.instance.updateDeck(tournament.getId(), playerId, deck);
|
||||
validDeck = TournamentManager.instance.updateDeck(tournament.getId(), playerId, deck);
|
||||
} else {
|
||||
logger.fatal("Tournament == null table: " + table.getId() + " userId: " + userId);
|
||||
}
|
||||
} else if (TableState.SIDEBOARDING == table.getState()) {
|
||||
match.updateDeck(playerId, deck);
|
||||
validDeck = match.updateDeck(playerId, deck);
|
||||
} else {
|
||||
// deck was meanwhile submitted so the autoupdate can be ignored
|
||||
}
|
||||
return validDeck;
|
||||
}
|
||||
|
||||
public boolean watchTable(UUID userId) {
|
||||
|
|
@ -472,13 +478,6 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
|
||||
// public boolean replayTable(UUID userId) {
|
||||
// if (table.getState() != TableState.FINISHED) {
|
||||
// return false;
|
||||
// }
|
||||
// ReplayManager.instance.replayGame(table.getId(), userId);
|
||||
// return true;
|
||||
// }
|
||||
private Optional<Player> createPlayer(String name, PlayerType playerType, int skill) {
|
||||
Optional<Player> playerOpt;
|
||||
if (options == null) {
|
||||
|
|
|
|||
|
|
@ -349,10 +349,11 @@ public class TournamentController {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateDeck(UUID playerId, Deck deck) {
|
||||
public boolean updateDeck(UUID playerId, Deck deck) {
|
||||
if (tournamentSessions.containsKey(playerId)) {
|
||||
tournamentSessions.get(playerId).updateDeck(deck);
|
||||
return tournamentSessions.get(playerId).updateDeck(deck);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void timeout(UUID userId) {
|
||||
|
|
|
|||
|
|
@ -24,14 +24,12 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.server.tournament;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.view.TournamentView;
|
||||
|
|
@ -74,8 +72,8 @@ public enum TournamentManager {
|
|||
controllers.get(tournamentId).submitDeck(playerId, deck);
|
||||
}
|
||||
|
||||
public void updateDeck(UUID tournamentId, UUID playerId, Deck deck) {
|
||||
controllers.get(tournamentId).updateDeck(playerId, deck);
|
||||
public boolean updateDeck(UUID tournamentId, UUID playerId, Deck deck) {
|
||||
return controllers.get(tournamentId).updateDeck(playerId, deck);
|
||||
}
|
||||
|
||||
public TournamentView getTournamentView(UUID tournamentId) {
|
||||
|
|
@ -87,13 +85,12 @@ public enum TournamentManager {
|
|||
}
|
||||
|
||||
public Optional<UUID> getChatId(UUID tournamentId) {
|
||||
if(controllers.containsKey(tournamentId)) {
|
||||
if (controllers.containsKey(tournamentId)) {
|
||||
return Optional.of(controllers.get(tournamentId).getChatId());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
public void removeTournament(UUID tournamentId) {
|
||||
TournamentController tournamentController = controllers.get(tournamentId);
|
||||
if (tournamentController != null) {
|
||||
|
|
|
|||
|
|
@ -24,10 +24,14 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.server.tournament;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
|
|
@ -38,16 +42,11 @@ import mage.server.util.ThreadExecutor;
|
|||
import mage.view.TournamentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TournamentSession {
|
||||
|
||||
protected final static Logger logger = Logger.getLogger(TournamentSession.class);
|
||||
|
||||
protected final UUID userId;
|
||||
|
|
@ -79,16 +78,16 @@ public class TournamentSession {
|
|||
|
||||
public void update() {
|
||||
if (!killed) {
|
||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||
user.fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_UPDATE, tournament.getId(), getTournamentView())));
|
||||
UserManager.instance.getUser(userId).ifPresent(user
|
||||
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_UPDATE, tournament.getId(), getTournamentView())));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void gameOver(final String message) {
|
||||
if (!killed) {
|
||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||
user.fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_OVER, tournament.getId(), message)));
|
||||
UserManager.instance.getUser(userId).ifPresent(user
|
||||
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_OVER, tournament.getId(), message)));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -108,8 +107,8 @@ public class TournamentSession {
|
|||
tournament.submitDeck(playerId, deck);
|
||||
}
|
||||
|
||||
public void updateDeck(Deck deck) {
|
||||
tournament.updateDeck(playerId, deck);
|
||||
public boolean updateDeck(Deck deck) {
|
||||
return tournament.updateDeck(playerId, deck);
|
||||
}
|
||||
|
||||
public void setKilled() {
|
||||
|
|
@ -171,9 +170,8 @@ public class TournamentSession {
|
|||
}
|
||||
|
||||
private void removeTournamentForUser() {
|
||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||
user.removeTournament(playerId));
|
||||
|
||||
UserManager.instance.getUser(userId).ifPresent(user
|
||||
-> user.removeTournament(playerId));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue