Added player's loss condition for 21 damage from generals

This commit is contained in:
Maxmtg
2013-04-01 21:49:12 +00:00
parent 998c8dae8b
commit 49f288197d
4 changed files with 23 additions and 16 deletions

View File

@@ -9139,4 +9139,13 @@ public class Card extends GameEntity implements Comparable<Card> {
cardRules = r; cardRules = r;
} }
/**
* TODO: Write javadoc for this method.
* @return
*/
public boolean isEdhGeneral() {
// TODO - have a field
return false;
}
} // end Card class } // end Card class

View File

@@ -34,6 +34,8 @@ public enum GameLossReason {
/** The Spell effect. */ /** The Spell effect. */
SpellEffect, SpellEffect,
EdhGeneralDamage,
OpponentWon OpponentWon
/* /*

View File

@@ -88,6 +88,8 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
/** The poison counters. */ /** The poison counters. */
private int poisonCounters = 0; private int poisonCounters = 0;
private int edhGeneralDamage = 0;
/** The life. */ /** The life. */
private int life = 20; private int life = 20;
@@ -641,7 +643,10 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
} }
} }
this.addAssignedDamage(damageToDo, source); this.assignedDamage.put(source, damageToDo);
if(source.isEdhGeneral())
this.edhGeneralDamage+= damageToDo;
GameActionUtil.executeDamageDealingEffects(source, damageToDo); GameActionUtil.executeDamageDealingEffects(source, damageToDo);
GameActionUtil.executeDamageToPlayerEffects(this, source, damageToDo); GameActionUtil.executeDamageToPlayerEffects(this, source, damageToDo);
@@ -916,20 +921,6 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
this.assignedDamage.clear(); this.assignedDamage.clear();
} }
/**
* <p>
* addAssignedDamage.
* </p>
*
* @param n
* a int.
* @param source
* a {@link forge.Card} object.
*/
public final void addAssignedDamage(final int n, final Card source) {
this.assignedDamage.put(source, n);
}
/** /**
* <p> * <p>
* Getter for the field <code>assignedDamage</code>. * Getter for the field <code>assignedDamage</code>.
@@ -2163,6 +2154,10 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
return this.loseConditionMet(GameLossReason.LifeReachedZero, null); return this.loseConditionMet(GameLossReason.LifeReachedZero, null);
} }
if(this.edhGeneralDamage >= 21) {
return this.loseConditionMet(GameLossReason.EdhGeneralDamage, null);
}
return false; return false;
} }

View File

@@ -72,6 +72,7 @@ public class PlayerOutcome {
case Poisoned: return "lost because of obtaining 10 poison counters"; case Poisoned: return "lost because of obtaining 10 poison counters";
case OpponentWon: return "lost because an opponent has won by spell '" + loseConditionSpell + "'"; case OpponentWon: return "lost because an opponent has won by spell '" + loseConditionSpell + "'";
case SpellEffect: return "lost due to effect of spell '" + loseConditionSpell + "'"; case SpellEffect: return "lost due to effect of spell '" + loseConditionSpell + "'";
case EdhGeneralDamage: return "lost due to accumulation of 21 damage from generals";
} }
return "lost for unknown reason (this is a bug)"; return "lost for unknown reason (this is a bug)";
} }