Notes to programmers: 1. This feature uses an awful lot of copy-pasta, using "protetcion from()" as a base. While I'm learning the architecture, it's easier for me to have a dedicated single-purpose piece of code to work with, than trying to create multi-purpose code. I'm aware that this isn't a very elegant approach though, and I hope to be able to refactor additions like this into multi-purpose code once I have a better understanding of the architecture as a whole. 2. Please check the questions I'll add in my next code comments, specifically about AI integration and activated abilities / instants / sorceries. 3. I did have a crash (with the debugger complaining about stack corruption around the cd variable) during testing. I wasn't able to reproduce it though. I did have to clean the solution in-between when I updated to the primitives system, so perhaps there was this cleaning solved whatever corruption was in my files. I'm mentioning the issue in case someone has an idea on where my code might be risky (I'm still probne to making beginners mistakes).
158 lines
3.8 KiB
C++
158 lines
3.8 KiB
C++
#ifndef _MTG_CARD_INSTANCE_H_
|
|
#define _MTG_CARD_INSTANCE_H_
|
|
|
|
#include "MTGCard.h"
|
|
#include "CardPrimitive.h"
|
|
#include "MTGGameZones.h"
|
|
#include "MTGAbility.h"
|
|
#include "WResourceManager.h"
|
|
#include "ManaCost.h"
|
|
#include "Blocker.h"
|
|
#include "Damage.h"
|
|
#include "Targetable.h"
|
|
|
|
|
|
class MTGCardInstance;
|
|
class MTGPlayerCards;
|
|
class MTGAbility;
|
|
class MTGCard;
|
|
class ManaCost;
|
|
class UntapBlockers;
|
|
class CardDescriptor;
|
|
class Counters;
|
|
struct Pos;
|
|
|
|
#include <list>
|
|
using namespace std;
|
|
|
|
class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
|
|
protected:
|
|
int untapping;
|
|
int nb_damages;
|
|
string sample;
|
|
int tapped;
|
|
|
|
int lifeOrig;
|
|
UntapBlockers * untapBlockers;
|
|
MTGPlayerCards * belongs_to;
|
|
MTGAbility * untapBlockerAbilities[10];
|
|
MTGCardInstance * getNextPartner();
|
|
void initMTGCI();
|
|
int setDefenser(MTGCardInstance * c);
|
|
int addBlocker(MTGCardInstance * c);
|
|
int removeBlocker(MTGCardInstance * c);
|
|
int setAttacker(int value);
|
|
int init();
|
|
public:
|
|
MTGGameZone * currentZone;
|
|
Pos* view;
|
|
int regenerateTokens;
|
|
bool isToken;
|
|
int stillInUse();
|
|
Player * lastController;
|
|
MTGGameZone * getCurrentZone();
|
|
MTGGameZone * previousZone;
|
|
MTGCardInstance * previous;
|
|
MTGCardInstance * next;
|
|
int doDamageTest;
|
|
int summoningSickness;
|
|
// The recommended method to test for summoning Sickness !
|
|
int hasSummoningSickness();
|
|
MTGCardInstance * changeController(Player * newcontroller);
|
|
float changedZoneRecently;
|
|
Player * owner;
|
|
Counters * counters;
|
|
int typeAsTarget(){return TARGET_CARD;}
|
|
const string getDisplayName() const;
|
|
MTGCardInstance * target;
|
|
|
|
|
|
//types
|
|
void addType(char * type_text);
|
|
virtual void addType(int id);
|
|
void setType(const char * type_text);
|
|
void setSubtype( string value);
|
|
int removeType(string value, int removeAll = 0);
|
|
int removeType(int value, int removeAll = 0);
|
|
|
|
//Combat
|
|
bool blocked; //Blocked this turn or not?
|
|
MTGCardInstance * defenser;
|
|
list<MTGCardInstance *>blockers;
|
|
int attacker;
|
|
int toggleDefenser(MTGCardInstance * opponent);
|
|
int raiseBlockerRankOrder(MTGCardInstance * blocker);
|
|
|
|
//Returns rank of the card in blockers if it is a blocker of this (starting at 1), 0 otherwise
|
|
int getDefenserRank(MTGCardInstance * blocker);
|
|
int toggleAttacker();
|
|
MTGCardInstance * banding; // If belongs to a band when attacking
|
|
int canBlock();
|
|
int canBlock(MTGCardInstance * opponent);
|
|
int canAttack();
|
|
int isAttacker();
|
|
MTGCardInstance * isDefenser();
|
|
int initAttackersDefensers();
|
|
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
|
|
int nbOpponents();
|
|
int stepPower(CombatStep step);
|
|
|
|
int afterDamage();
|
|
|
|
int has(int ability);
|
|
int cleanup();
|
|
|
|
MTGCard * model;
|
|
MTGCardInstance();
|
|
MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to);
|
|
UntapBlockers * getUntapBlockers();
|
|
int regenerate();
|
|
int triggerRegenerate();
|
|
Player * controller();
|
|
|
|
~MTGCardInstance();
|
|
int bury();
|
|
int destroy();
|
|
|
|
|
|
int addToToughness(int value);
|
|
int setToughness(int value);
|
|
|
|
vector<TargetChooser *>protections;
|
|
int addProtection(TargetChooser * tc);
|
|
int removeProtection(TargetChooser *tc, int erase = 0);
|
|
int protectedAgainst(MTGCardInstance * card);
|
|
|
|
vector<TargetChooser *>cantBeBlockedBys;
|
|
int addCantBeBlockedBy(TargetChooser * tc);
|
|
int removeCantBeBlockedBy(TargetChooser *tc, int erase = 0);
|
|
int cantBeBlockedBy(MTGCardInstance * card);
|
|
|
|
void copy(MTGCardInstance * card);
|
|
|
|
void setUntapping();
|
|
int isUntapping();
|
|
int isTapped();
|
|
void untap();
|
|
void tap();
|
|
void attemptUntap();
|
|
|
|
int isInPlay();
|
|
JSample * getSample();
|
|
|
|
JQuad * getIcon();
|
|
|
|
ostream& toString(ostream&) const;
|
|
|
|
static MTGCardInstance AnyCard;
|
|
static MTGCardInstance NoCard;
|
|
|
|
static MTGCardInstance ExtraRules[2];
|
|
|
|
};
|
|
|
|
ostream& operator<<(ostream&, const MTGCardInstance&);
|
|
|
|
|
|
#endif
|