mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Merge
This commit is contained in:
commit
8fcd50042e
13 changed files with 41 additions and 33 deletions
|
@ -44,6 +44,7 @@ import mage.MageObject;
|
|||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.TriggeredAbilities;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.costs.mana.ColoredManaCost;
|
||||
|
@ -225,6 +226,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (!target.isRequired())
|
||||
return false;
|
||||
}
|
||||
if (target instanceof TargetDiscard) {
|
||||
|
@ -243,6 +245,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (!target.isRequired())
|
||||
return false;
|
||||
}
|
||||
if (target instanceof TargetControlledPermanent) {
|
||||
|
@ -271,6 +274,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (!target.isRequired())
|
||||
return false;
|
||||
}
|
||||
if (target instanceof TargetCreatureOrPlayer) {
|
||||
|
@ -300,6 +304,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (!target.isRequired())
|
||||
return false;
|
||||
}
|
||||
throw new IllegalStateException("Target wasn't handled. class:" + target.getClass().toString());
|
||||
|
@ -484,11 +489,14 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
for (Mana mana: options) {
|
||||
for (Mana avail: available) {
|
||||
if (mana.enough(avail)) {
|
||||
SpellAbility ability = card.getSpellAbility();
|
||||
if (ability != null && ability.canActivate(playerId, game)) {
|
||||
if (card.getCardType().contains(CardType.INSTANT))
|
||||
playableInstant.add(card);
|
||||
else
|
||||
playableNonInstant.add(card);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!playableInstant.contains(card) && !playableNonInstant.contains(card))
|
||||
unplayable.put(mana.needed(avail), card);
|
||||
|
|
Binary file not shown.
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -325,6 +325,9 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
for (Player player: state.getPlayers().values()) {
|
||||
player.init(this, testMode);
|
||||
}
|
||||
for (Player player: state.getPlayers().values()) {
|
||||
player.beginTurn(this);
|
||||
}
|
||||
fireInformEvent("game has started");
|
||||
saveState();
|
||||
|
||||
|
@ -344,7 +347,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
else {
|
||||
choosingPlayer = this.getPlayer(choosingPlayerId);
|
||||
}
|
||||
if (choosingPlayer.chooseTarget(Outcome.Benefit, targetPlayer, null, this)) {
|
||||
if (choosingPlayer.choose(Outcome.Benefit, targetPlayer, this)) {
|
||||
startingPlayerId = ((List<UUID>)targetPlayer.getTargets()).get(0);
|
||||
fireInformEvent(state.getPlayer(startingPlayerId).getName() + " will start");
|
||||
}
|
||||
|
|
|
@ -168,7 +168,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
this.left = false;
|
||||
this.passed = false;
|
||||
this.passedTurn = false;
|
||||
findRange(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue