mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
*Draft - Non hidden picked cards go to the deck. Hidden cards to sideboard.
This commit is contained in:
parent
b0238b402e
commit
c22b54d262
13 changed files with 53 additions and 22 deletions
|
|
@ -31,6 +31,7 @@ package mage.server;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import mage.MageException;
|
||||
|
|
@ -667,13 +668,13 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DraftPickView sendCardPick(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException {
|
||||
public DraftPickView sendCardPick(final UUID draftId, final String sessionId, final UUID cardPick, final Set<UUID> hiddenCards) throws MageException {
|
||||
return executeWithResult("sendCardPick", sessionId, new ActionWithNullNegativeResult<DraftPickView>() {
|
||||
@Override
|
||||
public DraftPickView execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
return DraftManager.getInstance().sendCardPick(draftId, session.getUserId(), cardPick);
|
||||
return DraftManager.getInstance().sendCardPick(draftId, session.getUserId(), cardPick, hiddenCards);
|
||||
} else{
|
||||
logger.error("Session not found sessionId: "+ sessionId + " draftId:" + draftId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -854,6 +854,7 @@ public class TableController {
|
|||
|
||||
public void endDraft(Draft draft) {
|
||||
for (DraftPlayer player: draft.getPlayers()) {
|
||||
player.prepareDeck();
|
||||
tournament.getPlayer(player.getPlayer().getId()).setDeck(player.getDeck());
|
||||
}
|
||||
tournament.nextStep();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.server.draft;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.MageException;
|
||||
|
|
@ -60,7 +61,7 @@ public class DraftController {
|
|||
private final UUID draftSessionId;
|
||||
private final Draft draft;
|
||||
private final UUID tableId;
|
||||
private UUID markedCard;
|
||||
private final UUID markedCard;
|
||||
|
||||
public DraftController(Draft draft, ConcurrentHashMap<UUID, UUID> userPlayerMap, UUID tableId) {
|
||||
draftSessionId = UUID.randomUUID();
|
||||
|
|
@ -214,7 +215,7 @@ public class DraftController {
|
|||
if (draftSession != null) {
|
||||
UUID cardId = draftSession.getMarkedCard();
|
||||
if (cardId != null) {
|
||||
sendCardPick(userId, cardId);
|
||||
sendCardPick(userId, cardId, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -227,11 +228,11 @@ public class DraftController {
|
|||
return this.draftSessionId;
|
||||
}
|
||||
|
||||
public DraftPickView sendCardPick(UUID userId, UUID cardId) {
|
||||
public DraftPickView sendCardPick(UUID userId, UUID cardId, Set<UUID> hiddenCards) {
|
||||
DraftSession draftSession = draftSessions.get(userPlayerMap.get(userId));
|
||||
if (draftSession != null) {
|
||||
draftSession.setMarkedCard(null);
|
||||
return draftSession.sendCardPick(cardId);
|
||||
return draftSession.sendCardPick(cardId, hiddenCards);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.server.draft;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.game.draft.Draft;
|
||||
|
|
@ -62,8 +63,8 @@ public class DraftManager {
|
|||
draftControllers.remove(gameId);
|
||||
}
|
||||
|
||||
public DraftPickView sendCardPick(UUID draftId, UUID userId, UUID cardId) {
|
||||
return draftControllers.get(draftId).sendCardPick(userId, cardId);
|
||||
public DraftPickView sendCardPick(UUID draftId, UUID userId, UUID cardId, Set<UUID> hiddenCards) {
|
||||
return draftControllers.get(draftId).sendCardPick(userId, cardId, hiddenCards);
|
||||
}
|
||||
|
||||
public void sendCardMark(UUID draftId, UUID userId, UUID cardId) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.server.draft;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
|
@ -150,9 +151,9 @@ public class DraftSession {
|
|||
killed = true;
|
||||
}
|
||||
|
||||
public DraftPickView sendCardPick(UUID cardId) {
|
||||
public DraftPickView sendCardPick(UUID cardId, Set<UUID> hiddenCards) {
|
||||
cancelTimeout();
|
||||
if (draft.addPick(playerId, cardId)) {
|
||||
if (draft.addPick(playerId, cardId, hiddenCards)) {
|
||||
return getDraftPickView(0);
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue