Erwan
- Replaced the BasicAbilities Array with a map. This reduces the size of MTGCard from >500 bytes to 392. Should be cool for people who have memory issues
This commit is contained in:
@@ -987,6 +987,7 @@ protected:
|
||||
}
|
||||
if (!_target) return 0;
|
||||
REDamagePrevention * re = NEW REDamagePrevention (
|
||||
this,
|
||||
NEW CardTargetChooser(_target,NULL),
|
||||
NEW PlayerTargetChooser(0,1,source->controller()));
|
||||
current[re] = 1;
|
||||
|
||||
@@ -24,6 +24,7 @@ class TexturesCache;
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
class MTGCard {
|
||||
@@ -40,6 +41,7 @@ class MTGCard {
|
||||
char image_name[MTGCARD_NAME_SIZE];
|
||||
|
||||
int init();
|
||||
|
||||
|
||||
public:
|
||||
TexturesCache * mCache;
|
||||
@@ -47,7 +49,7 @@ class MTGCard {
|
||||
string name;
|
||||
|
||||
int colors[Constants::MTG_NB_COLORS];
|
||||
int basicAbilities[Constants::NB_BASIC_ABILITIES];
|
||||
map<int,int> basicAbilities;
|
||||
vector<string> formattedText;
|
||||
string magicText;
|
||||
int alias;
|
||||
|
||||
@@ -6,6 +6,7 @@ using namespace std;
|
||||
#include "WEvent.h"
|
||||
|
||||
class TargetChooser;
|
||||
class MTGAbility;
|
||||
|
||||
class ReplacementEffect {
|
||||
public:
|
||||
@@ -15,12 +16,13 @@ public:
|
||||
|
||||
class REDamagePrevention: public ReplacementEffect {
|
||||
protected:
|
||||
MTGAbility * source;
|
||||
TargetChooser * tcSource;
|
||||
TargetChooser * tcTarget;
|
||||
int damage;
|
||||
bool oneShot;
|
||||
public:
|
||||
REDamagePrevention(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);
|
||||
WEvent * replace (WEvent *e);
|
||||
~REDamagePrevention();
|
||||
};
|
||||
|
||||
@@ -91,7 +91,8 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card){
|
||||
|
||||
|
||||
//Abilities
|
||||
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
|
||||
for(map<int,int>::const_iterator it = basicAbilities.begin(); it != basicAbilities.end(); ++it){
|
||||
int j = it->first;
|
||||
if ((basicAbilities[j] == 1 && !card->basicAbilities[j]) || (basicAbilities[j] == -1 && card->basicAbilities[j])){
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ void GameApp::Create()
|
||||
// effect = new CardEffect();
|
||||
|
||||
char buf[512];
|
||||
sprintf(buf, "size of MTGCardInstance : %i\n" , sizeof(MTGCardInstance));
|
||||
sprintf(buf, "size of MTGCard : %i\n" , sizeof(MTGCard));
|
||||
OutputDebugString(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,10 @@ const char * MTGCard::getSetName(){
|
||||
|
||||
MTGCard::MTGCard(MTGCard * source){
|
||||
mCache = source->mCache;
|
||||
for (int i = 0; i< Constants::NB_BASIC_ABILITIES; i++){
|
||||
basicAbilities[i] = source->basicAbilities[i];
|
||||
for(map<int,int>::const_iterator it = source->basicAbilities.begin(); it != source->basicAbilities.end(); ++it){
|
||||
basicAbilities[it->first] = source->basicAbilities[it->first];
|
||||
}
|
||||
|
||||
for (int i = 0; i< MAX_TYPES_PER_CARD; i++){
|
||||
types[i] = source->types[i];
|
||||
}
|
||||
@@ -62,9 +63,8 @@ MTGCard::MTGCard(MTGCard * source){
|
||||
|
||||
int MTGCard::init(){
|
||||
nb_types = 0;
|
||||
for (int i = 0; i< Constants::NB_BASIC_ABILITIES; i++){
|
||||
basicAbilities[i] = 0;
|
||||
}
|
||||
basicAbilities.clear();
|
||||
|
||||
for (int i = 0; i< MAX_TYPES_PER_CARD; i++){
|
||||
types[i] = 0;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,10 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to):
|
||||
|
||||
void MTGCardInstance::copy(MTGCardInstance * card){
|
||||
MTGCard * source = card->model;
|
||||
for (int i = 0; i< Constants::NB_BASIC_ABILITIES; i++){
|
||||
basicAbilities[i] = source->basicAbilities[i];
|
||||
}
|
||||
for(map<int,int>::const_iterator it = source->basicAbilities.begin(); it != source->basicAbilities.end(); ++it){
|
||||
int i = it->first;
|
||||
basicAbilities[i] = source->basicAbilities[i];
|
||||
}
|
||||
for (int i = 0; i< MAX_TYPES_PER_CARD; i++){
|
||||
types[i] = source->types[i];
|
||||
}
|
||||
@@ -506,7 +507,8 @@ JSample * MTGCardInstance::getSample(){
|
||||
}
|
||||
}
|
||||
if (!sample.size()){
|
||||
for (int i = 0; i < Constants::NB_BASIC_ABILITIES; i++){
|
||||
for(map<int,int>::const_iterator it = basicAbilities.begin(); it != basicAbilities.end(); ++it){
|
||||
int i = it->first;
|
||||
if (!basicAbilities[i]) continue;
|
||||
string type = Constants::MTGBasicAbilities[i];
|
||||
type = "sound/sfx/" + type + ".wav";
|
||||
|
||||
@@ -52,6 +52,7 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"opponentshroud",
|
||||
};
|
||||
|
||||
|
||||
const char* Constants::MTGPhaseNames[] =
|
||||
{
|
||||
"---",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../include/Damage.h"
|
||||
|
||||
|
||||
REDamagePrevention::REDamagePrevention(TargetChooser *_tcSource, TargetChooser *_tcTarget,int _damage, bool _oneShot):damage(_damage), tcSource(_tcSource), tcTarget(_tcTarget), oneShot(_oneShot){
|
||||
REDamagePrevention::REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource, TargetChooser *_tcTarget,int _damage, bool _oneShot):source(_source),tcSource(_tcSource), tcTarget(_tcTarget),damage(_damage), oneShot(_oneShot){
|
||||
}
|
||||
|
||||
WEvent * REDamagePrevention::replace (WEvent *event){
|
||||
|
||||
Reference in New Issue
Block a user