mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
add Scry to AbilityFactory_ZoneAffecting
This commit is contained in:
@@ -354,6 +354,15 @@ public class AbilityFactory {
|
||||
SA = AbilityFactory_ZoneAffecting.createDrawbackMill(this);
|
||||
}
|
||||
|
||||
if (API.equals("Scry")){
|
||||
if (isAb)
|
||||
SA = AbilityFactory_ZoneAffecting.createAbilityScry(this);
|
||||
else if (isSp)
|
||||
SA = AbilityFactory_ZoneAffecting.createSpellScry(this);
|
||||
else if (isDb)
|
||||
SA = AbilityFactory_ZoneAffecting.createDrawbackScry(this);
|
||||
}
|
||||
|
||||
if (API.equals("Sacrifice")){
|
||||
if (isAb)
|
||||
SA = AbilityFactory_Sacrifice.createAbilitySacrifice(this);
|
||||
|
||||
@@ -875,4 +875,175 @@ public class AbilityFactory_ZoneAffecting {
|
||||
// if parent draws cards, make sure cards in hand + cards drawn > 0
|
||||
return true;
|
||||
}// discardCheckDrawbackAI()
|
||||
|
||||
//**********************************************************************
|
||||
//******************************* SCRY *********************************
|
||||
//**********************************************************************
|
||||
|
||||
public static SpellAbility createDrawbackScry(final AbilityFactory AF){
|
||||
final SpellAbility dbScry = new Ability_Sub(AF.getHostCard(), AF.getAbTgt()){
|
||||
private static final long serialVersionUID = 7763043327497404630L;
|
||||
final AbilityFactory af = AF;
|
||||
|
||||
@Override
|
||||
public String getStackDescription(){
|
||||
// when getStackDesc is called, just build exactly what is happening
|
||||
return scryStackDescription(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
scryResolve(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chkAI_Drawback() {
|
||||
return scryTargetAI(af, this);
|
||||
}
|
||||
|
||||
};
|
||||
return dbScry;
|
||||
}
|
||||
|
||||
private static void scryResolve(final AbilityFactory af, final SpellAbility sa){
|
||||
HashMap<String,String> params = af.getMapParams();
|
||||
|
||||
Card source = sa.getSourceCard();
|
||||
int num = 1;
|
||||
if (params.containsKey("ScryNum"))
|
||||
num = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("ScryNum"), sa);
|
||||
|
||||
ArrayList<Player> tgtPlayers;
|
||||
|
||||
Target tgt = af.getAbTgt();
|
||||
if (tgt != null)
|
||||
tgtPlayers = tgt.getTargetPlayers();
|
||||
else
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), af.getMapParams().get("Defined"), sa);
|
||||
|
||||
for(Player p : tgtPlayers) {
|
||||
if (tgt == null || p.canTarget(af.getHostCard())){
|
||||
p.scry(num);
|
||||
}
|
||||
}
|
||||
|
||||
if (af.hasSubAbility()){
|
||||
Ability_Sub abSub = sa.getSubAbility();
|
||||
if (abSub != null){
|
||||
abSub.resolve();
|
||||
}
|
||||
else{
|
||||
String DrawBack = params.get("SubAbility");
|
||||
if (af.hasSubAbility())
|
||||
CardFactoryUtil.doDrawBack(DrawBack, 0, source.getController(), source.getController().getOpponent(), tgtPlayers.get(0), source, null, sa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean scryTargetAI(AbilityFactory af, SpellAbility sa) {
|
||||
Target tgt = af.getAbTgt();
|
||||
|
||||
if (tgt != null) {
|
||||
// ability is targeted
|
||||
tgt.resetTargets();
|
||||
|
||||
tgt.addTarget(AllZone.ComputerPlayer);
|
||||
}
|
||||
|
||||
return true;
|
||||
}// scryTargetAI()
|
||||
|
||||
public static String scryStackDescription(AbilityFactory af, SpellAbility sa){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (!(sa instanceof Ability_Sub))
|
||||
sb.append(sa.getSourceCard().getName()).append(" - ");
|
||||
else
|
||||
sb.append(" ");
|
||||
|
||||
ArrayList<Player> tgtPlayers;
|
||||
|
||||
Target tgt = af.getAbTgt();
|
||||
if (tgt != null)
|
||||
tgtPlayers = tgt.getTargetPlayers();
|
||||
else
|
||||
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), af.getMapParams().get("Defined"), sa);
|
||||
|
||||
for(Player p : tgtPlayers)
|
||||
sb.append(p.toString()).append(" ");
|
||||
|
||||
int num = 1;
|
||||
if (af.getMapParams().containsKey("ScryNum"))
|
||||
num = AbilityFactory.calculateAmount(sa.getSourceCard(), af.getMapParams().get("ScryNum"), sa);
|
||||
|
||||
sb.append("scrys (").append(num).append(").");
|
||||
|
||||
Ability_Sub abSub = sa.getSubAbility();
|
||||
if (abSub != null){
|
||||
sb.append(abSub.getStackDescription());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static boolean scryCanPlayAI(final AbilityFactory af, SpellAbility sa){
|
||||
return true;
|
||||
}
|
||||
|
||||
public static SpellAbility createAbilityScry(final AbilityFactory AF){
|
||||
final SpellAbility abScry = new Ability_Activated(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()){
|
||||
private static final long serialVersionUID = 2631175859655699419L;
|
||||
final AbilityFactory af = AF;
|
||||
|
||||
@Override
|
||||
public String getStackDescription(){
|
||||
return scryStackDescription(af, this);
|
||||
}
|
||||
|
||||
public boolean canPlay(){
|
||||
// super takes care of AdditionalCosts
|
||||
return super.canPlay();
|
||||
}
|
||||
|
||||
public boolean canPlayAI()
|
||||
{
|
||||
return scryCanPlayAI(af,this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
scryResolve(af, this);
|
||||
}
|
||||
|
||||
};
|
||||
return abScry;
|
||||
}
|
||||
|
||||
public static SpellAbility createSpellScry(final AbilityFactory AF){
|
||||
final SpellAbility spScry = new Spell(AF.getHostCard(), AF.getAbCost(), AF.getAbTgt()){
|
||||
private static final long serialVersionUID = 6273876397392154403L;
|
||||
final AbilityFactory af = AF;
|
||||
|
||||
@Override
|
||||
public String getStackDescription(){
|
||||
return scryStackDescription(af, this);
|
||||
}
|
||||
|
||||
public boolean canPlay(){
|
||||
return super.canPlay();
|
||||
}
|
||||
|
||||
public boolean canPlayAI()
|
||||
{
|
||||
return scryCanPlayAI(af, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
scryResolve(af, this);
|
||||
}
|
||||
|
||||
};
|
||||
return spScry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +103,7 @@ public class HumanPlayer extends Player{
|
||||
int num = N;
|
||||
for(int i = 0; i < num; i++) {
|
||||
Object o;
|
||||
o = AllZone.Display.getChoiceOptional("Choose a card to put on the bottom of your library.",
|
||||
topN.toArray());
|
||||
o = AllZone.Display.getChoiceOptional("Put on bottom of library.",topN.toArray());
|
||||
if(o != null) {
|
||||
Card c = (Card) o;
|
||||
topN.remove(c);
|
||||
@@ -115,7 +114,7 @@ public class HumanPlayer extends Player{
|
||||
num = topN.size();
|
||||
if(num > 0) for(int i = 0; i < num; i++) {
|
||||
Object o;
|
||||
o = AllZone.Display.getChoice("Choose a card to put on the top of your library.", topN.toArray());
|
||||
o = AllZone.Display.getChoice("Put on top of library.", topN.toArray());
|
||||
if(o != null) {
|
||||
Card c = (Card) o;
|
||||
topN.remove(c);
|
||||
|
||||
Reference in New Issue
Block a user