This is pretty major, so there'll probably be something wrong with it... even though I did spend a few hours looking.
NOTES:
* If you've Retrieved it, don't delete it--- Use resources.Release(Whatever).
Textures automatically release subordinate quads.
* Most of the time, use resources.RetrieveQuad to grab a quad. Should handle everything for you.
RetrieveQuad will load the required texture, if needed.
Only managed resources have a resource name ("back", "simon", etc).
Managed resources can be retrieved with GetTexture/GetQuad/GetWhatever.
Non managed quads lookup by position/dimensions, defaulting to the whole texture.
* Use resources.RetrieveTexture only when you need to do something special to it.
Calling retrieve texture with RETRIEVE_MANAGE will permanently add a texture to the manager
RETRIEVE_LOCK and RETRIEVE_VRAM will lock a texture. It will not leave the cache until
Release(JTexture*) is called, or as a last resort during cache overflow.
* Try to only store (as a class member) pointers to textures retrieved with RETRIEVE_MANAGE.
All others may become invalid, although locked textures do have a high degree of stability. It's
pretty safe to store a locked texture if you're not going to load much between uses.
There's a lot going on here, so I might have missed something... but it runs through the test suite alright.
TODO:
* When called without any arguments, RetrieveQuad sometimes leaves a thin border around the image.
This can be bypassed by specifying a quad one or two pixels less than the image size. Why?
* I've had a crash while runing the Demo mode, something to do with receiveEventMinus?
This hasn't exactly reproduced on a clean SVN copy, (being a hang, rather than a crash) so
I've probably done something to worsen the problem somehow? I'll look into it tomorrow.
* Clean up lock/unlock system, memory usage. Streamline interface, consider phasing out calls using GetWhatever() format.
133 lines
3.0 KiB
C++
133 lines
3.0 KiB
C++
#ifndef _MTG_CARD_INSTANCE_H_
|
|
#define _MTG_CARD_INSTANCE_H_
|
|
|
|
#include "MTGCard.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 MTGCard, public Damageable {
|
|
protected:
|
|
int untapping;
|
|
int nb_damages;
|
|
string sample;
|
|
int tapped;
|
|
|
|
int lifeOrig;
|
|
UntapBlockers * untapBlockers;
|
|
MTGPlayerCards * belongs_to;
|
|
MTGAbility * untapBlockerAbilities[10];
|
|
void unband();
|
|
MTGCardInstance * getNextPartner();
|
|
void initMTGCI();
|
|
int setDefenser(MTGCardInstance * c);
|
|
int setAttacker(int value);
|
|
public:
|
|
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();
|
|
MTGCardInstance * target;
|
|
void addType(int type);
|
|
|
|
//Combat
|
|
MTGCardInstance * defenser;
|
|
list<MTGCardInstance *>blockers;
|
|
int attacker;
|
|
int toggleDefenser(MTGCardInstance * opponent);
|
|
int raiseBlockerRankOrder(MTGCardInstance * blocker);
|
|
int bringBlockerToFrontOfOrder(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);
|
|
MTGCardInstance * getNextDefenser(MTGCardInstance * previous=NULL);
|
|
int nbOpponents();
|
|
int stepPower(CombatStep step);
|
|
|
|
int afterDamage();
|
|
|
|
int has(int ability);
|
|
int cleanup();
|
|
int reset();
|
|
|
|
|
|
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);
|
|
|
|
CardDescriptor * protections[10];
|
|
int nbprotections;
|
|
int addProtection(CardDescriptor * cd);
|
|
int removeProtection(CardDescriptor *cd, int erase = 0);
|
|
int protectedAgainst(MTGCardInstance * card);
|
|
void copy(MTGCardInstance * card);
|
|
// in game
|
|
|
|
void setUntapping();
|
|
int isUntapping();
|
|
int isTapped();
|
|
void untap();
|
|
void tap();
|
|
void attemptUntap();
|
|
|
|
int isInPlay();
|
|
void resetAllDamage();
|
|
JSample * getSample();
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|