- Made some more code cleanups and (small) performance improvements.

- Fixed Sarkhan Vol and Ajani Goldmane token controllership issues. Also fixed Ajani Goldmane?\127 lifegain after a different player takes control of it.
- Memnarch's first ability will put the Artifact type at the beginning of the type text (so "Artifact Planeswalker - Ajani" instead of "Planeswalker - Ajani Artifact").
- Planeswalkers with the same "subtype" should get destroyed correctly now if there are two or more in play, even if one of them got "Memnarched" into an artifact.
This commit is contained in:
jendave
2011-08-06 03:13:21 +00:00
parent 0c3ad6f1f2
commit 12598c7088
23 changed files with 57 additions and 50 deletions

View File

@@ -1,6 +1,6 @@
program/mail=mtgerror@yahoo.com program/mail=mtgerror@yahoo.com
program/forum=http://www.slightlymagic.net/forum/viewforum.php?f=26 program/forum=http://www.slightlymagic.net/forum/viewforum.php?f=26
program/version=Forge -- official beta: 10/01/01, SVN revision: 272 program/version=Forge -- official beta: 10/01/01, SVN revision: 273
tokens--file=AllTokens.txt tokens--file=AllTokens.txt

View File

@@ -29,8 +29,7 @@ public class AnchorLayout implements LayoutManager2 {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private HashMap constraintMap = new HashMap(); private HashMap constraintMap = new HashMap();
private boolean sizesCalculated = false; private boolean sizesCalculated = false;
@SuppressWarnings("unused") //private Container container;
private Container container;
public AnchorLayout() { public AnchorLayout() {
super(); super();

View File

@@ -13,7 +13,7 @@ class BoosterDraft_1 implements BoosterDraft
{ {
private final BoosterDraftAI draftAI = new BoosterDraftAI(); private final BoosterDraftAI draftAI = new BoosterDraftAI();
private final int nPlayers = 8; private final int nPlayers = 8;
private final int boosterPackSize = 15; private static final int boosterPackSize = 15;
private final int stopCount = boosterPackSize * 3;//should total of 45 private final int stopCount = boosterPackSize * 3;//should total of 45
private int currentCount = 0; private int currentCount = 0;

View File

@@ -6,8 +6,8 @@ public class BoosterDraftAI
//once a deck has this number of creatures the computer randomly //once a deck has this number of creatures the computer randomly
//picks a card, so the final computer deck has 12-20 creatures //picks a card, so the final computer deck has 12-20 creatures
//minimum of creatures per deck //minimum of creatures per deck
private final int nCreatures = 16; private static final int nCreatures = 16;
private final int nDecks = 7; private static final int nDecks = 7;
//holds all the cards for each of the computer's decks //holds all the cards for each of the computer's decks
private CardList[] deck = new CardList[nDecks]; private CardList[] deck = new CardList[nDecks];

View File

@@ -294,16 +294,17 @@ public class Card extends MyObservable
return sb.toString(); return sb.toString();
} }
String s = ""; StringBuilder sb = new StringBuilder();
ArrayList<String> keyword = getKeyword(); ArrayList<String> keyword = getKeyword();
for(int i = 0; i < keyword.size(); i++) for(int i = 0; i < keyword.size(); i++)
{ {
if(i != 0) if(i != 0)
s += ", "; sb.append(", ");
s += keyword.get(i).toString(); sb.append(keyword.get(i).toString());
} }
sb.append("\r\n");
s += "\r\n" +text +"\r\n"; sb.append(text);
sb.append("\r\n");
SpellAbility[] sa = getSpellAbility(); SpellAbility[] sa = getSpellAbility();
for(int i = 0; i < sa.length; i++) for(int i = 0; i < sa.length; i++)
@@ -312,10 +313,13 @@ public class Card extends MyObservable
//skip the first SpellAbility for creatures, since it says "Summon this creature" //skip the first SpellAbility for creatures, since it says "Summon this creature"
//looks bad on the Gui card detail //looks bad on the Gui card detail
if(isPermanent() && (isLand() || i != 0) && !(manaAbility.contains(sa[i]) && ((Ability_Mana) sa[i]).isBasic()))//prevent mana ability duplication if(isPermanent() && (isLand() || i != 0) && !(manaAbility.contains(sa[i]) && ((Ability_Mana) sa[i]).isBasic()))//prevent mana ability duplication
s += sa[i].toString() +"\r\n"; {
sb.append(sa[i].toString());
sb.append("\r\n");
}
} }
return s.trim(); return sb.toString().trim();
}//getText() }//getText()
/* private ArrayList<Ability_Mana> addLandAbilities () /* private ArrayList<Ability_Mana> addLandAbilities ()

View File

@@ -886,7 +886,7 @@ public class CardFactory implements NewConstants {
final String DrawBack[] = {"none"}; final String DrawBack[] = {"none"};
final String spDesc[] = {"none"}; final String spDesc[] = {"none"};
final String stDesc[] = {"none"}; final String stDesc[] = {"none"};
String d = new String("none"); String d = "none";
if ((AttackX[0].equals("none") && !(NumAttack[0] == -1138)) && (DefenseX[0].equals("none") && !(NumDefense[0] == -1138)) && Keyword[0].equals("none")) if ((AttackX[0].equals("none") && !(NumAttack[0] == -1138)) && (DefenseX[0].equals("none") && !(NumDefense[0] == -1138)) && Keyword[0].equals("none"))
{ {
@@ -1772,7 +1772,7 @@ public class CardFactory implements NewConstants {
final String manaCost = tmpCost; final String manaCost = tmpCost;
String tempDesc = new String(); String tempDesc = "";
tempDesc = cardName + " deals " + dmg[0] + " damage to target creature or player."; tempDesc = cardName + " deals " + dmg[0] + " damage to target creature or player.";
final String Desc = tempDesc; final String Desc = tempDesc;
@@ -13027,6 +13027,8 @@ public class CardFactory implements NewConstants {
lands.addAll(play.getCards()); lands.addAll(play.getCards());
lands = lands.getType("Land"); lands = lands.getType("Land");
c = lands.get(0);
setTargetCard(c); setTargetCard(c);
} }

View File

@@ -9628,7 +9628,13 @@ public class CardFactory_Creatures {
{ {
if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) ) if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
{ {
getTargetCard().addType("Artifact"); Card crd = getTargetCard();
ArrayList<String> types = crd.getType();
crd.setType(new ArrayList<String>()); //clear
getTargetCard().addType("Artifact"); //make sure artifact is at the beginning
for (String type : types)
crd.addType(type);
} }
}//resolve() }//resolve()
public boolean canPlayAI() public boolean canPlayAI()

View File

@@ -315,9 +315,6 @@ class CardFactory_Planeswalkers {
public boolean canPlay() public boolean canPlay()
{ {
@SuppressWarnings("unused") // library
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card2.getController());
return 0 < card2.getCounters(Counters.LOYALTY) && return 0 < card2.getCounters(Counters.LOYALTY) &&
AllZone.getZone(card2).is(Constant.Zone.Play) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
turn[0] != AllZone.Phase.getTurn() && turn[0] != AllZone.Phase.getTurn() &&
@@ -941,8 +938,6 @@ class CardFactory_Planeswalkers {
public boolean canPlay() public boolean canPlay()
{ {
@SuppressWarnings("unused") // library
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card2.getController());
return 0 < card2.getCounters(Counters.LOYALTY) && return 0 < card2.getCounters(Counters.LOYALTY) &&
AllZone.getZone(card2).is(Constant.Zone.Play) && AllZone.getZone(card2).is(Constant.Zone.Play) &&
@@ -979,13 +974,13 @@ class CardFactory_Planeswalkers {
card2.subtractCounter(Counters.LOYALTY, 6); card2.subtractCounter(Counters.LOYALTY, 6);
turn[0] = AllZone.Phase.getTurn(); turn[0] = AllZone.Phase.getTurn();
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); PlayerZone play = AllZone.getZone(Constant.Zone.Play, card2.getController());
//Create token //Create token
Card c = new Card(); Card c = new Card();
c.setOwner(card.getController()); c.setOwner(card2.getController());
c.setController(card.getController()); c.setController(card2.getController());
c.setImageName("W N N Avatar"); c.setImageName("W N N Avatar");
c.setName("Avatar"); c.setName("Avatar");
@@ -1042,7 +1037,7 @@ class CardFactory_Planeswalkers {
turn[0] = AllZone.Phase.getTurn(); turn[0] = AllZone.Phase.getTurn();
AllZone.GameAction.getPlayerLife(card.getController()).addLife(2); AllZone.GameAction.getPlayerLife(card2.getController()).addLife(2);
System.out.println("current phase: " +AllZone.Phase.getPhase()); System.out.println("current phase: " +AllZone.Phase.getPhase());
} }
public boolean canPlayAI() public boolean canPlayAI()
@@ -2783,8 +2778,8 @@ class CardFactory_Planeswalkers {
{ {
Card c = new Card(); Card c = new Card();
c.setOwner(card.getController()); c.setOwner(card2.getController());
c.setController(card.getController()); c.setController(card2.getController());
c.setImageName("R 4 4 Dragon"); c.setImageName("R 4 4 Dragon");
c.setName("Dragon"); c.setName("Dragon");

View File

@@ -169,7 +169,7 @@ public class ComputerAI_General implements Computer {
Collection<Card> play = playMain1Cards; Collection<Card> play = playMain1Cards;
if(c.isLand()) return false; if(c.isLand()) return false;
if(play.contains(c.getName()) || (c.isCreature() && c.getKeyword().contains("Haste"))) return true; if(play.contains(c.getName()) || (c.isCreature() && c.getKeyword().contains("Haste"))) return true;
return false; return false;
} }
}); });
CardList all = new CardList(); CardList all = new CardList();

View File

@@ -14,8 +14,8 @@ public class FileFinder {
private long totalLength = 0; private long totalLength = 0;
private int filesNumber = 0; private int filesNumber = 0;
private long directoriesNumber = 0; private long directoriesNumber = 0;
private final int FILES = 0; private static final int FILES = 0;
private final int DIRECTORIES = 1; private static final int DIRECTORIES = 1;
private ArrayList<String> fileNames; private ArrayList<String> fileNames;
private ArrayList<String> fName; private ArrayList<String> fName;

View File

@@ -459,7 +459,8 @@ private Card getCurrentCard(int ID)
if(c.getCounters(Counters.LOYALTY) <= 0) if(c.getCounters(Counters.LOYALTY) <= 0)
AllZone.GameAction.moveToGraveyard(c); AllZone.GameAction.moveToGraveyard(c);
CardList cl = getPlaneswalkerSubtype(list, c); String subtype = c.getType().get(c.getType().size()-1);
CardList cl = getPlaneswalkerSubtype(list, subtype, c);
if (cl.size() > 1) if (cl.size() > 1)
{ {
@@ -505,15 +506,15 @@ private Card getCurrentCard(int ID)
return a; return a;
} }
public CardList getPlaneswalkerSubtype(CardList search, Card planeswalker) public CardList getPlaneswalkerSubtype(CardList search, String subtype, Card planeswalker)
{ {
final String type = planeswalker.getType().toString();
CardList list = search; CardList list = search;
final String type = subtype;
list = list.filter(new CardListFilter() list = list.filter(new CardListFilter()
{ {
public boolean addCard(Card c) public boolean addCard(Card c)
{ {
return c.getType().toString().equals(type); return c.getType().toString().contains(type);
} }
}); });

View File

@@ -45,7 +45,7 @@ public class Gui_BoosterDraft extends JFrame implements CardDetail, NewConstants
private BoosterDraft boosterDraft; private BoosterDraft boosterDraft;
private final boolean limitedDeckEditor = true; private static final boolean limitedDeckEditor = true;
private TableModel allCardModel; private TableModel allCardModel;
private TableModel deckModel; private TableModel deckModel;

View File

@@ -58,7 +58,7 @@ public class Gui_DeckEditor_Menu extends JMenuBar implements NewConstants {
private static File previousDirectory = null; private static File previousDirectory = null;
private final boolean debugPrint = false; private static final boolean debugPrint = false;
// private final DeckIO deckIO = new OldDeckIO(ForgeProps.getFile(DECKS)); // private final DeckIO deckIO = new OldDeckIO(ForgeProps.getFile(DECKS));
// private final DeckIO boosterDeckIO = new OldDeckIO(ForgeProps.getFile(BOOSTER_DECKS)); // private final DeckIO boosterDeckIO = new OldDeckIO(ForgeProps.getFile(BOOSTER_DECKS));

View File

@@ -33,7 +33,7 @@ public class Gui_Quest_DeckEditor_Menu extends JMenuBar {
//if true, the Quest Deck editor will let you edit the computer's decks //if true, the Quest Deck editor will let you edit the computer's decks
private final boolean canEditComputerDecks; private final boolean canEditComputerDecks;
private final String deckEditorName = "Deck Editor"; private static final String deckEditorName = "Deck Editor";
//used for import and export, try to made the gui user friendly //used for import and export, try to made the gui user friendly
private static File previousDirectory = null; private static File previousDirectory = null;

View File

@@ -39,10 +39,10 @@ public class ImagePreviewPanel extends JPanel
* handle so we don't try to draw something silly. * handle so we don't try to draw something silly.
*/ */
if ((name != null) && if ((name != null) &&
name.toLowerCase().endsWith(".jpg") || (name.toLowerCase().endsWith(".jpg") ||
name.toLowerCase().endsWith(".jpeg") || name.toLowerCase().endsWith(".jpeg") ||
name.toLowerCase().endsWith(".gif") || name.toLowerCase().endsWith(".gif") ||
name.toLowerCase().endsWith(".png")) { name.toLowerCase().endsWith(".png")) ) {
icon = new ImageIcon(name); icon = new ImageIcon(name);
image = icon.getImage(); image = icon.getImage();
scaleImage(); scaleImage();

View File

@@ -15,7 +15,7 @@ import forge.properties.NewConstants;
//balance the number of colors and creature/spells for //balance the number of colors and creature/spells for
//new cards that are won in quest mode //new cards that are won in quest mode
public class QuestData_BoosterPack implements NewConstants { public class QuestData_BoosterPack implements NewConstants {
final private String comment = "//"; final private static String comment = "//";
private ArrayList<String> commonCreature = new ArrayList<String>(); private ArrayList<String> commonCreature = new ArrayList<String>();
private ArrayList<String> commonSpell = new ArrayList<String>(); private ArrayList<String> commonSpell = new ArrayList<String>();

View File

@@ -17,7 +17,7 @@ public class ReadBoosterPack implements NewConstants {
// final private String uncommonFilename = Constant.IO.baseDir +"data/uncommon.txt"; // final private String uncommonFilename = Constant.IO.baseDir +"data/uncommon.txt";
// final private String rareFilename = Constant.IO.baseDir +"data/rare.txt"; // final private String rareFilename = Constant.IO.baseDir +"data/rare.txt";
final private String comment = "//"; final private static String comment = "//";
private CardList commonCreatureList; private CardList commonCreatureList;
private CardList commonNonCreatureList; private CardList commonNonCreatureList;

View File

@@ -34,7 +34,7 @@ import java.io.RandomAccessFile;
*/ */
public class RiffFile public class RiffFile
{ {
class RiffChunkHeader static class RiffChunkHeader
{ {
public int ckID = 0; // Four-character chunk ID public int ckID = 0; // Four-character chunk ID
public int ckSize = 0; // Length of data in chunk public int ckSize = 0; // Length of data in chunk

View File

@@ -32,7 +32,7 @@ public class WaveFile extends RiffFile
{ {
public static final int MAX_WAVE_CHANNELS = 2; public static final int MAX_WAVE_CHANNELS = 2;
class WaveFormat_ChunkData static class WaveFormat_ChunkData
{ {
public short wFormatTag = 0; // Format category (PCM=1) public short wFormatTag = 0; // Format category (PCM=1)
public short nChannels = 0; // Number of channels (mono=1, stereo=2) public short nChannels = 0; // Number of channels (mono=1, stereo=2)
@@ -88,7 +88,7 @@ public class WaveFile extends RiffFile
} }
} }
public class WaveFileSample public static class WaveFileSample
{ {
public short[] chan; public short[] chan;

View File

@@ -30,7 +30,7 @@ package javazoom.jl.converter;
import java.io.PrintWriter; import java.io.PrintWriter;
import javazoom.jl.decoder.Crc16; //import javazoom.jl.decoder.Crc16;
import javazoom.jl.decoder.JavaLayerException; import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.decoder.OutputChannels; import javazoom.jl.decoder.OutputChannels;

View File

@@ -41,7 +41,7 @@ package javazoom.jl.decoder;
*/ */
final class LayerIIIDecoder implements FrameDecoder final class LayerIIIDecoder implements FrameDecoder
{ {
final double d43 = (4.0/3.0); final static double d43 = (4.0/3.0);
public int[] scalefac_buffer; public int[] scalefac_buffer;
@@ -2407,7 +2407,7 @@ final class LayerIIIDecoder implements FrameDecoder
/* END OF INV_MDCT */ /* END OF INV_MDCT */
/***************************************************************/ /***************************************************************/
class Sftable static class Sftable
{ {
public int[] l; public int[] l;
public int[] s; public int[] s;

View File

@@ -43,7 +43,7 @@ public class AdvancedPlayer
/** The AudioDevice the audio samples are written to. */ /** The AudioDevice the audio samples are written to. */
private AudioDevice audio; private AudioDevice audio;
/** Has the player been closed? */ /** Has the player been closed? */
private boolean closed = false; //private boolean closed = false;
/** Has the player played back all frames from the stream? */ /** Has the player played back all frames from the stream? */
//private boolean complete = false; //private boolean complete = false;
@@ -124,7 +124,7 @@ public class AdvancedPlayer
AudioDevice out = audio; AudioDevice out = audio;
if (out != null) if (out != null)
{ {
closed = true; //closed = true;
audio = null; audio = null;
// this may fail, so ensure object state is set up before // this may fail, so ensure object state is set up before
// calling this method. // calling this method.

View File

@@ -100,7 +100,7 @@ public class jlap
return player; return player;
} }
public class InfoListener extends PlaybackListener public static class InfoListener extends PlaybackListener
{ {
public void playbackStarted(PlaybackEvent evt) public void playbackStarted(PlaybackEvent evt)
{ {