added Fireball from the original Limited base set. Everything seems to work for the Human. The AI doesn't do anything terribly clever - just finishes human off if it can. But this is a good start.

There are also some kinks with the flow of selecting a player or creature twice.  But others can add their input.

Also, there is a lot of debug code there that I left in on purpose.  Once we are confident the kinks are out, or before an upcoming release, it can be commented/removed.  Enjoy!
This commit is contained in:
jendave
2011-08-06 04:20:04 +00:00
parent e340bb08a4
commit 92422a241d
3 changed files with 208 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ snow_covered_mountain.jpg http://www.wizards.com/global/images/magic/gene
snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg
snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg
snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg
fireball.jpg http://www.wizards.com/global/images/magic/general/fireball.jpg
inferno.jpg http://www.wizards.com/global/images/magic/general/inferno.jpg
guan_yus_1000_li_march.jpg http://www.wizards.com/global/images/magic/general/guan_yus_1000_li_march.jpg
oust.jpg http://www.wizards.com/global/images/magic/general/oust.jpg

View File

@@ -1,3 +1,8 @@
Fireball
X R
Sorcery
Fireball deals X damage divided evenly, rounded down, among any number of target creatures and/or players. Fireball costs 1 more to cast for each target beyond the first.
Inferno
5 R R
Instant

View File

@@ -19430,6 +19430,208 @@ public class CardFactory implements NewConstants {
card.addSpellAbility(spell);
}// *************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Fireball")) {
//no reason this should never be enough targets
final Card[] target = new Card[100];
final int[] index = new int[1];
//it can target up to two players also
final String[] targetPlayers = new String[2];
final int[] index2 = new int[1];
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -6293612568525319357L;
@Override
public boolean canPlayAI() {
final int maxX = ComputerUtil.getAvailableMana().size() - 1;
int humanLife = AllZone.Human_Life.getLife();
if(maxX >= humanLife) {
index2[0] = 0;
targetPlayers[index2[0]] = Constant.Player.Human;
//index2[0] = 1;
return true;
}
return false;
}
@Override
public void resolve() {
int damage = (card.getXManaCostPaid() - getNumTargets() + 1) / getNumTargets();
//add that much damage to each creature
//DEBUG
System.out.println("Fireball - damage to each target: "+damage);
System.out.print("Fireball - card targets: ");
printCardTargets();
System.out.print("Fireball - player targets: ");
printPlayerTargets();
if(card.getController().equals(Constant.Player.Computer)) {
StringBuilder sb = new StringBuilder();
sb.append(cardName+" - Computer causes "+damage+" to:\n\n");
for(int i = 0; i < target.length; i++) {
if(AllZone.GameAction.isCardInPlay(target[i])
&& CardFactoryUtil.canTarget(card, target[i])
&& null != target[i]) {
sb.append(target[i]+"\n");
}
}
for(int i = 0; i < targetPlayers.length; i++) {
if( null != targetPlayers[i] ) {
sb.append(targetPlayers[i]+"\n");
}
}
javax.swing.JOptionPane.showMessageDialog(null, sb.toString());
}
for(int i = 0; i < target.length; i++) {
if(AllZone.GameAction.isCardInPlay(target[i])
&& CardFactoryUtil.canTarget(card, target[i])
&& null != target[i]) {
//DEBUG
System.out.println("Fireball does "+damage+" to: "+target[i]);
AllZone.GameAction.addDamage(target[i], card, damage);
}
}
for(int i = 0; i < targetPlayers.length; i++) {
if( null != targetPlayers[i] ) {
//DEBUG
System.out.println("Fireball does "+damage+" to: "+targetPlayers[i]);
AllZone.GameAction.addDamage(targetPlayers[i], card, damage);
}
}
}//resolve()
//DEBUG
private void printCardTargets() {
System.out.print("[");
for(int i = 0; i < target.length; i++) {
System.out.print(target[i]+",");
}
System.out.println("]");
}
//DEBUG
private void printPlayerTargets() {
System.out.print("[");
for(int i = 0; i < targetPlayers.length; i++) {
System.out.print(targetPlayers[i]+",");
}
System.out.println("]");
}
private int getNumTargets() {
int numTargets = 0;
for( int j = 0; j < target.length; j++ ) {
if( null != target[j] ) {
numTargets++;
}
}
for( int k = 0; k < targetPlayers.length; k++ ) {
if( null != targetPlayers[k] ) {
numTargets++;
}
}
//DEBUG
System.out.println("Fireball - numTargets = "+numTargets);
return numTargets;
}
};//SpellAbility
final Input input = new Input() {
private static final long serialVersionUID = 1099272655273322957L;
@Override
public void showMessage() {
AllZone.Display.showMessage("Select target creatures and/or players. Currently, "+getNumTargets()+" targets. Click OK when done.");
}
private int getNumTargets() {
int numTargets = 0;
for( int j = 0; j < target.length; j++ ) {
if( null != target[j] ) {
numTargets++;
}
}
for( int k = 0; k < targetPlayers.length; k++ ) {
if( null != targetPlayers[k] ) {
numTargets++;
}
}
//DEBUG
System.out.println("Fireball - numTargets = "+numTargets);
return numTargets;
}
@Override
public void selectButtonCancel() { stop(); }
@Override
public void selectButtonOK() {
if(this.isFree()) {
this.setFree(false);
AllZone.Stack.add(spell);
stop();
} else stopSetNext(new Input_PayManaCost(spell));
}
@Override
public void selectCard(Card c, PlayerZone zone) {
if( !CardFactoryUtil.canTarget(card, c)) {
AllZone.Display.showMessage("Cannot target this card.");
return; //cannot target
}
for(int i = 0; i < index[0]; i++) {
if(c.equals(target[i])) {
AllZone.Display.showMessage("You have already selected this target.");
return; //cannot target the same creature twice.
}
}
if(c.isCreature() && zone.is(Constant.Zone.Play)) {
target[index[0]] = c;
index[0]++;
showMessage();
/*if(index[0] == target.length) {
if(this.isFree()) {
this.setFree(false);
AllZone.Stack.add(spell);
stop();
} else stopSetNext(new Input_PayManaCost(spell));
}*/
}
}//selectCard()
@Override
public void selectPlayer(String player) {
for(int i = 0; i < index2[0]; i++) {
if(player.equals(targetPlayers[i])) {
AllZone.Display.showMessage("You have already selected this player.");
return; //cannot target the same player twice.
}
}
//spell.setTargetPlayer(player);
targetPlayers[index2[0]] = player;
index2[0]++;
showMessage();
}
};//Input
Input runtime = new Input() {
private static final long serialVersionUID = 3522833806455511494L;
@Override
public void showMessage() {
index[0] = 0;
index2[0] = 0;
stopSetNext(input);
}
};//Input
card.clearSpellAbility();
card.addSpellAbility(spell);
spell.setBeforePayMana(runtime);
}//*************** END ************ END **************************
// Cards with Cycling abilities
// -1 means keyword "Cycling" not found
if(hasKeyword(card, "Cycling") != -1) {