- Added early stages of SpellAbility_Restriction, which can activate Abilities from different zones.

- Ability_Activated.canPlay() now checks SA_Restriction.canPlay()
- Added Channel ability for Ghost-Lit Redeemer
- Added Ghost-Lit Raider
This commit is contained in:
jendave
2011-08-06 09:24:25 +00:00
parent 7da15f7895
commit 0112d55cf2
10 changed files with 123 additions and 11 deletions

2
.gitattributes vendored
View File

@@ -1621,6 +1621,7 @@ res/cardsfolder/ghitu_fire_eater.txt -text svneol=native#text/plain
res/cardsfolder/ghitu_slinger.txt -text svneol=native#text/plain
res/cardsfolder/ghitu_war_cry.txt -text svneol=native#text/plain
res/cardsfolder/ghor_clan_bloodscale.txt -text svneol=native#text/plain
res/cardsfolder/ghost_lit_raider.txt -text svneol=native#text/plain
res/cardsfolder/ghost_lit_redeemer.txt -text svneol=native#text/plain
res/cardsfolder/ghost_ship.txt -text svneol=native#text/plain
res/cardsfolder/ghost_tactician.txt -text svneol=native#text/plain
@@ -5482,6 +5483,7 @@ src/forge/SpellAbility.java -text svneol=native#text/plain
src/forge/SpellAbilityList.java svneol=native#text/plain
src/forge/SpellAbilityUtil.java svneol=native#text/plain
src/forge/SpellAbility_Requirements.java -text svneol=native#text/plain
src/forge/SpellAbility_Restriction.java -text svneol=native#text/plain
src/forge/Spell_Evoke.java svneol=native#text/plain
src/forge/Spell_Permanent.java svneol=native#text/plain
src/forge/StackObserver.java svneol=native#text/plain

View File

@@ -0,0 +1,10 @@
Name:Ghost-Lit Raider
ManaCost:2 R
Types:Creature Spirit
Text:no text
A:AB$DealDamage|Cost$2 R T|Tgt$TgtC|NumDmg$2|SpellDescription$CARDNAME deals 2 damage to target creature.
A:AB$DealDamage|Cost$3 R Discard<1/CARDNAME>|Tgt$TgtC|NumDmg$4|ActivatingZone$Hand|SpellDescription$CARDNAME deals 4 damage to target creature.
PT:2/1
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/ghost_lit_raider.jpg
End

View File

@@ -1,9 +1,10 @@
Name:Ghost-Lit Redeemer
ManaCost:W
Types:Creature Spirit
Text:(NOTE: "Channel" not implemented.)
K:abGainLife W T:2
Text:no text
A:AB$GainLife|Cost$W T|LifeAmount$2|SpellDescription$You gain 2 life.
A:AB$GainLife|Cost$1 W Discard<1/CARDNAME>|LifeAmount$4|ActivatingZone$Hand|SpellDescription$You gain 4 life.
PT:1/1
SVar:Rarity:Uncommon
SVar:Picture:http://resources.wizards.com/magic/cards/sok/en-us/card74082.jpg
End
End

View File

@@ -241,6 +241,9 @@ public class AbilityFactory {
if (!isTargeted)
SA.setStackDescription(hostCard.getName());
if (mapParams.containsKey("ActivatingZone"))
SA.getRestrictions().setActivateZone(mapParams.get("ActivatingZone"));
return SA;
}

View File

@@ -19,13 +19,17 @@ abstract public class Ability_Activated extends SpellAbility implements java.io.
if (c.isFaceDown() && isIntrinsic()) // Intrinsic abilities can't be activated by face down cards
return false;
if(c.isCreature()) {
if(c.isCreature() && AllZone.getZone(c).getZone().equals(Constant.Zone.Play)) {
CardList Silence = AllZoneUtil.getPlayerCardsInPlay(getSourceCard().getController().getOpponent());
Silence = Silence.getName("Linvala, Keeper of Silence");
if (Silence.size() != 0)
return false;
}
return Cost_Payment.canPayAdditionalCosts(payCosts, this) && AllZone.GameAction.isCardInPlay(c);
if (!(getRestrictions().canPlay(c)))
return false;
return Cost_Payment.canPayAdditionalCosts(payCosts, this);
//TODO: make sure you can't play the Computer's activated abilities
}
}

View File

@@ -56,6 +56,8 @@ public class Ability_Cost {
public int getDiscardAmount() { return discardAmount; }
private String discardType = "";
public String getDiscardType() { return discardType; }
private boolean discardThis = false;
public boolean getDiscardThis() { return discardThis;}
private boolean returnCost = false; // Return something to owner's hand
public boolean getReturnCost() { return returnCost; }
@@ -120,6 +122,7 @@ public class Ability_Cost {
discardAmount = Integer.parseInt(splitStr[0]);
discardType = splitStr[1];
discardThis = (discardType.equals("CARDNAME"));
}
String sacStr = "Sac<";
@@ -254,7 +257,11 @@ public class Ability_Cost {
cost.append("discard ");
else
cost.append("and discard ");
if (discardType.equals("Hand")){
if (discardThis){
cost.append(name);
}
else if (discardType.equals("Hand")){
cost.append(" your hand");
}
else{
@@ -368,7 +375,11 @@ public class Ability_Cost {
cost.append("Discard ");
else
cost.append(", discard ");
if (discardType.equals("Hand")){
if (discardThis){
cost.append(name);
}
else if (discardType.equals("Hand")){
cost.append(" your hand");
}
else{

View File

@@ -270,7 +270,12 @@ public class ComputerUtil
CardList handList = new CardList(zone.getCards());
String discType = cost.getDiscardType();
int discAmount = cost.getDiscardAmount();
if (discType.equals("Hand")){
if (cost.getDiscardThis()){
if (!AllZone.getZone(card).equals(Constant.Zone.Hand))
return false;
}
else if (discType.equals("Hand")){
// this will always work
}
else{

View File

@@ -113,7 +113,12 @@ public class Cost_Payment {
CardList handList = new CardList(zone.getCards());
String discType = cost.getDiscardType();
int discAmount = cost.getDiscardAmount();
if (discType.equals("Hand")){
if (cost.getDiscardThis()){
if (!AllZone.getZone(card).getZone().equals(Constant.Zone.Hand))
return false;
}
else if (discType.equals("Hand")){
// this will always work
}
else{
@@ -246,7 +251,12 @@ public class Cost_Payment {
CardList handList = new CardList(zone.getCards());
String discType = cost.getDiscardType();
int discAmount = cost.getDiscardAmount();
if (discType.equals("Hand")){
if (cost.getDiscardThis()){
AllZone.GameAction.discard(card, ability);
payDiscard = true;
}
else if (discType.equals("Hand")){
AllZone.GameAction.discardHand(card.getController(), ability);
payDiscard = true;
}
@@ -392,6 +402,11 @@ public class Cost_Payment {
}
}
if (cost.getDiscardThis()){
if (!AllZone.getZone(card).equals(Constant.Zone.Hand))
return;
}
if (cost.getTapXTypeCost()) {
boolean tap = cost.getTap();
@@ -433,7 +448,11 @@ public class Cost_Payment {
if (cost.getDiscardCost()){
String discType = cost.getDiscardType();
int discAmount = cost.getDiscardAmount();
if (discType.equals("Hand")){
if (cost.getDiscardThis()){
AllZone.GameAction.discard(card, ability);
}
else if (discType.equals("Hand")){
AllZone.GameAction.discardHand(card.getController(), ability);
}
else{

View File

@@ -45,6 +45,8 @@ public abstract class SpellAbility {
protected Ability_Cost payCosts = null;
protected Target chosenTarget = null;
private SpellAbility_Restriction restrictions = new SpellAbility_Restriction();
private CardList sacrificedCards = null;
private Command cancelCommand = Command.Blank;
@@ -252,6 +254,14 @@ public abstract class SpellAbility {
chosenTarget = tgt;
}
public void setRestrictions(SpellAbility_Restriction restrict){
restrictions = restrict;
}
public SpellAbility_Restriction getRestrictions(){
return restrictions;
}
public void addSacrificedCost(Card c){
if (sacrificedCards == null)
sacrificedCards = new CardList();

View File

@@ -0,0 +1,47 @@
package forge;
public class SpellAbility_Restriction {
// A class for handling SpellAbility Restrictions. These restrictions include:
// Zone, Phase, OwnTurn, Speed (instant/sorcery), Amount per Turn, Player,
// Threshold, Metalcraft, LevelRange, etc
// Each value will have a default, that can be overridden (mostly by AbilityFactory)
// The CanPlay function will use these values to determine if the current game state is ok with these restrictions
// default values for Sorcery speed abilities
String activateZone = Constant.Zone.Play;
public void setActivateZone(String zone){
activateZone = zone;
}
public String getActivateZone(){
return activateZone;
}
/*
* Some restrictions to come...
boolean bInstantActivation = false;
ArrayList<String> activatePhases = new ArrayList<String>();
int amountPerTurn = -1;
int activatedPerTurn = 0;
boolean bAnyPlayer = false;
boolean bHasThreshold = false;
boolean bHasMetalcraft = false;
int levelMin = 0;
int levelMax = 0;
boolean bThreshold = false;
boolean bMetalcraft = false;
*/
SpellAbility_Restriction(){ }
//SpellAbility_Restriction(String zone, Phase phase, boolean bIsInstantSpeed, int perTurn, String activatingPlayer){}
public boolean canPlay(Card c){
if (!AllZone.getZone(c).getZone().equals(activateZone))
return false;
return true;
}
}