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;
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.font.*;
import java.awt.geom.Rectangle2D;
@ -31,6 +18,18 @@ import java.text.CharacterIterator;
import java.util.ArrayList;
import java.util.Collection;
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;
/*
@ -77,9 +76,9 @@ public class ModernCardRenderer extends CardRenderer {
}
private static Font loadFont(String name) {
try(InputStream in = ModernCardRenderer.class.getResourceAsStream("/cardrender/" + name + ".ttf")) {
try (InputStream in = ModernCardRenderer.class.getResourceAsStream("/cardrender/" + name + ".ttf")) {
return Font.createFont(
Font.TRUETYPE_FONT,in);
Font.TRUETYPE_FONT, in);
} catch (IOException e) {
LOGGER.info("Failed to load font `" + name + "`, couldn't find resource.");
} catch (FontFormatException e) {
@ -353,7 +352,7 @@ public class ModernCardRenderer extends CardRenderer {
if (useInventionFrame()) {
drawArtIntoRect(g,
borderWidth, borderWidth,
cardWidth - 2*borderWidth, cardHeight - 2*borderWidth,
cardWidth - 2 * borderWidth, cardHeight - 2 * borderWidth,
getArtRect(), false);
}
@ -367,11 +366,11 @@ public class ModernCardRenderer extends CardRenderer {
// each filling half of the art rect
drawArtIntoRect(g,
totalContentInset + 1, totalContentInset + boxHeight,
contentWidth - 2, (typeLineY - totalContentInset - boxHeight)/2,
contentWidth - 2, (typeLineY - totalContentInset - boxHeight) / 2,
ArtRect.SPLIT_LEFT.rect, useInventionFrame());
drawArtIntoRect(g,
totalContentInset + 1, totalContentInset + boxHeight + (typeLineY - totalContentInset - boxHeight)/2,
contentWidth - 2, (typeLineY - totalContentInset - boxHeight)/2,
totalContentInset + 1, totalContentInset + boxHeight + (typeLineY - totalContentInset - boxHeight) / 2,
contentWidth - 2, (typeLineY - totalContentInset - boxHeight) / 2,
ArtRect.SPLIT_RIGHT.rect, useInventionFrame());
return;
} else if (rect != ArtRect.NORMAL) {
@ -849,6 +848,9 @@ public class ModernCardRenderer extends CardRenderer {
inset = cardWidth / 12;
}
int availWidth = w - inset;
if (availWidth < 0) {
return 0;
}
FontRenderContext frc = g.getFontRenderContext();
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_MINOR = 4;
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 = "";
private final int major;

View file

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

View file

@ -205,7 +205,9 @@ public class HumanPlayer extends PlayerImpl {
return;
}
response.clear();
loop = true;
if (isInGame()) {
loop = true;
}
}
}
if (recordingMacro && !macroTriggeredSelectionFlag) {

View file

@ -53,7 +53,7 @@ import mage.target.common.TargetCreaturePermanent;
public class DarksteelMutation extends CardImpl {
public DarksteelMutation(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -67,7 +67,7 @@ public class DarksteelMutation extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
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.",
Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ALL)));
Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ALL_BUT_COLOR)));
}

View file

@ -51,17 +51,16 @@ import mage.game.permanent.Permanent;
import mage.filter.FilterCard;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import mage.util.RandomUtil;
/**
*
*
* @author L_J
*/
public class ElkinLair extends CardImpl {
public ElkinLair(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{R}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
addSuperType(SuperType.WORLD);
// At the beginning of each player's upkeep, that player exiles a card at random from his or her hand. The player may play that card this turn. At the beginning of the next end step, if the player hasn't played the card, he or she puts it into his or her graveyard.
@ -111,11 +110,9 @@ class ElkinLairUpkeepEffect extends OneShotEffect {
ContinuousEffect effect = new ElkinLairPlayExiledEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
game.addEffect(effect, source);
DelayedTriggeredAbility delayed = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ElkinLairPutIntoGraveyardEffect());
game.addDelayedTriggeredAbility(delayed, source);
}
}
return true;
@ -150,8 +147,8 @@ class ElkinLairPlayExiledEffect extends AsThoughEffectImpl {
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Card card = game.getCard(objectId);
if (card != null
&& affectedControllerId.equals(card.getOwnerId())
&& game.getState().getZone(card.getId()) == Zone.EXILED) {
&& affectedControllerId.equals(card.getOwnerId())
&& game.getState().getZone(card.getId()) == Zone.EXILED) {
return true;
}
return false;
@ -173,7 +170,6 @@ class ElkinLairPutIntoGraveyardEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), 0);
Set<Card> cardsInExile = game.getExile().getExileZone(source.getSourceId()).getCards(game);
if (cardsInExile != null) {
player.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED);

View file

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

View file

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

View file

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

View file

@ -34,8 +34,8 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.condition.InvertCondition;
import mage.abilities.condition.common.TargetAttackedThisTurnCondition;
import mage.abilities.condition.common.BeforeAttackersAreDeclaredCondition;
import mage.abilities.condition.common.TargetAttackedThisTurnCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalActivatedAbility;
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.ControllerPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.AttackedThisTurnWatcher;
@ -62,13 +61,15 @@ import mage.watchers.common.AttackedThisTurnWatcher;
* @author MTGfan & L_J
*/
public class Norritt extends CardImpl {
private static final FilterCreaturePermanent filterBlue = new FilterCreaturePermanent("blue creature");
static {
filterBlue.add(new ColorPredicate(ObjectColor.BLUE));
}
private static final FilterCreaturePermanent filterCreature = new FilterCreaturePermanent("non-Wall creature");
static {
filterCreature.add(Predicates.not(new SubtypePredicate(SubType.WALL)));
filterCreature.add(new ControlledFromStartOfControllerTurnPredicate());
@ -90,7 +91,7 @@ public class Norritt extends CardImpl {
// {T}: Choose target non-Wall creature the active player has controlled continuously since the beginning of the turn. That creature attacks this turn if able. If it doesn't, destroy it at the beginning of the next end step. Activate this ability only before attackers are declared.
Ability ability2 = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new AttacksIfAbleTargetEffect(Duration.EndOfTurn),
new TapSourceCost(), BeforeAttackersAreDeclaredCondition.instance,
new TapSourceCost(), BeforeAttackersAreDeclaredCondition.instance,
"{T}: Choose target non-Wall creature the active player has controlled continuously since the beginning of the turn. "
+ "That creature attacks this turn if able. If it doesn't, destroy it at the beginning of the next end step. "
+ "Activate this ability only before attackers are declared.");

View file

@ -41,15 +41,13 @@ import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.WatcherScope;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.WatcherScope;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.filter.StaticFilters;
import mage.players.Player;
import mage.watchers.Watcher;
import mage.watchers.common.AttackedThisTurnWatcher;
@ -116,14 +114,14 @@ class SeasonOfTheWitchEffect extends OneShotEffect {
}
// Creatures that attacked are safe.
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
if (watcher != null
&& watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game)) ) {
if (watcher != null
&& watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) {
continue;
}
// Creatures that couldn't attack are safe.
CouldAttackThisTurnWatcher watcher2 = (CouldAttackThisTurnWatcher) game.getState().getWatchers().get(CouldAttackThisTurnWatcher.class.getSimpleName());
if (watcher2 != null
&& !watcher2.getCouldAttackThisTurnCreatures().contains(new MageObjectReference(permanent, game)) ) {
if (watcher2 != null
&& !watcher2.getCouldAttackThisTurnCreatures().contains(new MageObjectReference(permanent, game))) {
continue;
}
// Destroy the rest.
@ -156,11 +154,11 @@ class CouldAttackThisTurnWatcher extends Watcher {
if (permanent.isCreature()) {
for (UUID defender : game.getCombat().getDefenders()) {
if (defender != activePlayer.getId()) {
if (permanent.canAttack(defender, game)) {
if (permanent.canAttack(defender, game)) {
// exclude Propaganda style effects
if (!game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
if (!game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,
defender, permanent.getId(), permanent.getControllerId()), game)) {
defender, permanent.getId(), permanent.getControllerId()), game)) {
this.couldAttackThisTurnCreatures.add(new MageObjectReference(permanent.getId(), game));
break;
}

View file

@ -58,7 +58,7 @@ public enum CardRepository {
// raise this if db structure was changed
private static final long CARD_DB_VERSION = 51;
// 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 Set<String> classNames;

View file

@ -563,7 +563,12 @@ public abstract class GameImpl implements Game, Serializable {
// }
@Override
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.hasLeft() && player.isHuman()) {
if (!concedingPlayers.contains(playerId)) {

View file

@ -125,7 +125,7 @@ public class ManaPool implements Serializable {
}
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
return true;
}
@ -437,10 +437,11 @@ public class ManaPool implements Serializable {
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()) {
if (mana.get(manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId(), costToPay)) {
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());
event.setData(mana.getManaProducerOriginalId().toString());
game.fireEvent(event);

View file

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