- Gaining control of a creature equipped with Umezawa's Jitte and attacking with it shouldn't crash the game anymore. However, if you use this on the AI, you can use its abilities (gain life ability will give the AI life though).

- Added some kind of caching algorithm, hopefully it will actually make a difference.
- Rebel / Merc searches shouldn't fetch non-permanents (with Changeling) anymore.
This commit is contained in:
jendave
2011-08-06 03:05:49 +00:00
parent d21b79bf62
commit 9b23d90ec2
9 changed files with 99 additions and 37 deletions

View File

@@ -219,7 +219,7 @@
<object class="java.awt.Rectangle">
<int>254</int>
<int>0</int>
<int>902</int>
<int>926</int>
<int>827</int>
</object>
</void>
@@ -230,7 +230,7 @@
<object class="java.awt.Rectangle">
<int>254</int>
<int>0</int>
<int>902</int>
<int>926</int>
<int>147</int>
</object>
</void>
@@ -251,7 +251,7 @@
<object class="java.awt.Rectangle">
<int>254</int>
<int>147</int>
<int>902</int>
<int>926</int>
<int>10</int>
</object>
</void>
@@ -266,7 +266,7 @@
<object class="java.awt.Rectangle">
<int>254</int>
<int>157</int>
<int>902</int>
<int>926</int>
<int>169</int>
</object>
</void>
@@ -287,7 +287,7 @@
<object class="java.awt.Rectangle">
<int>254</int>
<int>326</int>
<int>902</int>
<int>926</int>
<int>10</int>
</object>
</void>
@@ -302,8 +302,8 @@
<object class="java.awt.Rectangle">
<int>254</int>
<int>336</int>
<int>902</int>
<int>154</int>
<int>926</int>
<int>187</int>
</object>
</void>
<void property="name">
@@ -322,8 +322,8 @@
<void property="bounds">
<object class="java.awt.Rectangle">
<int>254</int>
<int>490</int>
<int>902</int>
<int>523</int>
<int>926</int>
<int>10</int>
</object>
</void>
@@ -337,9 +337,9 @@
<void property="bounds">
<object class="java.awt.Rectangle">
<int>254</int>
<int>500</int>
<int>902</int>
<int>178</int>
<int>533</int>
<int>926</int>
<int>145</int>
</object>
</void>
<void property="name">
@@ -359,7 +359,7 @@
<object class="java.awt.Rectangle">
<int>254</int>
<int>678</int>
<int>902</int>
<int>926</int>
<int>10</int>
</object>
</void>
@@ -374,7 +374,7 @@
<object class="java.awt.Rectangle">
<int>254</int>
<int>688</int>
<int>902</int>
<int>926</int>
<int>139</int>
</object>
</void>
@@ -408,7 +408,7 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds">
<object class="java.awt.Rectangle">
<int>1156</int>
<int>1180</int>
<int>0</int>
<int>10</int>
<int>827</int>
@@ -423,9 +423,9 @@
<object id="MultiSplitLayout$Split3" class="org.jdesktop.swingx.MultiSplitLayout$Split">
<void property="bounds">
<object class="java.awt.Rectangle">
<int>1166</int>
<int>1190</int>
<int>0</int>
<int>274</int>
<int>250</int>
<int>827</int>
</object>
</void>
@@ -434,9 +434,9 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds">
<object class="java.awt.Rectangle">
<int>1166</int>
<int>1190</int>
<int>0</int>
<int>274</int>
<int>250</int>
<int>409</int>
</object>
</void>
@@ -455,9 +455,9 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds">
<object class="java.awt.Rectangle">
<int>1166</int>
<int>1190</int>
<int>409</int>
<int>274</int>
<int>250</int>
<int>10</int>
</object>
</void>
@@ -470,9 +470,9 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds">
<object class="java.awt.Rectangle">
<int>1166</int>
<int>1190</int>
<int>419</int>
<int>274</int>
<int>250</int>
<int>408</int>
</object>
</void>

View File

@@ -978,7 +978,7 @@ public class CardFactoryUtil
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return (c.getType().contains("Mercenary") || c.getKeyword().contains("Changeling")) && c.isPermanent() ;
return ( (c.getType().contains("Mercenary") || c.getKeyword().contains("Changeling")) ) && c.isPermanent() ;
}
});
@@ -1082,7 +1082,7 @@ public class CardFactoryUtil
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return (c.getType().contains("Rebel") || c.getKeyword().contains("Changeling")) && c.isPermanent() ;
return ( (c.getType().contains("Rebel") || c.getKeyword().contains("Changeling"))) && c.isPermanent() ;
}
});

View File

@@ -3749,10 +3749,8 @@ public class CardFactory_Creatures {
//because this card has Flash
public boolean canPlay()
{
if (!AllZone.GameAction.isCardInPlay(card))
return true;
else
return false;
return AllZone.GameAction.isCardInZone(card, AllZone.Human_Hand) ||
AllZone.GameAction.isCardInZone(card, AllZone.Computer_Hand);
}
});
}//*************** END ************ END **************************

View File

@@ -1885,7 +1885,6 @@ class CardFactory_Equipment {
boost.setDescription("Remove a charge counter from Umezawa's Jitte: Equipped creature gets +2/+2 until end of turn.");
boost.setStackDescription(cardName + " - Equipped creature gets +2/+2 untin end of turn.");
equip.setBeforePayMana(runtime);
equip.setDescription("Equip: 2");
card.addSpellAbility(equip);
@@ -1893,7 +1892,6 @@ class CardFactory_Equipment {
card.addSpellAbility(negBoost);
card.addSpellAbility(gainLife);
} //*************** END ************ END **************************

View File

@@ -3119,7 +3119,6 @@ class CardFactory_Lands {
}//transmute
return card;
}

View File

@@ -102,6 +102,17 @@ public class CardList implements Iterable<Card>
return c;
}
public CardList getImageName(String name)
{
CardList c = new CardList();
for(int i = 0; i < size(); i++)
if(getCard(i).getImageName().equals(name))
c.add(getCard(i));
return c;
}
//cardType is like "Land" or "Goblin", returns a new CardList that is a subset of current CardList
public CardList getType(String cardType)
{

View File

@@ -584,7 +584,17 @@ public class CombatUtil
PlayerZone play = AllZone.getZone(c);
CardList clist = new CardList(play.getCards());
clist = clist.getName("Umezawa's Jitte");
Card jitte = clist.get(0);
Card jitte;
if(clist.size() > 0)
jitte = clist.get(0);
else //jitte belongs to opponent
{
PlayerZone oppPlay = AllZone.getZone(Constant.Zone.Play, AllZone.GameAction.getOpponent(c.getController()));
CardList crdList = new CardList(oppPlay.getCards());
crdList.getName("Umezawa's Jitte");
jitte = crdList.get(0);
}
jitte.addCounter(Counters.CHARGE, 2);
}
}

View File

@@ -3,6 +3,7 @@ import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import javax.imageio.ImageIO;
@@ -84,6 +85,20 @@ public class ImageCache implements NewConstants {
/**
* Put to cache.
*/
if (cache.size() >= 35) {
int count = 10;
ArrayList<String> imgNames = new ArrayList<String>(count);
for (String imgName : cache.keySet()) {
imgNames.add(imgName);
count--;
if (count == 0)
break;
}
for (String imgName : imgNames)
cache.remove(imgName);
}
cache.put(name, resized);
return resized;

View File

@@ -1,4 +1,5 @@
package forge;
import java.util.*;
//@SuppressWarnings("unused") // java.util.*
@@ -182,6 +183,36 @@ package forge;
}
else if(phase.equals(Constant.Phase.End_Of_Turn))
{
System.out.println("Cache size: " + ImageCache.cache.size());
CardList visibleCards = new CardList();
PlayerZone hPlay = AllZone.Human_Play;
PlayerZone hand = AllZone.Human_Hand;
PlayerZone cPlay = AllZone.Computer_Play;
visibleCards.addAll(hPlay.getCards());
visibleCards.addAll(hand.getCards());
visibleCards.addAll(cPlay.getCards());
ArrayList<String> list = new ArrayList<String>();
Iterator<String> iter = ImageCache.cache.keySet().iterator();
while(iter.hasNext()) {
String cardName = iter.next();
if ( !(cardName.startsWith("Swamp") || cardName.startsWith("Mountain") || cardName.startsWith("Island")
|| cardName.startsWith("Plains") || cardName.startsWith("Forest")) &&
visibleCards.getImageName(cardName).size() == 0 ) {
list.add(cardName);
}
}
for (String s : list)
{
ImageCache.cache.remove(s);
System.out.println("Removing " + s + " from cache.");
}
if(AllZone.Display.stopEOT())
return new Input_EOT();
else