- Added "PreventAllCombatDamage" [from(...)] [to(...)] keyword. Please test it on a few cards before we "mass" use it. As a side effect, fixed issue 155 (ebony horse target).
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-11-14 11:35:29 +00:00
parent 5781060d83
commit 9ca552093e
15 changed files with 2695 additions and 2577 deletions
+1
View File
@@ -665,6 +665,7 @@ type=Sorcery
text={2}, {T}: Untap target attacking creature you control. Prevent all combat damage that would be dealt to and dealt by that creature this turn. text={2}, {T}: Untap target attacking creature you control. Prevent all combat damage that would be dealt to and dealt by that creature this turn.
id=1108 id=1108
name=Ebony Horse name=Ebony Horse
auto={2}{T}:untap target(creature[attacking]|myBattlefield) && preventAllCombatDamage to(mytgt) ueot && preventAllCombatDamage from(mytgt) ueot
rarity=R rarity=R
mana={3} mana={3}
type=Artifact type=Artifact
+1
View File
@@ -121,6 +121,7 @@ drift_of_the_dead.txt
dromad_purebred.txt dromad_purebred.txt
dross_harvester.txt dross_harvester.txt
duskwalker.txt duskwalker.txt
ebony_horse.txt
elvish_piper.txt elvish_piper.txt
elvish_promenade.txt elvish_promenade.txt
emblem_of_the_warmind.txt emblem_of_the_warmind.txt
+27
View File
@@ -0,0 +1,27 @@
#2, Tap: Untap target attacking creature you control.
# Prevent all combat damage that would be dealt to and dealt by that creature this turn.
[INIT]
COMBATATTACKERS
[PLAYER1]
inplay:grizzly bears,ebony horse,mountain,swamp
[PLAYER2]
inplay:hypnotic specter
[DO]
grizzly bears
next
hypnotic specter
next
yes
mountain
swamp
ebony horse
grizzly bears
endofinterruption
next
[ASSERT]
COMBATEND
[PLAYER1]
inplay:grizzly bears,ebony horse,mountain,swamp
[PLAYER2]
inplay:hypnotic specter
[END]
+76 -27
View File
@@ -2147,6 +2147,82 @@ public:
}; };
class APreventAllCombatDamage:public MTGAbility{
public:
string to, from;
REDamagePrevention * re;
APreventAllCombatDamage(int id,MTGCardInstance * source,string to,string from):MTGAbility(id,source),to(to),from(from){
re = NULL;
}
int addToGame(){
if (re) {
OutputDebugString("FATAL:re shouldn't be already set in APreventAllCombatDAMAGE\n");
return 0;
}
TargetChooserFactory tcf;
TargetChooser *toTc = tcf.createTargetChooser(to,source,this);
if (toTc) toTc->targetter = NULL;
TargetChooser *fromTc = tcf.createTargetChooser(from,source,this);
if (fromTc) fromTc->targetter = NULL;
re = NEW REDamagePrevention (this, fromTc, toTc, -1, false, DAMAGE_COMBAT);
game->replacementEffects->add(re);
return 1;
}
int Destroy(){
game->replacementEffects->remove(re);
delete re;
return 1;
}
APreventAllCombatDamage * clone() const{
APreventAllCombatDamage * a = NEW APreventAllCombatDamage(*this);
a->isClone = 1;
return a;
}
};
//Adds types/abilities/P/T to a card (until end of turn)
class APreventAllCombatDamageUEOT: public InstantAbility{
public:
APreventAllCombatDamage * ability;
APreventAllCombatDamageUEOT(int id,MTGCardInstance * source,string to, string from):InstantAbility(id,source){
ability = NEW APreventAllCombatDamage(id,source,to, from);
}
int resolve(){
ability->target = this->target;
ability->addToGame();
return 1;
}
int destroy(){
ability->destroy();
return 1;
}
const char * getMenuText(){
return ability->getMenuText();
}
APreventAllCombatDamageUEOT * clone() const{
APreventAllCombatDamageUEOT * a = NEW APreventAllCombatDamageUEOT(*this);
a->ability = this->ability->clone();
a->isClone = 1;
return a;
}
~APreventAllCombatDamageUEOT(){
delete ability;
}
};
/* /*
Specific Classes Specific Classes
*/ */
@@ -2607,33 +2683,6 @@ class ADisruptingScepter:public TargetAbility{
}; };
//1108 Ebony Horse
class AEbonyHorse:public TargetAbility{
public:
AEbonyHorse(int _id, MTGCardInstance * _source):TargetAbility(_id,_source, NEW CreatureTargetChooser()){
int _cost[] = {Constants::MTG_COLOR_ARTIFACT, 2};
cost = NEW ManaCost(_cost,1);
}
int resolve(){
MTGCardInstance * _target = tc->getNextCardTarget();
if (_target->isAttacker()) _target->toggleAttacker();
return 1;
}
virtual ostream& toString(ostream& out) const
{
out << "AEbonyHorse ::: (";
return TargetAbility::toString(out) << ")";
}
AEbonyHorse * clone() const{
AEbonyHorse * a = NEW AEbonyHorse(*this);
a->isClone = 1;
return a;
}
};
//1345 Farmstead //1345 Farmstead
class AFarmstead:public ActivatedAbility{ class AFarmstead:public ActivatedAbility{
public: public:
+7 -2
View File
@@ -13,6 +13,10 @@ class GameObserver;
#define DAMAGEABLE_MTGCARDINSTANCE 0 #define DAMAGEABLE_MTGCARDINSTANCE 0
#define DAMAGEABLE_PLAYER 1 #define DAMAGEABLE_PLAYER 1
#define DAMAGE_ALL_TYPES 0
#define DAMAGE_COMBAT 1
#define DAMAGE_OTHER 2
class Damageable:public Targetable { class Damageable:public Targetable {
protected: protected:
@@ -28,13 +32,14 @@ class Damageable:public Targetable {
class Damage: public Interruptible { class Damage: public Interruptible {
protected: protected:
void init(MTGCardInstance * source, Damageable * target, int damage); void init(MTGCardInstance * source, Damageable * target, int damage, int typeOfDamage);
public: public:
Damageable * target; Damageable * target;
int typeOfDamage;
int damage; int damage;
void Render(); void Render();
Damage(MTGCardInstance* source, Damageable * target); Damage(MTGCardInstance* source, Damageable * target);
Damage(MTGCardInstance* source, Damageable * target, int damage); Damage(MTGCardInstance* source, Damageable * target, int damage, int typeOfDamage = DAMAGE_OTHER);
int resolve(); int resolve();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
+244 -244
View File
@@ -1,249 +1,249 @@
#ifndef _MTGABILITY_H_ #ifndef _MTGABILITY_H_
#define _MTGABILITY_H_ #define _MTGABILITY_H_
class MTGCardInstance; class MTGCardInstance;
class GameObserver; class GameObserver;
class Spell; class Spell;
class Damageable; class Damageable;
class PlayGuiObject; class PlayGuiObject;
class ManaCost; class ManaCost;
class MTGGameZone; class MTGGameZone;
class Player; class Player;
class AManaProducer; class AManaProducer;
class WEvent; class WEvent;
#include "ActionElement.h" #include "ActionElement.h"
#include <string> #include <string>
#include <map> #include <map>
#include <hge/hgeparticle.h> #include <hge/hgeparticle.h>
#include "../include/Damage.h" #include "../include/Damage.h"
#include "../include/TargetChooser.h" #include "../include/TargetChooser.h"
using std::string; using std::string;
using std::map; using std::map;
//stupid variables used to give a hint to the AI: //stupid variables used to give a hint to the AI:
// Should I cast a spell on an enemy or friendly unit ? // Should I cast a spell on an enemy or friendly unit ?
#define BAKA_EFFECT_GOOD 1 #define BAKA_EFFECT_GOOD 1
#define BAKA_EFFECT_BAD -1 #define BAKA_EFFECT_BAD -1
#define BAKA_EFFECT_DONTKNOW 0 #define BAKA_EFFECT_DONTKNOW 0
#define MODE_PUTINTOPLAY 1 #define MODE_PUTINTOPLAY 1
#define MODE_ABILITY 2 #define MODE_ABILITY 2
#define MODE_TARGET 3 #define MODE_TARGET 3
#define COUNT_POWER 1 #define COUNT_POWER 1
#define PARSER_LORD 1 #define PARSER_LORD 1
#define PARSER_FOREACH 2 #define PARSER_FOREACH 2
#define PARSER_ASLONGAS 3 #define PARSER_ASLONGAS 3
class MTGAbility: public ActionElement{ class MTGAbility: public ActionElement{
protected: protected:
char menuText[25]; char menuText[25];
GameObserver * game; GameObserver * game;
public: public:
int oneShot; int oneShot;
int forceDestroy; int forceDestroy;
ManaCost * cost; ManaCost * cost;
Targetable * target; Targetable * target;
int aType; int aType;
MTGCardInstance * source; MTGCardInstance * source;
MTGAbility(int id, MTGCardInstance * card); MTGAbility(int id, MTGCardInstance * card);
MTGAbility(int id, MTGCardInstance * _source, Targetable * _target); MTGAbility(int id, MTGCardInstance * _source, Targetable * _target);
virtual int testDestroy(); virtual int testDestroy();
virtual ~MTGAbility(); virtual ~MTGAbility();
virtual void Render(){}; virtual void Render(){};
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){return 0;}; virtual int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){return 0;};
virtual int reactToClick(MTGCardInstance * card){return 0;}; virtual int reactToClick(MTGCardInstance * card){return 0;};
virtual int receiveEvent(WEvent * event){return 0;}; virtual int receiveEvent(WEvent * event){return 0;};
virtual void Update(float dt){}; virtual void Update(float dt){};
virtual int fireAbility(); virtual int fireAbility();
virtual int stillInUse(MTGCardInstance * card); virtual int stillInUse(MTGCardInstance * card);
virtual int resolve(){return 0;}; virtual int resolve(){return 0;};
virtual MTGAbility* clone() const = 0; virtual MTGAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
virtual int addToGame(); virtual int addToGame();
virtual int removeFromGame(); virtual int removeFromGame();
/*Poor man's casting */ /*Poor man's casting */
/* Todo replace that crap with dynamic casting */ /* Todo replace that crap with dynamic casting */
enum { enum {
UNKNOWN = 0, UNKNOWN = 0,
MANA_PRODUCER = 1, MANA_PRODUCER = 1,
MTG_ATTACK_RULE = 2, MTG_ATTACK_RULE = 2,
DAMAGER = 3, DAMAGER = 3,
STANDARD_REGENERATE = 4, STANDARD_REGENERATE = 4,
PUT_INTO_PLAY = 5, PUT_INTO_PLAY = 5,
MOMIR = 6, MOMIR = 6,
MTG_BLOCK_RULE = 7, MTG_BLOCK_RULE = 7,
}; };
}; };
class TriggeredAbility:public MTGAbility{ class TriggeredAbility:public MTGAbility{
public: public:
TriggeredAbility(int id, MTGCardInstance * card); TriggeredAbility(int id, MTGCardInstance * card);
TriggeredAbility(int id, MTGCardInstance * _source, Targetable * _target); TriggeredAbility(int id, MTGCardInstance * _source, Targetable * _target);
virtual void Update(float dt); virtual void Update(float dt);
virtual void Render(){}; virtual void Render(){};
virtual int trigger(){return 0;}; virtual int trigger(){return 0;};
virtual int triggerOnEvent(WEvent * e){return 0;}; virtual int triggerOnEvent(WEvent * e){return 0;};
int receiveEvent(WEvent * e); int receiveEvent(WEvent * e);
virtual int resolve() = 0; virtual int resolve() = 0;
virtual TriggeredAbility* clone() const = 0; virtual TriggeredAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class ActivatedAbility:public MTGAbility{ class ActivatedAbility:public MTGAbility{
public: public:
int playerturnonly; int playerturnonly;
int needsTapping; int needsTapping;
ActivatedAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1); ActivatedAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
virtual int reactToClick(MTGCardInstance * card); virtual int reactToClick(MTGCardInstance * card);
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); virtual int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
virtual int reactToTargetClick(Targetable * object); virtual int reactToTargetClick(Targetable * object);
virtual int resolve() = 0; virtual int resolve() = 0;
virtual ActivatedAbility* clone() const = 0; virtual ActivatedAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class TargetAbility:public ActivatedAbility{ class TargetAbility:public ActivatedAbility{
public: public:
MTGAbility * ability; MTGAbility * ability;
TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1); TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1); TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
virtual int reactToClick(MTGCardInstance * card); virtual int reactToClick(MTGCardInstance * card);
virtual int reactToTargetClick(Targetable * object); virtual int reactToTargetClick(Targetable * object);
virtual TargetAbility* clone() const = 0; virtual TargetAbility* clone() const = 0;
virtual void Render(); virtual void Render();
virtual int resolve(); virtual int resolve();
virtual const char * getMenuText(); virtual const char * getMenuText();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
~TargetAbility(); ~TargetAbility();
}; };
class InstantAbility:public MTGAbility{ class InstantAbility:public MTGAbility{
public: public:
int init; int init;
virtual void Update(float dt); virtual void Update(float dt);
virtual int testDestroy(); virtual int testDestroy();
InstantAbility(int _id, MTGCardInstance * source); InstantAbility(int _id, MTGCardInstance * source);
InstantAbility(int _id, MTGCardInstance * source,Damageable * _target); InstantAbility(int _id, MTGCardInstance * source,Damageable * _target);
virtual int resolve(){return 0;}; virtual int resolve(){return 0;};
virtual InstantAbility* clone() const = 0; virtual InstantAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
/* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */ /* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */
class ListMaintainerAbility:public MTGAbility{ class ListMaintainerAbility:public MTGAbility{
public: public:
map<MTGCardInstance *,bool> cards; map<MTGCardInstance *,bool> cards;
map<Player *,bool> players; map<Player *,bool> players;
ListMaintainerAbility(int _id):MTGAbility(_id,NULL){}; ListMaintainerAbility(int _id):MTGAbility(_id,NULL){};
ListMaintainerAbility(int _id, MTGCardInstance *_source):MTGAbility(_id, _source){}; ListMaintainerAbility(int _id, MTGCardInstance *_source):MTGAbility(_id, _source){};
ListMaintainerAbility(int _id, MTGCardInstance *_source,Damageable * _target):MTGAbility(_id, _source, _target){}; ListMaintainerAbility(int _id, MTGCardInstance *_source,Damageable * _target):MTGAbility(_id, _source, _target){};
virtual void Update(float dt); virtual void Update(float dt);
void updateTargets(); void updateTargets();
virtual bool canTarget(MTGGameZone * zone); virtual bool canTarget(MTGGameZone * zone);
virtual int canBeInList(MTGCardInstance * card) = 0; virtual int canBeInList(MTGCardInstance * card) = 0;
virtual int added(MTGCardInstance * card) = 0; virtual int added(MTGCardInstance * card) = 0;
virtual int removed(MTGCardInstance * card) = 0; virtual int removed(MTGCardInstance * card) = 0;
virtual int canBeInList(Player * p){return 0;}; virtual int canBeInList(Player * p){return 0;};
virtual int added(Player * p){return 0;}; virtual int added(Player * p){return 0;};
virtual int removed(Player * p){return 0;}; virtual int removed(Player * p){return 0;};
virtual int destroy(); virtual int destroy();
virtual ListMaintainerAbility* clone() const = 0; virtual ListMaintainerAbility* clone() const = 0;
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
class TriggerAtPhase:public TriggeredAbility{ class TriggerAtPhase:public TriggeredAbility{
public: public:
int phaseId; int phaseId;
int who; int who;
TriggerAtPhase(int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0); TriggerAtPhase(int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0);
virtual int trigger(); virtual int trigger();
int resolve(){return 0;}; int resolve(){return 0;};
virtual TriggerAtPhase* clone() const; virtual TriggerAtPhase* clone() const;
}; };
class TriggerNextPhase:public TriggerAtPhase{ class TriggerNextPhase:public TriggerAtPhase{
public: public:
int destroyActivated; int destroyActivated;
TriggerNextPhase(int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0); TriggerNextPhase(int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0);
virtual TriggerNextPhase* clone() const; virtual TriggerNextPhase* clone() const;
virtual int testDestroy(); virtual int testDestroy();
}; };
class GenericTriggeredAbility:public TriggeredAbility{ class GenericTriggeredAbility:public TriggeredAbility{
public: public:
TriggeredAbility * t; TriggeredAbility * t;
MTGAbility * ability; MTGAbility * ability;
MTGAbility * destroyCondition; MTGAbility * destroyCondition;
GenericTriggeredAbility(int id, MTGCardInstance * _source, TriggeredAbility * _t, MTGAbility * a,MTGAbility * dc = NULL, Targetable * _target = NULL); GenericTriggeredAbility(int id, MTGCardInstance * _source, TriggeredAbility * _t, MTGAbility * a,MTGAbility * dc = NULL, Targetable * _target = NULL);
virtual int trigger(); virtual int trigger();
virtual int triggerOnEvent(WEvent * e); virtual int triggerOnEvent(WEvent * e);
virtual int resolve(); virtual int resolve();
virtual int testDestroy(); virtual int testDestroy();
void Update(float dt); void Update(float dt);
virtual GenericTriggeredAbility* clone() const; virtual GenericTriggeredAbility* clone() const;
const char * getMenuText(); const char * getMenuText();
~GenericTriggeredAbility(); ~GenericTriggeredAbility();
}; };
/* Ability Factory */ /* Ability Factory */
class AbilityFactory{ class AbilityFactory{
private: private:
int countCards(TargetChooser * tc, Player * player = NULL, int option = 0); int countCards(TargetChooser * tc, Player * player = NULL, int option = 0);
int parsePowerToughness(string s, int *power, int *toughness); int parsePowerToughness(string s, int *power, int *toughness);
TriggeredAbility * parseTrigger(string s, int id, Spell * spell, MTGCardInstance *card, Targetable * target); TriggeredAbility * parseTrigger(string s, int id, Spell * spell, MTGCardInstance *card, Targetable * target);
public: public:
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0); MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0);
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL); int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL);
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL); int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
static int computeX(Spell * spell, MTGCardInstance * card); static int computeX(Spell * spell, MTGCardInstance * card);
int destroyAllInPlay(TargetChooser * tc, int bury = 0); int destroyAllInPlay(TargetChooser * tc, int bury = 0);
int moveAll(TargetChooser * tc, string destinationZone); int moveAll(TargetChooser * tc, string destinationZone);
int damageAll(TargetChooser * tc, int damage); int damageAll(TargetChooser * tc, int damage);
int TapAll(TargetChooser * tc); int TapAll(TargetChooser * tc);
int CantBlock(TargetChooser * tc); int CantBlock(TargetChooser * tc);
int UntapAll(TargetChooser * tc); int UntapAll(TargetChooser * tc);
void addAbilities(int _id, Spell * spell); void addAbilities(int _id, Spell * spell);
}; };
class ActivatedAbilityTP:public ActivatedAbility{ class ActivatedAbilityTP:public ActivatedAbility{
public: public:
int who; int who;
ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, ManaCost * cost=NULL, int doTap = 0, int who = TargetChooser::UNSET); ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, ManaCost * cost=NULL, int doTap = 0, int who = TargetChooser::UNSET);
Targetable * getTarget(); Targetable * getTarget();
}; };
class AManaProducer: public ActivatedAbilityTP{ class AManaProducer: public ActivatedAbilityTP{
protected: protected:
string menutext; string menutext;
Player * controller; Player * controller;
public: public:
ManaCost * output; ManaCost * output;
int tap; int tap;
AManaProducer(int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1, int who = TargetChooser::UNSET ); AManaProducer(int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1, int who = TargetChooser::UNSET );
int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL);
int resolve(); int resolve();
int reactToClick(MTGCardInstance * _card); int reactToClick(MTGCardInstance * _card);
const char * getMenuText(); const char * getMenuText();
~AManaProducer(); ~AManaProducer();
virtual AManaProducer * clone() const; virtual AManaProducer * clone() const;
}; };
#include "MTGCardInstance.h" #include "MTGCardInstance.h"
#endif #endif
+1 -1
View File
@@ -24,7 +24,7 @@ class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{
float defaultHeight; float defaultHeight;
bool mHasFocus; bool mHasFocus;
int type; int type;
virtual void Entering(){mHasFocus = true; zoom = 1.4;}; virtual void Entering(){mHasFocus = true; zoom = 1.4f;};
virtual bool Leaving(u32 key){mHasFocus = false; zoom = 1.0; return true;}; virtual bool Leaving(u32 key){mHasFocus = false; zoom = 1.0; return true;};
virtual bool CheckUserInput(u32 key) {return false;}; virtual bool CheckUserInput(u32 key) {return false;};
virtual bool ButtonPressed(){return true;}; virtual bool ButtonPressed(){return true;};
+3 -1
View File
@@ -3,6 +3,7 @@
#include <list> #include <list>
using namespace std; using namespace std;
#include "../include/Damage.h"
#include "WEvent.h" #include "WEvent.h"
class TargetChooser; class TargetChooser;
@@ -21,8 +22,9 @@ protected:
TargetChooser * tcTarget; TargetChooser * tcTarget;
int damage; int damage;
bool oneShot; bool oneShot;
int typeOfDamage;
public: public:
REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL,TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true); REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL,TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true, int typeOfDamage = DAMAGE_ALL_TYPES);
WEvent * replace (WEvent *e); WEvent * replace (WEvent *e);
~REDamagePrevention(); ~REDamagePrevention();
}; };
+1 -1
View File
@@ -58,7 +58,7 @@ class TargetChooser: public TargetsList {
class TargetChooserFactory{ class TargetChooserFactory{
public: public:
TargetChooser * createTargetChooser(string s, MTGCardInstance * card); TargetChooser * createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability = NULL);
TargetChooser * createTargetChooser(MTGCardInstance * card); TargetChooser * createTargetChooser(MTGCardInstance * card);
}; };
+5 -5
View File
@@ -7,14 +7,15 @@
#include "../include/WResourceManager.h" #include "../include/WResourceManager.h"
Damage::Damage(MTGCardInstance * source, Damageable * target) { Damage::Damage(MTGCardInstance * source, Damageable * target) {
init(source, target, source->getPower()); init(source, target, source->getPower(), DAMAGE_OTHER);
} }
Damage::Damage(MTGCardInstance * source, Damageable * target, int damage) { Damage::Damage(MTGCardInstance * source, Damageable * target, int damage,int _typeOfDamage) {
init(source, target, damage); init(source, target, damage, _typeOfDamage);
} }
void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage){ void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage, int _typeOfDamage){
typeOfDamage = _typeOfDamage;
target = _target; target = _target;
source = _source; source = _source;
@@ -70,7 +71,6 @@ int Damage::resolve(){
//Send (Damage/Replaced effect) event to listeners //Send (Damage/Replaced effect) event to listeners
g->receiveEvent(e); g->receiveEvent(e);
//SAFE_DELETE(e);
return a; return a;
} }
+1 -1
View File
@@ -28,7 +28,7 @@ void DamagerDamaged::addDamage(int damage, DamagerDamaged* source){
if (0 >= i->damage) damages.erase(i); if (0 >= i->damage) damages.erase(i);
return; return;
} }
if (0 < damage) damages.push_back(Damage(source->card, card, damage)); if (0 < damage) damages.push_back(Damage(source->card, card, damage,DAMAGE_COMBAT));
return; return;
} }
+1 -1
View File
@@ -314,7 +314,7 @@ int GuiCombat::resolve() // Returns the number of damage objects dealt this turn
stack->Add(NEW Damage(*d)); stack->Add(NEW Damage(*d));
dmg -= (*q)->sumDamages(); dmg -= (*q)->sumDamages();
} }
if (dmg > 0) stack->Add(NEW Damage((*it)->card, go->opponent(), dmg)); if (dmg > 0) stack->Add(NEW Damage((*it)->card, go->opponent(), dmg, DAMAGE_COMBAT));
for (vector<Damage>::iterator d = (*it)->damages.begin(); d != (*it)->damages.end(); ++d) for (vector<Damage>::iterator d = (*it)->damages.begin(); d != (*it)->damages.end(); ++d)
stack->Add(NEW Damage(*d)); stack->Add(NEW Damage(*d));
} }
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -2,10 +2,10 @@
#include "../include/ReplacementEffects.h" #include "../include/ReplacementEffects.h"
#include "../include/MTGCardInstance.h" #include "../include/MTGCardInstance.h"
#include "../include/TargetChooser.h" #include "../include/TargetChooser.h"
#include "../include/Damage.h"
REDamagePrevention::REDamagePrevention(MTGAbility * source, TargetChooser *tcSource, TargetChooser *tcTarget, int damage, bool oneShot):source(source), tcSource(tcSource), tcTarget(tcTarget), damage(damage), oneShot(oneShot){
REDamagePrevention::REDamagePrevention(MTGAbility * source, TargetChooser *tcSource, TargetChooser *tcTarget, int damage, bool oneShot, int typeOfDamage):source(source), tcSource(tcSource), tcTarget(tcTarget), damage(damage), oneShot(oneShot), typeOfDamage(typeOfDamage){
} }
WEvent * REDamagePrevention::replace (WEvent *event){ WEvent * REDamagePrevention::replace (WEvent *event){
@@ -14,6 +14,7 @@ WEvent * REDamagePrevention::replace (WEvent *event){
WEventDamage * e = dynamic_cast<WEventDamage*>(event); WEventDamage * e = dynamic_cast<WEventDamage*>(event);
if (!e) return event; if (!e) return event;
Damage *d = e->damage; Damage *d = e->damage;
if (d->typeOfDamage != typeOfDamage && typeOfDamage != DAMAGE_ALL_TYPES) return event;
if ((!tcSource || tcSource->canTarget(d->source)) && if ((!tcSource || tcSource->canTarget(d->source)) &&
(!tcTarget || tcTarget->canTarget(d->target)) (!tcTarget || tcTarget->canTarget(d->target))
){ ){
+8 -1
View File
@@ -7,7 +7,7 @@
TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInstance * card){ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability){
if (!s.size()) return NULL; if (!s.size()) return NULL;
int zones[10]; int zones[10];
@@ -15,6 +15,13 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
size_t found; size_t found;
bool other = false; bool other = false;
found = s.find("mytgt");
if (found == 0){
MTGCardInstance * target = card->target;
if (ability) target = (MTGCardInstance *) (ability->target);
return NEW CardTargetChooser(target,card);
};
found = s.find("other "); found = s.find("other ");
if (found == 0){ if (found == 0){
other = true; other = true;