mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08: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) {
|
public void select(String message, GameView gameView, int messageId, Map<String, Serializable> options) {
|
||||||
updateGame(gameView, options);
|
updateGame(gameView, options);
|
||||||
|
boolean controllingPlayer = false;
|
||||||
for (PlayerView playerView : gameView.getPlayers()) {
|
for (PlayerView playerView : gameView.getPlayers()) {
|
||||||
if (playerView.getPlayerId().equals(playerId)) {
|
if (playerView.getPlayerId().equals(playerId)) {
|
||||||
// magenoxx: because of uncaught bug with saving state, rolling back and stack
|
// magenoxx: because of uncaught bug with saving state, rolling back and stack
|
||||||
// undo is allowed only for empty stack
|
// undo is allowed only for empty stack
|
||||||
|
controllingPlayer = !gameView.getPriorityPlayerName().equals(playerView.getName());
|
||||||
if (playerView.getStatesSavedSize() > 0 && gameView.getStack().size() == 0) {
|
if (playerView.getStatesSavedSize() > 0 && gameView.getStack().size() == 0) {
|
||||||
feedbackPanel.allowUndo(playerView.getStatesSavedSize());
|
feedbackPanel.allowUndo(playerView.getStatesSavedSize());
|
||||||
}
|
}
|
||||||
|
|
@ -896,13 +898,17 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
Map<String, Serializable> panelOptions = new HashMap<>();
|
Map<String, Serializable> panelOptions = new HashMap<>();
|
||||||
panelOptions.put("your_turn", true);
|
panelOptions.put("your_turn", true);
|
||||||
String playerName;
|
String activePlayerText;
|
||||||
if (gameView.getActivePlayerId().equals(playerId)) {
|
if (gameView.getActivePlayerId().equals(playerId)) {
|
||||||
playerName = "Your turn";
|
activePlayerText = "Your turn";
|
||||||
} else {
|
} 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);
|
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -568,10 +568,18 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
revealFaceDownCard((Card) object, game);
|
revealFaceDownCard((Card) object, game);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getUseableActivatedAbilities(object, zone, game);
|
Player actingPlayer = null;
|
||||||
if (useableAbilities != null && useableAbilities.size() > 0) {
|
if (game.getPriorityPlayerId().equals(playerId)) {
|
||||||
activateAbility(useableAbilities, object, game);
|
actingPlayer = this;
|
||||||
result = true;
|
} 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import mage.game.events.GameEvent;
|
||||||
public class AtTheEndOfTurnStepPostDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
public class AtTheEndOfTurnStepPostDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||||
|
|
||||||
public AtTheEndOfTurnStepPostDelayedTriggeredAbility(Effect effect) {
|
public AtTheEndOfTurnStepPostDelayedTriggeredAbility(Effect effect) {
|
||||||
super(effect);
|
this(effect, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AtTheEndOfTurnStepPostDelayedTriggeredAbility(Effect effect, boolean usesStack) {
|
public AtTheEndOfTurnStepPostDelayedTriggeredAbility(Effect effect, boolean usesStack) {
|
||||||
|
|
@ -68,6 +68,6 @@ public class AtTheEndOfTurnStepPostDelayedTriggeredAbility extends DelayedTrigge
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
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 class LoseControlOnOtherPlayersControllerEffect extends OneShotEffect {
|
||||||
|
|
||||||
public LoseControlOnOtherPlayersControllerEffect() {
|
public LoseControlOnOtherPlayersControllerEffect(String controllingPlayerName, String controlledPlayerName) {
|
||||||
super(Outcome.Detriment);
|
super(Outcome.Detriment);
|
||||||
|
staticText = controlledPlayerName + " lost control over " + controlledPlayerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoseControlOnOtherPlayersControllerEffect(final LoseControlOnOtherPlayersControllerEffect effect) {
|
public LoseControlOnOtherPlayersControllerEffect(final LoseControlOnOtherPlayersControllerEffect effect) {
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ public class GraftAbility extends TriggeredAbilityImpl {
|
||||||
addSubAbility(new GraftStaticAbility(amount));
|
addSubAbility(new GraftStaticAbility(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraftAbility(GraftAbility ability) {
|
public GraftAbility(final GraftAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.amount = ability.amount;
|
this.amount = ability.amount;
|
||||||
this.cardtype = ability.cardtype;
|
this.cardtype = ability.cardtype;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ package mage.players;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -379,6 +380,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
List<Ability> getPlayableOptions(Ability ability, Game game);
|
List<Ability> getPlayableOptions(Ability ability, Game game);
|
||||||
|
|
||||||
Set<UUID> getPlayableInHand(Game game);
|
Set<UUID> getPlayableInHand(Game game);
|
||||||
|
LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game);
|
||||||
|
|
||||||
void addCounters(Counter counter, Game game);
|
void addCounters(Counter counter, Game game);
|
||||||
List<UUID> getAttachments();
|
List<UUID> getAttachments();
|
||||||
|
|
|
||||||
|
|
@ -550,7 +550,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
player.setGameUnderYourControl(false);
|
player.setGameUnderYourControl(false);
|
||||||
player.setTurnControlledBy(this.getId());
|
player.setTurnControlledBy(this.getId());
|
||||||
}
|
}
|
||||||
DelayedTriggeredAbility ability = new AtTheEndOfTurnStepPostDelayedTriggeredAbility(new LoseControlOnOtherPlayersControllerEffect());
|
DelayedTriggeredAbility ability = new AtTheEndOfTurnStepPostDelayedTriggeredAbility(new LoseControlOnOtherPlayersControllerEffect(this.getLogName(), player.getLogName()));
|
||||||
ability.setSourceId(getId());
|
ability.setSourceId(getId());
|
||||||
ability.setControllerId(getId());
|
ability.setControllerId(getId());
|
||||||
game.addDelayedTriggeredAbility(ability);
|
game.addDelayedTriggeredAbility(ability);
|
||||||
|
|
@ -1174,7 +1174,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
return useable;
|
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<>();
|
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<>();
|
||||||
if (!(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game)) {
|
if (!(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game)) {
|
||||||
for (Ability ability : object.getAbilities()) {
|
for (Ability ability : object.getAbilities()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue