- Added input_targetValid in Target_Selection for expanded Requirements coverage.

- Added V as an additional target parameter for abDamageTgt.
- Added Centaur Archer as a Sample of using abDamageTgtV.
This commit is contained in:
jendave
2011-08-06 07:17:15 +00:00
parent 0e5ff0600f
commit d737b60ce0
5 changed files with 111 additions and 25 deletions

1
.gitattributes vendored
View File

@@ -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/celestial_purge.txt -text svneol=native#text/plain
res/cardsfolder/cemetery_gate.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/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_courser.txt -text svneol=native#text/plain
res/cardsfolder/centaur_glade.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 res/cardsfolder/centaur_omenreader.txt -text svneol=native#text/plain

View File

@@ -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

View File

@@ -2283,7 +2283,17 @@ public class CardFactory implements NewConstants {
String k[] = parse.split(":"); String k[] = parse.split(":");
String tmpCost[] = k[0].replace("abDamage", "").split(" ", 2); String tmpCost[] = k[0].replace("abDamage", "").split(" ", 2);
int drawBack = 2;
final Target abTgt = new Target(tmpCost[0]); 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 Ability_Cost abCost = new Ability_Cost(tmpCost[1], card.getName(), true);
final int NumDmg[] = {-1}; final int NumDmg[] = {-1};
@@ -2303,15 +2313,15 @@ 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"};
if(k.length > 2) { if(k.length > drawBack) {
if(k[2].contains("Drawback$")) { if(k[drawBack].contains("Drawback$")) {
String kk[] = k[2].split("\\$"); String kk[] = k[drawBack].split("\\$");
DrawBack[0] = kk[1]; DrawBack[0] = kk[1];
if(k.length > 3) spDesc[0] = k[3]; if(k.length > drawBack+1) spDesc[0] = k[drawBack+1];
if(k.length > 4) stDesc[0] = k[4]; if(k.length > drawBack+2) stDesc[0] = k[drawBack+2];
} else { } else {
if(k.length > 2) spDesc[0] = k[2]; if(k.length > drawBack) spDesc[0] = k[drawBack];
if(k.length > 3) stDesc[0] = k[3]; if(k.length > drawBack+1) stDesc[0] = k[drawBack+1];
} }
} else { } else {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@@ -39,8 +39,6 @@ public class Target {
tgtCreature = true; tgtCreature = true;
if (tgtSplit[0].contains("P")) // player if (tgtSplit[0].contains("P")) // player
tgtPlayer = true; tgtPlayer = true;
//todo add Opponent and other permanent types
if (tgtSplit[0].contains("V")) // valid if (tgtSplit[0].contains("V")) // valid
tgtValid = true; tgtValid = true;
@@ -57,16 +55,20 @@ public class Target {
public String targetString() public String targetString()
{ {
String tgt = ""; StringBuilder sb = new StringBuilder("target ");
if (tgtCreature) if (tgtCreature)
tgt += "creature"; sb.append("creature");
if (tgtPlayer && !tgt.equals("")) if (tgtPlayer){
tgt += " or "; if (tgtCreature)
if (tgtPlayer) sb.append(" or ");
tgt += "player"; sb.append("player");
}
if (tgtValid){
sb.append(vtSelection);
}
sb.append(".");
tgt += "."; return sb.toString();
return "target " + tgt;
} }
} }

View File

@@ -38,6 +38,11 @@ public class Target_Selection {
target.resetTargets(); target.resetTargets();
} }
public void incrementTargets(){
if (target != null)
target.incrementTargets();
}
public boolean chooseTargets(){ public boolean chooseTargets(){
// if not enough targets chosen, reset and cancel Ability // if not enough targets chosen, reset and cancel Ability
if (bCancel || bDoneTarget && target.getNumTargeted() < target.getMinTargets()){ if (bCancel || bDoneTarget && target.getNumTargeted() < target.getMinTargets()){
@@ -46,8 +51,8 @@ public class Target_Selection {
return false; return false;
} }
// if we haven't reached minimum targets, or we're stil less than Max targets keep choosing // if we haven't reached minimum targets, or we're still less than Max targets keep choosing
// targetting, with forward code for multiple target abilities // targeting, with forward code for multiple target abilities
if (!bDoneTarget && target.getMinTargets() > 0 && target.getNumTargeted() < target.getMaxTargets()){ if (!bDoneTarget && target.getMinTargets() > 0 && target.getNumTargeted() < target.getMaxTargets()){
if (target.canTgtCreature() && target.canTgtPlayer()) if (target.canTgtCreature() && target.canTgtPlayer())
changeInput.stopSetNext(targetCreaturePlayer(ability, Command.Blank, true, this, req)); changeInput.stopSetNext(targetCreaturePlayer(ability, Command.Blank, true, this, req));
@@ -56,7 +61,7 @@ public class Target_Selection {
else if(target.canTgtPlayer()) else if(target.canTgtPlayer())
changeInput.stopSetNext(targetPlayer(ability, this, req)); changeInput.stopSetNext(targetPlayer(ability, this, req));
else if (target.canTgtValid()) 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; return false;
} }
@@ -108,7 +113,7 @@ public class Target_Selection {
} }
void done() { void done() {
select.getTgt().incrementTargets(); select.incrementTargets();
paid.execute(); paid.execute();
stop(); stop();
req.finishedTargeting(); req.finishedTargeting();
@@ -143,7 +148,7 @@ public class Target_Selection {
}//selectCard() }//selectCard()
void done() { void done() {
select.getTgt().incrementTargets(); select.incrementTargets();
stop(); stop();
req.finishedTargeting(); req.finishedTargeting();
} }
@@ -183,7 +188,7 @@ public class Target_Selection {
} }
void done() { void done() {
select.getTgt().incrementTargets(); select.incrementTargets();
stop(); stop();
req.finishedTargeting(); req.finishedTargeting();
} }
@@ -191,5 +196,64 @@ public class Target_Selection {
return target; return target;
}//targetPlayer() }//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()
} }