Erwan
- Adding new icons from J - fixed a bug with Zombie Master (for real this time, I swear !) - The AI should play Wrath of god in a more "clever" way
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -51,3 +51,4 @@ terror.txt
|
|||||||
volcanic_island.txt
|
volcanic_island.txt
|
||||||
white_knight1.txt
|
white_knight1.txt
|
||||||
wrath_of_god.txt
|
wrath_of_god.txt
|
||||||
|
zombie_master.txt
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#Testing Zombie Master crash ?
|
||||||
|
[INIT]
|
||||||
|
COMBATATTACKERS
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:1188,129693,135216
|
||||||
|
[PLAYER2]
|
||||||
|
inplay:1299
|
||||||
|
[DO]
|
||||||
|
129693
|
||||||
|
1188
|
||||||
|
next
|
||||||
|
1299
|
||||||
|
next
|
||||||
|
next
|
||||||
|
129693
|
||||||
|
[ASSERT]
|
||||||
|
COMBATEND
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:135216,129693
|
||||||
|
graveyard:1188
|
||||||
|
[PLAYER2]
|
||||||
|
life:18
|
||||||
|
inplay:1299
|
||||||
|
[END]
|
||||||
@@ -882,7 +882,8 @@ class ALord:public ListMaintainerAbility{
|
|||||||
card->addToToughness(toughness);
|
card->addToToughness(toughness);
|
||||||
if (ability != -1) card->basicAbilities[ability] +=1;
|
if (ability != -1) card->basicAbilities[ability] +=1;
|
||||||
if (regenCost){
|
if (regenCost){
|
||||||
AStandardRegenerate * regen = NEW AStandardRegenerate(0, card, card, regenCost);
|
ManaCost * _regenCost = NEW ManaCost(regenCost);
|
||||||
|
AStandardRegenerate * regen = NEW AStandardRegenerate(0, card, card, _regenCost);
|
||||||
regenerations[card] = regen;
|
regenerations[card] = regen;
|
||||||
game->addObserver(regen);
|
game->addObserver(regen);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,11 @@ using std::map;
|
|||||||
|
|
||||||
//Two stupid variables used to give a hint to the AI:
|
//Two stupid variables used to give a hint to the AI:
|
||||||
// Should I cast a spell on an enemy or friendly unit ?
|
// Should I cast a spell on an enemy or friendly unit ?
|
||||||
#define BAKA_EFFECT_GOOD 10
|
#define BAKA_EFFECT_GOOD 1
|
||||||
#define BAKA_EFFECT_BAD 11
|
#define BAKA_EFFECT_BAD -1
|
||||||
|
#define BAKA_EFFECT_DONTKNOW 0
|
||||||
|
|
||||||
|
#define COUNT_POWER 1
|
||||||
|
|
||||||
class MTGAbility: public ActionElement{
|
class MTGAbility: public ActionElement{
|
||||||
protected:
|
protected:
|
||||||
@@ -183,6 +184,7 @@ class GenericTriggeredAbility:public TriggeredAbility{
|
|||||||
/* Ability Factory */
|
/* Ability Factory */
|
||||||
class AbilityFactory{
|
class AbilityFactory{
|
||||||
private:
|
private:
|
||||||
|
int countCards(TargetChooser * tc, Player * player = NULL, int option = 0);
|
||||||
int destroyAllInPlay(TargetChooser * tc, int bury = 0);
|
int destroyAllInPlay(TargetChooser * tc, int bury = 0);
|
||||||
int putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p);
|
int putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p);
|
||||||
Trigger * parseTrigger(string magicText);
|
Trigger * parseTrigger(string magicText);
|
||||||
@@ -195,3 +197,4 @@ class AbilityFactory{
|
|||||||
#include "MTGCardInstance.h"
|
#include "MTGCardInstance.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -76,31 +76,7 @@ void AIPlayer::tapLandsForMana(ManaCost * potentialMana, ManaCost * cost){
|
|||||||
|
|
||||||
delete(diff);
|
delete(diff);
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
for (int i=MTG_NB_COLORS-1; i>= 0; i--){
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
char buf[4096];
|
|
||||||
sprintf(buf,"Testing %s \n" ,MTG_LAND_TEXTS[i]);
|
|
||||||
OutputDebugString(buf);
|
|
||||||
#endif
|
|
||||||
currentCost = cost->getCost(i);
|
|
||||||
while(currentCost){
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
|
||||||
sprintf(buf,"Cost for %s is %i \n" ,MTG_LAND_TEXTS[i], currentCost);
|
|
||||||
OutputDebugString(buf);
|
|
||||||
#endif
|
|
||||||
MTGCardInstance * card = NULL;
|
|
||||||
while(currentCost && (card = cd.nextmatch(game->inPlay, card))){
|
|
||||||
if (i==MTG_COLOR_ARTIFACT || card->hasSubtype(MTG_LAND_TEXTS[i]) ){
|
|
||||||
currentCost--;
|
|
||||||
gameObs->cardClick(card);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
OutputDebugString("ok land tapped");
|
OutputDebugString("ok land tapped");
|
||||||
#endif
|
#endif
|
||||||
@@ -167,7 +143,7 @@ int AIPlayer::effectBadOrGood(MTGCardInstance * card){
|
|||||||
int autoGuess = af->magicText(id,NULL,card);
|
int autoGuess = af->magicText(id,NULL,card);
|
||||||
delete af;
|
delete af;
|
||||||
if (autoGuess) return autoGuess;
|
if (autoGuess) return autoGuess;
|
||||||
return BAKA_EFFECT_BAD;
|
return BAKA_EFFECT_DONTKNOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AIPlayer::chooseTarget(TargetChooser * tc){
|
int AIPlayer::chooseTarget(TargetChooser * tc){
|
||||||
@@ -184,7 +160,7 @@ int AIPlayer::chooseTarget(TargetChooser * tc){
|
|||||||
if (!(gameObs->currentlyActing() == this)) return 0;
|
if (!(gameObs->currentlyActing() == this)) return 0;
|
||||||
Player * target = this;
|
Player * target = this;
|
||||||
int cardEffect = effectBadOrGood(tc->source);
|
int cardEffect = effectBadOrGood(tc->source);
|
||||||
if (cardEffect == BAKA_EFFECT_BAD){
|
if (cardEffect != BAKA_EFFECT_GOOD){
|
||||||
target = this->opponent();
|
target = this->opponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,6 +443,15 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * potentialMana, const c
|
|||||||
int hasTarget = (chooseTarget(tc));
|
int hasTarget = (chooseTarget(tc));
|
||||||
delete tc;
|
delete tc;
|
||||||
if (!hasTarget)continue;
|
if (!hasTarget)continue;
|
||||||
|
}else{
|
||||||
|
int shouldPlayPercentage = 10;
|
||||||
|
int shouldPlay = effectBadOrGood(card);
|
||||||
|
if (shouldPlay == BAKA_EFFECT_GOOD){
|
||||||
|
shouldPlayPercentage = 90;
|
||||||
|
}else if(BAKA_EFFECT_DONTKNOW == shouldPlay){
|
||||||
|
shouldPlayPercentage = 70;
|
||||||
|
}
|
||||||
|
if (rand() % 100 > shouldPlayPercentage) continue;
|
||||||
}
|
}
|
||||||
nextCardToPlay = card;
|
nextCardToPlay = card;
|
||||||
maxCost = currentCost;
|
maxCost = currentCost;
|
||||||
|
|||||||
@@ -9,11 +9,33 @@
|
|||||||
#include "../include/MTGDeck.h"
|
#include "../include/MTGDeck.h"
|
||||||
|
|
||||||
|
|
||||||
|
int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option){
|
||||||
|
int result = 0;
|
||||||
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
|
for (int i = 0; i < 2 ; i++){
|
||||||
|
if (player && player!= game->players[i]) continue;
|
||||||
|
for (int j = game->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){
|
||||||
|
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
|
||||||
|
if (tc->canTarget(current)){
|
||||||
|
switch (option){
|
||||||
|
case COUNT_POWER:
|
||||||
|
result+= current->power;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int AbilityFactory::destroyAllInPlay(TargetChooser * tc, int bury){
|
int AbilityFactory::destroyAllInPlay(TargetChooser * tc, int bury){
|
||||||
tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target
|
tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
for (int i = 0; i < 2 ; i++){
|
for (int i = 0; i < 2 ; i++){
|
||||||
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
|
for (int j = game->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){
|
||||||
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
|
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
|
||||||
if (tc->canTarget(current)){
|
if (tc->canTarget(current)){
|
||||||
if (bury){
|
if (bury){
|
||||||
@@ -38,7 +60,7 @@ int AbilityFactory::putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone
|
|||||||
|
|
||||||
|
|
||||||
Trigger * AbilityFactory::parseTrigger(string magicText){
|
Trigger * AbilityFactory::parseTrigger(string magicText){
|
||||||
size_t found = magicText.find("@");
|
int found = magicText.find("@");
|
||||||
if (found == string::npos) return NULL;
|
if (found == string::npos) return NULL;
|
||||||
|
|
||||||
//Next Time...
|
//Next Time...
|
||||||
@@ -199,8 +221,8 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Bury
|
//Bury
|
||||||
found = s.find("bury");
|
found = s.find("bury");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_BAD;
|
|
||||||
if (trigger){
|
if (trigger){
|
||||||
|
if (dryMode) return BAKA_EFFECT_BAD;
|
||||||
BuryEvent * action = NEW BuryEvent();
|
BuryEvent * action = NEW BuryEvent();
|
||||||
game->addObserver(NEW GenericTriggeredAbility(id, card,trigger,action));
|
game->addObserver(NEW GenericTriggeredAbility(id, card,trigger,action));
|
||||||
}else{
|
}else{
|
||||||
@@ -210,9 +232,21 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
string starget = s.substr(found + 4,end - found - 4);
|
string starget = s.substr(found + 4,end - found - 4);
|
||||||
TargetChooserFactory tcf;
|
TargetChooserFactory tcf;
|
||||||
TargetChooser * targetAll = tcf.createTargetChooser(starget, card);
|
TargetChooser * targetAll = tcf.createTargetChooser(starget, card);
|
||||||
|
if (dryMode){
|
||||||
|
int myNbCards = countCards(targetAll,card->controller());
|
||||||
|
int opponentNbCards = countCards(targetAll, card->controller()->opponent());
|
||||||
|
int myCardsPower = countCards(targetAll,card->controller(),COUNT_POWER);
|
||||||
|
int opponentCardsPower = countCards(targetAll, card->controller()->opponent(),COUNT_POWER);
|
||||||
|
delete targetAll;
|
||||||
|
if (myNbCards < opponentNbCards || myCardsPower < opponentCardsPower) return BAKA_EFFECT_GOOD;
|
||||||
|
return BAKA_EFFECT_BAD;
|
||||||
|
}else{
|
||||||
this->destroyAllInPlay(targetAll,1);
|
this->destroyAllInPlay(targetAll,1);
|
||||||
delete targetAll;
|
delete targetAll;
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
if (dryMode) return BAKA_EFFECT_BAD;
|
||||||
if (tc){
|
if (tc){
|
||||||
game->addObserver(NEW ABurier(id, card,tc));
|
game->addObserver(NEW ABurier(id, card,tc));
|
||||||
}else{
|
}else{
|
||||||
@@ -227,16 +261,27 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Destroy
|
//Destroy
|
||||||
found = s.find("destroy");
|
found = s.find("destroy");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_BAD; //TODO compute according to nb in case of destroy all
|
|
||||||
found = s.find("all(");
|
found = s.find("all(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
int end = s.find(")");
|
int end = s.find(")");
|
||||||
string starget = s.substr(found + 4,end - found - 4);
|
string starget = s.substr(found + 4,end - found - 4);
|
||||||
TargetChooserFactory tcf;
|
TargetChooserFactory tcf;
|
||||||
TargetChooser * targetAll = tcf.createTargetChooser(starget, card);
|
TargetChooser * targetAll = tcf.createTargetChooser(starget, card);
|
||||||
|
if (dryMode){
|
||||||
|
int myNbCards = countCards(targetAll,card->controller());
|
||||||
|
int opponentNbCards = countCards(targetAll, card->controller()->opponent());
|
||||||
|
int myCardsPower = countCards(targetAll,card->controller(),COUNT_POWER);
|
||||||
|
int opponentCardsPower = countCards(targetAll, card->controller()->opponent(),COUNT_POWER);
|
||||||
|
delete targetAll;
|
||||||
|
if (myNbCards < opponentNbCards || myCardsPower < opponentCardsPower) return BAKA_EFFECT_GOOD;
|
||||||
|
return BAKA_EFFECT_BAD;
|
||||||
|
}else{
|
||||||
this->destroyAllInPlay(targetAll);
|
this->destroyAllInPlay(targetAll);
|
||||||
delete targetAll;
|
delete targetAll;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
|
if (dryMode) return BAKA_EFFECT_BAD;
|
||||||
if (tc){
|
if (tc){
|
||||||
game->addObserver(NEW ADestroyer(id, card,tc));
|
game->addObserver(NEW ADestroyer(id, card,tc));
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -294,9 +294,9 @@ int TestSuite::assertGame(){
|
|||||||
}
|
}
|
||||||
for (int k = 0; k < endState.playerData[i].zones[j].nbitems; k++){
|
for (int k = 0; k < endState.playerData[i].zones[j].nbitems; k++){
|
||||||
int cardid = endState.playerData[i].zones[j].cards[k];
|
int cardid = endState.playerData[i].zones[j].cards[k];
|
||||||
int realcardid = zone->cards[k]->getMTGId();
|
MTGCardInstance * card = getCardByMTGId(cardid);
|
||||||
if ( realcardid!= cardid){
|
if (!card || !zone->hasCard(card)){
|
||||||
sprintf(result, "<span class=\"error\">==Card ID not the same. Expected %i, got %i==</span><br />", cardid, realcardid);
|
sprintf(result, "<span class=\"error\">==Card ID not the same. Didn't find %i</span><br />", cardid);
|
||||||
Log(result);
|
Log(result);
|
||||||
error++;
|
error++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user