Erwan
- Added a way to name and describe AI Decks. Let's find cool names and descriptions :)
This commit is contained in:
@@ -102,23 +102,31 @@ JLBFont::~JLBFont()
|
|||||||
void JLBFont::DrawString(const char *string, float x, float y, int align, float leftOffset, float displayWidth)
|
void JLBFont::DrawString(const char *string, float x, float y, int align, float leftOffset, float displayWidth)
|
||||||
{
|
{
|
||||||
char *p = (char*)string;
|
char *p = (char*)string;
|
||||||
float dx = x, dy = y;
|
float dx0 = x, dy = y;
|
||||||
|
|
||||||
if (mQuad == NULL) return;
|
if (mQuad == NULL) return;
|
||||||
|
|
||||||
float width = GetStringWidth(string);
|
float width = GetStringWidth(string);
|
||||||
|
|
||||||
if (align == JGETEXT_RIGHT)
|
if (align == JGETEXT_RIGHT)
|
||||||
dx -= width;
|
dx0 -= width;
|
||||||
else if (align == JGETEXT_CENTER)
|
else if (align == JGETEXT_CENTER)
|
||||||
dx -= width/2;
|
dx0 -= width/2;
|
||||||
|
|
||||||
dx = floorf(dx);
|
float dx = floorf(dx0);
|
||||||
dy = floorf(dy);
|
dy = floorf(dy);
|
||||||
float x0 = dx;
|
float x0 = dx;
|
||||||
int index;
|
int index;
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
|
if (*p == '\n') {
|
||||||
|
p++;
|
||||||
|
dy += (mHeight * 1.1 * mScale);
|
||||||
|
dy = floorf(dy);
|
||||||
|
dx = dx0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
index = (*p - 32)+mBase;
|
index = (*p - 32)+mBase;
|
||||||
float charWidth = mCharWidth[index];
|
float charWidth = mCharWidth[index];
|
||||||
float delta = (charWidth + mTracking) * mScale;
|
float delta = (charWidth + mTracking) * mScale;
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
#NAME:Rats!
|
||||||
|
#DESC:"They fought the dogs, and killed the cats,
|
||||||
|
#DESC:And bit the babies in the cradles,
|
||||||
|
#DESC:And ate the cheeses out of the vats
|
||||||
|
#DESC:And licked the soup from the cook's own ladles,
|
||||||
|
#DESC:Split open the kegs of salted sprats,
|
||||||
|
#DESC:Made nests inside men's Sunday hats,
|
||||||
|
#DESC:And even spoiled the women's chats,
|
||||||
|
#DESC:By drowning their speaking
|
||||||
|
#DESC:With shrieking and squeaking
|
||||||
|
#DESC:In fifty different sharps and flats."
|
||||||
#Black Deck, Rats
|
#Black Deck, Rats
|
||||||
#26 Swamps
|
#26 Swamps
|
||||||
157886
|
157886
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#NAME:Faeries
|
||||||
|
#DESC:Be warned, those are not butterflies...
|
||||||
|
#DESC:Or the dangerous kind.
|
||||||
#Plain blue deck
|
#Plain blue deck
|
||||||
#4 x Control Magic, {2}{U}{U}, Enchant creature
|
#4 x Control Magic, {2}{U}{U}, Enchant creature
|
||||||
1194
|
1194
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
#Plain Green Elf deck
|
#NAME:Elves
|
||||||
|
#DESC:And here you thought you would enjoy
|
||||||
|
#DESC:a little trip in the forest...
|
||||||
|
#DESC:
|
||||||
|
#DESC:Who said only Goblins were nasty?
|
||||||
#4x Elvish Archers,{1}{G},2/1,Creature Elf,first strike
|
#4x Elvish Archers,{1}{G},2/1,Creature Elf,first strike
|
||||||
1242
|
1242
|
||||||
1242
|
1242
|
||||||
|
|||||||
@@ -79,8 +79,11 @@ class MTGDeck:public MTGAllCards{
|
|||||||
protected:
|
protected:
|
||||||
string filename;
|
string filename;
|
||||||
MTGAllCards * allcards;
|
MTGAllCards * allcards;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards);
|
string meta_desc;
|
||||||
|
string meta_name;
|
||||||
|
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only = 0);
|
||||||
int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL);
|
int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL);
|
||||||
int add(int cardid);
|
int add(int cardid);
|
||||||
int remove(int cardid);
|
int remove(int cardid);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class SimpleMenu:public JGuiController{
|
|||||||
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title = "", int _maxItems = 7);
|
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title = "", int _maxItems = 7);
|
||||||
void Render();
|
void Render();
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
void Add(int id, const char * Text);
|
void Add(int id, const char * Text,string desc = "");
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
float selectionTargetY;
|
float selectionTargetY;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class SimpleMenuItem: public JGuiObject
|
|||||||
float mTargetScale;
|
float mTargetScale;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
string desc;
|
||||||
SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, string text, int x, int y, bool hasFocus = false);
|
SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, string text, int x, int y, bool hasFocus = false);
|
||||||
|
|
||||||
int mX;
|
int mX;
|
||||||
|
|||||||
@@ -272,22 +272,24 @@ void GameStateDuel::Update(float dt)
|
|||||||
char deckDesc[512];
|
char deckDesc[512];
|
||||||
sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1);
|
sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1);
|
||||||
if(fileExists(buffer)){
|
if(fileExists(buffer)){
|
||||||
found = 1;
|
MTGDeck * mtgd = NEW MTGDeck(buffer,NULL,NULL,1);
|
||||||
nbAIDecks++;
|
found = 1;
|
||||||
sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks);
|
nbAIDecks++;
|
||||||
DeckStats * stats = DeckStats::GetInstance();
|
sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks);
|
||||||
stats->load(mPlayers[0]);
|
DeckStats * stats = DeckStats::GetInstance();
|
||||||
int percentVictories = stats->percentVictories(string(aiSmallDeckName));
|
stats->load(mPlayers[0]);
|
||||||
string difficulty;
|
int percentVictories = stats->percentVictories(string(aiSmallDeckName));
|
||||||
if (percentVictories < 34){
|
string difficulty;
|
||||||
difficulty = "(hard)";
|
if (percentVictories < 34){
|
||||||
}else if (percentVictories < 67){
|
difficulty = "(hard)";
|
||||||
difficulty = "";
|
}else if (percentVictories < 67){
|
||||||
}else{
|
difficulty = "";
|
||||||
difficulty = "(easy)";
|
}else{
|
||||||
}
|
difficulty = "(easy)";
|
||||||
sprintf(deckDesc, "Deck %i %s",nbAIDecks, _(difficulty).c_str());
|
}
|
||||||
opponentMenu->Add(nbAIDecks,deckDesc);
|
sprintf(deckDesc, "%s %s",mtgd->meta_name.c_str(), _(difficulty).c_str());
|
||||||
|
opponentMenu->Add(nbAIDecks,deckDesc,mtgd->meta_desc);
|
||||||
|
delete mtgd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,16 +327,35 @@ MTGCard * MTGAllCards::getCardByName(string name){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards){
|
MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only){
|
||||||
mCache = cache;
|
mCache = cache;
|
||||||
total_cards = 0;
|
total_cards = 0;
|
||||||
allcards = _allcards;
|
allcards = _allcards;
|
||||||
filename = config_file;
|
filename = config_file;
|
||||||
|
size_t slash = filename.find_last_of("/");
|
||||||
|
size_t dot = filename.find(".");
|
||||||
|
meta_name = filename.substr(slash+1,dot-slash-1);
|
||||||
std::ifstream file(config_file);
|
std::ifstream file(config_file);
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
if(file){
|
if(file){
|
||||||
while(std::getline(file,s)){
|
while(std::getline(file,s)){
|
||||||
|
if (!s.size()) continue;
|
||||||
|
if (s[0] == '#'){
|
||||||
|
size_t found = s.find("NAME:");
|
||||||
|
if ( found != string::npos){
|
||||||
|
meta_name = s.substr(found+5);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
found = s.find("DESC:");
|
||||||
|
if ( found != string::npos){
|
||||||
|
if (meta_desc.size()) meta_desc.append("\n");
|
||||||
|
meta_desc.append(s.substr(found+5));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (meta_only) break;
|
||||||
int cardnb = atoi(s.c_str());
|
int cardnb = atoi(s.c_str());
|
||||||
if (cardnb){
|
if (cardnb){
|
||||||
add(cardnb);
|
add(cardnb);
|
||||||
|
|||||||
@@ -134,8 +134,10 @@ void SimpleMenu::Render(){
|
|||||||
if (i > mCount-1) break;
|
if (i > mCount-1) break;
|
||||||
if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7)
|
if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7)
|
||||||
{
|
{
|
||||||
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus())
|
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus()){
|
||||||
mFont->SetColor(ARGB(255,255,255,0));
|
GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+20,mY+15);
|
||||||
|
mFont->SetColor(ARGB(255,255,255,0));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mFont->SetColor(ARGB(255,255,255,255));
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
(static_cast<SimpleMenuItem*>(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId);
|
(static_cast<SimpleMenuItem*>(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId);
|
||||||
@@ -168,8 +170,10 @@ void SimpleMenu::Update(float dt){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::Add(int id, const char * text){
|
void SimpleMenu::Add(int id, const char * text,string desc){
|
||||||
JGuiController::Add(NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0)));
|
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0));
|
||||||
|
smi->desc = desc;
|
||||||
|
JGuiController::Add(smi);
|
||||||
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
|
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
from mtgCommon import *
|
from mtgCommon import *
|
||||||
|
|
||||||
setinfo=sets['OD']
|
setinfo=sets['UZ']
|
||||||
stripReminderText = False
|
stripReminderText = False
|
||||||
conffile = open(setinfo['dir'] + ".conf", 'w')
|
conffile = open(setinfo['dir'] + ".conf", 'w')
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ sets ={'BE':{'name':'Beta',
|
|||||||
'gathabbrev': '3E',
|
'gathabbrev': '3E',
|
||||||
'gathname':'RevisedEdition'
|
'gathname':'RevisedEdition'
|
||||||
},
|
},
|
||||||
|
'ARB':{'name':'Alara Reborn',
|
||||||
|
'dir':'ARB',
|
||||||
|
'abbrev':'ARB',
|
||||||
|
'gathdirs':['ARB/en-us'],
|
||||||
|
'gathabbrev': 'ARB',
|
||||||
|
'gathname':'Alara%20Reborn'
|
||||||
|
},
|
||||||
'4E':{'name':'4th Edition',
|
'4E':{'name':'4th Edition',
|
||||||
'dir':'4E',
|
'dir':'4E',
|
||||||
'abbrev':'4E',
|
'abbrev':'4E',
|
||||||
@@ -229,10 +236,11 @@ sets ={'BE':{'name':'Beta',
|
|||||||
'gathabbrev': 'EX',
|
'gathabbrev': 'EX',
|
||||||
'gathname':'Exodus',
|
'gathname':'Exodus',
|
||||||
},
|
},
|
||||||
'US':{'name':'Urza\'s Saga',
|
'UZ':{'name':'Urza\'s Saga',
|
||||||
'dir':'US',
|
'dir':'UZ',
|
||||||
'abbrev':'US',
|
'abbrev':'UZ',
|
||||||
'gathabbrev': 'UZ',
|
'gathabbrev': 'UZ',
|
||||||
|
'gathdirs':['UZ/en-us'],
|
||||||
'gathname':'UrzasSaga',
|
'gathname':'UrzasSaga',
|
||||||
},
|
},
|
||||||
'UL':{'name':'Urza\'s Legacy',
|
'UL':{'name':'Urza\'s Legacy',
|
||||||
@@ -250,7 +258,7 @@ sets ={'BE':{'name':'Beta',
|
|||||||
'MM':{'name':'Mercadian Masques',
|
'MM':{'name':'Mercadian Masques',
|
||||||
'dir':'MM',
|
'dir':'MM',
|
||||||
'abbrev':'MM',
|
'abbrev':'MM',
|
||||||
'gathdirs':['MM/en-us'],
|
'gathdirs':['MM/en-us'],
|
||||||
'gathabbrev': 'MM',
|
'gathabbrev': 'MM',
|
||||||
'gathname':'MercadianMasques',
|
'gathname':'MercadianMasques',
|
||||||
},
|
},
|
||||||
@@ -360,10 +368,11 @@ sets ={'BE':{'name':'Beta',
|
|||||||
'gathabbrev': 'SOK',
|
'gathabbrev': 'SOK',
|
||||||
'gathname':'SaviorsofKamigawa',
|
'gathname':'SaviorsofKamigawa',
|
||||||
},
|
},
|
||||||
'RA':{'name':'Ravnica: City of Guilds',
|
'RAV':{'name':'Ravnica: City of Guilds',
|
||||||
'dir':'RA',
|
'dir':'RAV',
|
||||||
'abbrev':'RA',
|
'abbrev':'RAV',
|
||||||
'gathabbrev': 'RAV',
|
'gathabbrev': 'RAV',
|
||||||
|
'gathdirs':['RAV/en-us'],
|
||||||
'gathname':'RavnicaCityofGuilds',
|
'gathname':'RavnicaCityofGuilds',
|
||||||
},
|
},
|
||||||
'GP':{'name':'Guildpact',
|
'GP':{'name':'Guildpact',
|
||||||
|
|||||||
Reference in New Issue
Block a user