mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- Small performance tweak.
- Reverted Riding the Dilu Horse from keyword to code.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
Riding the Dilu Horse
|
||||
2 G
|
||||
Sorcery
|
||||
no text
|
||||
|
||||
Mogg Jailer
|
||||
1 R
|
||||
Creature Goblin
|
||||
@@ -4406,12 +4411,6 @@ Creature Human Soldier Archer
|
||||
no text
|
||||
1/1
|
||||
|
||||
Riding the Dilu Horse
|
||||
2 G
|
||||
Sorcery
|
||||
no text
|
||||
spPumpTgt:+2/+2/Horsemanship
|
||||
|
||||
Magus of the Coffers
|
||||
4 B
|
||||
Creature Human Wizard
|
||||
|
||||
Binary file not shown.
@@ -17429,6 +17429,133 @@ public class CardFactory implements NewConstants {
|
||||
ability.setBeforePayMana(CardFactoryUtil.input_targetType(ability, "Creature"));
|
||||
}//Jandor's Saddlebags
|
||||
//****************END*******END***********************
|
||||
|
||||
//*************** START *********** START **************************
|
||||
|
||||
else if(cardName.equals("Reinforcements")) {
|
||||
/* Put up to three target creature cards from your
|
||||
* graveyard on top of your library.
|
||||
*/
|
||||
final SpellAbility spell = new Spell(card) {
|
||||
private static final long serialVersionUID = 4075591356690396548L;
|
||||
|
||||
CardList getComputerCreatures()
|
||||
{
|
||||
CardList list = new CardList(AllZone.Computer_Graveyard.getCards());
|
||||
list = list.getType("Creature");
|
||||
|
||||
//put biggest attack creats first
|
||||
if (list.size()>0)
|
||||
CardListUtil.sortAttack(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return getComputerCreatures().size() >= 3;
|
||||
}
|
||||
@Override
|
||||
public void resolve() {
|
||||
String player = card.getController();
|
||||
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
|
||||
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
|
||||
|
||||
CardList creatures = new CardList(grave.getCards());
|
||||
creatures = creatures.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
return c.isCreature();
|
||||
}
|
||||
});
|
||||
if (player.equals(Constant.Player.Human))
|
||||
{
|
||||
//now, select three creatures
|
||||
int end = -1;
|
||||
end = Math.min(creatures.size(), 3);
|
||||
for(int i = 1; i <= end; i++) {
|
||||
String Title = "Put on top of library: ";
|
||||
if(i == 2) Title = "Put second from top of library: ";
|
||||
if(i == 3) Title = "Put third from top of library: ";
|
||||
Object o = AllZone.Display.getChoiceOptional(Title, creatures.toArray());
|
||||
if(o == null) break;
|
||||
Card c_1 = (Card) o;
|
||||
creatures.remove(c_1); //remove from the display list
|
||||
grave.remove(c_1); //remove from graveyard
|
||||
lib.add(c_1, i - 1);
|
||||
}
|
||||
}
|
||||
else //Computer
|
||||
{
|
||||
CardList list = getComputerCreatures();
|
||||
int max = list.size();
|
||||
|
||||
if (max > 3)
|
||||
max = 3;
|
||||
|
||||
for (int i=0;i<max;i++)
|
||||
{
|
||||
grave.remove(list.get(i));
|
||||
lib.add(list.get(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};//spell
|
||||
card.clearSpellAbility();
|
||||
card.addSpellAbility(spell);
|
||||
}
|
||||
//*************** END ************ END **************************
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("Riding the Dilu Horse"))
|
||||
{
|
||||
SpellAbility spell = new Spell(card)
|
||||
{
|
||||
private static final long serialVersionUID = -620930445462994580L;
|
||||
|
||||
|
||||
public boolean canPlayAI()
|
||||
{
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
|
||||
|
||||
CardList list = new CardList(play.getCards());
|
||||
list = list.filter(new CardListFilter()
|
||||
{
|
||||
public boolean addCard(Card c)
|
||||
{
|
||||
return c.isCreature() && !c.getKeyword().contains("Horsemanship") && !c.getKeyword().contains("Defender");
|
||||
}
|
||||
});
|
||||
if (list.size() > 0) {
|
||||
Card c = CardFactoryUtil.AI_getBestCreature(list, card);
|
||||
setTargetCard(c);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resolve()
|
||||
{
|
||||
final Card[] target = new Card[1];
|
||||
|
||||
|
||||
target[0] = getTargetCard();
|
||||
if(AllZone.GameAction.isCardInPlay(target[0]) && CardFactoryUtil.canTarget(card, target[0]))
|
||||
{
|
||||
target[0].addTempAttackBoost(2);
|
||||
target[0].addTempDefenseBoost(2);
|
||||
target[0].addExtrinsicKeyword("Horsemanship");
|
||||
|
||||
//String s = target[0].getText();
|
||||
target[0].setText("(+2/+2 and Horsemanship from " +card+")");
|
||||
}
|
||||
}//resolve()
|
||||
};
|
||||
spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
|
||||
card.clearSpellAbility();
|
||||
card.addSpellAbility(spell);
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
|
||||
|
||||
// Cards with Cycling abilities
|
||||
|
||||
@@ -447,81 +447,83 @@ public class GameAction {
|
||||
new Gui_WinLose();
|
||||
return;
|
||||
}
|
||||
|
||||
//card state effects like Glorious Anthem
|
||||
for(String effect:AllZone.StaticEffects.getStateBasedMap().keySet()) {
|
||||
Command com = GameActionUtil.commands.get(effect);
|
||||
com.execute();
|
||||
}
|
||||
|
||||
GameActionUtil.executeCardStateEffects();
|
||||
|
||||
//System.out.println("checking state effects");
|
||||
ArrayList<Card> creature = PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Creature");
|
||||
creature.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Play, "Creature"));
|
||||
|
||||
Card c;
|
||||
Iterator<Card> it = creature.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
c = it.next();
|
||||
|
||||
if(c.isEquipped()) {
|
||||
for(int i = 0; i < c.getEquippedBy().size(); i++) {
|
||||
Card equipment = c.getEquippedBy().get(i);
|
||||
if(!AllZone.GameAction.isCardInPlay(equipment)) {
|
||||
equipment.unEquipCard(c);
|
||||
}
|
||||
}
|
||||
}//if isEquipped()
|
||||
|
||||
if(c.getNetDefense() <= c.getDamage() && !c.getKeyword().contains("Indestructible")) {
|
||||
destroy(c);
|
||||
AllZone.Combat.removeFromCombat(c); //this is untested with instants and abilities but required for First Strike combat phase
|
||||
}
|
||||
|
||||
else if(c.getNetDefense() <= 0) {
|
||||
destroy(c);
|
||||
AllZone.Combat.removeFromCombat(c);
|
||||
}
|
||||
|
||||
}//while it.hasNext()
|
||||
|
||||
|
||||
ArrayList<Card> enchantments = PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Enchantment");
|
||||
enchantments.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Play, "Enchantment"));
|
||||
|
||||
Iterator<Card> iterate = enchantments.iterator();
|
||||
while(iterate.hasNext()) {
|
||||
c = iterate.next();
|
||||
|
||||
if(c.isAura()) {
|
||||
for(int i = 0; i < c.getEnchanting().size(); i++) {
|
||||
Card perm = c.getEnchanting().get(i);
|
||||
if(!AllZone.GameAction.isCardInPlay(perm)
|
||||
|| CardFactoryUtil.hasProtectionFrom(c, perm)
|
||||
|| (c.getKeyword().contains("Enchant creature") && !perm.getType().contains("Creature"))) {
|
||||
c.unEnchantCard(perm);
|
||||
destroy(c);
|
||||
}
|
||||
}
|
||||
}//if isAura
|
||||
|
||||
}//while iterate.hasNext()
|
||||
|
||||
|
||||
//Make sure all equipment stops equipping previously equipped creatures that have left play.
|
||||
ArrayList<Card> equip = PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Equipment");
|
||||
equip.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Play, "Equipment"));
|
||||
|
||||
Iterator<Card> iter = equip.iterator();
|
||||
while(iter.hasNext()) {
|
||||
c = iter.next();
|
||||
if(c.isEquipping()) {
|
||||
Card equippedCreature = c.getEquipping().get(0);
|
||||
if(!AllZone.GameAction.isCardInPlay(equippedCreature)) c.unEquipCard(equippedCreature);
|
||||
}
|
||||
}//while iter.hasNext()
|
||||
//do this twice, sometimes creatures/permanents will survive when they shouldn't
|
||||
for (int q=0;q<2;q++)
|
||||
{
|
||||
//card state effects like Glorious Anthem
|
||||
for(String effect:AllZone.StaticEffects.getStateBasedMap().keySet()) {
|
||||
Command com = GameActionUtil.commands.get(effect);
|
||||
com.execute();
|
||||
}
|
||||
|
||||
GameActionUtil.executeCardStateEffects();
|
||||
|
||||
//System.out.println("checking state effects");
|
||||
ArrayList<Card> creature = PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Creature");
|
||||
creature.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Play, "Creature"));
|
||||
|
||||
Card c;
|
||||
Iterator<Card> it = creature.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
c = it.next();
|
||||
|
||||
if(c.isEquipped()) {
|
||||
for(int i = 0; i < c.getEquippedBy().size(); i++) {
|
||||
Card equipment = c.getEquippedBy().get(i);
|
||||
if(!AllZone.GameAction.isCardInPlay(equipment)) {
|
||||
equipment.unEquipCard(c);
|
||||
}
|
||||
}
|
||||
}//if isEquipped()
|
||||
|
||||
if(c.getNetDefense() <= c.getDamage() && !c.getKeyword().contains("Indestructible")) {
|
||||
destroy(c);
|
||||
AllZone.Combat.removeFromCombat(c); //this is untested with instants and abilities but required for First Strike combat phase
|
||||
}
|
||||
|
||||
else if(c.getNetDefense() <= 0) {
|
||||
destroy(c);
|
||||
AllZone.Combat.removeFromCombat(c);
|
||||
}
|
||||
|
||||
}//while it.hasNext()
|
||||
|
||||
|
||||
ArrayList<Card> enchantments = PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Enchantment");
|
||||
enchantments.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Play, "Enchantment"));
|
||||
|
||||
Iterator<Card> iterate = enchantments.iterator();
|
||||
while(iterate.hasNext()) {
|
||||
c = iterate.next();
|
||||
|
||||
if(c.isAura()) {
|
||||
for(int i = 0; i < c.getEnchanting().size(); i++) {
|
||||
Card perm = c.getEnchanting().get(i);
|
||||
if(!AllZone.GameAction.isCardInPlay(perm)
|
||||
|| CardFactoryUtil.hasProtectionFrom(c, perm)
|
||||
|| (c.getKeyword().contains("Enchant creature") && !perm.getType().contains("Creature"))) {
|
||||
c.unEnchantCard(perm);
|
||||
destroy(c);
|
||||
}
|
||||
}
|
||||
}//if isAura
|
||||
|
||||
}//while iterate.hasNext()
|
||||
|
||||
//Make sure all equipment stops equipping previously equipped creatures that have left play.
|
||||
ArrayList<Card> equip = PlayerZoneUtil.getCardType(AllZone.Computer_Play, "Equipment");
|
||||
equip.addAll(PlayerZoneUtil.getCardType(AllZone.Human_Play, "Equipment"));
|
||||
|
||||
Iterator<Card> iter = equip.iterator();
|
||||
while(iter.hasNext()) {
|
||||
c = iter.next();
|
||||
if(c.isEquipping()) {
|
||||
Card equippedCreature = c.getEquipping().get(0);
|
||||
if(!AllZone.GameAction.isCardInPlay(equippedCreature)) c.unEquipCard(equippedCreature);
|
||||
}
|
||||
}//while iter.hasNext()
|
||||
}//for q=0;q<2
|
||||
|
||||
destroyLegendaryCreatures();
|
||||
destroyPlaneswalkers();
|
||||
@@ -896,9 +898,28 @@ public class GameAction {
|
||||
c[i].setDamage(0);
|
||||
}
|
||||
|
||||
//for Quest fantasy mode
|
||||
public void newGame(Deck humanDeck, Deck computerDeck, CardList human, CardList computer, int humanLife, int computerLife)
|
||||
{
|
||||
this.newGame(humanDeck, computerDeck);
|
||||
|
||||
AllZone.Computer_Life.setLife(computerLife);
|
||||
AllZone.Human_Life.setLife(humanLife);
|
||||
|
||||
for (Card c : human)
|
||||
{
|
||||
AllZone.Human_Play.add(c);
|
||||
}
|
||||
|
||||
for (Card c: computer)
|
||||
{
|
||||
AllZone.Computer_Play.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
public void newGame(Deck humanDeck, Deck computerDeck) {
|
||||
// AllZone.Computer = new ComputerAI_Input(new ComputerAI_General());
|
||||
//System.gc(); //garbage collection... does it make a difference though?
|
||||
|
||||
lastPlayerToDraw = Constant.Player.Human;
|
||||
|
||||
AllZone.GameInfo.setComputerCanPlayNumberOfLands(1);
|
||||
@@ -936,9 +957,6 @@ public class GameAction {
|
||||
|
||||
AllZone.StaticEffects.reset();
|
||||
|
||||
//clear Image caches, so the problem doesn't get slower and slower
|
||||
//cached images are cleared in Gui_WinLose.quitButton_actionPerformed()
|
||||
|
||||
|
||||
{//re-number cards just so their unique numbers are low, just for user friendliness
|
||||
CardFactory c = AllZone.CardFactory;
|
||||
@@ -956,8 +974,6 @@ public class GameAction {
|
||||
}
|
||||
AllZone.Human_Library.add(card);
|
||||
|
||||
//get card picture so that it is in the image cache
|
||||
// ImageCache.getImage(card);
|
||||
}
|
||||
|
||||
for(int i = 0; i < computerDeck.countMain(); i++) {
|
||||
@@ -992,14 +1008,6 @@ public class GameAction {
|
||||
this.drawCard(Constant.Player.Computer);
|
||||
this.drawCard(Constant.Player.Human);
|
||||
}
|
||||
/*
|
||||
Card mp = new Card();
|
||||
mp.setName("Mana Pool");
|
||||
//mp.addType("Land");
|
||||
mp.addIntrinsicKeyword("Indestructible");
|
||||
mp.addIntrinsicKeyword("Shroud");
|
||||
AllZone.Human_Play.add(mp);
|
||||
*/
|
||||
|
||||
ManaPool mp = AllZone.ManaPool;
|
||||
AllZone.Human_Play.add(mp.smp);
|
||||
|
||||
@@ -46,9 +46,6 @@ public class Input_StackNotEmpty extends Input implements java.io.Serializable {
|
||||
AllZone.GameAction.scry(sa.getSourceCard().getController(), Integer.parseInt(kk[1]));
|
||||
}
|
||||
}
|
||||
|
||||
//check them twice, sometimes creatures will survive when they shouldn't
|
||||
AllZone.GameAction.checkStateEffects();
|
||||
AllZone.GameAction.checkStateEffects();
|
||||
|
||||
//special consideration for "Beacon of Unrest" and other "Beacon" cards
|
||||
|
||||
Reference in New Issue
Block a user