- Add?\127ed Spell Snare, Jace Beleren, Timber Protector, Viridian Zealot, ...

- Added Vasiliy's deck download option.
- Enchant creature Auras will get destroyed if the permanent which they enchanted ceases to be a creature (eg. Mishra's Factory).
- Fixed Mishra's Factory ability text.
- Removed Legendary type of all planeswalkers, and added in code to destroy planeswalkers if there are multiple of the same subtype in play.
This commit is contained in:
jendave
2011-08-06 02:50:32 +00:00
parent 9ba9b33126
commit 7a697458e2
12 changed files with 934 additions and 14 deletions

1
.gitattributes vendored
View File

@@ -136,6 +136,7 @@ src/forge/Deck.java svneol=native#text/plain
src/forge/DeckIO.java svneol=native#text/plain src/forge/DeckIO.java svneol=native#text/plain
src/forge/DefaultPlayerZone.java svneol=native#text/plain src/forge/DefaultPlayerZone.java svneol=native#text/plain
src/forge/Display.java svneol=native#text/plain src/forge/Display.java svneol=native#text/plain
src/forge/DownloadDeck.java -text svneol=native#text/plain
src/forge/EndOfTurn.java svneol=native#text/plain src/forge/EndOfTurn.java svneol=native#text/plain
src/forge/ExternalPanel.java svneol=native#text/plain src/forge/ExternalPanel.java svneol=native#text/plain
src/forge/FileUtil.java -text svneol=native#text/plain src/forge/FileUtil.java -text svneol=native#text/plain

View File

@@ -1,3 +1,43 @@
Jace Beleren
1 U U
Planeswalker - Jace
no text
Spell Snare
U
Instant
Counter target spell with converted mana cost 2.
Timber Protector
4 G
Creature Treefolk Warrior
Other Treefolk creatures you control get +1/+1. Other Treefolk and Forests you control are indestructible.
4/6
Viridian Zealot
G G
Creature Elf Warrior
no text
2/1
Ronom Unicorn
1 W
Creature Unicorn
no text
2/2
Kami of Ancient Law
1 W
Creature Spirit
no text
2/2
Capashen Unicorn
1 W
Creature Unicorn
no text
1/2
Qasali Pridemage Qasali Pridemage
G W G W
Creature Cat Wizard Creature Cat Wizard
@@ -2929,7 +2969,7 @@ Cycling:2
Nissa Revane Nissa Revane
2 G G 2 G G
Legendary Planeswalker - Nissa Planeswalker - Nissa
no text no text
Nissa's Chosen Nissa's Chosen
@@ -7713,7 +7753,7 @@ Whenever you draw a card, you may put a hoofprint counter on Hoofprints of the S
Nicol Bolas, Planeswalker Nicol Bolas, Planeswalker
4 U B B R 4 U B B R
Legendary Planeswalker - Bolas Planeswalker - Bolas
no text no text
Aven Squire Aven Squire
@@ -8769,7 +8809,7 @@ Exalted
Elspeth, Knight-Errant Elspeth, Knight-Errant
2 W W 2 W W
Legendary Planeswalker - Elspeth Planeswalker - Elspeth
no text no text
Ratcatcher Ratcatcher
@@ -11694,7 +11734,7 @@ Flying
Mishra's Factory Mishra's Factory
no cost no cost
Land Land
1: Mishra's Factory becomes a 2/2 Assembly-Worker artifact creature until end of turn. It's still a land. no text
tap: add 1 tap: add 1
Cranial Extraction Cranial Extraction
@@ -11765,22 +11805,22 @@ Choose two - Incendiary Command deals 4 damage to target player; or Incendiary C
Ajani Goldmane Ajani Goldmane
2 W W 2 W W
Legendary Planeswalker - Ajani Planeswalker - Ajani
no text no text
Chandra Nalaar Chandra Nalaar
3 R R 3 R R
Legendary Planeswalker - Chandra Planeswalker - Chandra
no text no text
Garruk Wildspeaker Garruk Wildspeaker
2 G G 2 G G
Legendary Planeswalker - Garruk Planeswalker - Garruk
no text no text
Liliana Vess Liliana Vess
3 B B 3 B B
Legendary Planeswalker - Liliana Planeswalker - Liliana
no text no text
Dark Banishing Dark Banishing

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=MTG Forge -- official beta: 09/11/02, SVN revision: 96 program/version=MTG Forge -- official beta: 09/11/02, SVN revision: 97
tokens--file=AllTokens.txt tokens--file=AllTokens.txt

View File

@@ -17434,6 +17434,34 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase();
}//*************** END ************ END ************************** }//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Spell Snare"))
{
SpellAbility spell = new Spell(card)
{
private static final long serialVersionUID = -3254886985412814994L;
public void resolve()
{
SpellAbility sa = AllZone.Stack.pop();
AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
}
public boolean canPlay()
{
if(AllZone.Stack.size() == 0)
return false;
//see if spell is on stack and that opponent played it
String opponent = AllZone.GameAction.getOpponent(card.getController());
SpellAbility sa = AllZone.Stack.peek();
return sa.isSpell() && opponent.equals(sa.getSourceCard().getController())
&& CardFactoryUtil.isCounterable(sa.getSourceCard()) && CardUtil.getConvertedManaCost(sa.getSourceCard().getManaCost()) == 2;
}
};
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
// Cards with Cycling abilities // Cards with Cycling abilities

View File

@@ -16528,11 +16528,25 @@ public class CardFactory_Creatures {
final Ability ability = new Ability(card, "1") final Ability ability = new Ability(card, "1")
{ {
public void resolve() { public void resolve() {
if (AllZone.GameAction.isCardInPlay(card)) if (AllZone.GameAction.isCardInPlay(card)) {
AllZone.GameAction.sacrifice(card); AllZone.GameAction.sacrifice(card);
Card c = getTargetCard(); Card c = getTargetCard();
AllZone.GameAction.destroy(c); AllZone.GameAction.destroy(c);
}
}
public boolean canPlay()
{
SpellAbility sa;
for (int i=0; i<AllZone.Stack.size(); i++)
{
sa = AllZone.Stack.peek(i);
if (sa.getSourceCard().equals(card))
return false;
}
return super.canPlay();
} }
public boolean canPlayAI() public boolean canPlayAI()
@@ -16586,6 +16600,243 @@ public class CardFactory_Creatures {
card.addSpellAbility(ability); card.addSpellAbility(ability);
}//*************** END ************ END ************************** }//*************** END ************ END **************************
//*************** START *********** START **************************
else if (cardName.equals("Viridian Zealot"))
{
final Ability ability = new Ability(card, "1 G")
{
public void resolve() {
if (AllZone.GameAction.isCardInPlay(card)) {
AllZone.GameAction.sacrifice(card);
Card c = getTargetCard();
AllZone.GameAction.destroy(c);
}
}
public boolean canPlay()
{
SpellAbility sa;
for (int i=0; i<AllZone.Stack.size(); i++)
{
sa = AllZone.Stack.peek(i);
if (sa.getSourceCard().equals(card))
return false;
}
return super.canPlay();
}
public boolean canPlayAI()
{
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
CardList list = new CardList();
list.addAll(hPlay.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return c.isArtifact() || c.isEnchantment() && CardUtil.getConvertedManaCost(c.getManaCost()) >= 4;
}
});
if (list.size() > 0)
{
list.shuffle();
setTargetCard(list.get(0));
}
return list.size() > 0;
}
};
ability.setDescription("1 G, Sacrifice Viridian Zealot: Destroy target artifact or enchantment.");
ability.setBeforePayMana(new Input()
{
private static final long serialVersionUID = -3565024591921095303L;
public void showMessage()
{
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
PlayerZone cPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
CardList list = new CardList();
list.addAll(hPlay.getCards());
list.addAll(cPlay.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return c.isArtifact() || c.isEnchantment();
}
});
stopSetNext(CardFactoryUtil.input_targetSpecific(ability, list, "Select an Artifact or Enchantment", true));
}
});
card.addSpellAbility(ability);
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if (cardName.equals("Ronom Unicorn") || cardName.equals("Kami of Ancient Law"))
{
final Ability ability = new Ability(card, "0")
{
public void resolve() {
if (AllZone.GameAction.isCardInPlay(card)) {
AllZone.GameAction.sacrifice(card);
Card c = getTargetCard();
AllZone.GameAction.destroy(c);
}
}
public boolean canPlay()
{
SpellAbility sa;
for (int i=0; i<AllZone.Stack.size(); i++)
{
sa = AllZone.Stack.peek(i);
if (sa.getSourceCard().equals(card))
return false;
}
return super.canPlay();
}
public boolean canPlayAI()
{
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
CardList list = new CardList();
list.addAll(hPlay.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return c.isEnchantment() && CardUtil.getConvertedManaCost(c.getManaCost()) >= 4;
}
});
if (list.size() > 0)
{
list.shuffle();
setTargetCard(list.get(0));
}
return list.size() > 0;
}
};
ability.setDescription("Sacrifice " +cardName +": Destroy target enchantment.");
ability.setBeforePayMana(new Input()
{
private static final long serialVersionUID = -2023409303136493987L;
public void showMessage()
{
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
PlayerZone cPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
CardList list = new CardList();
list.addAll(hPlay.getCards());
list.addAll(cPlay.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return c.isEnchantment();
}
});
stopSetNext(CardFactoryUtil.input_targetSpecific(ability, list, "Select target Enchantment", true));
}
});
card.addSpellAbility(ability);
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if (cardName.equals("Capashen Unicorn"))
{
final Ability_Tap ability = new Ability_Tap(card, "1 W")
{
private static final long serialVersionUID = 3723881006291076691L;
public void resolve() {
if (AllZone.GameAction.isCardInPlay(card)) {
AllZone.GameAction.sacrifice(card);
Card c = getTargetCard();
AllZone.GameAction.destroy(c);
}
}
public boolean canPlay()
{
SpellAbility sa;
for (int i=0; i<AllZone.Stack.size(); i++)
{
sa = AllZone.Stack.peek(i);
if (sa.getSourceCard().equals(card))
return false;
}
return super.canPlay();
}
public boolean canPlayAI()
{
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
CardList list = new CardList();
list.addAll(hPlay.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return c.isArtifact() || c.isEnchantment() && CardUtil.getConvertedManaCost(c.getManaCost()) >= 4;
}
});
if (list.size() > 0)
{
list.shuffle();
setTargetCard(list.get(0));
}
return list.size() > 0;
}
};
ability.setDescription("1 W, tap, Sacrifice Capashen Unicorn: Destroy target artifact or enchantment.");
ability.setBeforePayMana(new Input()
{
private static final long serialVersionUID = -4032330058005016682L;
public void showMessage()
{
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
PlayerZone cPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
CardList list = new CardList();
list.addAll(hPlay.getCards());
list.addAll(cPlay.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c) {
return c.isArtifact() || c.isEnchantment();
}
});
stopSetNext(CardFactoryUtil.input_targetSpecific(ability, list, "Select an Artifact or Enchantment", true));
}
});
card.addSpellAbility(ability);
}//*************** END ************ END **************************
// Cards with Cycling abilities // Cards with Cycling abilities
// -1 means keyword "Cycling" not found // -1 means keyword "Cycling" not found
if (shouldCycle(card) != -1) if (shouldCycle(card) != -1)

View File

@@ -557,6 +557,7 @@ class CardFactory_Lands {
} }
};//SpellAbility };//SpellAbility
card.addSpellAbility(a1); card.addSpellAbility(a1);
a1.setDescription("1: Mishra's Factory becomes a 2/2 Assembly-Worker artifact creature until end of turn. It's still a land.");
a1.setStackDescription(card +" - becomes a 2/2 creature until EOT"); a1.setStackDescription(card +" - becomes a 2/2 creature until EOT");
Command paid1 = new Command() { Command paid1 = new Command() {

View File

@@ -1866,6 +1866,143 @@ class CardFactory_Planeswalkers {
return card2; return card2;
}//*************** END ************ END ************************** }//*************** END ************ END **************************
//*************** START *********** START **************************
else if (cardName.equals("Jace Beleren"))
{
final int turn[] = new int[1];
turn[0] = -1;
final Card card2 = new Card()
{
public void addDamage(int n)
{
subtractCounter(Counters.LOYALTY,n);
AllZone.GameAction.checkStateEffects();
}
};
card2.addCounter(Counters.LOYALTY,3);
card2.setOwner(owner);
card2.setController(owner);
card2.setName(card.getName());
card2.setType(card.getType());
card2.setManaCost(card.getManaCost());
card2.addSpellAbility(new Spell_Permanent(card2));
//ability1
final SpellAbility ability1 = new Ability(card2, "0")
{
public void resolve()
{
card2.addCounter(Counters.LOYALTY, 2);
turn[0] = AllZone.Phase.getTurn();
AllZone.GameAction.drawCard(Constant.Player.Computer);
AllZone.GameAction.drawCard(Constant.Player.Human);
}//resolve()
public boolean canPlayAI()
{
return card2.getCounters(Counters.LOYALTY) < 11 && AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
}
public boolean canPlay()
{
return AllZone.getZone(card2).is(Constant.Zone.Play) &&
turn[0] != AllZone.Phase.getTurn() &&
AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
!AllZone.Phase.getPhase().equals("End of Turn") &&
(AllZone.Phase.getPhase().equals("Main1") || AllZone.Phase.getPhase().equals("Main2"));
}//canPlay()
};
ability1.setDescription("+2: Each player draws a card.");
ability1.setStackDescription(cardName + " - Each player draws a card.");
//ability2
final SpellAbility ability2 = new Ability(card2, "0")
{
public void resolve()
{
card2.subtractCounter(Counters.LOYALTY, 1);
turn[0] = AllZone.Phase.getTurn();
String player = getTargetPlayer();
AllZone.GameAction.drawCard(player);
}//resolve()
public boolean canPlayAI()
{
return false;
}
public boolean canPlay()
{
return AllZone.getZone(card2).is(Constant.Zone.Play) &&
card2.getCounters(Counters.LOYALTY) >= 1 &&
turn[0] != AllZone.Phase.getTurn() &&
AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
!AllZone.Phase.getPhase().equals("End of Turn") &&
(AllZone.Phase.getPhase().equals("Main1") || AllZone.Phase.getPhase().equals("Main2"));
}//canPlay()
};
ability2.setDescription("-1: Target player draws a card.");
ability2.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ability2));
//ability3
final SpellAbility ability3 = new Ability(card2, "0")
{
public void resolve()
{
card2.subtractCounter(Counters.LOYALTY, 10);
turn[0] = AllZone.Phase.getTurn();
String player = getTargetPlayer();
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
CardList libList = new CardList(lib.getCards());
int max = 20;
if (libList.size() < 20)
max = libList.size();
for (int i=0;i<max;i++)
{
Card c = libList.get(i);
lib.remove(c);
grave.add(c);
}
}//resolve()
public boolean canPlayAI()
{
setTargetPlayer(Constant.Player.Human);
return card2.getCounters(Counters.LOYALTY) >= 11;
}
public boolean canPlay()
{
return AllZone.getZone(card2).is(Constant.Zone.Play) &&
card2.getCounters(Counters.LOYALTY) >= 10 &&
turn[0] != AllZone.Phase.getTurn() &&
AllZone.Phase.getActivePlayer().equals(card2.getController()) &&
!AllZone.Phase.getPhase().equals("End of Turn") &&
(AllZone.Phase.getPhase().equals("Main1") || AllZone.Phase.getPhase().equals("Main2"));
}//canPlay()
};
ability3.setDescription("-10: Target player puts the top twenty cards of his or her library into his or her graveyard.");
ability3.setBeforePayMana(CardFactoryUtil.input_targetPlayer(ability3));
card2.addSpellAbility(ability1);
card2.addSpellAbility(ability2);
card2.addSpellAbility(ability3);
return card2;
}//*************** END ************ END **************************
return card; return card;
} }
} }

147
src/forge/DownloadDeck.java Normal file
View File

@@ -0,0 +1,147 @@
package forge;
public class DownloadDeck {
private Card DownloadCard;
public String FoundNumberCard(String rStr)
{
int temp;
int i;
for(i=0; i<rStr.length();i++)
{
temp=rStr.codePointAt(i) ;
if(temp>=48 && temp<=57)
{
break;
}
}
if(rStr.codePointAt(i+1)>=48 &&rStr.codePointAt(i+1)<=57)
{
return rStr.substring(i,i+2);
}else
{
return rStr.substring(i,i+1);
}
}
public String FoundNameCard(String rStr)
{
int temp;
int i;
for(i=0; i<rStr.length();i++)
{
temp=rStr.codePointAt(i) ;
if(temp>=48 && temp<=57)
{
break;
}
}
return rStr.substring(0,i-1);
}
public String RemoveSpace(String rStr)
{
int temp;
int i;
for(i=0; i<rStr.length();i++)
{
temp=rStr.codePointAt(i) ;
if(temp!=32)
{
break;
}
}
return rStr.substring(i);
}
public String RemoveSpaceBack(String rStr)
{
int temp;
int i;
for(i=rStr.length()-1; i>-1;i=i-1)
{
temp=rStr.codePointAt(i) ;
if(temp!=32)
{
break;
}
}
return rStr.substring(0,i+1);
}
public String RemoveFoundNumberCard(String rStr, String Number)
{
int a;
int temp;
a=rStr.indexOf(Number);
temp=rStr.codePointAt(a+1) ;
if(temp>=48 && temp<=57)
{
return rStr.substring(a+2);
}else
{
return rStr.substring(a+1);
}
}
public String RemoveFoundNameCard(String rStr, String Name)
{
int a;
a=Name.length();
return rStr.substring(a);
}
public boolean IsCardSupport(String CardName)
{
CardList all = AllZone.CardFactory.getAllCards();
Card gCard = new Card();
for(int i=0;i<all.size();i++)
{
gCard = all.getCard(i);
if(CardName.equalsIgnoreCase(gCard.getName()))
{
return true;
}
}
return false;
}
public Card GetCardDownload(Card c, String CardName)
{
CardList all = AllZone.CardFactory.getAllCards();
for(int i=0;i<all.size();i++)
{
DownloadCard = all.getCard(i);
if(CardName.equalsIgnoreCase(DownloadCard.getName()))
{
return DownloadCard;
}
}
return DownloadCard;
}
}

View File

@@ -391,7 +391,8 @@ private Card getCurrentCard(int ID)
for (int i=0;i < c.getEnchanting().size(); i++) for (int i=0;i < c.getEnchanting().size(); i++)
{ {
Card perm = c.getEnchanting().get(i); Card perm = c.getEnchanting().get(i);
if (!AllZone.GameAction.isCardInPlay(perm) || CardFactoryUtil.hasProtectionFrom(c, perm)) if (!AllZone.GameAction.isCardInPlay(perm) || CardFactoryUtil.hasProtectionFrom(c, perm)
|| (c.getKeyword().contains("Enchant creature") && !perm.getType().contains("Creature")) )
{ {
c.unEnchantCard(perm); c.unEnchantCard(perm);
destroy(c); destroy(c);
@@ -436,9 +437,21 @@ private Card getCurrentCard(int ID)
for(int i = 0; i < list.size(); i++) for(int i = 0; i < list.size(); i++)
{ {
c = list.get(i); c = list.get(i);
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);
if (cl.size() > 1)
{
for (Card crd : cl)
{
AllZone.GameAction.moveToGraveyard(crd);
}
}
} }
} }
private void destroyLegendaryCreatures() private void destroyLegendaryCreatures()
@@ -454,6 +467,8 @@ private Card getCurrentCard(int ID)
{ {
for(int i = 0; i < b.size(); i++) for(int i = 0; i < b.size(); i++)
AllZone.GameAction.destroy((Card)b.get(i)); AllZone.GameAction.destroy((Card)b.get(i));
} }
} }
}//destroyLegendaryCreatures() }//destroyLegendaryCreatures()
@@ -472,6 +487,21 @@ private Card getCurrentCard(int ID)
return a; return a;
} }
public CardList getPlaneswalkerSubtype(CardList search, Card planeswalker)
{
final String type = planeswalker.getType().toString();
CardList list = search;
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.getType().toString().equals(type);
}
});
return list;
}
public void sacrificeCreature(String player, SpellAbility sa) public void sacrificeCreature(String player, SpellAbility sa)
{ {

View File

@@ -8809,6 +8809,115 @@ public class GameActionUtil
};//Elvish_Champion_Other };//Elvish_Champion_Other
public static Command Timber_Protector_Pump = new Command()
{
private static final long serialVersionUID = 395882142255572162L;
CardList gloriousAnthemList = new CardList();
public void execute()
{
CardList cList = gloriousAnthemList;
Card c;
for (int i = 0; i < cList.size(); i++)
{
c = cList.get(i);
if (c.isCreature()) {
c.addSemiPermanentAttackBoost(-1);
c.addSemiPermanentDefenseBoost(-1);
c.removeExtrinsicKeyword("Indestructible");
}
else //forest
{
c.removeExtrinsicKeyword("Indestructible");
}
}
cList.clear();
PlayerZone[] zone = getZone("Timber Protector");
// for each zone found add +1/+1 to each card
for (int outer = 0; outer < zone.length; outer++)
{
CardList creature = new CardList();
creature.addAll(AllZone.Human_Play.getCards());
creature.addAll(AllZone.Computer_Play.getCards());
creature = creature.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.getType().equals("Treefolk") || c.getType().equals("Forest") || c.getKeyword().contains("Changeling");
}
});
for (int i = 0; i < creature.size(); i++)
{
c = creature.get(i);
if (c.isCreature()
&& !c.getName().equals("Timber Protector"))
{
c.addSemiPermanentAttackBoost(1);
c.addSemiPermanentDefenseBoost(1);
c.addExtrinsicKeyword("Indestructible");
gloriousAnthemList.add(c);
}
else if (c.getKeyword().contains("Forest"))
{
c.addExtrinsicKeyword("Indestructible");
}
} // for
} // for
}// execute()
};//Timber_Protector_Pump
public static Command Timber_Protector_Other = new Command()
{
private static final long serialVersionUID = -3107498901233064819L;
int otherLords=0;
private int countOtherLords()
{
PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human);
PlayerZone cPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer);
CardList lords = new CardList();
lords.addAll(hPlay.getCards());
lords.addAll(cPlay.getCards());
lords = lords.getName("Timber Protector");
return lords.size()-1;
}
public void execute()
{
CardList creature = new CardList();
creature.addAll(AllZone.Human_Play.getCards());
creature.addAll(AllZone.Computer_Play.getCards());
creature = creature.getName("Timber Protector");
for (int i = 0; i < creature.size(); i++)
{
Card c = creature.get(i);
otherLords = countOtherLords();
c.setOtherAttackBoost(otherLords);
c.setOtherDefenseBoost(otherLords);
if (!c.getExtrinsicKeyword().contains("Indestructible") && otherLords > 0)
c.addExtrinsicKeyword("Indestructible");
//else if (c.getExtrinsicKeyword().contains("Mountainwalk") && otherLords == 0 )
}// for inner
}// execute()
};//Timber_Protector_Other
public static Command Goblin_Chieftain_Pump = new Command() public static Command Goblin_Chieftain_Pump = new Command()
{ {
@@ -11582,6 +11691,8 @@ public class GameActionUtil
commands.put("Merfolk_Sovereign_Other", Merfolk_Sovereign_Other); commands.put("Merfolk_Sovereign_Other", Merfolk_Sovereign_Other);
commands.put("Lord_of_Atlantis_Pump", Lord_of_Atlantis_Pump); commands.put("Lord_of_Atlantis_Pump", Lord_of_Atlantis_Pump);
commands.put("Lord_of_Atlantis_Other", Lord_of_Atlantis_Other); commands.put("Lord_of_Atlantis_Other", Lord_of_Atlantis_Other);
commands.put("Timber_Protector_Pump", Timber_Protector_Pump);
commands.put("Timber_Protector_Other", Timber_Protector_Other);
commands.put("Goblin_Chieftain_Pump", Goblin_Chieftain_Pump); commands.put("Goblin_Chieftain_Pump", Goblin_Chieftain_Pump);
commands.put("Goblin_Chieftain_Other", Goblin_Chieftain_Other); commands.put("Goblin_Chieftain_Other", Goblin_Chieftain_Other);
commands.put("Goblin_King_Pump", Goblin_King_Pump); commands.put("Goblin_King_Pump", Goblin_King_Pump);

View File

@@ -4,12 +4,18 @@ package forge;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.net.Proxy;
import java.net.URL;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -26,6 +32,7 @@ import javax.swing.filechooser.FileFilter;
import forge.error.ErrorViewer; import forge.error.ErrorViewer;
import forge.properties.ForgeProps; import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.properties.NewConstants.LANG.Gui_DownloadPictures.ERRORS;
interface DeckDisplay { interface DeckDisplay {
@@ -67,6 +74,7 @@ public class Gui_DeckEditor_Menu extends JMenuBar implements NewConstants {
private Command exitCommand; private Command exitCommand;
public Gui_DeckEditor_Menu(DeckDisplay in_display, Command exit) { public Gui_DeckEditor_Menu(DeckDisplay in_display, Command exit) {
deckDisplay = in_display; deckDisplay = in_display;
exitCommand = exit; exitCommand = exit;
@@ -309,6 +317,8 @@ public class Gui_DeckEditor_Menu extends JMenuBar implements NewConstants {
}; };
private File getImportFilename() { private File getImportFilename() {
JFileChooser chooser = new JFileChooser(previousDirectory); JFileChooser chooser = new JFileChooser(previousDirectory);
@@ -402,6 +412,153 @@ public class Gui_DeckEditor_Menu extends JMenuBar implements NewConstants {
}//importDeck() }//importDeck()
private void downloadDeck(){
Object o = JOptionPane.showInputDialog(null, "URL(only from http://magic.tcgplayer.com):", "Download Deck", JOptionPane.OK_CANCEL_OPTION);
if(o==null )
{
return;
}
String url = o.toString();
if((url.length()<37)||(url.substring(0, 39).equalsIgnoreCase("http://magic.tcgplayer.com/db/deck.asp") ) )
{
JOptionPane.showMessageDialog(null, "Bad URL." +"\n"+ "Support only deck from http://magic.tcgplayer.com"+ "\n"+ "Example: http://magic.tcgplayer.com/db/deck.asp?deck_id=474146", "Information", JOptionPane.INFORMATION_MESSAGE );
return;
}
Proxy p = null;
p = Proxy.NO_PROXY;
BufferedInputStream in;
BufferedOutputStream out;
try {
byte[] buf = new byte[1024];
int len;
File f = new File("deck_temp.html");
in = new BufferedInputStream(new URL(url).openConnection(p).getInputStream());
out = new BufferedOutputStream(new FileOutputStream(f));
//while - read and write file
while((len = in.read(buf)) != -1) {
out.write(buf, 0, len);
}//while - read and write file
in.close();
out.flush();
out.close();
String fileName = "deck_temp.html";
FileReader fr = new FileReader(fileName);
BufferedReader br = new BufferedReader(fr);
String s = "";
String z = "";
while((z=br.readLine())!=null){s=s+z;}
br.close();
int start = s.indexOf("MAIN DECK");
int finish = s.indexOf("SIDEBOARD");
String rStr = "";
rStr = s.substring(start+9, finish);
int first;
int second;
while (rStr.indexOf("<")!=-1)
{
first = rStr.indexOf("<");
second = rStr.indexOf(">", first);
if(first==0){
rStr =rStr.substring(second+1);
}else
{
rStr = rStr.substring(0, first)+" "+rStr.substring(second+1);
}
}
first = rStr.indexOf("Creatures [");
second = rStr.indexOf("]", first);
if (first!=-1){
rStr = rStr.substring(0,first)+rStr.substring(second+1);
}
first = rStr.indexOf("Spells [");
second = rStr.indexOf("]", first);
if (first!=-1){
rStr = rStr.substring(0,first)+rStr.substring(second+1);
}
first = rStr.indexOf("Lands [");
second = rStr.indexOf("]", first);
if (first!=-1){
rStr = rStr.substring(0,first)+rStr.substring(second+1);
}
String number[] =new String[59];
String name[]=new String[59];
int count=0;
DownloadDeck download = new DownloadDeck();
while(rStr.length()!=0)
{
rStr=download.RemoveSpace(rStr);
number[count]=download.FoundNumberCard(rStr);
rStr=download.RemoveFoundNumberCard(rStr, number[count]);
rStr=download.RemoveSpace(rStr);
name[count]=download.FoundNameCard(rStr);
name[count]=download.RemoveSpaceBack(name[count]);
rStr=download.RemoveFoundNameCard(rStr, name[count]);
rStr=download.RemoveSpace(rStr);
count=count+1;
}
String trueName[]=new String[59];
String trueNumber[]=new String[59];
String falseName[]=new String[59];
int trueCount=0;
int falseCount=0;
for(int i=0;i<count;i++)
{
if (download.IsCardSupport(name[i])==true)
{
trueName[trueCount]=name[i];
trueNumber[trueCount]=number[i];
trueCount = trueCount+1;
}else
{
falseName[falseCount]=name[i];
falseCount = falseCount+1;
}
}
Card c = new Card();
CardList trueList = new CardList();
for(int i=0;i<trueCount;i++)
{
for(int k=0; k<Integer.parseInt(trueNumber[i]);k++)
{
c= download.GetCardDownload(c, trueName[i]);
trueList.add(c);
}
}
String FalseCards ="";
for(int i=0;i<falseCount;i++)
{
FalseCards = FalseCards +"\n" +falseName[i] +",";
}
deckDisplay.updateDisplay(deckDisplay.getTop(), trueList);
if(falseCount==0){
JOptionPane.showMessageDialog(null, "Deck downloads.", "Information", JOptionPane.INFORMATION_MESSAGE );
}else
{
JOptionPane.showMessageDialog(null, "Sorry, cards:"+FalseCards+"\nnot supported in this version MTGForge. \nDeck downloads without this cards.", "Information", JOptionPane.INFORMATION_MESSAGE );
}
f.delete();
} catch(Exception ex) {
ErrorViewer.showError(ex, ForgeProps.getLocalized(ERRORS.OTHER), "deck_temp.html",
url);
}
}
private void exportDeck() { private void exportDeck() {
File filename = getExportFilename(); File filename = getExportFilename();
@@ -714,7 +871,7 @@ public class Gui_DeckEditor_Menu extends JMenuBar implements NewConstants {
// save(); // save();
deckIO.close(); deckIO.close();
boosterDeckIO.close(); boosterDeckIO.close();
exitCommand.execute(); exitCommand.execute();
}//close }//close
@@ -838,6 +995,7 @@ public class Gui_DeckEditor_Menu extends JMenuBar implements NewConstants {
JMenuItem importDeck = new JMenuItem("Import Deck"); JMenuItem importDeck = new JMenuItem("Import Deck");
JMenuItem exportDeck = new JMenuItem("Export Deck"); JMenuItem exportDeck = new JMenuItem("Export Deck");
JMenuItem downloadDeck = new JMenuItem("Download Deck");
JMenuItem openConstructed = new JMenuItem("Open Deck - Constructed"); JMenuItem openConstructed = new JMenuItem("Open Deck - Constructed");
@@ -866,6 +1024,7 @@ public class Gui_DeckEditor_Menu extends JMenuBar implements NewConstants {
fileMenu.add(importDeck); fileMenu.add(importDeck);
fileMenu.add(exportDeck); fileMenu.add(exportDeck);
fileMenu.add(downloadDeck);
fileMenu.addSeparator(); fileMenu.addSeparator();
fileMenu.add(newRandomConstructed); fileMenu.add(newRandomConstructed);
@@ -913,6 +1072,20 @@ public class Gui_DeckEditor_Menu extends JMenuBar implements NewConstants {
} }
}); });
downloadDeck.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
try {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
downloadDeck();
}
});
} catch(Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("Gui_DeckEditor_Menu : downloadDeck() error - " + ex);
}
}
});
newConstructed.addActionListener(new ActionListener() { newConstructed.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {

View File

@@ -65,6 +65,7 @@ public class StateBasedEffects
cardToEffectsList.put("Privileged Position", new String[] {"Privileged_Position", "Privileged_Position_Other"}); cardToEffectsList.put("Privileged Position", new String[] {"Privileged_Position", "Privileged_Position_Other"});
cardToEffectsList.put("Elvish Archdruid", new String[] {"Elvish_Archdruid_Pump", "Elvish_Archdruid_Other"}); cardToEffectsList.put("Elvish Archdruid", new String[] {"Elvish_Archdruid_Pump", "Elvish_Archdruid_Other"});
cardToEffectsList.put("Wizened Cenn", new String[] {"Wizened_Cenn_Pump", "Wizened_Cenn_Other"}); cardToEffectsList.put("Wizened Cenn", new String[] {"Wizened_Cenn_Pump", "Wizened_Cenn_Other"});
cardToEffectsList.put("Timber Protector", new String[] {"Timber_Protector_Pump", "Timber_Protector_Other"});
cardToEffectsList.put("Goblin Chieftain", new String[] {"Goblin_Chieftain_Pump", "Goblin_Chieftain_Other"}); cardToEffectsList.put("Goblin Chieftain", new String[] {"Goblin_Chieftain_Pump", "Goblin_Chieftain_Other"});
cardToEffectsList.put("Goblin King", new String[] {"Goblin_King_Pump", "Goblin_King_Other"}); cardToEffectsList.put("Goblin King", new String[] {"Goblin_King_Pump", "Goblin_King_Other"});
cardToEffectsList.put("Merfolk Sovereign", new String[] {"Merfolk_Sovereign_Pump", "Merfolk_Sovereign_Other"}); cardToEffectsList.put("Merfolk Sovereign", new String[] {"Merfolk_Sovereign_Pump", "Merfolk_Sovereign_Other"});