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