mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
* Some rework of User/Tournament/Quit handling.
This commit is contained in:
parent
9ea54b38c2
commit
0ef340d108
10 changed files with 130 additions and 113 deletions
|
|
@ -40,6 +40,7 @@ import java.util.UUID;
|
|||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -47,6 +48,8 @@ import mage.game.Game;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializable {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CardsImpl.class);
|
||||
|
||||
private static Random rnd = new Random();
|
||||
private UUID ownerId;
|
||||
|
|
@ -62,7 +65,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
this.zone = zone;
|
||||
}
|
||||
|
||||
public CardsImpl(Zone zone, List<Card> cards) {
|
||||
public CardsImpl(Zone zone, Collection<Card> cards) {
|
||||
this(zone);
|
||||
for (Card card: cards) {
|
||||
this.add(card.getId());
|
||||
|
|
@ -181,8 +184,14 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public Set<Card> getCards(Game game) {
|
||||
Set<Card> cards = new LinkedHashSet<>();
|
||||
for (UUID card: this) {
|
||||
cards.add(game.getCard(card));
|
||||
for (UUID cardId: this) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
} else {
|
||||
// this bug seems to happen, if cause is removed, this check can also be removed
|
||||
logger.error("Card not found cardId: " + cardId + " gameId: " + game.getId() );
|
||||
}
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ public interface Game extends MageItem, Serializable {
|
|||
int mulliganDownTo(UUID playerId);
|
||||
void mulligan(UUID playerId);
|
||||
void endMulligan(UUID playerId);
|
||||
void quit(UUID playerId);
|
||||
// void quit(UUID playerId);
|
||||
void timerTimeout(UUID playerId);
|
||||
void idleTimeout(UUID playerId);
|
||||
void concede(UUID playerId);
|
||||
|
|
|
|||
|
|
@ -1036,15 +1036,15 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
player.drawCards(numCards - deduction, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quit(UUID playerId) {
|
||||
if (state != null) {
|
||||
Player player = state.getPlayer(playerId);
|
||||
if (player != null && player.isInGame()) {
|
||||
player.quit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public void quit(UUID playerId) {
|
||||
// if (state != null) {
|
||||
// Player player = state.getPlayer(playerId);
|
||||
// if (player != null && player.isInGame()) {
|
||||
// player.quit(this);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public synchronized void timerTimeout(UUID playerId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue