fixed issue with X costs

This commit is contained in:
BetaSteward 2011-02-22 21:39:24 -05:00
parent 4bb22e0138
commit 47e1a7dd87
9 changed files with 21 additions and 23 deletions

View file

@ -36,8 +36,6 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -56,11 +54,11 @@ import mage.players.Player;
import mage.server.ChatManager;
import mage.server.util.ThreadExecutor;
import mage.sets.Sets;
import mage.util.Logging;
import mage.view.AbilityPickerView;
import mage.view.CardsView;
import mage.view.GameView;
import mage.view.ChatMessage.MessageColor;
import org.apache.log4j.Logger;
/**
*
@ -69,7 +67,7 @@ import mage.view.ChatMessage.MessageColor;
public class GameController implements GameCallback {
private static ExecutorService gameExecutor = ThreadExecutor.getInstance().getGameExecutor();
private final static Logger logger = Logging.getLogger(GameController.class.getName());
private final static Logger logger = Logger.getLogger(GameController.class);
public static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
private ConcurrentHashMap<UUID, GameSession> gameSessions = new ConcurrentHashMap<UUID, GameSession>();
@ -104,7 +102,7 @@ public class GameController implements GameCallback {
break;
case INFO:
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK);
logger.finest(game.getId() + " " + event.getMessage());
logger.debug(game.getId() + " " + event.getMessage());
break;
case REVEAL:
revealCards(event.getMessage(), event.getCards());
@ -178,7 +176,7 @@ public class GameController implements GameCallback {
if (gameFuture == null) {
for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) {
if (!entry.getValue().init(getGameView(entry.getKey()))) {
logger.severe("Unable to initialize client");
logger.fatal("Unable to initialize client");
//TODO: generate client error message
return;
}
@ -238,7 +236,7 @@ public class GameController implements GameCallback {
card.putOntoBattlefield(game, Zone.OUTSIDE, null, playerId);
}
} catch (GameException ex) {
logger.warning(ex.getMessage());
logger.warn(ex.getMessage());
}
addCardsForTesting(game);
updateGame();
@ -434,7 +432,7 @@ public class GameController implements GameCallback {
File f = new File(INIT_FILE_PATH);
Pattern pattern = Pattern.compile("([a-zA-Z]*):([\\w]*):([a-zA-Z ,\\-.!'\\d]*):([\\d]*)");
if (!f.exists()) {
logger.warning("Couldn't find init file: " + INIT_FILE_PATH);
logger.warn("Couldn't find init file: " + INIT_FILE_PATH);
return;
}
@ -444,7 +442,7 @@ public class GameController implements GameCallback {
try {
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (line.startsWith("#")) continue;
if (line.trim().length() == 0 || line.startsWith("#")) continue;
Matcher m = pattern.matcher(line);
if (m.matches()) {
@ -476,14 +474,14 @@ public class GameController implements GameCallback {
game.loadCards(cards, player.getId());
swapWithAnyCard(game, player, card, gameZone);
} else {
logger.severe("Couldn't find a card: " + cardName);
logger.fatal("Couldn't find a card: " + cardName);
}
}
} else {
logger.warning("Was skipped: " + line);
logger.warn("Was skipped: " + line);
}
} else {
logger.warning("Init string wasn't parsed: " + line);
logger.warn("Init string wasn't parsed: " + line);
}
}
}
@ -491,7 +489,7 @@ public class GameController implements GameCallback {
scanner.close();
}
} catch (Exception e) {
logger.log(Level.SEVERE, "", e);
logger.fatal("", e);
}
}

View file

@ -90,8 +90,8 @@ class MartialCoupEffect extends OneShotEffect<MartialCoupEffect> {
@Override
public boolean apply(Game game, Ability source) {
int amount = 0;
if (source.getManaCosts().getVariableCosts().size() > 0) {
amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
if (source.getManaCostsToPay().getVariableCosts().size() > 0) {
amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
}
if (amount > 4) {

View file

@ -93,7 +93,7 @@ class EarthquakeEffect extends OneShotEffect<EarthquakeEffect> {
@Override
public boolean apply(Game game, Ability source) {
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
permanent.damage(amount, source.getId(), game, true, false);

View file

@ -91,7 +91,7 @@ class FireballEffect extends OneShotEffect<FireballEffect> {
@Override
public boolean apply(Game game, Ability source) {
int numTargets = source.getTargets().get(0).getTargets().size();
int damage = source.getManaCosts().getVariableCosts().get(0).getAmount();
int damage = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
if (numTargets > 0) {
int damagePer = damage/numTargets;
if (damagePer > 0) {

View file

@ -84,7 +84,7 @@ class MindSpringEffect extends OneShotEffect<MindSpringEffect> {
@Override
public boolean apply(Game game, Ability source) {
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.drawCards(amount, game);

View file

@ -99,7 +99,7 @@ public class ProteanHydra extends CardImpl<ProteanHydra> {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
permanent.addCounters(new PlusOneCounter(amount));
}
return true;

View file

@ -102,8 +102,8 @@ class VengefulArchonEffect extends PreventionEffectImpl<VengefulArchonEffect> {
@Override
public void init(Ability source, Game game) {
super.init(source, game);
if (source.getManaCosts().getVariableCosts().size() > 0)
amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
if (source.getManaCostsToPay().getVariableCosts().size() > 0)
amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
}
@Override

View file

@ -76,7 +76,7 @@ class ExsanguinateEffect extends OneShotEffect<ExsanguinateEffect> {
@Override
public boolean apply(Game game, Ability source) {
int loseLife = 0;
int damage = source.getManaCosts().getVariableCosts().get(0).getAmount();
int damage = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
loseLife += game.getPlayer(opponentId).loseLife(damage, game);
}

View file

@ -85,7 +85,7 @@ class SigilofDistinctionEffect extends OneShotEffect<SigilofDistinctionEffect> {
@Override
public boolean apply(Game game, Ability source) {
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {
p.addCounters(CounterType.CHARGE.createInstance(amount));