mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
fixed issue with X costs
This commit is contained in:
parent
4bb22e0138
commit
47e1a7dd87
9 changed files with 21 additions and 23 deletions
|
@ -36,8 +36,6 @@ import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -56,11 +54,11 @@ import mage.players.Player;
|
||||||
import mage.server.ChatManager;
|
import mage.server.ChatManager;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
import mage.sets.Sets;
|
import mage.sets.Sets;
|
||||||
import mage.util.Logging;
|
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.AbilityPickerView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
import mage.view.GameView;
|
import mage.view.GameView;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -69,7 +67,7 @@ import mage.view.ChatMessage.MessageColor;
|
||||||
public class GameController implements GameCallback {
|
public class GameController implements GameCallback {
|
||||||
|
|
||||||
private static ExecutorService gameExecutor = ThreadExecutor.getInstance().getGameExecutor();
|
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";
|
public static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
|
||||||
|
|
||||||
private ConcurrentHashMap<UUID, GameSession> gameSessions = new ConcurrentHashMap<UUID, GameSession>();
|
private ConcurrentHashMap<UUID, GameSession> gameSessions = new ConcurrentHashMap<UUID, GameSession>();
|
||||||
|
@ -104,7 +102,7 @@ public class GameController implements GameCallback {
|
||||||
break;
|
break;
|
||||||
case INFO:
|
case INFO:
|
||||||
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK);
|
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK);
|
||||||
logger.finest(game.getId() + " " + event.getMessage());
|
logger.debug(game.getId() + " " + event.getMessage());
|
||||||
break;
|
break;
|
||||||
case REVEAL:
|
case REVEAL:
|
||||||
revealCards(event.getMessage(), event.getCards());
|
revealCards(event.getMessage(), event.getCards());
|
||||||
|
@ -178,7 +176,7 @@ public class GameController implements GameCallback {
|
||||||
if (gameFuture == null) {
|
if (gameFuture == null) {
|
||||||
for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) {
|
for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) {
|
||||||
if (!entry.getValue().init(getGameView(entry.getKey()))) {
|
if (!entry.getValue().init(getGameView(entry.getKey()))) {
|
||||||
logger.severe("Unable to initialize client");
|
logger.fatal("Unable to initialize client");
|
||||||
//TODO: generate client error message
|
//TODO: generate client error message
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +236,7 @@ public class GameController implements GameCallback {
|
||||||
card.putOntoBattlefield(game, Zone.OUTSIDE, null, playerId);
|
card.putOntoBattlefield(game, Zone.OUTSIDE, null, playerId);
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
logger.warning(ex.getMessage());
|
logger.warn(ex.getMessage());
|
||||||
}
|
}
|
||||||
addCardsForTesting(game);
|
addCardsForTesting(game);
|
||||||
updateGame();
|
updateGame();
|
||||||
|
@ -434,7 +432,7 @@ public class GameController implements GameCallback {
|
||||||
File f = new File(INIT_FILE_PATH);
|
File f = new File(INIT_FILE_PATH);
|
||||||
Pattern pattern = Pattern.compile("([a-zA-Z]*):([\\w]*):([a-zA-Z ,\\-.!'\\d]*):([\\d]*)");
|
Pattern pattern = Pattern.compile("([a-zA-Z]*):([\\w]*):([a-zA-Z ,\\-.!'\\d]*):([\\d]*)");
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
logger.warning("Couldn't find init file: " + INIT_FILE_PATH);
|
logger.warn("Couldn't find init file: " + INIT_FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +442,7 @@ public class GameController implements GameCallback {
|
||||||
try {
|
try {
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
String line = scanner.nextLine().trim();
|
String line = scanner.nextLine().trim();
|
||||||
if (line.startsWith("#")) continue;
|
if (line.trim().length() == 0 || line.startsWith("#")) continue;
|
||||||
Matcher m = pattern.matcher(line);
|
Matcher m = pattern.matcher(line);
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
|
|
||||||
|
@ -476,14 +474,14 @@ public class GameController implements GameCallback {
|
||||||
game.loadCards(cards, player.getId());
|
game.loadCards(cards, player.getId());
|
||||||
swapWithAnyCard(game, player, card, gameZone);
|
swapWithAnyCard(game, player, card, gameZone);
|
||||||
} else {
|
} else {
|
||||||
logger.severe("Couldn't find a card: " + cardName);
|
logger.fatal("Couldn't find a card: " + cardName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.warning("Was skipped: " + line);
|
logger.warn("Was skipped: " + line);
|
||||||
}
|
}
|
||||||
} else {
|
} 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();
|
scanner.close();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.SEVERE, "", e);
|
logger.fatal("", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,8 +90,8 @@ class MartialCoupEffect extends OneShotEffect<MartialCoupEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
if (source.getManaCosts().getVariableCosts().size() > 0) {
|
if (source.getManaCostsToPay().getVariableCosts().size() > 0) {
|
||||||
amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
|
amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount > 4) {
|
if (amount > 4) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ class EarthquakeEffect extends OneShotEffect<EarthquakeEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
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)) {
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
||||||
permanent.damage(amount, source.getId(), game, true, false);
|
permanent.damage(amount, source.getId(), game, true, false);
|
||||||
|
|
|
@ -91,7 +91,7 @@ class FireballEffect extends OneShotEffect<FireballEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int numTargets = source.getTargets().get(0).getTargets().size();
|
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) {
|
if (numTargets > 0) {
|
||||||
int damagePer = damage/numTargets;
|
int damagePer = damage/numTargets;
|
||||||
if (damagePer > 0) {
|
if (damagePer > 0) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ class MindSpringEffect extends OneShotEffect<MindSpringEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
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());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.drawCards(amount, game);
|
player.drawCards(amount, game);
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class ProteanHydra extends CardImpl<ProteanHydra> {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
int amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
|
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||||
permanent.addCounters(new PlusOneCounter(amount));
|
permanent.addCounters(new PlusOneCounter(amount));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -102,8 +102,8 @@ class VengefulArchonEffect extends PreventionEffectImpl<VengefulArchonEffect> {
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
public void init(Ability source, Game game) {
|
||||||
super.init(source, game);
|
super.init(source, game);
|
||||||
if (source.getManaCosts().getVariableCosts().size() > 0)
|
if (source.getManaCostsToPay().getVariableCosts().size() > 0)
|
||||||
amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
|
amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -76,7 +76,7 @@ class ExsanguinateEffect extends OneShotEffect<ExsanguinateEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int loseLife = 0;
|
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())) {
|
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
|
||||||
loseLife += game.getPlayer(opponentId).loseLife(damage, game);
|
loseLife += game.getPlayer(opponentId).loseLife(damage, game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ class SigilofDistinctionEffect extends OneShotEffect<SigilofDistinctionEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
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());
|
Permanent p = game.getPermanent(source.getSourceId());
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.addCounters(CounterType.CHARGE.createInstance(amount));
|
p.addCounters(CounterType.CHARGE.createInstance(amount));
|
||||||
|
|
Loading…
Reference in a new issue