Erwan
-fix issue 79 (AI and legendary cards)
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
#Bug:Does ai put 2 legends of same name in play ?
|
||||||
|
[INIT]
|
||||||
|
SECONDMAIN
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:urborg
|
||||||
|
hand:forest,urborg
|
||||||
|
[PLAYER2]
|
||||||
|
[DO]
|
||||||
|
ai
|
||||||
|
ai
|
||||||
|
[ASSERT]
|
||||||
|
COMBATEND
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:Wildslayer Elves,Armadillo Cloak
|
||||||
|
life:25
|
||||||
|
[PLAYER2]
|
||||||
|
graveyard:grizzly bears
|
||||||
|
life:17
|
||||||
|
[END]
|
||||||
@@ -79,6 +79,7 @@ class MTGGameZone {
|
|||||||
MTGCardInstance * hasCard(MTGCardInstance * card);
|
MTGCardInstance * hasCard(MTGCardInstance * card);
|
||||||
void cleanupPhase();
|
void cleanupPhase();
|
||||||
int countByType(const char * value);
|
int countByType(const char * value);
|
||||||
|
MTGCardInstance * findByName(string name);
|
||||||
int hasType(const char * value);
|
int hasType(const char * value);
|
||||||
void setOwner(Player * player);
|
void setOwner(Player * player);
|
||||||
MTGCardInstance * lastCardDrawn;
|
MTGCardInstance * lastCardDrawn;
|
||||||
|
|||||||
@@ -590,6 +590,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * potentialMana, const c
|
|||||||
card = NULL;
|
card = NULL;
|
||||||
while((card = cd.nextmatch(game->hand, card))){
|
while((card = cd.nextmatch(game->hand, card))){
|
||||||
if (card->hasType("land") && !this->canPutLandsIntoPlay) continue;
|
if (card->hasType("land") && !this->canPutLandsIntoPlay) continue;
|
||||||
|
if (card->has(Constants::LEGENDARY) && game->inPlay->findByName(card->name)) continue;
|
||||||
int currentCost = card->getManaCost()->getConvertedCost();
|
int currentCost = card->getManaCost()->getConvertedCost();
|
||||||
if (currentCost > maxCost && potentialMana->canAfford(card->getManaCost())){
|
if (currentCost > maxCost && potentialMana->canAfford(card->getManaCost())){
|
||||||
TargetChooserFactory * tcf = NEW TargetChooserFactory();
|
TargetChooserFactory * tcf = NEW TargetChooserFactory();
|
||||||
@@ -656,17 +657,6 @@ int AIPlayerBaka::computeActions(){
|
|||||||
case Constants::MTG_PHASE_FIRSTMAIN:
|
case Constants::MTG_PHASE_FIRSTMAIN:
|
||||||
case Constants::MTG_PHASE_SECONDMAIN:
|
case Constants::MTG_PHASE_SECONDMAIN:
|
||||||
{
|
{
|
||||||
if (canPutLandsIntoPlay){
|
|
||||||
//Attempt to put land into play
|
|
||||||
cd.init();
|
|
||||||
cd.setColor(Constants::MTG_COLOR_LAND);
|
|
||||||
card = cd.match(game->hand);
|
|
||||||
if (card){
|
|
||||||
AIAction * a = NEW AIAction(card);
|
|
||||||
clickstream.push(a);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//No mana, try to get some
|
//No mana, try to get some
|
||||||
SAFE_DELETE(potentialMana);
|
SAFE_DELETE(potentialMana);
|
||||||
@@ -674,30 +664,26 @@ int AIPlayerBaka::computeActions(){
|
|||||||
if (!currentMana->getConvertedCost()){
|
if (!currentMana->getConvertedCost()){
|
||||||
currentMana = getPotentialMana();
|
currentMana = getPotentialMana();
|
||||||
}
|
}
|
||||||
if (currentMana->getConvertedCost() > 0){
|
|
||||||
|
|
||||||
|
nextCardToPlay = FindCardToPlay(currentMana, "land");
|
||||||
//look for the most expensive creature we can afford
|
//look for the most expensive creature we can afford
|
||||||
nextCardToPlay = FindCardToPlay(currentMana, "creature");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "creature");
|
||||||
//Let's Try an enchantment maybe ?
|
//Let's Try an enchantment maybe ?
|
||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "enchantment");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "enchantment");
|
||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "artifact");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "artifact");
|
||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "sorcery");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "sorcery");
|
||||||
if (nextCardToPlay){
|
if (nextCardToPlay){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
char buffe[4096];
|
char buffe[4096];
|
||||||
sprintf(buffe, "Putting Card Into Play: %s", nextCardToPlay->getName().c_str());
|
sprintf(buffe, "Putting Card Into Play: %s", nextCardToPlay->getName().c_str());
|
||||||
OutputDebugString(buffe);
|
OutputDebugString(buffe);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (currentMana == potentialMana) tapLandsForMana(currentMana,nextCardToPlay->getManaCost());
|
if (currentMana == potentialMana) tapLandsForMana(currentMana,nextCardToPlay->getManaCost());
|
||||||
AIAction * a = NEW AIAction(nextCardToPlay);
|
AIAction * a = NEW AIAction(nextCardToPlay);
|
||||||
clickstream.push(a);
|
clickstream.push(a);
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
|
||||||
selectAbility();
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
selectAbility();
|
selectAbility();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,6 +232,15 @@ int MTGGameZone::countByType(const char * value){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MTGCardInstance * MTGGameZone::findByName(string name){
|
||||||
|
for (int i=0; i<(nb_cards); i++) {
|
||||||
|
if (cards[i]->name == name){
|
||||||
|
return cards[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int MTGGameZone::hasType(const char * value){
|
int MTGGameZone::hasType(const char * value){
|
||||||
for (int i=0; i<(nb_cards); i++) {
|
for (int i=0; i<(nb_cards); i++) {
|
||||||
if (cards[i]->hasType(value)){
|
if (cards[i]->hasType(value)){
|
||||||
|
|||||||
Reference in New Issue
Block a user