mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
- Fix for GainLife Drawback
- Added LoseLife SubAbility handling - Converted Death Cultist to SubAbility
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
Name:Death Cultist
|
||||
ManaCost:B
|
||||
Types:Creature Human Wizard
|
||||
Text:Sacrifice Death Cultist: Target player loses 1 life and you gain 1 life.
|
||||
Text:no text
|
||||
PT:1/1
|
||||
A:AB$LoseLife | Cost$ Sac<1/CARDNAME> | ValidTgts$ player | TgtPrompt$ Target a player to lose a life | LifeAmount$ 1 | SubAbility$ YouGainLife/1 | SpellDescription$ Target player loses 1 life.
|
||||
A:AB$LoseLife | Cost$ Sac<1/CARDNAME> | ValidTgts$ player | TgtPrompt$ Target a player to lose a life | LifeAmount$ 1 | SubAbility$ SVar=DB1 | SpellDescription$ Target player loses 1 life and you gain 1 life.
|
||||
SVar:DB1:DB$GainLife | LifeAmount$ 1
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/death_cultist.jpg
|
||||
End
|
||||
|
||||
@@ -244,7 +244,7 @@ public class AbilityFactory {
|
||||
else if (isSp)
|
||||
SA = AbilityFactory_AlterLife.createSpellGainLife(this);
|
||||
else if (isDb)
|
||||
SA = AbilityFactory_AlterLife.createSpellGainLife(this);
|
||||
SA = AbilityFactory_AlterLife.createDrawbackGainLife(this);
|
||||
if(hasSubAbility())
|
||||
SA.setSubAbility(getSubAbility());
|
||||
}
|
||||
@@ -252,9 +252,13 @@ public class AbilityFactory {
|
||||
if (API.equals("LoseLife")){
|
||||
if (isAb)
|
||||
SA = AbilityFactory_AlterLife.createAbilityLoseLife(this);
|
||||
if (isSp){
|
||||
else if (isSp){
|
||||
SA = AbilityFactory_AlterLife.createSpellLoseLife(this);
|
||||
}
|
||||
else if (isDb)
|
||||
SA = AbilityFactory_AlterLife.createDrawbackLoseLife(this);
|
||||
if(hasSubAbility())
|
||||
SA.setSubAbility(getSubAbility());
|
||||
}
|
||||
|
||||
if (API.equals("Fog")){
|
||||
|
||||
@@ -123,17 +123,7 @@ public class AbilityFactory_AlterLife {
|
||||
@Override
|
||||
public String getStackDescription(){
|
||||
// when getStackDesc is called, just build exactly what is happening
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String name = af.getHostCard().getName();
|
||||
int amount = calculateAmount(af.getHostCard(), params.get("LifeAmount"), this);
|
||||
|
||||
Player player = getActivatingPlayer().getOpponent();
|
||||
|
||||
if (af.getAbTgt() != null)
|
||||
player = getTargetPlayer();
|
||||
sb.append(name).append(" - ").append(player).append(" loses ").append(amount).append(" life.");
|
||||
|
||||
return sb.toString();
|
||||
return loseLifeStackDescription(af, this);
|
||||
}
|
||||
|
||||
public boolean canPlay(){
|
||||
@@ -159,7 +149,7 @@ public class AbilityFactory_AlterLife {
|
||||
}
|
||||
|
||||
public static SpellAbility createSpellLoseLife(final AbilityFactory AF){
|
||||
final SpellAbility abLoseLife = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()){
|
||||
final SpellAbility spLoseLife = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()){
|
||||
private static final long serialVersionUID = -2966932725306192437L;
|
||||
|
||||
final AbilityFactory af = AF;
|
||||
@@ -168,16 +158,7 @@ public class AbilityFactory_AlterLife {
|
||||
@Override
|
||||
public String getStackDescription(){
|
||||
// when getStackDesc is called, just build exactly what is happening
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String name = af.getHostCard().getName();
|
||||
int amount = calculateAmount(af.getHostCard(), params.get("LifeAmount"), this);
|
||||
|
||||
Player player = getActivatingPlayer().getOpponent();
|
||||
if (af.getAbTgt() != null)
|
||||
player = getTargetPlayer();
|
||||
sb.append(name).append(" - ").append(player).append(" loses ").append(amount).append(" life.");
|
||||
|
||||
return sb.toString();
|
||||
return loseLifeStackDescription(af, this);
|
||||
}
|
||||
|
||||
public boolean canPlay(){
|
||||
@@ -199,7 +180,42 @@ public class AbilityFactory_AlterLife {
|
||||
loseLifeResolve(af, this, amount);
|
||||
}
|
||||
};
|
||||
return abLoseLife;
|
||||
return spLoseLife;
|
||||
}
|
||||
|
||||
public static SpellAbility createDrawbackLoseLife(final AbilityFactory AF){
|
||||
final SpellAbility dbLoseLife = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()){
|
||||
private static final long serialVersionUID = -2966932725306192437L;
|
||||
|
||||
final AbilityFactory af = AF;
|
||||
final HashMap<String,String> params = af.getMapParams();
|
||||
|
||||
@Override
|
||||
public String getStackDescription(){
|
||||
// when getStackDesc is called, just build exactly what is happening
|
||||
return loseLifeStackDescription(af, this);
|
||||
}
|
||||
|
||||
public boolean canPlayAI()
|
||||
{
|
||||
// if X depends on abCost, the AI needs to choose which card he would sacrifice first
|
||||
// then call xCount with that card to properly calculate the amount
|
||||
// Or choosing how many to sacrifice
|
||||
return loseLifeCanPlayAI(af, this, params.get("LifeAmount"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
int amount = calculateAmount(af.getHostCard(), params.get("LifeAmount"), this);
|
||||
loseLifeResolve(af, this, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAI_Drawback() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return dbLoseLife;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,6 +264,30 @@ public class AbilityFactory_AlterLife {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static String loseLifeStackDescription(AbilityFactory af, SpellAbility sa){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int amount = calculateAmount(af.getHostCard(), af.getMapParams().get("LifeAmount"), sa);
|
||||
|
||||
Player player = sa.getActivatingPlayer().getOpponent();
|
||||
|
||||
if (!(sa instanceof Ability_Sub))
|
||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||
else
|
||||
sb.append(" ");
|
||||
|
||||
if (af.getAbTgt() != null)
|
||||
player = sa.getTargetPlayer();
|
||||
sb.append(player).append(" loses ").append(amount).append(" life.");
|
||||
|
||||
Ability_Sub abSub = sa.getSubAbility();
|
||||
if (abSub != null) {
|
||||
abSub.setParent(sa);
|
||||
sb.append(abSub.getStackDescription());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static boolean gainLifeCanPlayAI(final AbilityFactory af, final SpellAbility sa, final String amountStr){
|
||||
Random r = new Random();
|
||||
Ability_Cost abCost = sa.getPayCosts();
|
||||
@@ -375,7 +415,6 @@ public class AbilityFactory_AlterLife {
|
||||
|
||||
public static void loseLifeResolve(final AbilityFactory af, final SpellAbility sa, int lifeAmount){
|
||||
HashMap<String,String> params = af.getMapParams();
|
||||
String DrawBack = params.get("SubAbility");
|
||||
Card card = af.getHostCard();
|
||||
|
||||
ArrayList<Player> tgtPlayers;
|
||||
@@ -392,7 +431,18 @@ public class AbilityFactory_AlterLife {
|
||||
if (tgt == null || p.canTarget(af.getHostCard()))
|
||||
p.loseLife(lifeAmount, sa.getSourceCard());
|
||||
|
||||
if (af.hasSubAbility())
|
||||
CardFactoryUtil.doDrawBack(DrawBack, lifeAmount, card.getController(), card.getController().getOpponent(), tgtPlayers.get(0), card, null, sa);
|
||||
if (af.hasSubAbility()){
|
||||
Ability_Sub abSub = sa.getSubAbility();
|
||||
if (abSub != null){
|
||||
if (abSub.getParent() == null)
|
||||
abSub.setParent(sa);
|
||||
abSub.resolve();
|
||||
}
|
||||
else{
|
||||
String DrawBack = params.get("SubAbility");
|
||||
if (af.hasSubAbility())
|
||||
CardFactoryUtil.doDrawBack(DrawBack, lifeAmount, card.getController(), card.getController().getOpponent(), tgtPlayers.get(0), card, null, sa);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user