- Some fixes related to SpellAbility_Requirements and copying spells onto the stack.

This commit is contained in:
jendave
2011-08-06 13:03:57 +00:00
parent f87be965b3
commit 95918c781e
2 changed files with 20 additions and 13 deletions

View File

@@ -2822,11 +2822,9 @@ public class GameAction {
if (sa.getPayCosts() != null){
Target_Selection ts = new Target_Selection(sa.getTarget(), sa);
Cost_Payment payment = new Cost_Payment(sa.getPayCosts(), sa);
payment.getCost().setMana(sa.getAdditionalManaCost());
payment.changeCost();
SpellAbility_Requirements req = new SpellAbility_Requirements(sa, ts, payment);
req.setFree(true);
req.fillRequirements();
}
else if(sa.getBeforePayMana() == null) {

View File

@@ -6,6 +6,8 @@ public class SpellAbility_Requirements {
private SpellAbility ability = null;
private Target_Selection select = null;
private Cost_Payment payment = null;
private boolean isFree = false;
public void setFree(boolean bFree) { isFree = bFree; }
private PlayerZone fromZone = null;
private boolean bCasting = false;
@@ -32,13 +34,13 @@ public class SpellAbility_Requirements {
AllZone.Stack.freezeStack();
// Skip to paying if parent ability doesn't target and has no subAbilities.
if (!select.doesTarget() && ability.getSubAbility() == null)
startPaying();
else{
if (select.doesTarget() || ability.getSubAbility() != null){
select.setRequirements(this);
select.resetTargets();
select.chooseTargets();
}
else
needPayment();
}
public void finishedTargeting(){
@@ -53,7 +55,15 @@ public class SpellAbility_Requirements {
AllZone.Stack.clearFrozen();
return;
}
startPaying();
else
needPayment();
}
public void needPayment(){
if (!isFree)
startPaying();
else
finishPaying();
}
public void startPaying(){
@@ -62,13 +72,12 @@ public class SpellAbility_Requirements {
}
public void finishPaying(){
if (payment.isAllPaid())
if (isFree || payment.isAllPaid())
addAbilityToStack();
else if (payment.isCanceled()){
if (bCasting){ // and not a copy
// add back to hand
fromZone.add(ability.getSourceCard());
}
if (bCasting && !ability.getSourceCard().isCopiedSpell())
fromZone.add(ability.getSourceCard()); // add back to hand
if (select != null)
select.resetTargets();