mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
...
This commit is contained in:
parent
e9249bfcf6
commit
904727e9dc
3 changed files with 48 additions and 6 deletions
|
@ -31,6 +31,9 @@ package mage.interfaces.callback;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.util.Logging;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -38,6 +41,8 @@ import java.util.concurrent.Executors;
|
|||
*/
|
||||
public class CallbackClientDaemon extends Thread {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(CallbackClientDaemon.class.getName());
|
||||
|
||||
private static ExecutorService callbackExecutor = Executors.newCachedThreadPool();
|
||||
private final CallbackClient client;
|
||||
private final CallbackServer server;
|
||||
|
@ -60,13 +65,18 @@ public class CallbackClientDaemon extends Thread {
|
|||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
client.processCallback(callback);
|
||||
try {
|
||||
client.processCallback(callback);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
System.out.print(ex.getMessage());
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ import mage.Constants.Rarity;
|
|||
import mage.ObjectColor;
|
||||
import mage.cards.Card;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -77,15 +79,39 @@ public class CardView implements Serializable {
|
|||
this.superTypes = card.getSupertype();
|
||||
this.color = card.getColor();
|
||||
this.manaCost = card.getManaCost().getSymbols();
|
||||
this.art = card.getArt();
|
||||
this.rarity = card.getRarity();
|
||||
this.expansionSetCode = card.getExpansionSetCode();
|
||||
if (card instanceof PermanentToken) {
|
||||
this.art = "";
|
||||
this.rarity = Rarity.NA;
|
||||
this.expansionSetCode = "";
|
||||
}
|
||||
else {
|
||||
this.art = card.getArt();
|
||||
this.rarity = card.getRarity();
|
||||
this.expansionSetCode = card.getExpansionSetCode();
|
||||
}
|
||||
}
|
||||
|
||||
protected CardView() {
|
||||
|
||||
}
|
||||
|
||||
CardView(Token token) {
|
||||
this.id = token.getId();
|
||||
this.name = token.getName();
|
||||
this.rules = formatRules(token.getAbilities().getRules());
|
||||
this.power = token.getPower().toString();
|
||||
this.toughness = token.getToughness().toString();
|
||||
this.loyalty = token.getLoyalty().toString();
|
||||
this.cardTypes = token.getCardType();
|
||||
this.subTypes = token.getSubtype();
|
||||
this.superTypes = token.getSupertype();
|
||||
this.color = token.getColor();
|
||||
this.manaCost = token.getManaCost().getSymbols();
|
||||
this.art = "";
|
||||
this.rarity = Rarity.NA;
|
||||
this.expansionSetCode = "";
|
||||
}
|
||||
|
||||
protected List<String> formatRules(List<String> rules) {
|
||||
List<String> newRules = new ArrayList<String>();
|
||||
for (String rule: rules) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.UUID;
|
|||
import mage.cards.Card;
|
||||
import mage.counters.Counter;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -67,7 +68,12 @@ public class PermanentView extends CardView {
|
|||
counters.add(new CounterView(counter));
|
||||
}
|
||||
}
|
||||
original = new CardView(card);
|
||||
if (permanent instanceof PermanentToken) {
|
||||
original = new CardView(((PermanentToken)permanent).getToken());
|
||||
}
|
||||
else {
|
||||
original = new CardView(card);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTapped() {
|
||||
|
|
Loading…
Reference in a new issue