going to go ahead and commit this now as updating the ai decks to use this tool is going to be a huge task...i originally wanted to commit this when i had a substantial amount of ai decks using it, to show case how it makes a huge difference.
it is a feature that is for ai deck building what it will do is as follows #NAME:sample deck #DESC:The forces of fire and nature unite. #DESC: #DESC:Can you withstand #DESC:their combined fervor? toggledifficulty:lotus petal|black lotus (*) * 4 grizzly bear (*) * 4 someCard (8) *4 notice the toggle dificulty? syntax is ....toggledifficulty:easy card name or number|hard card (optional set if both belong to same set otheriwse use * ) *howmany toggledifficulty:frying pan|machine gun toggledifficulty:tomatoe|pumpkin (MBS) * 3 toggledifficulty:tomatoe|squash grizzly bear (*) * 4 the above exsample as easy will have a deck with: frying pan 4X tomatoe 4X grizzly bear and on hard it will have: machine gun 3x pumpkin squash 4X grizzly bears the entire deck can be built with toggledifficulty cards....its not limited to just a single use. you can also mix it up, some can be toggledifficulty some can be just like normal, you are not limited to having to have a complete deck of toggled cards... if your currently selected deck has an over all win ratio of 65% or higher...this deck will have 4 black lotuses in it...if youre overall win with the current deck you are playing is below 65% then those 4 black lotuses are replaced by 4 lotus petals instead...effectively making it an easier ai deck... note, the 2 cards used are exsamples...its a great way to show you the potential this change can have...an ai deck with 4 black lotuses will do WAY better then the same deck with 4 lotus petal...if you catch my drift...
This commit is contained in:
@@ -160,7 +160,7 @@ public:
|
|||||||
int totalCards();
|
int totalCards();
|
||||||
int totalPrice();
|
int totalPrice();
|
||||||
MTGDeck(MTGAllCards * _allcards);
|
MTGDeck(MTGAllCards * _allcards);
|
||||||
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0);
|
MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0);
|
||||||
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL,
|
int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL,
|
||||||
int * colors = NULL, int nbcolors = 0);
|
int * colors = NULL, int nbcolors = 0);
|
||||||
int add(int cardid);
|
int add(int cardid);
|
||||||
|
|||||||
@@ -1178,8 +1178,18 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op
|
|||||||
sprintf(avatarFile, "avatar%i.jpg", deckid);
|
sprintf(avatarFile, "avatar%i.jpg", deckid);
|
||||||
sprintf(deckFileSmall, "ai_baka_deck%i", deckid);
|
sprintf(deckFileSmall, "ai_baka_deck%i", deckid);
|
||||||
}
|
}
|
||||||
|
DeckStats * stats = DeckStats::GetInstance();
|
||||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, collection);
|
int deckSetting = NULL;
|
||||||
|
int diff = stats->percentVictories();
|
||||||
|
if (diff > 65)
|
||||||
|
{
|
||||||
|
deckSetting = HARD;
|
||||||
|
}
|
||||||
|
else if (diff < 65)
|
||||||
|
{
|
||||||
|
deckSetting = EASY;
|
||||||
|
}
|
||||||
|
MTGDeck * tempDeck = NEW MTGDeck(deckFile, collection,0,deckSetting);
|
||||||
AIPlayerBaka * baka = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, avatarFile);
|
AIPlayerBaka * baka = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, avatarFile);
|
||||||
baka->deckId = deckid;
|
baka->deckId = deckid;
|
||||||
SAFE_DELETE(tempDeck);
|
SAFE_DELETE(tempDeck);
|
||||||
|
|||||||
@@ -742,7 +742,7 @@ int MTGDeck::totalPrice()
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only)
|
MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only,int difficultyRating)
|
||||||
{
|
{
|
||||||
total_cards = 0;
|
total_cards = 0;
|
||||||
database = _allcards;
|
database = _allcards;
|
||||||
@@ -753,7 +753,7 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl
|
|||||||
meta_id = atoi(meta_name.substr(4).c_str());
|
meta_id = atoi(meta_name.substr(4).c_str());
|
||||||
wagic::ifstream file(config_file);
|
wagic::ifstream file(config_file);
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
while (std::getline(file, s))
|
while (std::getline(file, s))
|
||||||
@@ -778,6 +778,29 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (meta_only) break;
|
if (meta_only) break;
|
||||||
|
int nb = 1;
|
||||||
|
size_t found = s.find(" *");
|
||||||
|
if (found != string::npos)
|
||||||
|
{
|
||||||
|
nb = atoi(s.substr(found + 2).c_str());
|
||||||
|
s = s.substr(0, found);
|
||||||
|
}
|
||||||
|
size_t diff = s.find("toggledifficulty:");
|
||||||
|
if(diff != string::npos)
|
||||||
|
{
|
||||||
|
string cards = s.substr(diff + 17);
|
||||||
|
size_t separator = cards.find("|");
|
||||||
|
string cardeasy = cards.substr(0,separator);
|
||||||
|
string cardhard = cards.substr(separator + 1);
|
||||||
|
if(difficultyRating == HARD)
|
||||||
|
{
|
||||||
|
s = cardhard;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = cardeasy;
|
||||||
|
}
|
||||||
|
}
|
||||||
int cardnb = atoi(s.c_str());
|
int cardnb = atoi(s.c_str());
|
||||||
if (cardnb)
|
if (cardnb)
|
||||||
{
|
{
|
||||||
@@ -785,7 +808,6 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int nb = 1;
|
|
||||||
size_t found = s.find(" *");
|
size_t found = s.find(" *");
|
||||||
if (found != string::npos)
|
if (found != string::npos)
|
||||||
{
|
{
|
||||||
@@ -800,6 +822,7 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl
|
|||||||
add(card);
|
add(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DebugTrace("could not find Card matching name: " << s);
|
DebugTrace("could not find Card matching name: " << s);
|
||||||
|
|||||||
Reference in New Issue
Block a user