- Damage Functions now return whether or not they dealt any damage

- DamageAll can now Remember what Cards it damaged
- Added Aggravate
This commit is contained in:
Sol
2012-04-27 16:48:49 +00:00
parent c7a09910c1
commit 560bc516f7
6 changed files with 59 additions and 37 deletions

1
.gitattributes vendored
View File

@@ -125,6 +125,7 @@ res/cardsfolder/a/ageless_sentinels.txt -text
res/cardsfolder/a/agent_of_masks.txt svneol=native#text/plain
res/cardsfolder/a/agent_of_shauku.txt svneol=native#text/plain
res/cardsfolder/a/agent_of_stromgald.txt svneol=native#text/plain
res/cardsfolder/a/aggravate.txt -text
res/cardsfolder/a/aggression.txt svneol=native#text/plain
res/cardsfolder/a/aggressive_urge.txt svneol=native#text/plain
res/cardsfolder/a/agility.txt svneol=native#text/plain

View File

@@ -0,0 +1,11 @@
Name:Aggravate
ManaCost:3 R R
Types:Instant
Text:no text
A:SP$ DamageAll | Cost$ 3 R R | ValidTgts$ Player | TgtPrompt$ Select target player | NumDmg$ 1 | RememberDamaged$ True | ValidCards$ Creature | ValidDescription$ each creature target player controls. | SubAbility$ DBAttack | SpellDescription$ CARDNAME deals 1 damage to each creature target player controls.
SVar:DBAttack:DB$ PumpAll | Defined$ Remembered | KW$ HIDDEN CARDNAME attacks each turn if able. | SubAbility$ DBCleanup | SpellDescription$ Each creature dealt damage this way attacks this turn if able.
SVar:DBCleanup:DB$Cleanup | ClearRemembered$ True
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/aggravate.jpg
SetInfo:AVR|Uncommon|http://magiccards.info/scans/en/avr/125.jpg
End

View File

@@ -8114,14 +8114,15 @@ public class Card extends GameEntity implements Comparable<Card> {
* a {@link forge.Card} object.
* @param isCombat
* a boolean.
* @return whether or not damage as dealt
*/
@Override
public final void addDamageAfterPrevention(final int damageIn, final Card source, final boolean isCombat) {
public final boolean addDamageAfterPrevention(final int damageIn, final Card source, final boolean isCombat) {
final int damageToAdd = damageIn;
boolean wither = false;
if (damageToAdd == 0) {
return; // Rule 119.8
return false; // Rule 119.8
}
System.out.println("Adding " + damageToAdd + " damage to " + this.getName());
@@ -8142,7 +8143,7 @@ public class Card extends GameEntity implements Comparable<Card> {
if (this.isPlaneswalker()) {
this.subtractCounter(Counters.LOYALTY, damageToAdd);
return;
return true;
}
if ((source.hasKeyword("Wither") || source.hasKeyword("Infect"))) {
@@ -8159,7 +8160,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} else if (AllZoneUtil.isCardInPlay(this) && !wither) {
this.damage += damageToAdd;
}
return true;
}
private String curSetCode = "";

View File

@@ -75,14 +75,15 @@ public abstract class GameEntity extends MyObservable {
* a int.
* @param source
* a {@link forge.Card} object.
* @return whether or not damage was dealt
*/
public void addDamage(final int damage, final Card source) {
public boolean addDamage(final int damage, final Card source) {
int damageToDo = damage;
damageToDo = this.replaceDamage(damageToDo, source, false);
damageToDo = this.preventDamage(damageToDo, source, false);
this.addDamageAfterPrevention(damageToDo, source, false);
return this.addDamageAfterPrevention(damageToDo, source, false);
}
/**
@@ -94,13 +95,14 @@ public abstract class GameEntity extends MyObservable {
* a int.
* @param source
* a {@link forge.Card} object.
* @return whether or not damage was dealt
*/
public void addDamageWithoutPrevention(final int damage, final Card source) {
public boolean addDamageWithoutPrevention(final int damage, final Card source) {
int damageToDo = damage;
damageToDo = this.replaceDamage(damageToDo, source, false);
this.addDamageAfterPrevention(damageToDo, source, false);
return this.addDamageAfterPrevention(damageToDo, source, false);
}
// This function handles damage after replacement and prevention effects are
@@ -116,10 +118,9 @@ public abstract class GameEntity extends MyObservable {
* a {@link forge.Card} object.
* @param isCombat
* a boolean.
* @return whether or not damage was dealt
*/
public void addDamageAfterPrevention(final int damage, final Card source, final boolean isCombat) {
}
public abstract boolean addDamageAfterPrevention(final int damage, final Card source, final boolean isCombat);
/**
* <p>
@@ -197,9 +198,7 @@ public abstract class GameEntity extends MyObservable {
* a boolean.
* @return a int.
*/
public int replaceDamage(final int damage, final Card source, final boolean isCombat) {
return 0;
}
public abstract int replaceDamage(final int damage, final Card source, final boolean isCombat);
/**
* <p>
@@ -214,9 +213,7 @@ public abstract class GameEntity extends MyObservable {
* a boolean.
* @return a int.
*/
public int preventDamage(final int damage, final Card source, final boolean isCombat) {
return 0;
}
public abstract int preventDamage(final int damage, final Card source, final boolean isCombat);
// ////////////////////////
//

View File

@@ -1248,6 +1248,7 @@ public class AbilityFactoryDealDamage {
final ArrayList<Card> definedSources = AbilityFactory.getDefinedCards(sa.getSourceCard(),
params.get("DamageSource"), sa);
final Card card = definedSources.get(0);
final Card source = sa.getSourceCard();
final int dmg = this.getNumDamage(sa);
@@ -1275,13 +1276,17 @@ public class AbilityFactoryDealDamage {
list = AbilityFactory.filterListByType(list, params.get("ValidCards"), sa);
for (final Card c : list) {
c.addDamage(dmg, card);
if (c.addDamage(dmg, card) && params.containsKey("RememberDamaged")) {
source.addRemembered(c);
}
}
if (!players.equals("")) {
final ArrayList<Player> playerList = AbilityFactory.getDefinedPlayers(card, players, sa);
for (final Player p : playerList) {
p.addDamage(dmg, card);
if (p.addDamage(dmg, card) && params.containsKey("RememberDamaged")) {
source.addRemembered(p);
}
}
}
}

View File

@@ -516,10 +516,16 @@ public abstract class Player extends GameEntity {
* a {@link forge.Card} object.
* @param isCombat
* a boolean.
* @return whether or not damage was dealt
*/
@Override
public final void addDamageAfterPrevention(final int damage, final Card source, final boolean isCombat) {
public final boolean addDamageAfterPrevention(final int damage, final Card source, final boolean isCombat) {
final int damageToDo = damage;
if (damageToDo == 0) {
return false;
}
boolean infect = source.hasKeyword("Infect");
final StringBuilder sb = new StringBuilder(
"As long as you have 0 or less life, all damage is dealt to you as though its source had infect.");
@@ -547,26 +553,27 @@ public abstract class Player extends GameEntity {
this.loseLife(damageToDo, source);
}
}
if (damageToDo > 0) {
this.addAssignedDamage(damageToDo, source);
GameActionUtil.executeDamageDealingEffects(source, damageToDo);
GameActionUtil.executeDamageToPlayerEffects(this, source, damageToDo);
if (isCombat) {
final ArrayList<String> types = source.getType();
for (final String type : types) {
source.getController().addProwlType(type);
}
this.addAssignedDamage(damageToDo, source);
GameActionUtil.executeDamageDealingEffects(source, damageToDo);
GameActionUtil.executeDamageToPlayerEffects(this, source, damageToDo);
if (isCombat) {
final ArrayList<String> types = source.getType();
for (final String type : types) {
source.getController().addProwlType(type);
}
// Run triggers
final HashMap<String, Object> runParams = new HashMap<String, Object>();
runParams.put("DamageSource", source);
runParams.put("DamageTarget", this);
runParams.put("DamageAmount", damageToDo);
runParams.put("IsCombatDamage", isCombat);
AllZone.getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams);
}
// Run triggers
final HashMap<String, Object> runParams = new HashMap<String, Object>();
runParams.put("DamageSource", source);
runParams.put("DamageTarget", this);
runParams.put("DamageAmount", damageToDo);
runParams.put("IsCombatDamage", isCombat);
AllZone.getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams);
return true;
}
/**