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

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

View File

@@ -33,6 +33,8 @@ public enum GameLossReason {
// 104.3e and others
/** The Spell effect. */
SpellEffect,
EdhGeneralDamage,
OpponentWon

View File

@@ -88,6 +88,8 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
/** The poison counters. */
private int poisonCounters = 0;
private int edhGeneralDamage = 0;
/** The life. */
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.executeDamageToPlayerEffects(this, source, damageToDo);
@@ -916,20 +921,6 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
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>
* Getter for the field <code>assignedDamage</code>.
@@ -2162,6 +2153,10 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
if (hasNoLife && !this.cantLoseForZeroOrLessLife()) {
return this.loseConditionMet(GameLossReason.LifeReachedZero, null);
}
if(this.edhGeneralDamage >= 21) {
return this.loseConditionMet(GameLossReason.EdhGeneralDamage, null);
}
return false;
}

View File

@@ -72,6 +72,7 @@ public class PlayerOutcome {
case Poisoned: return "lost because of obtaining 10 poison counters";
case OpponentWon: return "lost because an opponent has won by 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)";
}