forked from External/mage
* Fixed handling of Phyrexian mana.
This commit is contained in:
parent
0c44857e80
commit
b80e27f3b3
10 changed files with 359 additions and 370 deletions
|
|
@ -240,7 +240,7 @@ public class GameController implements GameCallback {
|
|||
select(event.getPlayerId(), event.getMessage(), event.getOptions());
|
||||
break;
|
||||
case PLAY_MANA:
|
||||
playMana(event.getPlayerId(), event.getMessage());
|
||||
playMana(event.getPlayerId(), event.getMessage(), event.getOptions());
|
||||
break;
|
||||
case PLAY_X_MANA:
|
||||
playXMana(event.getPlayerId(), event.getMessage());
|
||||
|
|
@ -850,11 +850,11 @@ public class GameController implements GameCallback {
|
|||
});
|
||||
}
|
||||
|
||||
private synchronized void playMana(UUID playerId, final String message) throws MageException {
|
||||
private synchronized void playMana(UUID playerId, final String message, final Map<String, Serializable> options) throws MageException {
|
||||
perform(playerId, new Command() {
|
||||
@Override
|
||||
public void execute(UUID playerId) {
|
||||
getGameSession(playerId).playMana(message);
|
||||
getGameSession(playerId).playMana(message, options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1026,7 +1026,7 @@ public class GameController implements GameCallback {
|
|||
// player has game under control (is not cotrolled by other player)
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.isGameUnderControl()) {
|
||||
// if it's your priority (or game not started yet in which case it will be null)
|
||||
// if it's your priority (or game not started yet in which case it will be null)
|
||||
// then execute only your action
|
||||
if (game.getPriorityPlayerId() == null || game.getPriorityPlayerId().equals(playerId)) {
|
||||
if (gameSessions.containsKey(playerId)) {
|
||||
|
|
@ -1041,7 +1041,7 @@ public class GameController implements GameCallback {
|
|||
command.execute(controlled);
|
||||
}
|
||||
}
|
||||
// else player has no priority to do something, so ignore the command
|
||||
// else player has no priority to do something, so ignore the command
|
||||
// e.g. you click at one of your cards, but you can't play something at that moment
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* 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.game;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -45,7 +44,6 @@ import mage.game.Game;
|
|||
import mage.game.Table;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.players.Player;
|
||||
import mage.players.net.UserData;
|
||||
import mage.server.User;
|
||||
import mage.server.UserManager;
|
||||
import mage.server.util.ThreadExecutor;
|
||||
|
|
@ -80,7 +78,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
|||
super.CleanUp();
|
||||
}
|
||||
|
||||
public void ask(final String question) {
|
||||
public void ask(final String question) {
|
||||
if (!killed) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
|
|
@ -134,11 +132,11 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
public void playMana(final String message) {
|
||||
public void playMana(final String message, final Map<String, Serializable> options) {
|
||||
if (!killed) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
user.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(getGameView(), message)));
|
||||
user.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(getGameView(), message, options)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -176,19 +174,18 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
|||
User requestedUser = UserManager.getInstance().getUser(userId);
|
||||
if (requestedUser != null && requestingUser != null) {
|
||||
String message;
|
||||
switch(numberTurns) {
|
||||
case 0:
|
||||
switch (numberTurns) {
|
||||
case 0:
|
||||
message = "Allow rollback to the start of the current turn?";
|
||||
break;
|
||||
case 1:
|
||||
message = "Allow rollback to the start of the previous turn?";
|
||||
break;
|
||||
default:
|
||||
message = "Allow to rollback "+numberTurns+ " turns?";
|
||||
message = "Allow to rollback " + numberTurns + " turns?";
|
||||
}
|
||||
UserRequestMessage userRequestMessage = new UserRequestMessage(
|
||||
"Request by " + requestedUser.getName(), message
|
||||
, PlayerAction.REQUEST_PERMISSION_TO_ROLLBACK_TURN);
|
||||
"Request by " + requestedUser.getName(), message, PlayerAction.REQUEST_PERMISSION_TO_ROLLBACK_TURN);
|
||||
userRequestMessage.setRelatedUser(requestingUserId, requestingUser.getName());
|
||||
userRequestMessage.setGameId(game.getId());
|
||||
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_ROLLBACK_TURN);
|
||||
|
|
@ -197,7 +194,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void requestPermissionToSeeHandCards(UUID watcherId) {
|
||||
if (!killed) {
|
||||
User watcher = UserManager.getInstance().getUser(watcherId);
|
||||
|
|
@ -205,9 +202,8 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
|||
if (user != null && watcher != null) {
|
||||
UserRequestMessage userRequestMessage = new UserRequestMessage(
|
||||
"User request",
|
||||
"Allow user <b>" + watcher.getName() + "</b> for this match to see your hand cards?<br>" +
|
||||
"(You can revoke this every time using related popup menu item of your battlefield.)"
|
||||
, PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS);
|
||||
"Allow user <b>" + watcher.getName() + "</b> for this match to see your hand cards?<br>"
|
||||
+ "(You can revoke this every time using related popup menu item of your battlefield.)", PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS);
|
||||
userRequestMessage.setRelatedUser(watcherId, watcher.getName());
|
||||
userRequestMessage.setGameId(game.getId());
|
||||
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_SEE_HAND_CARDS);
|
||||
|
|
@ -286,39 +282,39 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
|||
final Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.isInGame()) {
|
||||
callExecutor.execute(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (game.getStartTime() == null) {
|
||||
// gameController is still waiting to start the game
|
||||
player.leave();
|
||||
} else {
|
||||
// game was already started
|
||||
player.quit(game);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
if (ex != null) {
|
||||
// It seems this can happen if two threads try to end the game at the exact same time (one wins and one ends here)
|
||||
logger.fatal("Game session game quit exception " + (ex.getMessage() == null ? "null":ex.getMessage()));
|
||||
logger.debug("- gameId:" + game.getId() +" playerId: " + playerId);
|
||||
if (ex.getCause() != null) {
|
||||
logger.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null":ex.getCause().getMessage()), ex);
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (game.getStartTime() == null) {
|
||||
// gameController is still waiting to start the game
|
||||
player.leave();
|
||||
} else {
|
||||
logger.debug("- ex: " + ex.toString(), ex);
|
||||
// game was already started
|
||||
player.quit(game);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
if (ex != null) {
|
||||
// It seems this can happen if two threads try to end the game at the exact same time (one wins and one ends here)
|
||||
logger.fatal("Game session game quit exception " + (ex.getMessage() == null ? "null" : ex.getMessage()));
|
||||
logger.debug("- gameId:" + game.getId() + " playerId: " + playerId);
|
||||
if (ex.getCause() != null) {
|
||||
logger.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null" : ex.getCause().getMessage()), ex);
|
||||
} else {
|
||||
logger.debug("- ex: " + ex.toString(), ex);
|
||||
}
|
||||
} else {
|
||||
logger.fatal("Game session game quit exception - null gameId:" + game.getId() + " playerId: " + playerId);
|
||||
}
|
||||
}else {
|
||||
logger.fatal("Game session game quit exception - null gameId:" + game.getId() +" playerId: " + playerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
logger.error("game object missing playerId: " + (playerId == null ? "[null]":playerId));
|
||||
logger.error("game object missing playerId: " + (playerId == null ? "[null]" : playerId));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue