Modifications to make the game more generic.
Included in a new modrules.xml tags. <cardgui> <background> Stores information concerning the colors </ background> <renderbig> Stores information to draw the card </ renderbig> <rendertinycrop> Stores information to draw the card </ rendertinycrop> </ cardgui> Change the variables array for vectors
This commit is contained in:
@@ -13,4 +13,32 @@
|
||||
<other>
|
||||
<item displayName="Trophy Room" action="trophies" key="btn_next" />
|
||||
</other>
|
||||
</menu>
|
||||
</menu>
|
||||
<cardgui>
|
||||
<background>
|
||||
<card id="6" color="artifact" img="artifact.jpg" thumb="artifact_thumb.jpg" menuicon="1"/>
|
||||
<card id="0" color="green" img="green.jpg" thumb="green_thumb.jpg" menuicon="1"/>
|
||||
<card id="1" color="blue" img="blue.jpg" thumb="blue_thumb.jpg" menuicon="1"/>
|
||||
<card id="3" color="red" img="red.jpg" thumb="red_thumb.jpg" menuicon="1"/>
|
||||
<card id="2" color="black" img="black.jpg" thumb="black_thumb.jpg" menuicon="1"/>
|
||||
<card id="4" color="white" img="white.jpg" thumb="white_thumb.jpg" menuicon="1"/>
|
||||
<card id="5" color="land" img="land.jpg" thumb="land_thumb.jpg" menuicon="1"/>
|
||||
<card id="7" color="gold" img="gold.jpg" thumb="gold_thumb.jpg" menuicon="0"/>
|
||||
</background>
|
||||
<renderbig>
|
||||
<item name="title" posx="22" posy="25" formattedtext="" type=""/>
|
||||
<item name="description" posx="22" posy="80" formattedtext="" type=""/>
|
||||
<item name="powerlife" posx="158" posy="106" formattedtext="power/life" type="creature"/>
|
||||
<item name="mana" posx="75" posy="-112" formattedtext="" type=""/>
|
||||
<item name="types" posx="22" posy="49" formattedtext="" type=""/>
|
||||
<item name="expansionrarity" posx="22" posy="113" formattedtext="expansion rarity" type=""/>
|
||||
</renderbig>
|
||||
<rendertinycrop>
|
||||
<item name="title" posx="22" posy="25" formattedtext="" type=""/>
|
||||
<item name="description" posx="22" posy="80" formattedtext="" type=""/>
|
||||
<item name="powerlife" posx="158" posy="106" formattedtext="power/life" type="creature"/>
|
||||
<item name="mana" posx="75" posy="-112" formattedtext="" type=""/>
|
||||
<item name="types" posx="22" posy="49" formattedtext="" type=""/>
|
||||
<item name="expansionrarity" posx="22" posy="113" formattedtext="expansion rarity" type=""/>
|
||||
</rendertinycrop>
|
||||
</cardgui>
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
if(s == "prex")
|
||||
{
|
||||
ManaCost * cX = card->controller()->getManaPool()->Diff(card->getManaCost());
|
||||
intValue = cX->getCost(Constants::MTG_NB_COLORS);
|
||||
intValue = cX->getCost(Constants::NB_Colors);
|
||||
delete cX;
|
||||
}
|
||||
else if (s == "x" || s == "X")
|
||||
@@ -2533,7 +2533,7 @@ public:
|
||||
if(sabilities.find("battleready") != string::npos)
|
||||
battleReady = true;
|
||||
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors; j++)
|
||||
{
|
||||
size_t found = sabilities.find(Constants::MTGColorStrings[j]);
|
||||
if (found != string::npos)
|
||||
@@ -3834,7 +3834,9 @@ public:
|
||||
MTGAbility(observer, id, _source)
|
||||
{
|
||||
counters = 0;
|
||||
int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, 4 };
|
||||
std::vector<int8_t> _cost;
|
||||
_cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
_cost.push_back(4);
|
||||
cost = ManaCost(_cost, 1);
|
||||
}
|
||||
|
||||
@@ -3896,7 +3898,9 @@ public:
|
||||
MTGAbility(observer, _id, _source)
|
||||
{
|
||||
canprevent = 0;
|
||||
int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, 2 };
|
||||
std::vector<int8_t> _cost;
|
||||
_cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
_cost.push_back(2);
|
||||
cost = ManaCost(_cost, 1);
|
||||
}
|
||||
|
||||
@@ -3990,7 +3994,9 @@ public:
|
||||
AFarmstead(GameObserver* observer, int _id, MTGCardInstance * source, MTGCardInstance * _target) :
|
||||
ActivatedAbility(observer, _id, source, 0, 1)
|
||||
{
|
||||
int8_t _cost[] = { Constants::MTG_COLOR_WHITE, 2 };
|
||||
std::vector<int8_t> _cost;
|
||||
_cost.push_back(Constants::MTG_COLOR_WHITE);
|
||||
_cost.push_back(2);
|
||||
setCost(NEW ManaCost(_cost, 1), true);
|
||||
target = _target;
|
||||
usedThisTurn = 0;
|
||||
|
||||
@@ -38,6 +38,7 @@ protected:
|
||||
static void RenderCountersBig(MTGCard * card, const Pos& pos, int drawMode = DrawMode::kNormal);
|
||||
static void AlternateRender(MTGCard * card, const Pos& pos);
|
||||
static void TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad);
|
||||
static string FormattedData (string data, string replace, string value);
|
||||
|
||||
public:
|
||||
static const float Width;
|
||||
|
||||
@@ -108,6 +108,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
extern JQuadPtr manaIcons[7];
|
||||
extern vector<JQuadPtr> manaIcons;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -75,13 +75,13 @@ enum DECK_VIEWER_MENU_ITEMS
|
||||
#define MED_SPEED 5.0f
|
||||
#define LOW_SPEED 1.5
|
||||
|
||||
#define MAX_SAVED_FILTERS 8
|
||||
#define CARDS_DISPLAYED 7
|
||||
#define MAX_SAVED_FILTERS Constants::NB_Colors + 1
|
||||
#define CARDS_DISPLAYED 10
|
||||
|
||||
class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
JQuadPtr mIcons[CARDS_DISPLAYED];
|
||||
vector<JQuadPtr> mIcons;
|
||||
JQuadPtr pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
float last_user_activity;
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
|
||||
protected:
|
||||
int conf_read_mode;
|
||||
int colorsCount[Constants::MTG_NB_COLORS];
|
||||
vector <int> colorsCount;
|
||||
int total_cards;
|
||||
void init();
|
||||
void initCounters();
|
||||
|
||||
@@ -249,7 +249,7 @@ class Constants
|
||||
};
|
||||
|
||||
static char MTGColorChars[];
|
||||
static const char* MTGColorStrings[];
|
||||
static vector <const char*> MTGColorStrings;
|
||||
static int _r[], _g[], _b[];
|
||||
|
||||
static map<string,int> MTGBasicAbilitiesMap;
|
||||
@@ -259,7 +259,7 @@ class Constants
|
||||
|
||||
static int GetBasicAbilityIndex(string mtgAbility);
|
||||
static int GetColorStringIndex(string mtgColor);
|
||||
|
||||
static int NB_Colors;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,7 @@ class ManaCost
|
||||
friend std::ostream& operator<<(std::ostream& out, ManaCost m);
|
||||
|
||||
protected:
|
||||
int8_t cost[Constants::MTG_NB_COLORS+1];
|
||||
std::vector<int8_t> cost;
|
||||
std::vector<ManaCostHybrid> hybrids;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
virtual void reinit();
|
||||
void x();
|
||||
int hasX();
|
||||
ManaCost(int8_t _cost[], int nb_elems = 1);
|
||||
ManaCost(std::vector<int8_t>& _cost, int nb_elems = 1);
|
||||
ManaCost();
|
||||
~ManaCost();
|
||||
ManaCost(ManaCost * _manaCost);
|
||||
@@ -83,8 +83,8 @@ public:
|
||||
int doPayExtra();
|
||||
|
||||
int addHybrid(int c1, int v1, int c2, int v2);
|
||||
int tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids, int8_t diff[]);
|
||||
void randomDiffHybrids(ManaCost * _cost, int8_t diff[]);
|
||||
int tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids,std::vector<int8_t>& diff);
|
||||
void randomDiffHybrids(ManaCost * _cost, std::vector<int8_t>& diff);
|
||||
int add(ManaCost * _cost);
|
||||
int remove(ManaCost * _cost);
|
||||
int removeAll(int color);
|
||||
|
||||
@@ -84,6 +84,42 @@ public:
|
||||
~ModRulesMenu();
|
||||
};
|
||||
|
||||
|
||||
class ModRulesBackGroundCardGuiItem
|
||||
{
|
||||
protected:
|
||||
static int strToint(string str);
|
||||
public:
|
||||
int mColorId;
|
||||
string MColorName;
|
||||
string mDisplayImg;
|
||||
string mDisplayThumb;
|
||||
int mMenuIcon;
|
||||
ModRulesBackGroundCardGuiItem(string ColorId,string ColorName, string DisplayImg, string DisplayThumb,string MenuIcon);
|
||||
};
|
||||
|
||||
class ModRulesRenderCardGuiItem
|
||||
{
|
||||
public:
|
||||
string mName;
|
||||
int mPosX;
|
||||
int mPosY;
|
||||
string mType;
|
||||
string mFormattedData;
|
||||
|
||||
ModRulesRenderCardGuiItem(string Name, string PosX, string PosY, string FormattedData, string Type);
|
||||
};
|
||||
|
||||
class ModRulesCardGui
|
||||
{
|
||||
public:
|
||||
vector<ModRulesBackGroundCardGuiItem *> background;
|
||||
vector<ModRulesRenderCardGuiItem *> renderbig;
|
||||
vector<ModRulesRenderCardGuiItem *> rendertinycrop;
|
||||
void parse(TiXmlElement* element);
|
||||
~ModRulesCardGui();
|
||||
};
|
||||
|
||||
class ModRulesGame
|
||||
{
|
||||
public:
|
||||
@@ -123,7 +159,7 @@ public:
|
||||
ModRulesCards cards;
|
||||
ModRulesMenu menu;
|
||||
ModRulesGame game;
|
||||
|
||||
ModRulesCardGui cardgui;
|
||||
bool load(string filename);
|
||||
static int getValueAsInt(TiXmlElement* element, string childName);
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ string AIHints::constraintsNotFulfilled(AIAction * action, AIHint * hint, ManaCo
|
||||
{
|
||||
//Not enough Mana, try to find which mana we should get in priority
|
||||
ManaCost * diff = potentialMana->Diff(a->getCost());
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
if(diff->getCost(i) < 0)
|
||||
{
|
||||
|
||||
@@ -52,7 +52,10 @@ int AIMomirPlayer::momir()
|
||||
|
||||
if (efficiency >= chance)
|
||||
{
|
||||
int8_t _cost[] = { Constants::MTG_COLOR_ARTIFACT, converted };
|
||||
|
||||
std::vector<int8_t> _cost;
|
||||
_cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
_cost.push_back(converted);
|
||||
ManaCost * cost = NEW ManaCost(_cost);
|
||||
MTGAbility * ability = getMomirAbility();
|
||||
MTGCardInstance * card = game->hand->cards[0];
|
||||
|
||||
@@ -773,7 +773,7 @@ bool AIPlayerBaka::payTheManaCost(ManaCost * cost, MTGCardInstance * target,vect
|
||||
{
|
||||
used[card] = true;
|
||||
int doUse = 1;
|
||||
for (int i = Constants::MTG_NB_COLORS - 1; i >= 0; i--)
|
||||
for (int i = Constants::NB_Colors - 1; i >= 0; i--)
|
||||
{
|
||||
if (diff->getCost(i) && amp->output->getCost(i))
|
||||
{
|
||||
@@ -908,7 +908,7 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
}
|
||||
else if (amp && canHandleCost(amp) && amp->isReactingToClick(amp->source,amp->getCost()))
|
||||
{
|
||||
for (int k = Constants::MTG_NB_COLORS-1; k > 0 ; k--)//go backwards.
|
||||
for (int k = Constants::NB_Colors-1; k > 0 ; k--)//go backwards.
|
||||
{
|
||||
if (cost->hasColor(k) && amp->output->hasColor(k) && result->getCost(k) < cost->getCost(k))
|
||||
{
|
||||
@@ -993,7 +993,7 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
ManaCost * checkResult = NEW ManaCost();
|
||||
check->init();
|
||||
checkResult->init();
|
||||
for (int k = 1; k < Constants::MTG_NB_COLORS; k++)
|
||||
for (int k = 1; k < Constants::NB_Colors; k++)
|
||||
{
|
||||
check->add(k,cost->getCost(k));
|
||||
checkResult->add(k,result->getCost(k));
|
||||
@@ -1056,7 +1056,7 @@ vector<MTGAbility*> AIPlayerBaka::canPaySunBurst(ManaCost * cost)
|
||||
continue;//pentid prism, has no cost but contains a counter cost, without this check ai will think it can still use this mana.
|
||||
if (amp && canHandleCost(amp) && amp->isReactingToClick(amp->source,amp->getCost()))
|
||||
{
|
||||
for (int k = Constants::MTG_NB_COLORS-1; k > 0 ; k--)
|
||||
for (int k = Constants::NB_Colors-1; k > 0 ; k--)
|
||||
{
|
||||
if (amp->output->hasColor(k) && result->getCost(k) < 1 && result->getConvertedCost() < cost->getConvertedCost())
|
||||
{
|
||||
|
||||
@@ -240,7 +240,7 @@ Interruptible(observer, id), tc(tc), cost(_cost), payResult(payResult)
|
||||
int Spell::computeX(MTGCardInstance * card)
|
||||
{
|
||||
ManaCost * c = cost->Diff(card->getManaCost());
|
||||
int x = c->getCost(Constants::MTG_NB_COLORS);
|
||||
int x = c->getCost(Constants::NB_Colors);
|
||||
delete c;
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -1952,7 +1952,7 @@ int AARemoveMana::resolve()
|
||||
{
|
||||
if (mManaDesc) // Remove all mana Matching a description
|
||||
{
|
||||
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
if (mManaDesc->hasColor(i))
|
||||
manaPool->removeAll(i);
|
||||
@@ -2635,7 +2635,7 @@ void AAlterCost::increaseTheCost(MTGCardInstance * card)
|
||||
{
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
{
|
||||
for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::MTG_NB_COLORS;k++)
|
||||
for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::NB_Colors;k++)
|
||||
{
|
||||
card->getManaCost()->add(k,card->getIncreasedManaCost()->getCost(k));
|
||||
if (card->getManaCost()->alternative)
|
||||
@@ -2655,7 +2655,7 @@ void AAlterCost::decreaseTheCost(MTGCardInstance * card)
|
||||
{
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
{
|
||||
for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::MTG_NB_COLORS;k++)
|
||||
for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::NB_Colors;k++)
|
||||
{
|
||||
card->getManaCost()->remove(k,card->getReducedManaCost()->getCost(k));
|
||||
if (card->getManaCost()->alternative)
|
||||
@@ -2739,7 +2739,7 @@ int ATransformer::addToGame()
|
||||
while (_target->next)
|
||||
_target = _target->next;
|
||||
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors; j++)
|
||||
{
|
||||
if (_target->hasColor(j))
|
||||
oldcolors.push_back(j);
|
||||
@@ -4210,7 +4210,7 @@ void PopulateColorIndexVector(list<int>& colors, const string& colorStringList,
|
||||
vector<string> abilitiesList = split(colorStringList, delimiter);
|
||||
for (vector<string>::iterator iter = abilitiesList.begin(); iter != abilitiesList.end(); ++iter)
|
||||
{
|
||||
for (int colorIndex = Constants::MTG_COLOR_ARTIFACT; colorIndex < Constants::MTG_NB_COLORS; ++colorIndex)
|
||||
for (int colorIndex = Constants::MTG_COLOR_ARTIFACT; colorIndex < Constants::NB_Colors; ++colorIndex)
|
||||
{
|
||||
// if the text is not a basic ability but contains a valid color add it to the color vector
|
||||
if ((Constants::GetBasicAbilityIndex(*iter) == -1)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -132,16 +132,12 @@ const string CardPrimitive::getOtherRestrictions()
|
||||
|
||||
void CardPrimitive::setColor(const string& _color, int removeAllOthers)
|
||||
{
|
||||
if (_color.compare(Constants::kManaBlue) == 0)
|
||||
return setColor(Constants::MTG_COLOR_BLUE, removeAllOthers);
|
||||
if (_color.compare(Constants::kManaRed) == 0)
|
||||
return setColor(Constants::MTG_COLOR_RED, removeAllOthers);
|
||||
if (_color.compare(Constants::kManaGreen) == 0)
|
||||
return setColor(Constants::MTG_COLOR_GREEN, removeAllOthers);
|
||||
if (_color.compare(Constants::kManaBlack) == 0)
|
||||
return setColor(Constants::MTG_COLOR_BLACK, removeAllOthers);
|
||||
if (_color.compare(Constants::kManaWhite) == 0)
|
||||
return setColor(Constants::MTG_COLOR_WHITE, removeAllOthers);
|
||||
for( size_t i =0 ; i< Constants::MTGColorStrings.size(); i++)
|
||||
{
|
||||
if (_color.compare(Constants::MTGColorStrings._Myfirst[i]) == 0)
|
||||
return setColor(i, removeAllOthers);
|
||||
}
|
||||
//Keep artifact compare, to Remove this we need change all MTG.txt
|
||||
if (_color.compare("artifact") == 0)
|
||||
return setColor(Constants::MTG_COLOR_ARTIFACT, removeAllOthers);
|
||||
}
|
||||
@@ -164,7 +160,7 @@ int CardPrimitive::getColor()
|
||||
{
|
||||
if (colors)
|
||||
{
|
||||
for (int i = 1; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 1; i < Constants::NB_Colors; i++)
|
||||
if (hasColor(i))
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
this->countSpellsPerCost[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i <= Constants::NB_Colors; i++)
|
||||
{
|
||||
this->totalCostPerColor[i] = 0;
|
||||
this->countLandsPerColor[i] = 0;
|
||||
@@ -412,7 +412,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
|
||||
for (int i = 0; i <= Constants::STATS_MAX_MANA_COST; i++)
|
||||
{
|
||||
for (int k = 0; k <= Constants::MTG_NB_COLORS; k++)
|
||||
for (int k = 0; k <= Constants::NB_Colors; k++)
|
||||
{
|
||||
this->countCardsPerCostAndColor[i][k] = 0;
|
||||
this->countCreaturesPerCostAndColor[i][k] = 0;
|
||||
@@ -481,7 +481,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
{
|
||||
s = s.substr(t + 3);
|
||||
ManaCost * mc = ManaCost::parseManaCost(s);
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors; j++)
|
||||
{
|
||||
if (mc->hasColor(j))
|
||||
{
|
||||
@@ -508,7 +508,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
|
||||
// Add to the per color counters
|
||||
// a. regular costs
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors; j++)
|
||||
{
|
||||
this->totalCostPerColor[j] += currentCost->getCost(j) * currentCount;
|
||||
if (current->data->hasColor(j))
|
||||
@@ -539,7 +539,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
}
|
||||
|
||||
this->totalColoredSymbols = 0;
|
||||
for (int j = 1; j < Constants::MTG_NB_COLORS; j++)
|
||||
for (int j = 1; j < Constants::NB_Colors; j++)
|
||||
{
|
||||
this->totalColoredSymbols += this->totalCostPerColor[j];
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ JMusic * GameApp::music = NULL;
|
||||
string GameApp::currentMusicFile = "";
|
||||
string GameApp::systemError = "";
|
||||
|
||||
JQuadPtr manaIcons[7];
|
||||
vector<JQuadPtr > manaIcons;
|
||||
|
||||
GameState::GameState(GameApp* parent, string id) :
|
||||
mParent(parent), mStringID(id)
|
||||
@@ -161,22 +161,25 @@ void GameApp::Create()
|
||||
LOG("--Loading menuicons.png");
|
||||
WResourceManager::Instance()->RetrieveTexture("menuicons.png", RETRIEVE_MANAGE);
|
||||
LOG("---Gettings menuicons.png quads");
|
||||
//Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id
|
||||
manaIcons[Constants::MTG_COLOR_GREEN] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 0 * 36, 38, 32, 32, "c_green",
|
||||
RETRIEVE_MANAGE);
|
||||
manaIcons[Constants::MTG_COLOR_BLUE] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 1 * 36, 38, 32, 32, "c_blue",
|
||||
RETRIEVE_MANAGE);
|
||||
manaIcons[Constants::MTG_COLOR_RED] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 3 * 36, 38, 32, 32, "c_red", RETRIEVE_MANAGE);
|
||||
manaIcons[Constants::MTG_COLOR_BLACK] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 2 * 36, 38, 32, 32, "c_black",
|
||||
RETRIEVE_MANAGE);
|
||||
manaIcons[Constants::MTG_COLOR_WHITE] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 4 * 36, 38, 32, 32, "c_white",
|
||||
RETRIEVE_MANAGE);
|
||||
manaIcons[Constants::MTG_COLOR_LAND] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 5 * 36, 38, 32, 32, "c_land",
|
||||
RETRIEVE_MANAGE);
|
||||
manaIcons[Constants::MTG_COLOR_ARTIFACT] = WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + 6 * 36, 38, 32, 32, "c_artifact",
|
||||
RETRIEVE_MANAGE);
|
||||
|
||||
//Load all icons from gModRules and save in manaIcons -> todo. Change the icons positions on menuicons.png to avoid use item->mColorId
|
||||
vector<ModRulesBackGroundCardGuiItem *>items = gModRules.cardgui.background;
|
||||
for(size_t i= 0; i < items.size(); i ++)
|
||||
{
|
||||
|
||||
ModRulesBackGroundCardGuiItem * item = items[i];
|
||||
if (item->mMenuIcon == 1)
|
||||
{
|
||||
manaIcons.push_back(WResourceManager::Instance()->RetrieveQuad("menuicons.png", 2 + (float)item->mColorId * 36, 38, 32, 32, "c_" + item->MColorName, RETRIEVE_MANAGE));
|
||||
Constants::MTGColorStrings.push_back(item->MColorName.c_str());
|
||||
}
|
||||
}
|
||||
Constants::NB_Colors = (int)Constants::MTGColorStrings.size();
|
||||
|
||||
items.erase(items.begin(),items.end());
|
||||
|
||||
|
||||
for (int i = sizeof(manaIcons) / sizeof(manaIcons[0]) - 1; i >= 0; --i)
|
||||
for (int i = manaIcons.size()-1; i >= 0; --i)
|
||||
if (manaIcons[i].get())
|
||||
manaIcons[i]->SetHotSpot(16, 16);
|
||||
|
||||
|
||||
@@ -225,14 +225,8 @@ void GameStateDeckViewer::Start()
|
||||
displayed_deck = myCollection;
|
||||
|
||||
//Icons
|
||||
mIcons[Constants::MTG_COLOR_ARTIFACT] = WResourceManager::Instance()->GetQuad("c_artifact");
|
||||
mIcons[Constants::MTG_COLOR_LAND] = WResourceManager::Instance()->GetQuad("c_land");
|
||||
mIcons[Constants::MTG_COLOR_WHITE] = WResourceManager::Instance()->GetQuad("c_white");
|
||||
mIcons[Constants::MTG_COLOR_RED] = WResourceManager::Instance()->GetQuad("c_red");
|
||||
mIcons[Constants::MTG_COLOR_BLACK] = WResourceManager::Instance()->GetQuad("c_black");
|
||||
mIcons[Constants::MTG_COLOR_BLUE] = WResourceManager::Instance()->GetQuad("c_blue");
|
||||
mIcons[Constants::MTG_COLOR_GREEN] = WResourceManager::Instance()->GetQuad("c_green");
|
||||
for (int i = 0; i < 7; i++)
|
||||
mIcons = manaIcons;
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
mIcons[i]->SetHotSpot(16, 16);
|
||||
}
|
||||
@@ -723,7 +717,7 @@ void GameStateDeckViewer::renderDeckBackground()
|
||||
int max2 = 0;
|
||||
int maxC2 = 4;
|
||||
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS - 1; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors - 1; i++)
|
||||
{
|
||||
int value = myDeck->getCount(i);
|
||||
if (value > max1)
|
||||
@@ -816,7 +810,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
//Your Deck Information
|
||||
char buffer[300];
|
||||
int nb_letters = 0;
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors; j++)
|
||||
{
|
||||
int value = myDeck->getCount(j);
|
||||
if (value > 0)
|
||||
@@ -890,7 +884,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
posY += 10;
|
||||
|
||||
// Counts by color
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors; j++)
|
||||
{
|
||||
int value = myDeck->getCount(j);
|
||||
if (value > 0)
|
||||
@@ -1008,7 +1002,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
posY = 70;
|
||||
|
||||
// Column titles
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS - 1; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors - 1; j++)
|
||||
{
|
||||
r->RenderQuad(mIcons[j].get(), 52 + j * 15 + leftTransition, posY - 10, 0, 0.5, 0.5);
|
||||
}
|
||||
@@ -1017,20 +1011,20 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
//font->DrawString(_("Ty"), 27 + leftTransition, posY-16);
|
||||
|
||||
// Horizontal table lines
|
||||
r->DrawLine(27 + leftTransition, posY - 20, 60 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, posY - 20,
|
||||
r->DrawLine(27 + leftTransition, posY - 20, 60 + (Constants::NB_Colors - 2) * 15 + leftTransition, posY - 20,
|
||||
ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(27 + leftTransition, posY - 1, 60 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, posY - 1,
|
||||
r->DrawLine(27 + leftTransition, posY - 1, 60 + (Constants::NB_Colors - 2) * 15 + leftTransition, posY - 1,
|
||||
ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(27 + leftTransition, 2 * 10 + posY + 12, 60 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, 2 * 10
|
||||
r->DrawLine(27 + leftTransition, 2 * 10 + posY + 12, 60 + (Constants::NB_Colors - 2) * 15 + leftTransition, 2 * 10
|
||||
+ posY + 12, ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(27 + leftTransition, 3 * 10 + posY + 14, 60 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, 3 * 10
|
||||
r->DrawLine(27 + leftTransition, 3 * 10 + posY + 14, 60 + (Constants::NB_Colors - 2) * 15 + leftTransition, 3 * 10
|
||||
+ posY + 14, ARGB(128, 255, 255, 255));
|
||||
|
||||
// Vertical table lines
|
||||
r->DrawLine(26 + leftTransition, posY - 20, 26 + leftTransition, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(43 + leftTransition, posY - 20, 43 + leftTransition, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(60 + leftTransition + (Constants::MTG_NB_COLORS - 2) * 15, posY - 20, 60 + leftTransition
|
||||
+ (Constants::MTG_NB_COLORS - 2) * 15, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(60 + leftTransition + (Constants::NB_Colors - 2) * 15, posY - 20, 60 + leftTransition
|
||||
+ (Constants::NB_Colors - 2) * 15, 3 * 10 + posY + 14, ARGB(128, 255, 255, 255));
|
||||
|
||||
font->DrawString(_("BL"), 27 + leftTransition, posY);
|
||||
font->DrawString(_("NB"), 27 + leftTransition, posY + 10);
|
||||
@@ -1039,7 +1033,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
|
||||
int curCount;
|
||||
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS - 1; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors - 1; j++)
|
||||
{
|
||||
curCount = stw->countBasicLandsPerColor[j];
|
||||
sprintf(buffer, (curCount == 0 ? "." : "%i"), curCount);
|
||||
@@ -1076,13 +1070,13 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
|
||||
int totalProducedSymbols;
|
||||
totalProducedSymbols = 0;
|
||||
for (int i = 1; i < Constants::MTG_NB_COLORS - 1; i++)
|
||||
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
||||
{
|
||||
totalProducedSymbols += stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i]; //!! Move to updatestats!
|
||||
}
|
||||
|
||||
posY = 50;
|
||||
for (int i = 1; i < Constants::MTG_NB_COLORS - 1; i++)
|
||||
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
||||
{
|
||||
if (stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i] > 0)
|
||||
{
|
||||
@@ -1154,7 +1148,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
posY = 70;
|
||||
|
||||
// Column titles
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS - 1; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors - 1; j++)
|
||||
{
|
||||
r->RenderQuad(mIcons[j].get(), 67 + j * 15 + leftTransition, posY - 10, 0, 0.5, 0.5);
|
||||
}
|
||||
@@ -1163,11 +1157,11 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
font->DrawString(_("#"), 45 + leftTransition, posY - 16);
|
||||
|
||||
// Horizontal table lines
|
||||
r->DrawLine(27 + leftTransition, posY - 20, 75 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, posY - 20,
|
||||
r->DrawLine(27 + leftTransition, posY - 20, 75 + (Constants::NB_Colors - 2) * 15 + leftTransition, posY - 20,
|
||||
ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(27 + leftTransition, posY - 1, 75 + (Constants::MTG_NB_COLORS - 2) * 15 + leftTransition, posY - 1,
|
||||
r->DrawLine(27 + leftTransition, posY - 1, 75 + (Constants::NB_Colors - 2) * 15 + leftTransition, posY - 1,
|
||||
ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(27 + leftTransition, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, 75 + (Constants::MTG_NB_COLORS - 2)
|
||||
r->DrawLine(27 + leftTransition, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, 75 + (Constants::NB_Colors - 2)
|
||||
* 15 + leftTransition, Constants::STATS_MAX_MANA_COST * 10 + posY + 12, ARGB(128, 255, 255, 255));
|
||||
|
||||
// Vertical table lines
|
||||
@@ -1177,8 +1171,8 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(58 + leftTransition, posY - 20, 58 + leftTransition, Constants::STATS_MAX_MANA_COST * 10 + posY + 12,
|
||||
ARGB(128, 255, 255, 255));
|
||||
r->DrawLine(75 + leftTransition + (Constants::MTG_NB_COLORS - 2) * 15, posY - 20, 75 + leftTransition
|
||||
+ (Constants::MTG_NB_COLORS - 2) * 15, Constants::STATS_MAX_MANA_COST * 10 + posY + 12,
|
||||
r->DrawLine(75 + leftTransition + (Constants::NB_Colors - 2) * 15, posY - 20, 75 + leftTransition
|
||||
+ (Constants::NB_Colors - 2) * 15, Constants::STATS_MAX_MANA_COST * 10 + posY + 12,
|
||||
ARGB(128, 255, 255, 255));
|
||||
|
||||
for (int i = 0; i <= Constants::STATS_MAX_MANA_COST; i++)
|
||||
@@ -1187,12 +1181,12 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
font->DrawString(buffer, 30 + leftTransition, posY);
|
||||
sprintf(buffer, ((*countPerCost)[i] > 0) ? _("%i").c_str() : ".", (*countPerCost)[i]);
|
||||
font->DrawString(buffer, 45 + leftTransition, posY);
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS - 1; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors - 1; j++)
|
||||
{
|
||||
sprintf(buffer, ((*countPerCostAndColor)[i][j] > 0) ? _("%i").c_str() : ".", (*countPerCostAndColor)[i][j]);
|
||||
font->DrawString(buffer, 64 + leftTransition + j * 15, posY);
|
||||
}
|
||||
r->FillRect(77.f + leftTransition + (Constants::MTG_NB_COLORS - 2) * 15.0f, posY + 2.0f, (*countPerCost)[i] * 5.0f,
|
||||
r->FillRect(77.f + leftTransition + (Constants::NB_Colors - 2) * 15.0f, posY + 2.0f, (*countPerCost)[i] * 5.0f,
|
||||
8.0f, graphColor);
|
||||
posY += 10;
|
||||
}
|
||||
@@ -1257,7 +1251,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
||||
font->DrawString(_("Total colored manasymbols in cards' casting costs:"), 20 + leftTransition, 30);
|
||||
|
||||
posY = 50;
|
||||
for (int i = 1; i < Constants::MTG_NB_COLORS - 1; i++)
|
||||
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
||||
{
|
||||
if (stw->totalCostPerColor[i] > 0)
|
||||
{
|
||||
|
||||
@@ -240,11 +240,12 @@ GuiMana::~GuiMana()
|
||||
|
||||
void GuiMana::RenderStatic()
|
||||
{
|
||||
int values[Constants::MTG_NB_COLORS];
|
||||
vector<int> values;
|
||||
values.resize(Constants::NB_Colors);
|
||||
int totalColors = 0;
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||
JRenderer * r = JRenderer::GetInstance();
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i)
|
||||
for (int i = 0; i < Constants::NB_Colors; ++i)
|
||||
values[i] = 0;
|
||||
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||
if (ManaIcon::ALIVE == (*it)->mode)
|
||||
@@ -263,7 +264,7 @@ void GuiMana::RenderStatic()
|
||||
r->FillRoundRect(x0, y - 5, static_cast<float> (20 * totalColors + 5), 20, 2, ARGB(128,0,0,0));
|
||||
|
||||
int offset = 0;
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i)
|
||||
for (int i = 0; i < Constants::NB_Colors; ++i)
|
||||
{
|
||||
if (values[i])
|
||||
{
|
||||
@@ -273,7 +274,7 @@ void GuiMana::RenderStatic()
|
||||
}
|
||||
r->FillRoundRect(x0, y, static_cast<float> (20 * totalColors + 5), 8, 2, ARGB(100,0,0,0));
|
||||
offset = 0;
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i)
|
||||
for (int i = 0; i < Constants::NB_Colors; ++i)
|
||||
{
|
||||
if (values[i])
|
||||
{
|
||||
|
||||
@@ -2983,7 +2983,10 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
||||
|
||||
case 1103: //Crystal Rod
|
||||
{
|
||||
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||
|
||||
std::vector<int8_t> cost;
|
||||
cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
cost.push_back(1);
|
||||
ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_BLUE, NEW ManaCost(cost, 1), 1);
|
||||
observer->addObserver(ability);
|
||||
break;
|
||||
@@ -3015,7 +3018,10 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
||||
}
|
||||
case 1113: //Iron Star
|
||||
{
|
||||
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||
|
||||
std::vector<int8_t> cost;
|
||||
cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
cost.push_back(1);
|
||||
ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_RED, NEW ManaCost(cost, 1), 1);
|
||||
observer->addObserver(ability);
|
||||
break;
|
||||
@@ -3027,7 +3033,9 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
||||
}
|
||||
case 1114: //Ivory cup
|
||||
{
|
||||
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||
std::vector<int8_t> cost;
|
||||
cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
cost.push_back(1);
|
||||
ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_WHITE, NEW ManaCost(cost, 1), 1);
|
||||
observer->addObserver(ability);
|
||||
break;
|
||||
@@ -3100,7 +3108,9 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
||||
|
||||
case 1140: //Throne of Bone
|
||||
{
|
||||
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||
std::vector<int8_t> cost;
|
||||
cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
cost.push_back(1);
|
||||
ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_BLACK, NEW ManaCost(cost, 1), 1);
|
||||
observer->addObserver(ability);
|
||||
break;
|
||||
@@ -3108,7 +3118,9 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
||||
|
||||
case 1142: //Wooden Sphere
|
||||
{
|
||||
int8_t cost[] = { Constants::MTG_COLOR_ARTIFACT, 1 };
|
||||
std::vector<int8_t> cost;
|
||||
cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
cost.push_back(1);
|
||||
ASpellCastLife* ability = NEW ASpellCastLife(observer, _id, card, Constants::MTG_COLOR_GREEN, NEW ManaCost(cost, 1), 1);
|
||||
observer->addObserver(ability);
|
||||
break;
|
||||
|
||||
@@ -308,8 +308,9 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
|
||||
void MTGAllCards::initCounters()
|
||||
{
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
colorsCount[i] = 0;
|
||||
colorsCount.erase(colorsCount.begin(),colorsCount.end());
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
colorsCount.push_back(0);
|
||||
}
|
||||
|
||||
void MTGAllCards::init()
|
||||
@@ -480,7 +481,7 @@ int MTGAllCards::countByColor(int color)
|
||||
{
|
||||
if (colorsCount[color] == 0)
|
||||
{
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
colorsCount[i] = 0;
|
||||
}
|
||||
@@ -811,8 +812,9 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
|
||||
{
|
||||
if (howmany <= 0) return 1;
|
||||
|
||||
int unallowedColors[Constants::MTG_NB_COLORS + 1];
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i)
|
||||
vector<int> unallowedColors;
|
||||
unallowedColors.resize(Constants::NB_Colors + 1);
|
||||
for (int i = 0; i < Constants::NB_Colors; ++i)
|
||||
{
|
||||
if (nbcolors)
|
||||
unallowedColors[i] = 1;
|
||||
@@ -854,7 +856,7 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
|
||||
|
||||
if (ok)
|
||||
{
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; ++j)
|
||||
for (int j = 0; j < Constants::NB_Colors; ++j)
|
||||
{
|
||||
if (unallowedColors[j] && card->data->hasColor(j))
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using std::string;
|
||||
#include "MTGDefinitions.h"
|
||||
|
||||
char Constants::MTGColorChars[] = {'x','g','u','r','b','w','l'};
|
||||
const char* Constants::MTGColorStrings[] = {"artifact", "green", "blue", "red", "black", "white", "land"};
|
||||
vector <const char*> Constants::MTGColorStrings;
|
||||
|
||||
const string Constants::kManaColorless = "colorless";
|
||||
const string Constants::kManaGreen = "green";
|
||||
@@ -26,6 +26,8 @@ const string Constants::kRetraceKeyword = "retrace";
|
||||
const string Constants::kKickerKeyword = "kicker";
|
||||
const string Constants::kMorphKeyword = "facedown";
|
||||
|
||||
int Constants::NB_Colors; //Store de Max number of colors
|
||||
|
||||
const char* Constants::MTGBasicAbilities[] = {
|
||||
"trample",
|
||||
"forestwalk",
|
||||
@@ -141,7 +143,7 @@ int Constants::GetBasicAbilityIndex(string basicAbllity)
|
||||
|
||||
int Constants::GetColorStringIndex(string mtgColor)
|
||||
{
|
||||
for (int idx = 0; idx < Constants::MTG_NB_COLORS; ++idx)
|
||||
for (int idx = 0; idx < Constants::NB_Colors; ++idx)
|
||||
{
|
||||
if (Constants::MTGColorStrings[idx])
|
||||
return idx;
|
||||
|
||||
@@ -208,7 +208,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
for (int j = 0; j < Constants::NB_Colors; j++)
|
||||
{
|
||||
if (c == Constants::MTGColorChars[j])
|
||||
{
|
||||
@@ -245,12 +245,12 @@ ManaCost::ManaCost()
|
||||
init();
|
||||
}
|
||||
|
||||
ManaCost::ManaCost(int8_t _cost[], int nb_elems)
|
||||
ManaCost::ManaCost(vector<int8_t>& _cost, int nb_elems)
|
||||
{
|
||||
init();
|
||||
for (int i = 0; i < nb_elems; i++)
|
||||
{
|
||||
cost[_cost[i * 2]] = _cost[i * 2 + 1];
|
||||
cost[_cost._Myfirst[i * 2]] = _cost._Myfirst[i * 2 + 1];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -262,7 +262,7 @@ ManaCost::ManaCost(ManaCost * manaCost)
|
||||
init();
|
||||
if ( !manaCost )
|
||||
return;
|
||||
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i <= Constants::NB_Colors; i++)
|
||||
{
|
||||
cost[i] = manaCost->getCost(i);
|
||||
}
|
||||
@@ -288,9 +288,9 @@ ManaCost::ManaCost(const ManaCost& manaCost)
|
||||
: InstanceCounter<ManaCost>(manaCost)
|
||||
#endif
|
||||
{
|
||||
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i <= Constants::NB_Colors; i++)
|
||||
{
|
||||
cost[i] = manaCost.cost[i];
|
||||
cost.push_back(manaCost.cost[i]);
|
||||
}
|
||||
|
||||
hybrids = manaCost.hybrids;
|
||||
@@ -312,7 +312,7 @@ ManaCost & ManaCost::operator= (const ManaCost & manaCost)
|
||||
{
|
||||
if ( this != &manaCost )
|
||||
{
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
cost[i] = manaCost.cost[i];
|
||||
|
||||
hybrids = manaCost.hybrids;
|
||||
@@ -338,24 +338,27 @@ ManaCost::~ManaCost()
|
||||
SAFE_DELETE(Retrace);
|
||||
SAFE_DELETE(morph);
|
||||
SAFE_DELETE(suspend);
|
||||
|
||||
cost.erase(cost.begin() ,cost.end());
|
||||
}
|
||||
|
||||
void ManaCost::x()
|
||||
{
|
||||
cost[Constants::MTG_NB_COLORS] = 1;
|
||||
cost[Constants::NB_Colors] = 1;
|
||||
}
|
||||
|
||||
int ManaCost::hasX()
|
||||
{
|
||||
return cost[Constants::MTG_NB_COLORS];
|
||||
return cost[Constants::NB_Colors];
|
||||
}
|
||||
|
||||
void ManaCost::init()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i <= Constants::MTG_NB_COLORS; i++)
|
||||
cost.erase(cost.begin(),cost.end());
|
||||
for (i = 0; i <= Constants::NB_Colors; i++)
|
||||
{
|
||||
cost[i] = 0;
|
||||
cost.push_back(0);
|
||||
}
|
||||
extraCosts = NULL;
|
||||
kicker = NULL;
|
||||
@@ -371,9 +374,12 @@ void ManaCost::init()
|
||||
void ManaCost::reinit()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i <= Constants::MTG_NB_COLORS; i++)
|
||||
|
||||
cost.erase(cost.begin() ,cost.end());
|
||||
|
||||
for (i = 0; i <= Constants::NB_Colors; i++)
|
||||
{
|
||||
cost[i] = 0;
|
||||
cost.push_back(0);
|
||||
}
|
||||
SAFE_DELETE(extraCosts);
|
||||
SAFE_DELETE(kicker);
|
||||
@@ -389,9 +395,12 @@ void ManaCost::copy(ManaCost * _manaCost)
|
||||
{
|
||||
if (!_manaCost)
|
||||
return;
|
||||
for (unsigned int i = 0; i <= Constants::MTG_NB_COLORS; i++)
|
||||
|
||||
cost.erase(cost.begin() ,cost.end());
|
||||
|
||||
for (int i = 0; i <= Constants::NB_Colors; i++)
|
||||
{
|
||||
cost[i] = _manaCost->getCost(i);
|
||||
cost.push_back(_manaCost->getCost(i));
|
||||
}
|
||||
|
||||
hybrids = _manaCost->hybrids;
|
||||
@@ -483,7 +492,7 @@ int ManaCost::isNull()
|
||||
int ManaCost::getConvertedCost()
|
||||
{
|
||||
int result = 0;
|
||||
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for ( int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
result += cost[i];
|
||||
}
|
||||
@@ -524,7 +533,7 @@ int ManaCost::add(ManaCost * _cost)
|
||||
{
|
||||
if (!_cost)
|
||||
return 0;
|
||||
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for ( int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
cost[i] += _cost->getCost(i);
|
||||
}
|
||||
@@ -538,7 +547,7 @@ int ManaCost::remove(ManaCost * _cost)
|
||||
{
|
||||
if (!_cost)
|
||||
return 0;
|
||||
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for ( int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
int8_t toRemove = min(cost[i], (int8_t)_cost->getCost(i)); //we don't want to be negative
|
||||
cost[i] -= toRemove;
|
||||
@@ -601,7 +610,7 @@ int ManaCost::pay(ManaCost * _cost)
|
||||
ManaCost * toPay = NEW ManaCost();
|
||||
toPay->copy(_cost);
|
||||
ManaCost * diff = Diff(toPay);
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
cost[i] = diff->getCost(i);
|
||||
}
|
||||
@@ -626,10 +635,10 @@ int ManaCost::canAfford(ManaCost * _cost)
|
||||
|
||||
int ManaCost::isPositive()
|
||||
{
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
|
||||
if (cost[i] < 0)
|
||||
if (cost._Myfirst[i] < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -638,7 +647,7 @@ int ManaCost::isPositive()
|
||||
|
||||
}
|
||||
|
||||
void ManaCost::randomDiffHybrids(ManaCost * _cost, int8_t diff[])
|
||||
void ManaCost::randomDiffHybrids(ManaCost * _cost, std::vector<int8_t>& diff)
|
||||
{
|
||||
for (size_t i = 0; i < _cost->hybrids.size(); i++)
|
||||
{
|
||||
@@ -650,7 +659,7 @@ void ManaCost::randomDiffHybrids(ManaCost * _cost, int8_t diff[])
|
||||
/**
|
||||
starting from the end of the array (diff)
|
||||
*/
|
||||
int ManaCost::tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids, int8_t diff[])
|
||||
int ManaCost::tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids, std::vector<int8_t>& diff)
|
||||
{
|
||||
if (!_nbhybrids)
|
||||
return 1;
|
||||
@@ -681,12 +690,13 @@ ManaCost * ManaCost::Diff(ManaCost * _cost)
|
||||
if (!_cost)
|
||||
return NEW ManaCost(*this); //diff with null is equivalent to diff with 0
|
||||
|
||||
int8_t diff[(Constants::MTG_NB_COLORS + 1) * 2];
|
||||
diff[Constants::MTG_NB_COLORS * 2] = Constants::MTG_NB_COLORS;
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
vector<int8_t> diff;
|
||||
diff.resize((Constants::NB_Colors + 1) * 2);
|
||||
diff[Constants::NB_Colors * 2] = Constants::NB_Colors;
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
diff[i * 2] = i;
|
||||
diff[i * 2 + 1] = cost[i] - _cost->getCost(i);
|
||||
diff[i * 2 + 1] = cost._Myfirst[i] - _cost->getCost(i);
|
||||
}
|
||||
int hybridResult = tryToPayHybrids(_cost->hybrids, _cost->hybrids.size(), diff);
|
||||
if (!hybridResult)
|
||||
@@ -696,7 +706,7 @@ ManaCost * ManaCost::Diff(ManaCost * _cost)
|
||||
int colorless_idx = Constants::MTG_COLOR_ARTIFACT * 2 + 1;
|
||||
if (diff[colorless_idx] < 0)
|
||||
{
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
if (diff[i * 2 + 1] > 0)
|
||||
{
|
||||
@@ -718,18 +728,18 @@ ManaCost * ManaCost::Diff(ManaCost * _cost)
|
||||
//Cost X
|
||||
if (_cost->hasX())
|
||||
{
|
||||
diff[Constants::MTG_NB_COLORS * 2 + 1] = 0;
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
diff[Constants::NB_Colors * 2 + 1] = 0;
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
if (diff[i * 2 + 1] > 0)
|
||||
{
|
||||
diff[Constants::MTG_NB_COLORS * 2 + 1] += diff[i * 2 + 1];
|
||||
diff[Constants::NB_Colors * 2 + 1] += diff[i * 2 + 1];
|
||||
diff[i * 2 + 1] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ManaCost * result = NEW ManaCost(diff, Constants::MTG_NB_COLORS + 1);
|
||||
ManaCost * result = NEW ManaCost(diff, Constants::NB_Colors + 1);
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -737,7 +747,7 @@ ManaCost * ManaCost::Diff(ManaCost * _cost)
|
||||
string ManaCost::toString()
|
||||
{
|
||||
ostringstream oss;
|
||||
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i <= Constants::NB_Colors; i++)
|
||||
{
|
||||
if (cost[i])
|
||||
{
|
||||
@@ -828,7 +838,7 @@ int ManaPool::add(ManaCost * _cost, MTGCardInstance * source)
|
||||
if (!_cost)
|
||||
return 0;
|
||||
int result = ManaCost::add(_cost);
|
||||
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
for (int j = 0; j < _cost->getCost(i); j++)
|
||||
{
|
||||
@@ -841,14 +851,14 @@ int ManaPool::add(ManaCost * _cost, MTGCardInstance * source)
|
||||
|
||||
int ManaPool::pay(ManaCost * _cost)
|
||||
{
|
||||
int current[Constants::MTG_NB_COLORS];
|
||||
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
vector<int> current;
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
current[i] = cost[i];
|
||||
current.push_back(cost[i]);
|
||||
}
|
||||
|
||||
int result = ManaCost::pay(_cost);
|
||||
for (unsigned int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
int value = current[i] - cost[i];
|
||||
for (int j = 0; j < value; j++)
|
||||
@@ -858,5 +868,6 @@ int ManaPool::pay(ManaCost * _cost)
|
||||
|
||||
}
|
||||
}
|
||||
current.erase(current.begin(),current.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ bool ModRules::load(string filename)
|
||||
{
|
||||
game.parse(element);
|
||||
}
|
||||
else if (strcmp(element->Value(), "cardgui") == 0)
|
||||
{
|
||||
cardgui.parse(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -277,3 +281,82 @@ ModRulesCards::~ModRulesCards()
|
||||
{
|
||||
SAFE_DELETE(activateEffect);
|
||||
}
|
||||
|
||||
ModRulesBackGroundCardGuiItem::ModRulesBackGroundCardGuiItem(string ColorId,string ColorName, string DisplayImg, string DisplayThumb,string MenuIcon)
|
||||
{
|
||||
mColorId = atoi(ColorId.c_str());
|
||||
MColorName = ColorName;
|
||||
mDisplayImg = DisplayImg;
|
||||
mDisplayThumb = DisplayThumb;
|
||||
mMenuIcon = atoi(MenuIcon.c_str());
|
||||
}
|
||||
|
||||
ModRulesRenderCardGuiItem::ModRulesRenderCardGuiItem(string Name, string PosX, string PosY, string FormattedData, string Type)
|
||||
{
|
||||
mName = Name;
|
||||
mPosX = atoi(PosX.c_str());
|
||||
mPosY = atoi(PosY.c_str());
|
||||
mFormattedData = FormattedData;
|
||||
mType = Type;
|
||||
}
|
||||
|
||||
void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
{
|
||||
TiXmlNode* mainNode = element->FirstChild("background");
|
||||
if (mainNode) {
|
||||
for (TiXmlNode* node = mainNode->ToElement()->FirstChild("card"); node; node = node->NextSibling("card"))
|
||||
{
|
||||
TiXmlElement* element = node->ToElement();
|
||||
{
|
||||
background.push_back(NEW ModRulesBackGroundCardGuiItem(
|
||||
element->Attribute("id"),
|
||||
element->Attribute("color"),
|
||||
element->Attribute("img"),
|
||||
element->Attribute("thumb"),
|
||||
element->Attribute("menuicon")));
|
||||
}
|
||||
}
|
||||
}
|
||||
mainNode = element->FirstChild("renderbig");
|
||||
if (mainNode) {
|
||||
for (TiXmlNode* node = mainNode->ToElement()->FirstChild("item"); node; node = node->NextSibling("item"))
|
||||
{
|
||||
TiXmlElement* element = node->ToElement();
|
||||
{
|
||||
renderbig.push_back(NEW ModRulesRenderCardGuiItem(
|
||||
element->Attribute("name"),
|
||||
element->Attribute("posx"),
|
||||
element->Attribute("posy"),
|
||||
element->Attribute("formattedtext"),
|
||||
element->Attribute("type")));
|
||||
}
|
||||
}
|
||||
}
|
||||
mainNode = element->FirstChild("rendertinycrop");
|
||||
if (mainNode) {
|
||||
for (TiXmlNode* node = mainNode->ToElement()->FirstChild("item"); node; node = node->NextSibling("item"))
|
||||
{
|
||||
TiXmlElement* element = node->ToElement();
|
||||
{
|
||||
renderbig.push_back(NEW ModRulesRenderCardGuiItem(
|
||||
element->Attribute("name"),
|
||||
element->Attribute("posx"),
|
||||
element->Attribute("posy"),
|
||||
element->Attribute("formattedtext"),
|
||||
element->Attribute("type")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModRulesCardGui::~ModRulesCardGui()
|
||||
{
|
||||
for (size_t i = 0; i < background.size(); ++i)
|
||||
SAFE_DELETE(background[i]);
|
||||
for (size_t i = 0; i < renderbig.size(); ++i)
|
||||
SAFE_DELETE(renderbig[i]);
|
||||
|
||||
background.clear();
|
||||
renderbig.clear();
|
||||
|
||||
}
|
||||
|
||||
@@ -552,7 +552,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
int attributefound = 0;
|
||||
//Colors - remove Artifact and Land from the loop
|
||||
for (int cid = 1; cid < Constants::MTG_NB_COLORS - 1; cid++)
|
||||
for (int cid = 1; cid < Constants::NB_Colors - 1; cid++)
|
||||
{
|
||||
if (attribute.find(Constants::MTGColorStrings[cid]) != string::npos)
|
||||
{
|
||||
|
||||
@@ -950,7 +950,7 @@ void TaskMassiveBurial::restoreCustomAttribs()
|
||||
|
||||
void TaskMassiveBurial::randomize()
|
||||
{
|
||||
color = rand() % (Constants::MTG_NB_COLORS - 1) + 1;
|
||||
color = rand() % (Constants::NB_Colors - 1) + 1;
|
||||
bodyCount = 5 + ((Constants::MTG_COLOR_LAND == color) ? rand() % 10 : rand() % 20);
|
||||
Task::randomize();
|
||||
}
|
||||
@@ -1044,7 +1044,7 @@ void TaskWisdom::restoreCustomAttribs()
|
||||
|
||||
void TaskWisdom::randomize()
|
||||
{
|
||||
color = rand() % (Constants::MTG_NB_COLORS - 1) + 1;
|
||||
color = rand() % (Constants::NB_Colors - 1) + 1;
|
||||
cardCount = 2 + ((Constants::MTG_COLOR_LAND == color) ? rand() % 5 : rand() % 7);
|
||||
Task::randomize();
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ string WCFilterColor::getCode()
|
||||
{
|
||||
char buf[12];
|
||||
char c = '?';
|
||||
if (color < 0 || color >= Constants::MTG_NB_COLORS) c = Constants::MTGColorChars[color];
|
||||
if (color < 0 || color >= Constants::NB_Colors) c = Constants::MTGColorChars[color];
|
||||
sprintf(buf, "color:%c;", c);
|
||||
return buf;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ WCFilterColor::WCFilterColor(string arg)
|
||||
{
|
||||
color = -1;
|
||||
char c = tolower(arg[0]);
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
if (Constants::MTGColorChars[i] == c)
|
||||
{
|
||||
@@ -240,7 +240,7 @@ WCFilterColor::WCFilterColor(string arg)
|
||||
bool WCFilterOnlyColor::isMatch(MTGCard * c)
|
||||
{
|
||||
if (!c || !c->data) return false;
|
||||
for (int i = 0; i < Constants::MTG_NB_COLORS; i++)
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
if (i == color) continue;
|
||||
if (c->data->hasColor(i)) return false;
|
||||
@@ -251,7 +251,7 @@ string WCFilterOnlyColor::getCode()
|
||||
{
|
||||
char buf[12];
|
||||
char c = '?';
|
||||
if (color < 0 || color >= Constants::MTG_NB_COLORS) c = Constants::MTGColorChars[color];
|
||||
if (color < 0 || color >= Constants::NB_Colors) c = Constants::MTGColorChars[color];
|
||||
sprintf(buf, "xcolor:%c;", c);
|
||||
return buf;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ string WCFilterProducesColor::getCode()
|
||||
{
|
||||
char buf[12];
|
||||
char c = '?';
|
||||
if (color < 0 || color >= Constants::MTG_NB_COLORS) c = Constants::MTGColorChars[color];
|
||||
if (color < 0 || color >= Constants::NB_Colors) c = Constants::MTGColorChars[color];
|
||||
sprintf(buf, "produces:%c;", c);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ void WFBFont::DrawString(const char *s, float x, float y, int align, float leftO
|
||||
mRenderer->RenderQuad(manaIcons[mana].get(), xx + 3 * sinf(2 * M_PI * ((float) t) / 256.0f), yy + 3 * cosf(2
|
||||
* M_PI * ((float) (t - 35)) / 256.0f), 0, 0.5f * mScale, 0.5f * mScale);
|
||||
}
|
||||
mana = Constants::MTG_NB_COLORS + 1; // do not draw colorless cost in hybrid mana cost
|
||||
mana = Constants::NB_Colors + 1; // do not draw colorless cost in hybrid mana cost
|
||||
}
|
||||
else
|
||||
mRenderer->RenderQuad(manaIcons[mana].get(), xx, yy, 0, 0.5f * mScale, 0.5f * mScale);
|
||||
@@ -935,7 +935,7 @@ void WGBKFont::DrawString(const char *s, float x, float y, int align, float left
|
||||
mRenderer->RenderQuad(manaIcons[mana].get(), xx + 3 * sinf(2 * M_PI * ((float) t) / 256.0f), yy + 3 * cosf(2
|
||||
* M_PI * ((float) (t - 35)) / 256.0f), 0, 0.5f * mScale, 0.5f * mScale);
|
||||
}
|
||||
mana = Constants::MTG_NB_COLORS + 1; // donot draw colorless cost in hybrid mana cost
|
||||
mana = Constants::NB_Colors + 1; // donot draw colorless cost in hybrid mana cost
|
||||
}
|
||||
else
|
||||
mRenderer->RenderQuad(manaIcons[mana].get(), xx, yy, 0, 0.5f * mScale, 0.5f * mScale);
|
||||
|
||||
@@ -1686,7 +1686,7 @@ bool WGuiFilters::Finish(bool emptyset)
|
||||
{
|
||||
WCFilterFactory * wc = WCFilterFactory::GetInstance();
|
||||
WCardFilter * f = wc->Construct(src);
|
||||
if (recolorTo > -1 && recolorTo < Constants::MTG_NB_COLORS)
|
||||
if (recolorTo > -1 && recolorTo < Constants::NB_Colors)
|
||||
{
|
||||
f = NEW WCFilterAND(f, NEW WCFilterColor(recolorTo));
|
||||
}
|
||||
@@ -1694,7 +1694,7 @@ bool WGuiFilters::Finish(bool emptyset)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (recolorTo > -1 && recolorTo < Constants::MTG_NB_COLORS)
|
||||
if (recolorTo > -1 && recolorTo < Constants::NB_Colors)
|
||||
{
|
||||
WCardFilter * f = NEW WCFilterColor(recolorTo);
|
||||
source->addFilter(f);
|
||||
|
||||
Reference in New Issue
Block a user