mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Added F5 button to skip priority until end step of opponent. Added PlayerAction handling.
This commit is contained in:
parent
ebd21eab1d
commit
aa842efacc
17 changed files with 185 additions and 327 deletions
|
|
@ -66,6 +66,7 @@ import java.util.Locale;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.constants.TableState;
|
||||
|
||||
/**
|
||||
|
|
@ -663,32 +664,6 @@ public class MageServerImpl implements MageServer {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManaPoolMode(final UUID gameId, final String sessionId, final boolean autoPayment) throws MageException {
|
||||
execute("setManaPoolMode", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
GameManager.getInstance().setManaPoolMode(gameId, userId, autoPayment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void concedeGame(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("concedeGame", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
GameManager.getInstance().concedeGame(gameId, session.getUserId());
|
||||
} else{
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" +gameId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitMatch(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("quitMatch", sessionId, new Action() {
|
||||
|
|
@ -740,8 +715,8 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void undo(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("undo", sessionId, new Action() {
|
||||
public void sendPlayerAction(final PlayerAction playerAction, final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("setdPlayerAction", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
|
|
@ -749,57 +724,11 @@ public class MageServerImpl implements MageServer {
|
|||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().undo(gameId, session.getUserId());
|
||||
GameManager.getInstance().sendPlayerAction(playerAction, gameId, session.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passPriorityUntilNextYourTurn(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("passPriorityUntilNextYourTurn", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session == null) {
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().passPriorityUntilNextYourTurn(gameId, session.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passTurnPriority(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("passTurnPriority", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session == null) {
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().passTurnPriority(gameId, session.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restorePriority(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("restorePriority", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session == null) {
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().restorePriority(gameId, session.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean watchTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import mage.constants.PlayerAction;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -359,14 +360,6 @@ public class GameController implements GameCallback {
|
|||
}
|
||||
}
|
||||
|
||||
public void concede(UUID userId) {
|
||||
game.concede(getPlayerId(userId));
|
||||
}
|
||||
|
||||
public void setManaPoolMode(UUID userId, boolean autoPayment) {
|
||||
game.setManaPoolMode(getPlayerId(userId), autoPayment);
|
||||
}
|
||||
|
||||
// public void removeUser(UUID userId) {
|
||||
// UUID playerId = userPlayerMap.get(userId);
|
||||
// if (playerId != null) {
|
||||
|
|
@ -389,22 +382,25 @@ public class GameController implements GameCallback {
|
|||
game.quit(getPlayerId(userId));
|
||||
}
|
||||
|
||||
public void undo(UUID userId) {
|
||||
game.undo(getPlayerId(userId));
|
||||
public void sendPlayerAction(PlayerAction playerAction, UUID userId) {
|
||||
switch(playerAction) {
|
||||
case UNDO:
|
||||
game.undo(getPlayerId(userId));
|
||||
break;
|
||||
case CONCEDE:
|
||||
game.concede(getPlayerId(userId));
|
||||
break;
|
||||
case MANA_AUTO_PAYMENT_OFF:
|
||||
game.setManaPoolMode(getPlayerId(userId), false);
|
||||
break;
|
||||
case MANA_AUTO_PAYMENT_ON:
|
||||
game.setManaPoolMode(getPlayerId(userId), true);
|
||||
break;
|
||||
default:
|
||||
game.sendPlayerAction(playerAction, getPlayerId(userId));
|
||||
}
|
||||
}
|
||||
|
||||
public void passPriorityUntilNextYourTurn(UUID userId) {
|
||||
game.passPriorityUntilNextYourTurn(getPlayerId(userId));
|
||||
}
|
||||
|
||||
public void passTurnPriority(UUID userId) {
|
||||
game.passTurnPriority(getPlayerId(userId));
|
||||
}
|
||||
|
||||
public void restorePriority(UUID userId) {
|
||||
game.restorePriority(getPlayerId(userId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void cheat(UUID userId, UUID playerId, DeckCardLists deckList) {
|
||||
Deck deck;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import java.util.UUID;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.game.Game;
|
||||
import mage.view.GameView;
|
||||
|
||||
|
|
@ -106,52 +107,17 @@ public class GameManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void setManaPoolMode(UUID gameId, UUID userId, boolean autoPayment) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.setManaPoolMode(userId, autoPayment);
|
||||
}
|
||||
}
|
||||
|
||||
public void concedeGame(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.concede(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void quitMatch(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.quitMatch(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void undo(UUID gameId, UUID userId) {
|
||||
|
||||
public void sendPlayerAction(PlayerAction playerAction, UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.undo(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void passPriorityUntilNextYourTurn(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.passPriorityUntilNextYourTurn(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void passTurnPriority(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.passTurnPriority(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void restorePriority(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.restorePriority(userId);
|
||||
if (gameController != null) {
|
||||
gameController.sendPlayerAction(playerAction, userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue