mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Reverting concurrent code to start fresh
This commit is contained in:
parent
88f3db03c4
commit
02d9287cfa
1 changed files with 14 additions and 54 deletions
|
@ -1,8 +1,6 @@
|
|||
|
||||
package mage.cards.j;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
@ -36,13 +34,10 @@ import mage.players.Player;
|
|||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInExile;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -244,21 +239,23 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
|
|||
if (controller == null || sourcePermanent == null) {
|
||||
return false;
|
||||
}
|
||||
ArrayList<JaceArchitectOfThoughtEffect3Helper> threads = new ArrayList<>();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
JaceArchitectOfThoughtEffect3Helper thread = new JaceArchitectOfThoughtEffect3Helper(playerId, game, source, sourcePermanent, controller);
|
||||
thread.execute();
|
||||
thread.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if("state".equals(evt.getPropertyName()) && SwingWorker.StateValue.DONE.equals(evt.getNewValue())){
|
||||
threads.remove(evt.getSource());
|
||||
}
|
||||
Player player = game.getPlayer(playerId);
|
||||
String playerName = new StringBuilder(player.getLogName()).append("'s").toString();
|
||||
if (source.isControlledBy(player.getId())) {
|
||||
playerName = "your";
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard(new StringBuilder("nonland card from ").append(playerName).append(" library").toString()));
|
||||
if (controller.searchLibrary(target, game, playerId)) {
|
||||
UUID targetId = target.getFirstTarget();
|
||||
Card card = player.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
controller.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
||||
}
|
||||
});
|
||||
threads.add(thread);
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
}
|
||||
while(threads.size() > 0) {}
|
||||
|
||||
ExileZone jaceExileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
||||
if (jaceExileZone == null) {
|
||||
return true;
|
||||
|
@ -277,40 +274,3 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class JaceArchitectOfThoughtEffect3Helper extends SwingWorker<Boolean, Void> {
|
||||
|
||||
UUID playerId;
|
||||
Game game;
|
||||
Ability source;
|
||||
Permanent sourcePermanent;
|
||||
Player controller;
|
||||
|
||||
public JaceArchitectOfThoughtEffect3Helper (UUID playerId, Game game, Ability source, Permanent sourcePermanent, Player controller) {
|
||||
this.playerId = playerId;
|
||||
this.game = game;
|
||||
this.source = source;
|
||||
this.sourcePermanent = sourcePermanent;
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground() throws Exception {
|
||||
Player player = this.game.getPlayer(this.playerId);
|
||||
String playerName = new StringBuilder(player.getLogName()).append("'s").toString();
|
||||
if (this.source.isControlledBy(player.getId())) {
|
||||
playerName = "your";
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard(new StringBuilder("nonland card from ").append(playerName).append(" library").toString()));
|
||||
if (this.controller.searchLibrary(target, this.game, this.playerId)) {
|
||||
UUID targetId = target.getFirstTarget();
|
||||
Card card = player.getLibrary().remove(targetId, this.game);
|
||||
if (card != null) {
|
||||
this.controller.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(this.game, this.source), this.sourcePermanent.getIdName(), this.source.getSourceId(), this.game, Zone.LIBRARY, true);
|
||||
}
|
||||
player.shuffleLibrary(this.source, this.game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue