mirror of
https://github.com/correl/mage.git
synced 2024-11-24 19:19:56 +00:00
* Fixed human players controlling other human players turn (e.g. by Mindsliver).
This commit is contained in:
parent
be11d287dc
commit
15efe14fd5
8 changed files with 34 additions and 16 deletions
|
@ -883,10 +883,12 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
public void select(String message, GameView gameView, int messageId, Map<String, Serializable> options) {
|
||||
updateGame(gameView, options);
|
||||
boolean controllingPlayer = false;
|
||||
for (PlayerView playerView : gameView.getPlayers()) {
|
||||
if (playerView.getPlayerId().equals(playerId)) {
|
||||
// magenoxx: because of uncaught bug with saving state, rolling back and stack
|
||||
// undo is allowed only for empty stack
|
||||
controllingPlayer = !gameView.getPriorityPlayerName().equals(playerView.getName());
|
||||
if (playerView.getStatesSavedSize() > 0 && gameView.getStack().size() == 0) {
|
||||
feedbackPanel.allowUndo(playerView.getStatesSavedSize());
|
||||
}
|
||||
|
@ -896,13 +898,17 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
Map<String, Serializable> panelOptions = new HashMap<>();
|
||||
panelOptions.put("your_turn", true);
|
||||
String playerName;
|
||||
String activePlayerText;
|
||||
if (gameView.getActivePlayerId().equals(playerId)) {
|
||||
playerName = "Your turn";
|
||||
activePlayerText = "Your turn";
|
||||
} else {
|
||||
playerName = gameView.getActivePlayerName();
|
||||
activePlayerText = gameView.getActivePlayerName() +"'s turn";
|
||||
}
|
||||
String messageToDisplay = message + "<div style='font-size:11pt'>" + playerName +" / " + gameView.getStep().toString() + "</div>";
|
||||
String priorityPlayerText = "";
|
||||
if (controllingPlayer) {
|
||||
priorityPlayerText = " / priority " + gameView.getPriorityPlayerName();
|
||||
}
|
||||
String messageToDisplay = message + "<div style='font-size:11pt'>" + activePlayerText +" / " + gameView.getStep().toString() + priorityPlayerText + "</div>";
|
||||
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId);
|
||||
}
|
||||
|
|
|
@ -568,10 +568,18 @@ public class HumanPlayer extends PlayerImpl {
|
|||
revealFaceDownCard((Card) object, game);
|
||||
result = true;
|
||||
}
|
||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getUseableActivatedAbilities(object, zone, game);
|
||||
if (useableAbilities != null && useableAbilities.size() > 0) {
|
||||
activateAbility(useableAbilities, object, game);
|
||||
result = true;
|
||||
Player actingPlayer = null;
|
||||
if (game.getPriorityPlayerId().equals(playerId)) {
|
||||
actingPlayer = this;
|
||||
} else if (getPlayersUnderYourControl().contains(game.getPriorityPlayerId())) {
|
||||
actingPlayer = game.getPlayer(game.getPriorityPlayerId());
|
||||
}
|
||||
if (actingPlayer != null) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = actingPlayer.getUseableActivatedAbilities(object, zone, game);
|
||||
if (useableAbilities != null && useableAbilities.size() > 0) {
|
||||
activateAbility(useableAbilities, object, game);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class PlayLandAbility extends ActivatedAbilityImpl {
|
|||
if (!controlsAbility(playerId, game)) {
|
||||
return false;
|
||||
}
|
||||
//20091005 - 114.2a
|
||||
//20091005 - 114.2a
|
||||
return game.canPlaySorcery(playerId) && game.getPlayer(playerId).canPlayLand();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import mage.game.events.GameEvent;
|
|||
public class AtTheEndOfTurnStepPostDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
public AtTheEndOfTurnStepPostDelayedTriggeredAbility(Effect effect) {
|
||||
super(effect);
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public AtTheEndOfTurnStepPostDelayedTriggeredAbility(Effect effect, boolean usesStack) {
|
||||
|
@ -68,6 +68,6 @@ public class AtTheEndOfTurnStepPostDelayedTriggeredAbility extends DelayedTrigge
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "At end of turn " + modes.getText();
|
||||
return "At end of turn " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,9 @@ import mage.players.Player;
|
|||
*/
|
||||
public class LoseControlOnOtherPlayersControllerEffect extends OneShotEffect {
|
||||
|
||||
public LoseControlOnOtherPlayersControllerEffect() {
|
||||
public LoseControlOnOtherPlayersControllerEffect(String controllingPlayerName, String controlledPlayerName) {
|
||||
super(Outcome.Detriment);
|
||||
staticText = controlledPlayerName + " lost control over " + controlledPlayerName;
|
||||
}
|
||||
|
||||
public LoseControlOnOtherPlayersControllerEffect(final LoseControlOnOtherPlayersControllerEffect effect) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class GraftAbility extends TriggeredAbilityImpl {
|
|||
addSubAbility(new GraftStaticAbility(amount));
|
||||
}
|
||||
|
||||
public GraftAbility(GraftAbility ability) {
|
||||
public GraftAbility(final GraftAbility ability) {
|
||||
super(ability);
|
||||
this.amount = ability.amount;
|
||||
this.cardtype = ability.cardtype;
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.players;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -379,7 +380,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
List<Ability> getPlayableOptions(Ability ability, Game game);
|
||||
|
||||
Set<UUID> getPlayableInHand(Game game);
|
||||
|
||||
LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game);
|
||||
|
||||
void addCounters(Counter counter, Game game);
|
||||
List<UUID> getAttachments();
|
||||
boolean addAttachment(UUID permanentId, Game game);
|
||||
|
|
|
@ -550,7 +550,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
player.setGameUnderYourControl(false);
|
||||
player.setTurnControlledBy(this.getId());
|
||||
}
|
||||
DelayedTriggeredAbility ability = new AtTheEndOfTurnStepPostDelayedTriggeredAbility(new LoseControlOnOtherPlayersControllerEffect());
|
||||
DelayedTriggeredAbility ability = new AtTheEndOfTurnStepPostDelayedTriggeredAbility(new LoseControlOnOtherPlayersControllerEffect(this.getLogName(), player.getLogName()));
|
||||
ability.setSourceId(getId());
|
||||
ability.setControllerId(getId());
|
||||
game.addDelayedTriggeredAbility(ability);
|
||||
|
@ -1174,7 +1174,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return useable;
|
||||
}
|
||||
|
||||
protected LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
@Override
|
||||
public LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<>();
|
||||
if (!(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game)) {
|
||||
for (Ability ability : object.getAbilities()) {
|
||||
|
|
Loading…
Reference in a new issue