mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Fixed a problem that Ai players did no longer work in tournaments.
This commit is contained in:
parent
f90d49ae0a
commit
88d121f6e9
1 changed files with 38 additions and 25 deletions
|
@ -27,6 +27,10 @@
|
||||||
*/
|
*/
|
||||||
package mage.server.tournament;
|
package mage.server.tournament;
|
||||||
|
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
@ -58,11 +62,6 @@ import mage.view.ChatMessage.SoundToPlay;
|
||||||
import mage.view.TournamentView;
|
import mage.view.TournamentView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -158,8 +157,8 @@ public class TournamentController {
|
||||||
UUID playerId = userPlayerMap.get(userId);
|
UUID playerId = userPlayerMap.get(userId);
|
||||||
if (playerId == null) {
|
if (playerId == null) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
logger.debug(user.getName() + " shows tournament panel tournamentId: " + tournament.getId()));
|
-> logger.debug(user.getName() + " shows tournament panel tournamentId: " + tournament.getId()));
|
||||||
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -251,21 +250,35 @@ public class TournamentController {
|
||||||
table.setState(TableState.WAITING);
|
table.setState(TableState.WAITING);
|
||||||
TournamentPlayer player1 = pair.getPlayer1();
|
TournamentPlayer player1 = pair.getPlayer1();
|
||||||
TournamentPlayer player2 = pair.getPlayer2();
|
TournamentPlayer player2 = pair.getPlayer2();
|
||||||
Optional<UUID> user1Id = getPlayerUserId(player1.getPlayer().getId());
|
UUID user1Uuid = null;
|
||||||
Optional<UUID> user2Id = getPlayerUserId(player2.getPlayer().getId());
|
UUID user2Uuid = null;
|
||||||
if (user1Id.isPresent() && user2Id.isPresent()) {
|
if (player1.getPlayerType() == PlayerType.HUMAN) {
|
||||||
tableManager.addPlayer(getPlayerUserId(player1.getPlayer().getId()).get(), table.getId(), player1);
|
Optional<UUID> user1Id = getPlayerUserId(player1.getPlayer().getId());
|
||||||
tableManager.addPlayer(getPlayerUserId(player2.getPlayer().getId()).get(), table.getId(), player2);
|
if (!user1Id.isPresent()) {
|
||||||
table.setState(TableState.STARTING);
|
logger.fatal("Player 1 not found");
|
||||||
tableManager.startTournamentSubMatch(null, table.getId());
|
} else {
|
||||||
tableManager.getMatch(table.getId()).ifPresent(match -> {
|
user1Uuid = user1Id.get();
|
||||||
match.setTableId(tableId);
|
}
|
||||||
pair.setMatch(match);
|
|
||||||
pair.setTableId(table.getId());
|
|
||||||
player1.setState(TournamentPlayerState.DUELING);
|
|
||||||
player2.setState(TournamentPlayerState.DUELING);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if (player2.getPlayerType() == PlayerType.HUMAN) {
|
||||||
|
Optional<UUID> user2Id = getPlayerUserId(player2.getPlayer().getId());
|
||||||
|
if (!user2Id.isPresent()) {
|
||||||
|
logger.fatal("Player 2 not found");
|
||||||
|
} else {
|
||||||
|
user2Uuid = user2Id.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tableManager.addPlayer(user1Uuid, table.getId(), player1);
|
||||||
|
tableManager.addPlayer(user2Uuid, table.getId(), player2);
|
||||||
|
table.setState(TableState.STARTING);
|
||||||
|
tableManager.startTournamentSubMatch(null, table.getId());
|
||||||
|
tableManager.getMatch(table.getId()).ifPresent(match -> {
|
||||||
|
match.setTableId(tableId);
|
||||||
|
pair.setMatch(match);
|
||||||
|
pair.setTableId(table.getId());
|
||||||
|
player1.setState(TournamentPlayerState.DUELING);
|
||||||
|
player2.setState(TournamentPlayerState.DUELING);
|
||||||
|
});
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
logger.fatal("TournamentController startMatch error", ex);
|
logger.fatal("TournamentController startMatch error", ex);
|
||||||
}
|
}
|
||||||
|
@ -349,8 +362,8 @@ public class TournamentController {
|
||||||
tournament.autoSubmit(userPlayerMap.get(userId), tournamentPlayer.generateDeck());
|
tournament.autoSubmit(userPlayerMap.get(userId), tournamentPlayer.generateDeck());
|
||||||
} else {
|
} else {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
sb.append(user.getName()));
|
-> sb.append(user.getName()));
|
||||||
|
|
||||||
sb.append(" - no deck found for auto submit");
|
sb.append(" - no deck found for auto submit");
|
||||||
logger.fatal(sb);
|
logger.fatal(sb);
|
||||||
|
@ -399,8 +412,8 @@ public class TournamentController {
|
||||||
this.abortDraftTournament();
|
this.abortDraftTournament();
|
||||||
} else {
|
} else {
|
||||||
DraftManager.instance.getController(tableId).ifPresent(draftController -> {
|
DraftManager.instance.getController(tableId).ifPresent(draftController -> {
|
||||||
draftController.getDraftSession(playerId).ifPresent(draftSession ->
|
draftController.getDraftSession(playerId).ifPresent(draftSession
|
||||||
DraftManager.instance.kill(draftSession.getDraftId(), userId));
|
-> DraftManager.instance.kill(draftSession.getDraftId(), userId));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue