mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
* Expropriate - Fixed a strange problem that the prompt text of the select permanent selection to get the control of the permanent was not shown. Still not clear what the exact reason was but using a player list to save the voters seemed to cause the problem.
This commit is contained in:
parent
06ed2f5927
commit
1dc8f37d20
5 changed files with 64 additions and 29 deletions
|
@ -1,5 +1,12 @@
|
|||
package mage.remote;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.*;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.repository.CardInfo;
|
||||
|
@ -28,14 +35,6 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
|
|||
import org.jboss.remoting.transport.socket.SocketWrapper;
|
||||
import org.jboss.remoting.transporter.TransporterClient;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
|
@ -502,7 +501,7 @@ public class SessionImpl implements Session {
|
|||
|
||||
/**
|
||||
* @param askForReconnect - true = connection was lost because of error and
|
||||
* ask the user if they want to try to reconnect
|
||||
* ask the user if they want to try to reconnect
|
||||
*/
|
||||
@Override
|
||||
public synchronized void disconnect(boolean askForReconnect) {
|
||||
|
@ -557,8 +556,21 @@ public class SessionImpl implements Session {
|
|||
|
||||
@Override
|
||||
public void handleCallback(Callback callback) throws HandleCallbackException {
|
||||
//logger.info("callback handler");
|
||||
client.processCallback((ClientCallback) callback.getCallbackObject());
|
||||
try {
|
||||
// Object object = callback.getCallbackObject();
|
||||
// if (((ClientCallback) object).getMethod().equals(ClientCallbackMethod.GAME_TARGET)) {
|
||||
// Object data = ((ClientCallback) object).getData();
|
||||
// if (data instanceof GameClientMessage) {
|
||||
// GameClientMessage message = (GameClientMessage) ((ClientCallback) object).getData();
|
||||
// logger.info("Client Session Event->" + ((ClientCallback) object).getMethod() + " (id:" + ((ClientCallback) object).getMessageId() + ") " + message.getMessage()
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
client.processCallback((ClientCallback) callback.getCallbackObject());
|
||||
} catch (Exception ex) {
|
||||
logger.error("handleCallback error", ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.server;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -352,7 +351,16 @@ public class Session {
|
|||
if (valid && callBackLock.tryLock(50, TimeUnit.MILLISECONDS)) {
|
||||
call.setMessageId(messageId++);
|
||||
lockSet = true;
|
||||
callbackHandler.handleCallbackOneway(new Callback(call));
|
||||
Callback callback = new Callback(call);
|
||||
// if (call.getMethod().equals(ClientCallbackMethod.GAME_TARGET)) {
|
||||
// Object object = call.getData();
|
||||
// if (object instanceof GameClientMessage) {
|
||||
// String message = ((GameClientMessage) object).getMessage();
|
||||
// logger.info("Server Session Event->" + call.getMethod() + " (id:" + call.getMessageId() + ") " + message);
|
||||
// logger.info(callback.toString());
|
||||
// }
|
||||
// }
|
||||
callbackHandler.handleCallbackOneway(callback);
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
logger.warn("SESSION LOCK - fireCallback - userId: " + userId + " messageId: " + call.getMessageId(), ex);
|
||||
|
@ -364,6 +372,8 @@ public class Session {
|
|||
logger.trace("Stack trace:", ex);
|
||||
SessionManager.instance.disconnect(sessionId, LostConnection);
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
logger.warn("Unspecific exception:", ex);
|
||||
} finally {
|
||||
if (lockSet) {
|
||||
callBackLock.unlock();
|
||||
|
|
|
@ -47,6 +47,8 @@ public final class Expropriate extends CardImpl {
|
|||
|
||||
class ExpropriateDilemmaEffect extends CouncilsDilemmaVoteEffect {
|
||||
|
||||
private ArrayList<UUID> choiceTwoVoters = new ArrayList<>();
|
||||
|
||||
public ExpropriateDilemmaEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "<i>Council's dilemma</i> — Starting with you, each player votes for time or money. For each time vote, take an extra turn after this one. For each money vote, choose a permanent owned by the voter and gain control of it";
|
||||
|
@ -56,10 +58,6 @@ class ExpropriateDilemmaEffect extends CouncilsDilemmaVoteEffect {
|
|||
super(effect);
|
||||
}
|
||||
|
||||
public ExpropriateDilemmaEffect(Outcome outcome) {
|
||||
super(outcome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
@ -99,7 +97,7 @@ class ExpropriateDilemmaEffect extends CouncilsDilemmaVoteEffect {
|
|||
private void controlForMoneyVote(Player controller, Game game, Ability source) {
|
||||
List<Permanent> chosenCards = new ArrayList<>();
|
||||
|
||||
for (UUID playerId : choiceTwoVoters.keySet()) {
|
||||
for (UUID playerId : choiceTwoVoters) {
|
||||
FilterPermanent filter = new FilterPermanent("permanent owned by " + game.getPlayer(playerId).getName());
|
||||
filter.add(new OwnerIdPredicate(playerId));
|
||||
|
||||
|
@ -125,6 +123,25 @@ class ExpropriateDilemmaEffect extends CouncilsDilemmaVoteEffect {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void vote(String choiceOne, String choiceTwo, Player controller, Game game, Ability source) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
if (player.chooseUse(Outcome.Vote,
|
||||
"Choose " + choiceOne + " or " + choiceTwo + "?",
|
||||
source.getRule(), choiceOne, choiceTwo, source, game)) {
|
||||
voteOneCount++;
|
||||
game.informPlayers(player.getName() + " has voted for " + choiceOne);
|
||||
} else {
|
||||
voteTwoCount++;
|
||||
game.informPlayers(player.getName() + " has voted for " + choiceTwo);
|
||||
choiceTwoVoters.add(player.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpropriateDilemmaEffect copy() {
|
||||
return new ExpropriateDilemmaEffect(this);
|
||||
|
@ -154,8 +171,11 @@ class ExpropriateControlEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
return permanent != null
|
||||
&& controllerId != null
|
||||
&& permanent.changeControllerId(controllerId, game);
|
||||
if (permanent == null || controllerId == null) {
|
||||
this.discard();
|
||||
} else {
|
||||
permanent.changeControllerId(controllerId, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.players.Players;
|
||||
|
||||
/**
|
||||
* @author JRHerlehy
|
||||
|
@ -14,8 +13,6 @@ import mage.players.Players;
|
|||
public abstract class CouncilsDilemmaVoteEffect extends OneShotEffect {
|
||||
|
||||
protected int voteOneCount = 0, voteTwoCount = 0;
|
||||
protected final Players choiceOneVoters = new Players();
|
||||
protected final Players choiceTwoVoters = new Players();
|
||||
|
||||
public CouncilsDilemmaVoteEffect(Outcome outcome) {
|
||||
super(outcome);
|
||||
|
@ -33,11 +30,9 @@ public abstract class CouncilsDilemmaVoteEffect extends OneShotEffect {
|
|||
"Choose " + choiceOne + " or " + choiceTwo + "?",
|
||||
source.getRule(), choiceOne, choiceTwo, source, game)) {
|
||||
voteOneCount++;
|
||||
choiceOneVoters.addPlayer(player);
|
||||
game.informPlayers(player.getName() + " has voted for " + choiceOne);
|
||||
} else {
|
||||
voteTwoCount++;
|
||||
choiceTwoVoters.addPlayer(player);
|
||||
game.informPlayers(player.getName() + " has voted for " + choiceTwo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.game.events;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -30,7 +28,7 @@ public abstract class EventDispatcher<E extends ExternalEvent> implements Serial
|
|||
listener.event(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removeAllListener() {
|
||||
listeners.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue