Files
wagic/projects/mtg/include/MTGRules.h
omegablast2002@yahoo.com c54de679d4 couple bug fixes, a slight refactor,
ok here goes, first, fixed a crash that would happen when ever a player would gain more then 2000 life or take more then 2000 damage...the buffer was becoming corrupted i imagine because it was too small, increasing it to 10 slots allowed players to successfully take massive amounts of damage, highest i bothered checking was about 35k gained/lost, no crash...

2nd, removed the and refactored cantcaster rule, moved it to stateEffects() and renamed stateeffects to better reflect what it will be handling,

removed sneak attack rule and moved it into stateeffects

the following ints have been converted into bool, 
all the cantcasters, canputlandsintoplay is becoming a bool, the amount of lands you can play is now handled by a new varible int landsPlayerCanStillPlay (this is for my ability additional lands increase in support on perminents coming after the release)

the changes to bools were for an obvious reason, they were all ints pretending to be bools, my varibles were confusing as you would often see code like this if(cantblahblah > 0)
which to another coder might not make any sense.

these varible ints were returning 0 as false and 1 as true...changed them all to bools, same goes for putlandsinplay int, in half the places it was being used as a bool, AND it was tracking the amount, when i was coding additional land ability, this made it impossible to maintain correct amounts without damaging the rest of the code.
as a bool, controlled by stateeffects, it can now be used correctly as a bool in all cases, and the stateEffects manages the switch on it to false if you no longer have any landsPlayerCanStillPlay left.

the refactor on cantcaster was also a bug fix, it was reported to me that cantcasters were not correctly working, sometimes ai or player would still be allowed to play a card with one in play, because of the old way i had it setup somecases of bothcantcaster were reseting the cantcast to 0, basically making the check do nothing.

it is now handled in stateeffects if you have one in play, then its true, if not then false...this returns very accurate tracking of the cards instantly instead of checking as cards enter or left play.

the "both" versions now have their own bools to avoid future conflicts with the single player cantcast...

added a case for the fancy moving text, some move to library effects were incorrectly returing fetch.
2010-12-10 20:51:50 +00:00

250 lines
6.6 KiB
C++

/* Default observers/Abilities that are added to the game for a standard Magic Game
*/
#ifndef _MTGRULES_H_
#define _MTGRULES_H_
#include "MTGAbility.h"
#include "Counters.h"
#include "WEvent.h"
#include "CardSelector.h"
class OtherAbilitiesEventReceiver:public MTGAbility{
public:
int testDestroy();
int receiveEvent(WEvent * event);
OtherAbilitiesEventReceiver(int _id);
OtherAbilitiesEventReceiver * clone() const;
};
class MTGPutInPlayRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGPutInPlayRule(int _id);
const char * getMenuText(){return "Play Card Normally";}
virtual MTGPutInPlayRule * clone() const;
};
class MTGAlternativeCostRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGAlternativeCostRule(int _id);
const char * getMenuText(){return "Pay Alternative Cost";}
virtual MTGAlternativeCostRule * clone() const;
};
class MTGBuyBackRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGBuyBackRule(int _id);
const char * getMenuText(){return "Cast And Buy Back";}
virtual MTGBuyBackRule * clone() const;
};
class MTGFlashBackRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGFlashBackRule(int _id);
const char * getMenuText(){return "Flash Back";}
virtual MTGFlashBackRule * clone() const;
};
class MTGRetraceRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGRetraceRule(int _id);
const char * getMenuText(){return "Retrace";}
virtual MTGRetraceRule * clone() const;
};
class MTGAttackRule:public MTGAbility, public Limitor{
public:
virtual bool select(Target*);
virtual bool greyout(Target*);
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGAttackRule(int _id);
const char * getMenuText(){return "Attacker";}
int receiveEvent(WEvent * event);
virtual MTGAttackRule * clone() const;
};
/* handles combat trigger send recieve events*/
class MTGCombatTriggersRule:public MTGAbility{
public:
MTGCombatTriggersRule(int _id);
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();
virtual MTGCombatTriggersRule * clone() const;
};
class MTGBlockRule:public MTGAbility{
public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
MTGBlockRule(int _id);
const char * getMenuText(){return "Blocker";}
virtual MTGBlockRule * clone() const;
};
/* Persist Rule */
class MTGPersistRule:public MTGAbility{
public:
MTGPersistRule(int _id);
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();
virtual MTGPersistRule * clone() const;
};
//affinity rules
class MTGAffinityRule:public MTGAbility{
public:
MTGAffinityRule(int _id);
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();
virtual MTGAffinityRule * clone() const;
};
//unearths destruction if leaves play effect
class MTGUnearthRule:public MTGAbility{
public:
MTGUnearthRule(int _id);
int receiveEvent(WEvent * event);
virtual ostream& toString(ostream& out) const;
int testDestroy();
virtual MTGUnearthRule * clone() const;
};
class MTGTokensCleanup:public MTGAbility{
public:
vector<MTGCardInstance *> list;
MTGTokensCleanup(int _id);
int receiveEvent(WEvent * event);
int testDestroy();
virtual MTGTokensCleanup * clone() const;
};
/*
* Rule 420.5e (Legend Rule)
* If two or more legendary permanents with the same name are in play, all are put into their
* owners' graveyards. This is called the "legend rule." If only one of those permanents is
* legendary, this rule doesn't apply.
*/
class MTGLegendRule:public ListMaintainerAbility{
public:
MTGLegendRule(int _id);
int canBeInList(MTGCardInstance * card);
int added(MTGCardInstance * card);
int removed(MTGCardInstance * card);
int testDestroy();
virtual ostream& toString(ostream& out) const;
virtual MTGLegendRule * clone() const;
};
class MTGMomirRule:public MTGAbility{
private:
int genRandomCreatureId(int convertedCost);
static vector<int> pool[20];
static int initialized;
int textAlpha;
string text;
public:
int alreadyplayed;
MTGAllCards * collection;
MTGCardInstance * genCreature(int id);
int testDestroy();
void Update(float dt);
void Render();
MTGMomirRule(int _id, MTGAllCards * _collection);
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card, int id);
const char * getMenuText(){return "Momir";}
virtual ostream& toString(ostream& out) const;
virtual MTGMomirRule * clone() const;
};
/* LifeLink */
class MTGLifelinkRule:public MTGAbility{
public:
MTGLifelinkRule(int _id);
int receiveEvent(WEvent * event);
int testDestroy();
virtual ostream& toString(ostream& out) const;
virtual MTGLifelinkRule * clone() const;
};
/* Deathtouch */
class MTGDeathtouchRule:public MTGAbility{
public:
MTGDeathtouchRule(int _id);
int receiveEvent(WEvent * event);
int testDestroy();
const char * getMenuText(){return "Deathtouch";}
virtual MTGDeathtouchRule * clone() const;
};
/* HUD Display */
class HUDString {
public:
string value;
float timestamp;
int quantity;
HUDString(string s, float ts):value(s),timestamp(ts){quantity = 1;};
};
class HUDDisplay:public MTGAbility{
private:
list<HUDString *> events;
float timestamp;
float popdelay;
WFont * f;
float maxWidth;
int addEvent(string s);
public:
int testDestroy();
int receiveEvent(WEvent * event);
void Update(float dt);
void Render();
HUDDisplay(int _id);
~HUDDisplay();
virtual HUDDisplay * clone() const;
};
#endif