From d66ef78d1216cf5d121ae7bbfa99cbf6a06d18f8 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew" Date: Mon, 1 Dec 2008 12:10:55 +0000 Subject: [PATCH] Erwan - AI:increased percentage of chance to play an "unknown" Card - removed delay before displaying big card ingame - added 2 new AI Decks - Fixed a bug with afflict (see tests/afflict.txt) --- projects/mtg/bin/Res/ai/baka/deck14.txt | 67 +++++++++++++++++++++++ projects/mtg/bin/Res/ai/baka/deck15.txt | 69 ++++++++++++++++++++++++ projects/mtg/bin/Res/sets/10E/_cards.dat | 2 +- projects/mtg/bin/Res/sets/RV/_cards.dat | 2 +- projects/mtg/bin/Res/test/_tests.txt | 1 + projects/mtg/bin/Res/test/afflict.txt | 37 +++++++++++++ projects/mtg/src/AIPlayer.cpp | 6 +-- projects/mtg/src/DeckStats.cpp | 7 ++- projects/mtg/src/MTGAbility.cpp | 11 ++-- projects/mtg/src/MTGDeck.cpp | 4 +- projects/mtg/src/MTGGuiPlay.cpp | 2 +- 11 files changed, 194 insertions(+), 14 deletions(-) create mode 100644 projects/mtg/bin/Res/ai/baka/deck14.txt create mode 100644 projects/mtg/bin/Res/ai/baka/deck15.txt create mode 100644 projects/mtg/bin/Res/test/afflict.txt diff --git a/projects/mtg/bin/Res/ai/baka/deck14.txt b/projects/mtg/bin/Res/ai/baka/deck14.txt new file mode 100644 index 000000000..5a82d5bb8 --- /dev/null +++ b/projects/mtg/bin/Res/ai/baka/deck14.txt @@ -0,0 +1,67 @@ +#Blue Deck, with Persusasion +#28 Islands +176428 +176428 +176428 +176428 +176428 +176428 +176428 +158237 +158237 +158237 +158237 +158237 +158237 +158237 +157875 +157875 +157875 +157875 +157875 +157875 +157875 +157883 +157883 +157883 +157883 +157883 +157883 +157883 +#4persusasion +129900 +129900 +129900 +129900 +#4Boomerang +129494 +129494 +129494 +129494 +#2Lord of Atlantis +1206 +1206 +#2Merfolk +1210 +1210 +#4Gravelgill +141935 +141935 +141935 +141935 +#4Unsummon +136218 +136218 +136218 +136218 +#4Counsel of the Soratami +134757 +134757 +134757 +134757 +#2Air Elemental +129459 +129459 +#2 Mahamoti djinn +129633 +129633 \ No newline at end of file diff --git a/projects/mtg/bin/Res/ai/baka/deck15.txt b/projects/mtg/bin/Res/ai/baka/deck15.txt new file mode 100644 index 000000000..dbcdebfc0 --- /dev/null +++ b/projects/mtg/bin/Res/ai/baka/deck15.txt @@ -0,0 +1,69 @@ +#Black Deck, Rats +#26 Swamps +157886 +157886 +157886 +157886 +157886 +157871 +157871 +157871 +157871 +157871 +157871 +157871 +158239 +158239 +158239 +158239 +158239 +158239 +158239 +157889 +157889 +157889 +157889 +157889 +157889 +157889 +#4plague rats +1173 +1173 +1173 +1173 +#4plague beetle +129678 +129678 +129678 +129678 +#12 relentless rats +135236 +135236 +135236 +135236 +135236 +135236 +135236 +135236 +135236 +135236 +135236 +135236 +#4Oona's Gatewarden +141975 +141975 +141975 +141975 +#4Fear +129544 +129544 +129544 +129544 +#Ascendant Evincar +106525 +106525 +#4rain of tears +135220 +135220 +135220 +135220 \ No newline at end of file diff --git a/projects/mtg/bin/Res/sets/10E/_cards.dat b/projects/mtg/bin/Res/sets/10E/_cards.dat index 4d302b5c3..1d0e8bcd9 100644 --- a/projects/mtg/bin/Res/sets/10E/_cards.dat +++ b/projects/mtg/bin/Res/sets/10E/_cards.dat @@ -1204,7 +1204,7 @@ subtype=Aura [card] text=Relentless Rats gets +1/+1 for each other creature in play named Relentless Rats. A deck can have any number of cards named Relentless Rats. id=135236 -auto=champion(name:Relentless Rats) +auto=foreach(name:Relentless Rats) name=Relentless Rats rarity=U color=Black diff --git a/projects/mtg/bin/Res/sets/RV/_cards.dat b/projects/mtg/bin/Res/sets/RV/_cards.dat index 45fc6aadb..06fd7a3ff 100644 --- a/projects/mtg/bin/Res/sets/RV/_cards.dat +++ b/projects/mtg/bin/Res/sets/RV/_cards.dat @@ -1581,7 +1581,7 @@ subtype=Plains Mountain text=Plague Rats's power and toughness are each equal to the number of creatures named Plague Rats in play. id=1173 name=Plague Rats -auto=champion(name:Plague Rats) +auto=foreach(name:Plague Rats) rarity=C color=Black type=Creature diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 905c17915..a190e116a 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -11,6 +11,7 @@ generic/wither.txt ######################## #Specific Cards ######################## +afflict.txt anarchy.txt animate_dead.txt animate_dead2.txt diff --git a/projects/mtg/bin/Res/test/afflict.txt b/projects/mtg/bin/Res/test/afflict.txt new file mode 100644 index 000000000..0034f5f48 --- /dev/null +++ b/projects/mtg/bin/Res/test/afflict.txt @@ -0,0 +1,37 @@ +#Make sure afflict does -1/-1 and makes you draw a card +[INIT] +FIRSTMAIN +[PLAYER1] +hand:135206 +inplay:2455 +library:129580 +manapool:{B}{2} +[PLAYER2] +inplay:129586 +[DO] +135206 +129586 +next +#combat begin +next +#attackers +2455 +next +#blockers +129586 +next +#damage +next +#combat end +[ASSERT] +COMBATEND +[PLAYER1] +hand:129580 +graveyard:135206 +inplay:2455 +manapool:{0} +life:20 +[PLAYER2] +graveyard:129586 +life:20 +[END] \ No newline at end of file diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 7bf547b62..01a699513 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -229,11 +229,11 @@ int AIPlayer::chooseAttackers(){ int opponentCreatures = getCreaturesInfo(opponent(), INFO_NBCREATURES); int myForce = getCreaturesInfo(this,INFO_CREATURESPOWER,-1,1); int myCreatures = getCreaturesInfo(this, INFO_NBCREATURES, -1,1); - bool attack = (myCreatures > opponentCreatures || myForce > opponentForce || myForce > 2*opponent()->life); + bool attack = ((myCreatures > opponentCreatures) || (myForce > opponentForce) || (myForce > 2*opponent()->life)); if (attack){ CardDescriptor cd; cd.init(); - cd.setType("Creature"); + cd.setType("creature"); MTGCardInstance * card = NULL; while((card = cd.nextmatch(game->inPlay, card))){ GameObserver::GetInstance()->cardClick(card); @@ -433,7 +433,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * potentialMana, const c if (shouldPlay == BAKA_EFFECT_GOOD){ shouldPlayPercentage = 90; }else if(BAKA_EFFECT_DONTKNOW == shouldPlay){ - shouldPlayPercentage = 70; + shouldPlayPercentage = 80; } if (rand() % 100 > shouldPlayPercentage) continue; } diff --git a/projects/mtg/src/DeckStats.cpp b/projects/mtg/src/DeckStats.cpp index 503d02437..baf7d1586 100644 --- a/projects/mtg/src/DeckStats.cpp +++ b/projects/mtg/src/DeckStats.cpp @@ -84,7 +84,12 @@ void DeckStats::save(const char * filename){ void DeckStats::saveStats(Player *player, Player *opponent, GameObserver * game){ int victory = 1; - if (game->gameOver == player) victory = 0; + if (!game->gameOver){ + if (player->life == opponent->life) return; + if (player->life < opponent->life) victory = 0; + }else if (game->gameOver == player) { + victory = 0; + } load(player); map::iterator it = stats.find(opponent->deckFile); if (it == stats.end()){ diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index d4db8310c..0dce80350 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -154,13 +154,13 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ } } - //Champion. Very basic, needs to be improved ! - found = s.find("champion(name:"); + //foreach. Very basic, needs to be improved ! + found = s.find("foreach(name:"); if (found != string::npos){ if (dryMode) return BAKA_EFFECT_GOOD; - unsigned int end = s.find(")", found+14); + unsigned int end = s.find(")", found+13); if (end != string::npos){ - string type = s.substr(found+14,end-found-14).c_str(); + string type = s.substr(found+13,end-found-13).c_str(); game->addObserver(NEW APlagueRats(id,card,type.c_str())); result++; continue; @@ -365,7 +365,8 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ found = s.find("/"); if (found != string::npos){ unsigned int start = s.find(":"); - if (start == string::npos) start = found-2; + if (start == string::npos) start = s.find(" "); + if (start == string::npos) start = -1; int power = atoi(s.substr(start+1,size-found).c_str()); unsigned int end = s.find(" ",start); int toughness; diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index a18d35ab8..4e4b98854 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -234,13 +234,13 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){ if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files switch(conf_read_mode) { case 0: - if (s.find("[card]") != string::npos){ + if (s[0] == '['){ collection[total_cards] = NEW MTGCard(mCache,set_id); conf_read_mode = 1; } break; case 1: - if (s.find("[/card]") != string::npos){ + if (s[0] == '[' && s[1] == '/'){ conf_read_mode = 0; total_cards++; }else{ diff --git a/projects/mtg/src/MTGGuiPlay.cpp b/projects/mtg/src/MTGGuiPlay.cpp index b5b23b621..02746373e 100644 --- a/projects/mtg/src/MTGGuiPlay.cpp +++ b/projects/mtg/src/MTGGuiPlay.cpp @@ -358,7 +358,7 @@ void MTGGuiPlay::Render(){ if (mCount && mObjects[mCurr] != NULL){ mObjects[mCurr]->Render(); - if (hasFocus && mCurr >= offset && showBigCards && last_user_move > BIG_CARD_RENDER_TIME){ + if (hasFocus && mCurr >= offset && showBigCards){ ((CardGui *)mObjects[mCurr])->RenderBig(-1,-1,showBigCards-1); } }