Merge pull request #18 from magefree/master

Merge https://github.com/magefree/mage
This commit is contained in:
Zzooouhh 2017-11-05 20:39:13 +01:00 committed by GitHub
commit e6fe4b5478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 78 additions and 80 deletions

View file

@ -5,19 +5,6 @@
*/ */
package org.mage.card.arcane; package org.mage.card.arcane;
import mage.ObjectColor;
import mage.cards.ArtRect;
import mage.cards.FrameStyle;
import mage.client.dialog.PreferencesDialog;
import mage.constants.CardType;
import mage.constants.MageObjectType;
import mage.constants.SubType;
import mage.util.SubTypeList;
import mage.view.CardView;
import mage.view.PermanentView;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.font.*; import java.awt.font.*;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
@ -31,6 +18,18 @@ import java.text.CharacterIterator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import javax.swing.*;
import mage.ObjectColor;
import mage.cards.ArtRect;
import mage.cards.FrameStyle;
import mage.client.dialog.PreferencesDialog;
import mage.constants.CardType;
import mage.constants.MageObjectType;
import mage.constants.SubType;
import mage.util.SubTypeList;
import mage.view.CardView;
import mage.view.PermanentView;
import org.apache.log4j.Logger;
/* /*
@ -849,6 +848,9 @@ public class ModernCardRenderer extends CardRenderer {
inset = cardWidth / 12; inset = cardWidth / 12;
} }
int availWidth = w - inset; int availWidth = w - inset;
if (availWidth < 0) {
return 0;
}
FontRenderContext frc = g.getFontRenderContext(); FontRenderContext frc = g.getFontRenderContext();
AttributedCharacterIterator textIter = text.getIterator(); AttributedCharacterIterator textIter = text.getIterator();

View file

@ -41,7 +41,7 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
public final static int MAGE_VERSION_MAJOR = 1; public final static int MAGE_VERSION_MAJOR = 1;
public final static int MAGE_VERSION_MINOR = 4; public final static int MAGE_VERSION_MINOR = 4;
public final static int MAGE_VERSION_PATCH = 26; public final static int MAGE_VERSION_PATCH = 26;
public final static String MAGE_VERSION_MINOR_PATCH = "V7"; public final static String MAGE_VERSION_MINOR_PATCH = "V8";
public final static String MAGE_VERSION_INFO = ""; public final static String MAGE_VERSION_INFO = "";
private final int major; private final int major;

View file

@ -161,10 +161,9 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
Game sim = createSimulation(game); Game sim = createSimulation(game);
SimulationNode2.resetCount(); SimulationNode2.resetCount();
root = new SimulationNode2(null, sim, maxDepth, playerId); root = new SimulationNode2(null, sim, maxDepth, playerId);
addActionsTimed(); addActionsTimed();
if (root.children != null && !root.children.isEmpty()) {
logger.trace("After add actions timed: root.children.size = " + root.children.size()); logger.trace("After add actions timed: root.children.size = " + root.children.size());
if (!root.children.isEmpty()) {
root = root.children.get(0); root = root.children.get(0);
// int bestScore = root.getScore(); // int bestScore = root.getScore();
// if (bestScore > currentScore || allowBadMoves) { // if (bestScore > currentScore || allowBadMoves) {

View file

@ -205,9 +205,11 @@ public class HumanPlayer extends PlayerImpl {
return; return;
} }
response.clear(); response.clear();
if (isInGame()) {
loop = true; loop = true;
} }
} }
}
if (recordingMacro && !macroTriggeredSelectionFlag) { if (recordingMacro && !macroTriggeredSelectionFlag) {
// logger.info("Adding an action " + response); // logger.info("Adding an action " + response);
actionQueueSaved.add(new PlayerResponse(response)); actionQueueSaved.add(new PlayerResponse(response));

View file

@ -67,7 +67,7 @@ public class DarksteelMutation extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new BecomesCreatureAttachedEffect(new DarksteelMutationInsectToken(), new BecomesCreatureAttachedEffect(new DarksteelMutationInsectToken(),
"Enchanted creature is an Insect artifact creature with base power and toughness 0/1 and has indestructible, and it loses all other abilities, card types, and creature types.", "Enchanted creature is an Insect artifact creature with base power and toughness 0/1 and has indestructible, and it loses all other abilities, card types, and creature types.",
Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ALL))); Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ALL_BUT_COLOR)));
} }

View file

@ -51,7 +51,6 @@ import mage.game.permanent.Permanent;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import mage.util.RandomUtil; import mage.util.RandomUtil;
/** /**
@ -114,8 +113,6 @@ class ElkinLairUpkeepEffect extends OneShotEffect {
DelayedTriggeredAbility delayed = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ElkinLairPutIntoGraveyardEffect()); DelayedTriggeredAbility delayed = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ElkinLairPutIntoGraveyardEffect());
game.addDelayedTriggeredAbility(delayed, source); game.addDelayedTriggeredAbility(delayed, source);
} }
} }
return true; return true;
@ -173,7 +170,6 @@ class ElkinLairPutIntoGraveyardEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId()); Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) { if (player != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), 0);
Set<Card> cardsInExile = game.getExile().getExileZone(source.getSourceId()).getCards(game); Set<Card> cardsInExile = game.getExile().getExileZone(source.getSourceId()).getCards(game);
if (cardsInExile != null) { if (cardsInExile != null) {
player.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED); player.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED);

View file

@ -37,10 +37,7 @@ import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.players.PlayerList;
import static mage.filter.StaticFilters.FILTER_PERMANENT_CREATURES; import static mage.filter.StaticFilters.FILTER_PERMANENT_CREATURES;
/** /**
@ -72,6 +69,7 @@ class InvasionPlansEffect extends ContinuousRuleModifyingEffectImpl {
public InvasionPlansEffect() { public InvasionPlansEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, true, false); super(Duration.WhileOnBattlefield, Outcome.Benefit, true, false);
staticText = "The attacking player chooses how each creature blocks each ";
} }
public InvasionPlansEffect(final InvasionPlansEffect effect) { public InvasionPlansEffect(final InvasionPlansEffect effect) {
@ -103,4 +101,3 @@ class InvasionPlansEffect extends ContinuousRuleModifyingEffectImpl {
return false; return false;
} }
} }

View file

@ -30,6 +30,7 @@ package mage.cards.k;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl; import mage.abilities.effects.common.cost.CostModificationEffectImpl;
@ -111,7 +112,9 @@ class KopalaWardenOfWavesCostReductionEffect extends CostModificationEffectImpl
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify.getAbilityType() == AbilityType.SPELL) { if (abilityToModify.getAbilityType() == AbilityType.SPELL) {
if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
for (Target target : abilityToModify.getTargets()) { for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
Mode mode = abilityToModify.getModes().get(modeId);
for (Target target : mode.getTargets()) {
for (UUID targetUUID : target.getTargets()) { for (UUID targetUUID : target.getTargets()) {
Permanent creature = game.getPermanent(targetUUID); Permanent creature = game.getPermanent(targetUUID);
if (creature != null if (creature != null
@ -123,6 +126,7 @@ class KopalaWardenOfWavesCostReductionEffect extends CostModificationEffectImpl
} }
} }
} }
}
return false; return false;
} }

View file

@ -27,8 +27,6 @@
*/ */
package mage.cards.m; package mage.cards.m;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -96,23 +94,16 @@ class MistOfStagnationEffect extends OneShotEffect {
if (activePlayer != null) { if (activePlayer != null) {
int cardsInGrave = activePlayer.getGraveyard().size(); int cardsInGrave = activePlayer.getGraveyard().size();
if (cardsInGrave > 0) { if (cardsInGrave > 0) {
Set<TargetPermanent> targets = new HashSet<>(); TargetPermanent target = new TargetPermanent(cardsInGrave, cardsInGrave, new FilterPermanent("permanents to untap"), true);
for (int i = 1; 1 <= cardsInGrave; i++) { activePlayer.chooseTarget(outcome, target, source, game);
TargetPermanent target = new TargetPermanent(1, 1, new FilterPermanent(), true); for (UUID oneTarget : target.getTargets()) {
target.setTargetController(activePlayer.getId()); Permanent p = game.getPermanent(oneTarget);
target.setTargetController(activePlayer.getId());
if (target.canChoose(source.getSourceId(), activePlayer.getId(), game) && activePlayer.chooseTarget(Outcome.Untap, target, source, game)) {
targets.add(target);
}
}
for (TargetPermanent target : targets) {
Permanent p = game.getPermanent(target.getFirstTarget());
if (p != null) { if (p != null) {
p.untap(game); p.untap(game);
} }
} }
return true;
} }
return true;
} }
return false; return false;
} }

View file

@ -34,8 +34,8 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.condition.InvertCondition; import mage.abilities.condition.InvertCondition;
import mage.abilities.condition.common.TargetAttackedThisTurnCondition;
import mage.abilities.condition.common.BeforeAttackersAreDeclaredCondition; import mage.abilities.condition.common.BeforeAttackersAreDeclaredCondition;
import mage.abilities.condition.common.TargetAttackedThisTurnCondition;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalActivatedAbility; import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -52,7 +52,6 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControlledFromStartOfControllerTurnPredicate; import mage.filter.predicate.permanent.ControlledFromStartOfControllerTurnPredicate;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.AttackedThisTurnWatcher; import mage.watchers.common.AttackedThisTurnWatcher;
@ -64,11 +63,13 @@ import mage.watchers.common.AttackedThisTurnWatcher;
public class Norritt extends CardImpl { public class Norritt extends CardImpl {
private static final FilterCreaturePermanent filterBlue = new FilterCreaturePermanent("blue creature"); private static final FilterCreaturePermanent filterBlue = new FilterCreaturePermanent("blue creature");
static { static {
filterBlue.add(new ColorPredicate(ObjectColor.BLUE)); filterBlue.add(new ColorPredicate(ObjectColor.BLUE));
} }
private static final FilterCreaturePermanent filterCreature = new FilterCreaturePermanent("non-Wall creature"); private static final FilterCreaturePermanent filterCreature = new FilterCreaturePermanent("non-Wall creature");
static { static {
filterCreature.add(Predicates.not(new SubtypePredicate(SubType.WALL))); filterCreature.add(Predicates.not(new SubtypePredicate(SubType.WALL)));
filterCreature.add(new ControlledFromStartOfControllerTurnPredicate()); filterCreature.add(new ControlledFromStartOfControllerTurnPredicate());

View file

@ -41,15 +41,13 @@ import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.WatcherScope;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.WatcherScope;
import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.filter.StaticFilters;
import mage.players.Player; import mage.players.Player;
import mage.watchers.Watcher; import mage.watchers.Watcher;
import mage.watchers.common.AttackedThisTurnWatcher; import mage.watchers.common.AttackedThisTurnWatcher;

View file

@ -58,7 +58,7 @@ public enum CardRepository {
// raise this if db structure was changed // raise this if db structure was changed
private static final long CARD_DB_VERSION = 51; private static final long CARD_DB_VERSION = 51;
// raise this if new cards were added to the server // raise this if new cards were added to the server
private static final long CARD_CONTENT_VERSION = 94; private static final long CARD_CONTENT_VERSION = 95;
private Dao<CardInfo, Object> cardDao; private Dao<CardInfo, Object> cardDao;
private Set<String> classNames; private Set<String> classNames;

View file

@ -563,7 +563,12 @@ public abstract class GameImpl implements Game, Serializable {
// } // }
@Override @Override
public void setConcedingPlayer(UUID playerId) { public void setConcedingPlayer(UUID playerId) {
Player player = getPlayer(state.getPriorityPlayerId()); Player player = null;
if (state.getChoosingPlayerId() != null) {
player = getPlayer(state.getChoosingPlayerId());
} else if (state.getPriorityPlayerId() != null) {
player = getPlayer(state.getPriorityPlayerId());
}
if (player != null) { if (player != null) {
if (!player.hasLeft() && player.isHuman()) { if (!player.hasLeft() && player.isHuman()) {
if (!concedingPlayers.contains(playerId)) { if (!concedingPlayers.contains(playerId)) {

View file

@ -125,7 +125,7 @@ public class ManaPool implements Serializable {
} }
if (getConditional(manaType, ability, filter, game, costToPay) > 0) { if (getConditional(manaType, ability, filter, game, costToPay) > 0) {
removeConditional(manaType, ability, game, costToPay); removeConditional(manaType, ability, game, costToPay, usedManaToPay);
lockManaType(); // pay only one mana if mana payment is set to manually lockManaType(); // pay only one mana if mana payment is set to manually
return true; return true;
} }
@ -437,10 +437,11 @@ public class ManaPool implements Serializable {
return new ManaPool(this); return new ManaPool(this);
} }
private void removeConditional(ManaType manaType, Ability ability, Game game, Cost costToPay) { private void removeConditional(ManaType manaType, Ability ability, Game game, Cost costToPay, Mana usedManaToPay) {
for (ConditionalMana mana : getConditionalMana()) { for (ConditionalMana mana : getConditionalMana()) {
if (mana.get(manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId(), costToPay)) { if (mana.get(manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId(), costToPay)) {
mana.set(manaType, mana.get(manaType) - 1); mana.set(manaType, mana.get(manaType) - 1);
usedManaToPay.increase(manaType);
GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAID, ability.getId(), mana.getManaProducerId(), ability.getControllerId(), 0, mana.getFlag()); GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAID, ability.getId(), mana.getManaProducerId(), ability.getControllerId(), 0, mana.getFlag());
event.setData(mana.getManaProducerOriginalId().toString()); event.setData(mana.getManaProducerOriginalId().toString());
game.fireEvent(event); game.fireEvent(event);

View file

@ -1751,7 +1751,9 @@ public abstract class PlayerImpl implements Player, Serializable {
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(this.getLogName() + " loses " + event.getAmount() + " life"); game.informPlayers(this.getLogName() + " loses " + event.getAmount() + " life");
} }
if (amount > 0) {
game.fireEvent(new GameEvent(GameEvent.EventType.LOST_LIFE, playerId, playerId, playerId, amount, atCombat)); game.fireEvent(new GameEvent(GameEvent.EventType.LOST_LIFE, playerId, playerId, playerId, amount, atCombat));
}
return amount; return amount;
} }
return 0; return 0;