[AKH] Fixed that Aftermath card images were shown wrongly rotated.

This commit is contained in:
LevelX2 2017-04-16 22:57:08 +02:00
parent a8631c6ff3
commit ed341528d9
66 changed files with 356 additions and 426 deletions

View file

@ -27,6 +27,7 @@
*/
package mage.abilities;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.costs.Cost;
import mage.abilities.costs.VariableCost;
@ -44,8 +45,6 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -94,7 +93,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
public boolean canActivate(UUID playerId, Game game) {
if (game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST_AS_INSTANT, this, playerId, game) // check this first to allow Offering in main phase
|| this.spellCanBeActivatedRegularlyNow(playerId, game)) {
if (spellAbilityType == SpellAbilityType.SPLIT) {
if (spellAbilityType == SpellAbilityType.SPLIT || spellAbilityType == SpellAbilityType.SPLIT_AFTERMATH) {
return false;
}
// fix for Gitaxian Probe and casting opponent's spells
@ -110,7 +109,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
}
}
// Alternate spell abilities (Flashback, Overload) can't be cast with no mana to pay option
if (getSpellAbilityType()== SpellAbilityType.BASE_ALTERNATE) {
if (getSpellAbilityType() == SpellAbilityType.BASE_ALTERNATE) {
Player player = game.getPlayer(playerId);
if (player != null && getSourceId().equals(player.getCastSourceIdWithAlternateMana())) {
return false;
@ -183,27 +182,27 @@ public class SpellAbility extends ActivatedAbilityImpl {
public int getConvertedXManaCost(Card card) {
int xMultiplier = 0;
int amount = 0;
if(card == null) {
if (card == null) {
return 0;
}
for(ManaCost manaCost : card.getManaCost()) {
if(manaCost instanceof VariableManaCost) {
xMultiplier = ((VariableManaCost)manaCost).getMultiplier();
for (ManaCost manaCost : card.getManaCost()) {
if (manaCost instanceof VariableManaCost) {
xMultiplier = ((VariableManaCost) manaCost).getMultiplier();
break;
}
}
boolean hasNonManaXCost = false;
for(Cost cost : getCosts()) {
if(cost instanceof VariableCost) {
for (Cost cost : getCosts()) {
if (cost instanceof VariableCost) {
hasNonManaXCost = true;
amount = ((VariableCost) cost).getAmount();
break;
}
}
if(!hasNonManaXCost) {
if (!hasNonManaXCost) {
amount = getManaCostsToPay().getX();
}
return amount * xMultiplier;

View file

@ -27,31 +27,31 @@
*/
package mage.abilities.keyword;
import mage.MageObject;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.*;
import mage.cards.Card;
import mage.cards.SplitCardHalf;
import mage.cards.SplitCardHalfImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.stack.Spell;
import mage.players.Player;
import java.util.UUID;
/**
* Aftermath
*
* TODO: Implement once we get details on the comprehensive rules meaning of the ability
* TODO: Implement once we get details on the comprehensive rules meaning of the
* ability
*
* Current text is a shell copied from Flashback
*
* @author stravant
*/
public class AftermathAbility extends SimpleStaticAbility {
public AftermathAbility() {
super(Zone.ALL, new AftermathCastFromGraveyard());
addEffect(new AftermathCantCastFromHand());
@ -99,13 +99,13 @@ class AftermathCastFromGraveyard extends AsThoughEffectImpl {
}
private static String msb(UUID id) {
return Integer.toUnsignedString((int)id.getMostSignificantBits(), 16);
return Integer.toUnsignedString((int) id.getMostSignificantBits(), 16);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (objectId.equals(source.getSourceId()) &
affectedControllerId.equals(source.getControllerId())) {
if (objectId.equals(source.getSourceId())
& affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(source.getSourceId());
if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
return true;
@ -122,7 +122,7 @@ class AftermathCantCastFromHand extends ContinuousRuleModifyingEffectImpl {
staticText = ", but not from anywhere else";
}
public AftermathCantCastFromHand (final AftermathCantCastFromHand effect) {
public AftermathCantCastFromHand(final AftermathCantCastFromHand effect) {
super(effect);
}
@ -213,7 +213,7 @@ class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl {
if (sourceCard != null) {
Player player = game.getPlayer(sourceCard.getOwnerId());
if (player != null) {
return player.moveCardToExileWithInfo(sourceCard, null, "", sourceId, game, ((ZoneChangeEvent)event).getFromZone(), true);
return player.moveCardToExileWithInfo(sourceCard, null, "", sourceId, game, ((ZoneChangeEvent) event).getFromZone(), true);
}
}
return false;
@ -224,4 +224,4 @@ class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl {
return new AftermathExileAsResolvesFromGraveyard(this);
}
}
}

View file

@ -30,7 +30,6 @@ package mage.cards;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability;
@ -49,12 +48,12 @@ public abstract class SplitCard extends CardImpl {
protected Card leftHalfCard;
protected Card rightHalfCard;
public SplitCard(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costsLeft, String costsRight, boolean fused) {
this(ownerId, setInfo, cardTypes, cardTypes, costsLeft, costsRight, fused);
public SplitCard(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costsLeft, String costsRight, SpellAbilityType spellAbilityType) {
this(ownerId, setInfo, cardTypes, cardTypes, costsLeft, costsRight, spellAbilityType);
}
public SplitCard(UUID ownerId, CardSetInfo setInfo, CardType[] typesLeft, CardType[] typesRight, String costsLeft, String costsRight, boolean fused) {
super(ownerId, setInfo, CardType.mergeTypes(typesLeft, typesRight), costsLeft + costsRight, (fused ? SpellAbilityType.SPLIT_FUSED : SpellAbilityType.SPLIT));
public SplitCard(UUID ownerId, CardSetInfo setInfo, CardType[] typesLeft, CardType[] typesRight, String costsLeft, String costsRight, SpellAbilityType spellAbilityType) {
super(ownerId, setInfo, CardType.mergeTypes(typesLeft, typesRight), costsLeft + costsRight, spellAbilityType);
String[] names = setInfo.getName().split(" // ");
leftHalfCard = new SplitCardHalfImpl(this.getOwnerId(), new CardSetInfo(names[0], setInfo.getExpansionSetCode(), setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()), typesLeft, costsLeft, this, SpellAbilityType.SPLIT_LEFT);
rightHalfCard = new SplitCardHalfImpl(this.getOwnerId(), new CardSetInfo(names[1], setInfo.getExpansionSetCode(), setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()), typesRight, costsRight, this, SpellAbilityType.SPLIT_RIGHT);
@ -135,7 +134,9 @@ public abstract class SplitCard extends CardImpl {
public Abilities<Ability> getAbilities() {
Abilities<Ability> allAbilites = new AbilitiesImpl<>();
for (Ability ability : super.getAbilities()) {
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT) {
if (ability instanceof SpellAbility
&& ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT
&& ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT_AFTERMATH) {
allAbilites.add(ability);
}
}
@ -149,6 +150,7 @@ public abstract class SplitCard extends CardImpl {
* gets any abilities on a split card as a whole, and not on either half
* individually.
*
* @return
*/
public Abilities<Ability> getSharedAbilities() {
return super.getAbilities();
@ -158,7 +160,9 @@ public abstract class SplitCard extends CardImpl {
public Abilities<Ability> getAbilities(Game game) {
Abilities<Ability> allAbilites = new AbilitiesImpl<>();
for (Ability ability : super.getAbilities(game)) {
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT) {
if (ability instanceof SpellAbility
&& ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT
&& ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT_AFTERMATH) {
allAbilites.add(ability);
}
}

View file

@ -8,6 +8,7 @@ import mage.cards.SplitCard;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.CardType;
import mage.constants.SpellAbilityType;
/**
*
@ -20,7 +21,7 @@ public class MockSplitCard extends SplitCard {
card.getTypes().toArray(new CardType[0]),
join(card.getManaCosts()),
"",
join(card.getRules()).contains("Fuse"));
getSpellAbilityType(card));
this.expansionSetCode = card.getSetCode();
this.power = mageIntFromString(card.getPower());
this.toughness = mageIntFromString(card.getToughness());
@ -77,6 +78,16 @@ public class MockSplitCard extends SplitCard {
}
}
private static SpellAbilityType getSpellAbilityType(CardInfo cardInfo) {
if (cardInfo.isSplitFuseCard()) {
return SpellAbilityType.SPLIT_FUSED;
}
if (cardInfo.isSplitAftermathCard()) {
return SpellAbilityType.SPLIT_AFTERMATH;
}
return SpellAbilityType.SPLIT;
}
private static String join(List<String> strings) {
StringBuilder sb = new StringBuilder();
for (String string : strings) {

View file

@ -30,9 +30,7 @@ package mage.cards.repository;
import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import java.util.*;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
@ -106,6 +104,10 @@ public class CardInfo {
@DatabaseField
protected boolean splitCard;
@DatabaseField
protected boolean splitCardFuse;
@DatabaseField
protected boolean splitCardAftermath;
@DatabaseField
protected boolean splitCardHalf;
@DatabaseField
protected boolean flipCard;
@ -131,6 +133,8 @@ public class CardInfo {
this.convertedManaCost = card.getConvertedManaCost();
this.rarity = card.getRarity();
this.splitCard = card.isSplitCard();
this.splitCardFuse = card.getSpellAbility() != null && card.getSpellAbility().getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED;
this.splitCardAftermath = card.getSpellAbility() != null && card.getSpellAbility().getSpellAbilityType() == SpellAbilityType.SPLIT_AFTERMATH;
this.flipCard = card.isFlipCard();
this.flipCardName = card.getFlipCardName();
@ -355,6 +359,14 @@ public class CardInfo {
return splitCard;
}
public boolean isSplitFuseCard() {
return splitCardFuse;
}
public boolean isSplitAftermathCard() {
return splitCardAftermath;
}
public boolean isSplitCardHalf() {
return splitCardHalf;
}

View file

@ -37,11 +37,9 @@ import com.j256.ormlite.stmt.Where;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.support.DatabaseConnection;
import com.j256.ormlite.table.TableUtils;
import java.io.File;
import java.sql.SQLException;
import java.util.*;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SetType;
@ -58,9 +56,9 @@ public enum CardRepository {
private static final String JDBC_URL = "jdbc:h2:file:./db/cards.h2;AUTO_SERVER=TRUE";
private static final String VERSION_ENTITY_NAME = "card";
// raise this if db structure was changed
private static final long CARD_DB_VERSION = 50;
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 = 74;
private static final long CARD_CONTENT_VERSION = 75;
private final TreeSet<String> landTypes = new TreeSet<>();
private Dao<CardInfo, Object> cardDao;
private Set<String> classNames;

View file

@ -9,6 +9,7 @@ public enum SpellAbilityType {
BASE_ALTERNATE("Basic SpellAbility Alternate"), // used for Overload, Flashback to know they must be handled as Alternate casting costs
FACE_DOWN_CREATURE("Face down creature"), // used for Lands with Morph to cast as Face Down creature
SPLIT("Split SpellAbility"),
SPLIT_AFTERMATH("AftermathSplit SpellAbility"),
SPLIT_FUSED("Split SpellAbility"),
SPLIT_LEFT("LeftSplit SpellAbility"),
SPLIT_RIGHT("RightSplit SpellAbility"),

View file

@ -1237,7 +1237,8 @@ public abstract class PlayerImpl implements Player, Serializable {
continue;
}
}
if (((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.SPLIT) {
if (((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.SPLIT
|| ((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.SPLIT_AFTERMATH) {
continue;
}
useable.put(ability.getId(), (SpellAbility) ability);
@ -2447,7 +2448,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (!copy.canActivate(playerId, game)) {
return false;
}
if(available != null) {
if (available != null) {
game.getContinuousEffects().costModification(copy, game);
}