diff --git a/.gitattributes b/.gitattributes index be2e4c560b8..32b0a21a2f1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -563,6 +563,7 @@ res/cardsfolder/celestial_prism.txt -text svneol=native#text/plain res/cardsfolder/celestial_purge.txt -text svneol=native#text/plain res/cardsfolder/cemetery_gate.txt -text svneol=native#text/plain res/cardsfolder/cemetery_reaper.txt -text svneol=native#text/plain +res/cardsfolder/centaur_archer.txt -text svneol=native#text/plain res/cardsfolder/centaur_courser.txt -text svneol=native#text/plain res/cardsfolder/centaur_glade.txt -text svneol=native#text/plain res/cardsfolder/centaur_omenreader.txt -text svneol=native#text/plain diff --git a/res/cardsfolder/centaur_archer.txt b/res/cardsfolder/centaur_archer.txt new file mode 100644 index 00000000000..54702de8229 --- /dev/null +++ b/res/cardsfolder/centaur_archer.txt @@ -0,0 +1,9 @@ +Name:Centaur Archer +ManaCost:1 R G +Types:Creature Centaur Archer +Text:no text +PT:3/2 +K:abDamageTgtV T:1:Creature.withFlying +K:SVar:Rarity:Common +K:SVar:Picture:http://www.wizards.com/global/images/magic/general/centaur_archer.jpg +End diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index d2c38ff1309..24d9a992cf5 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -2283,7 +2283,17 @@ public class CardFactory implements NewConstants { String k[] = parse.split(":"); String tmpCost[] = k[0].replace("abDamage", "").split(" ", 2); + int drawBack = 2; + final Target abTgt = new Target(tmpCost[0]); + if (abTgt.canTgtValid()){ + int valid = drawBack; + // Looks like VTSelection is used for the Message box, should improve the message + abTgt.setVTSelection(k[valid]); + abTgt.setValidTgts(k[valid].split(",")); + drawBack++; + } + final Ability_Cost abCost = new Ability_Cost(tmpCost[1], card.getName(), true); final int NumDmg[] = {-1}; @@ -2303,15 +2313,15 @@ public class CardFactory implements NewConstants { final String DrawBack[] = {"none"}; final String spDesc[] = {"none"}; final String stDesc[] = {"none"}; - if(k.length > 2) { - if(k[2].contains("Drawback$")) { - String kk[] = k[2].split("\\$"); + if(k.length > drawBack) { + if(k[drawBack].contains("Drawback$")) { + String kk[] = k[drawBack].split("\\$"); DrawBack[0] = kk[1]; - if(k.length > 3) spDesc[0] = k[3]; - if(k.length > 4) stDesc[0] = k[4]; + if(k.length > drawBack+1) spDesc[0] = k[drawBack+1]; + if(k.length > drawBack+2) stDesc[0] = k[drawBack+2]; } else { - if(k.length > 2) spDesc[0] = k[2]; - if(k.length > 3) stDesc[0] = k[3]; + if(k.length > drawBack) spDesc[0] = k[drawBack]; + if(k.length > drawBack+1) stDesc[0] = k[drawBack+1]; } } else { StringBuilder sb = new StringBuilder(); diff --git a/src/forge/Target.java b/src/forge/Target.java index 9564603735f..7b92cd2b580 100644 --- a/src/forge/Target.java +++ b/src/forge/Target.java @@ -38,9 +38,7 @@ public class Target { if (tgtSplit[0].contains("C")) // creature tgtCreature = true; if (tgtSplit[0].contains("P")) // player - tgtPlayer = true; - //todo add Opponent and other permanent types - + tgtPlayer = true; if (tgtSplit[0].contains("V")) // valid tgtValid = true; @@ -57,16 +55,20 @@ public class Target { public String targetString() { - String tgt = ""; + StringBuilder sb = new StringBuilder("target "); + if (tgtCreature) - tgt += "creature"; - if (tgtPlayer && !tgt.equals("")) - tgt += " or "; - if (tgtPlayer) - tgt += "player"; + sb.append("creature"); + if (tgtPlayer){ + if (tgtCreature) + sb.append(" or "); + sb.append("player"); + } + if (tgtValid){ + sb.append(vtSelection); + } + sb.append("."); - tgt += "."; - - return "target " + tgt; + return sb.toString(); } } diff --git a/src/forge/Target_Selection.java b/src/forge/Target_Selection.java index c074982b076..54d7911b42e 100644 --- a/src/forge/Target_Selection.java +++ b/src/forge/Target_Selection.java @@ -38,6 +38,11 @@ public class Target_Selection { target.resetTargets(); } + public void incrementTargets(){ + if (target != null) + target.incrementTargets(); + } + public boolean chooseTargets(){ // if not enough targets chosen, reset and cancel Ability if (bCancel || bDoneTarget && target.getNumTargeted() < target.getMinTargets()){ @@ -46,8 +51,8 @@ public class Target_Selection { return false; } - // if we haven't reached minimum targets, or we're stil less than Max targets keep choosing - // targetting, with forward code for multiple target abilities + // if we haven't reached minimum targets, or we're still less than Max targets keep choosing + // targeting, with forward code for multiple target abilities if (!bDoneTarget && target.getMinTargets() > 0 && target.getNumTargeted() < target.getMaxTargets()){ if (target.canTgtCreature() && target.canTgtPlayer()) changeInput.stopSetNext(targetCreaturePlayer(ability, Command.Blank, true, this, req)); @@ -56,7 +61,7 @@ public class Target_Selection { else if(target.canTgtPlayer()) changeInput.stopSetNext(targetPlayer(ability, this, req)); else if (target.canTgtValid()) - changeInput.stopSetNext(CardFactoryUtil.input_targetValid(ability, target.getValidTgts(), target.getVTSelection())); + changeInput.stopSetNext(input_targetValid(ability, target.getValidTgts(), target.getVTSelection(), this, req)); return false; } @@ -108,7 +113,7 @@ public class Target_Selection { } void done() { - select.getTgt().incrementTargets(); + select.incrementTargets(); paid.execute(); stop(); req.finishedTargeting(); @@ -143,7 +148,7 @@ public class Target_Selection { }//selectCard() void done() { - select.getTgt().incrementTargets(); + select.incrementTargets(); stop(); req.finishedTargeting(); } @@ -183,7 +188,7 @@ public class Target_Selection { } void done() { - select.getTgt().incrementTargets(); + select.incrementTargets(); stop(); req.finishedTargeting(); } @@ -191,5 +196,64 @@ public class Target_Selection { return target; }//targetPlayer() + // these have been copied over from CardFactoryUtil as they need two extra parameters for target selection. + // however, due to the changes necessary for SA_Requirements this is much different than the original + public static Input input_targetValid(final SpellAbility sa, final String[] Tgts, final String message, + final Target_Selection select, final SpellAbility_Requirements req) + { + return new Input() { + private static final long serialVersionUID = -2397096454771577476L; + + @Override + public void showMessage() { + CardList allCards = new CardList(); + allCards.addAll(AllZone.Human_Play.getCards()); + allCards.addAll(AllZone.Computer_Play.getCards()); + + CardList choices = allCards.getValidCards(Tgts); + + stopSetNext(input_targetSpecific(sa, choices, message, true, select, req)); + } + }; + }//input_targetValid + + //CardList choices are the only cards the user can successful select + public static Input input_targetSpecific(final SpellAbility spell, final CardList choices, final String message, + final boolean targeted, final Target_Selection select, final SpellAbility_Requirements req) { + Input target = new Input() { + private static final long serialVersionUID = -1091595663541356356L; + + @Override + public void showMessage() { + AllZone.Display.showMessage(message); + ButtonUtil.enableOnlyCancel(); + } + + @Override + public void selectButtonCancel() { + select.setCancel(true); + stop(); + req.finishedTargeting(); + } + + @Override + public void selectCard(Card card, PlayerZone zone) { + if(targeted && !CardFactoryUtil.canTarget(spell, card)) { + AllZone.Display.showMessage("Cannot target this card (Shroud? Protection? Restrictions?)."); + } + else if(choices.contains(card)) { + spell.setTargetCard(card); + done(); + } + }//selectCard() + + void done() { + select.incrementTargets(); + stop(); + req.finishedTargeting(); + } + }; + return target; + }//input_targetSpecific() }