mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Code cleanup
This commit is contained in:
@@ -50,8 +50,7 @@ public class HumanPlaySpellAbility {
|
|||||||
this.payment = cp;
|
this.payment = cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void playAbility(boolean mayChooseTargets, boolean isFree, boolean skipStack) {
|
||||||
public final void playAbility(boolean mayChoseTargets, boolean isFree, boolean skipStack) {
|
|
||||||
final Game game = ability.getActivatingPlayer().getGame();
|
final Game game = ability.getActivatingPlayer().getGame();
|
||||||
|
|
||||||
// used to rollback
|
// used to rollback
|
||||||
@@ -72,8 +71,8 @@ public class HumanPlaySpellAbility {
|
|||||||
// is only executed or evaluated if the first argument does not suffice to determine the value of the expression
|
// is only executed or evaluated if the first argument does not suffice to determine the value of the expression
|
||||||
boolean prerequisitesMet = this.announceValuesLikeX()
|
boolean prerequisitesMet = this.announceValuesLikeX()
|
||||||
&& this.announceType()
|
&& this.announceType()
|
||||||
&& ( !mayChoseTargets || setupTargets() ) // if you can choose targets, then do choose them.
|
&& (!mayChooseTargets || setupTargets()) // if you can choose targets, then do choose them.
|
||||||
&& ( isFree || this.payment.payCost(game) );
|
&& (isFree || this.payment.payCost(game));
|
||||||
|
|
||||||
|
|
||||||
if (!prerequisitesMet) {
|
if (!prerequisitesMet) {
|
||||||
@@ -88,7 +87,6 @@ public class HumanPlaySpellAbility {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isFree || this.payment.isFullyPaid()) {
|
if (isFree || this.payment.isFullyPaid()) {
|
||||||
if (skipStack) {
|
if (skipStack) {
|
||||||
AbilityUtils.resolve(this.ability);
|
AbilityUtils.resolve(this.ability);
|
||||||
@@ -100,11 +98,10 @@ public class HumanPlaySpellAbility {
|
|||||||
|
|
||||||
// no worries here. The same thread must resolve, and by this moment ability will have been resolved already
|
// no worries here. The same thread must resolve, and by this moment ability will have been resolved already
|
||||||
// Triggers haven't resolved yet ??
|
// Triggers haven't resolved yet ??
|
||||||
if (mayChoseTargets) {
|
if (mayChooseTargets) {
|
||||||
clearTargets(ability);
|
clearTargets(ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean setupTargets() {
|
private final boolean setupTargets() {
|
||||||
@@ -114,16 +111,17 @@ public class HumanPlaySpellAbility {
|
|||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
do {
|
do {
|
||||||
TargetRestrictions tgt = currentAbility.getTargetRestrictions();
|
TargetRestrictions tgt = currentAbility.getTargetRestrictions();
|
||||||
if( tgt != null && tgt.doesTarget()) {
|
if (tgt != null && tgt.doesTarget()) {
|
||||||
clearTargets(currentAbility);
|
clearTargets(currentAbility);
|
||||||
Player targetingPlayer = ability.hasParam("TargetingPlayer") ?
|
Player targetingPlayer = ability.hasParam("TargetingPlayer") ?
|
||||||
AbilityUtils.getDefinedPlayers(source, ability.getParam("TargetingPlayer"), currentAbility).get(0) : ability.getActivatingPlayer();
|
AbilityUtils.getDefinedPlayers(source, ability.getParam("TargetingPlayer"), currentAbility).get(0) : ability.getActivatingPlayer();
|
||||||
if (targetingPlayer.isHuman()) {
|
if (targetingPlayer.isHuman()) {
|
||||||
final TargetSelection select = new TargetSelection(currentAbility);
|
final TargetSelection select = new TargetSelection(currentAbility);
|
||||||
if (!select.chooseTargets(null) ) {
|
if (!select.chooseTargets(null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else { //AI
|
}
|
||||||
|
else { //AI
|
||||||
return currentAbility.doTrigger(true, targetingPlayer);
|
return currentAbility.doTrigger(true, targetingPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +160,6 @@ public class HumanPlaySpellAbility {
|
|||||||
game.getStack().clearFrozen();
|
game.getStack().clearFrozen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean announceValuesLikeX() {
|
private boolean announceValuesLikeX() {
|
||||||
// Announcing Requirements like Choosing X or Multikicker
|
// Announcing Requirements like Choosing X or Multikicker
|
||||||
// SA Params as comma delimited list
|
// SA Params as comma delimited list
|
||||||
@@ -176,13 +173,15 @@ public class HumanPlaySpellAbility {
|
|||||||
boolean allowZero = !ability.hasParam("XCantBe0") && (!isX || manaCost == null || manaCost.canXbe0());
|
boolean allowZero = !ability.hasParam("XCantBe0") && (!isX || manaCost == null || manaCost.canXbe0());
|
||||||
|
|
||||||
Integer value = ability.getActivatingPlayer().getController().announceRequirements(ability, varName, allowZero);
|
Integer value = ability.getActivatingPlayer().getController().announceRequirements(ability, varName, allowZero);
|
||||||
if ( null == value )
|
if (value == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ability.setSVar(varName, value.toString());
|
ability.setSVar(varName, value.toString());
|
||||||
if( "Multikicker".equals(varName) ) {
|
if ("Multikicker".equals(varName)) {
|
||||||
ability.getSourceCard().setKickerMagnitude(value);
|
ability.getSourceCard().setKickerMagnitude(value);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ability.getSourceCard().setSVar(varName, value.toString());
|
ability.getSourceCard().setSVar(varName, value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user