fixed Ai not using regenerate during combat, taught Ai a little about prevent:number, changed "removepoison" mtgability to "alterpoison" as it made more sense.

This commit is contained in:
omegablast2002@yahoo.com
2010-10-21 15:52:04 +00:00
parent f209dd7b89
commit 18ff503bd9
5 changed files with 32 additions and 15 deletions

View File

@@ -2784,6 +2784,7 @@ class AADamagePrevent:public ActivatedAbilityTP{
public: public:
int preventing; int preventing;
AADamagePrevent(int _id, MTGCardInstance * _source, Targetable * _target,int preventing, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),preventing(preventing){ AADamagePrevent(int _id, MTGCardInstance * _source, Targetable * _target,int preventing, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),preventing(preventing){
aType = MTGAbility::STANDARD_PREVENT;
} }
int resolve(){ int resolve(){
@@ -2810,31 +2811,31 @@ public:
}; };
//poison removel //poison removel
class AARemovePoison:public ActivatedAbilityTP{ class AAAlterPoison:public ActivatedAbilityTP{
public: public:
int poison; int poison;
AARemovePoison(int _id, MTGCardInstance * _source, Targetable * _target,int poison, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),poison(poison){ AAAlterPoison(int _id, MTGCardInstance * _source, Targetable * _target,int poison, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),poison(poison){
} }
int resolve(){ int resolve(){
Damageable * _target = (Damageable *) getTarget(); Damageable * _target = (Damageable *) getTarget();
if(_target){ if(_target){
_target->poisonCount -= poison; _target->poisonCount += poison;
} }
return 0; return 0;
} }
const char * getMenuText(){ const char * getMenuText(){
return "Remove Poison"; return "Poison";
} }
AARemovePoison * clone() const{ AAAlterPoison * clone() const{
AARemovePoison * a = NEW AARemovePoison(*this); AAAlterPoison * a = NEW AAAlterPoison(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
~AARemovePoison(){ ~AAAlterPoison(){
} }

View File

@@ -89,7 +89,8 @@ class MTGAbility: public ActionElement{
BUYBACK_COST = 9, BUYBACK_COST = 9,
FLASHBACK_COST = 10, FLASHBACK_COST = 10,
RETRACE_COST = 11, RETRACE_COST = 11,
MTG_COMBATTRIGGERS_RULE = 13, MTG_COMBATTRIGGERS_RULE = 12,
STANDARD_PREVENT = 13,
}; };

View File

@@ -189,9 +189,24 @@ int AIAction::getEfficiency(){
{ {
MTGCardInstance * _target = (MTGCardInstance *)(a->target); MTGCardInstance * _target = (MTGCardInstance *)(a->target);
efficiency = 0; efficiency = 0;
if (!_target->regenerateTokens && g->getCurrentGamePhase()< Constants::MTG_PHASE_COMBATDAMAGE && (_target->defenser || _target->blockers.size())){ if (!_target->regenerateTokens && g->getCurrentGamePhase() == Constants::MTG_PHASE_COMBATBLOCKERS && (_target->defenser || _target->blockers.size())){
efficiency = 95; efficiency = 95;
} }
//TODO If the card is the target of a damage spell
break;
}
case MTGAbility::STANDARD_PREVENT:
{
MTGCardInstance * _target = (MTGCardInstance *)(a->target);
efficiency = 10;//starts out low to avoid spamming it when its not needed.
if (!_target->regenerateTokens && g->getCurrentGamePhase() == Constants::MTG_PHASE_COMBATBLOCKERS && (_target->defenser || _target->blockers.size()) && _target->preventable < 2 || (_target->canBlock()||_target->canAttack()) && _target->preventable < 2){
efficiency = 95;//increase this chance to be used in combat.
}
if (_target->preventable > 2){
efficiency -= 10; //lower the chance to be used if the creature already has over 3 prevent points.
}
//basically a rip off of regen, if it is not regenerating, its combat blockers, it is being blocked or blocking, and has less then 3 prevents, the effeincy is increased.
//TODO If the card is the target of a damage spell //TODO If the card is the target of a damage spell
break; break;
} }
@@ -454,6 +469,7 @@ int AIPlayer::canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy
if (ennemy->has(Constants::FIRSTSTRIKE) || ennemy->has(Constants::DOUBLESTRIKE)) return 0; if (ennemy->has(Constants::FIRSTSTRIKE) || ennemy->has(Constants::DOUBLESTRIKE)) return 0;
if (!(card->has(Constants::FIRSTSTRIKE) || card->has(Constants::DOUBLESTRIKE))) return 0; if (!(card->has(Constants::FIRSTSTRIKE) || card->has(Constants::DOUBLESTRIKE))) return 0;
if (!(card->power >= ennemy->toughness)) return 0; if (!(card->power >= ennemy->toughness)) return 0;
if (!(card->power >= ennemy->toughness + 1) && ennemy->has(Constants::FLANKING)) return 0;
return 1; return 1;
} }
@@ -514,7 +530,7 @@ int AIPlayer::chooseBlockers(){
MTGCardInstance * attacker = card->defenser; MTGCardInstance * attacker = card->defenser;
if (opponentsToughness[attacker] <= 0 || if (opponentsToughness[attacker] <= 0 ||
(card->toughness <= attacker->power && opponentForce*2 <life && !canFirstStrikeKill(card,attacker)) || (card->toughness <= attacker->power && opponentForce*2 <life && !canFirstStrikeKill(card,attacker)) ||
attacker->nbOpponents()>1){ attacker->nbOpponents()>1){
g->mLayers->actionLayer()->reactToClick(a,card); g->mLayers->actionLayer()->reactToClick(a,card);
}else{ }else{
set = 1; set = 1;

View File

@@ -5,7 +5,7 @@
#include "../include/MTGCardInstance.h" #include "../include/MTGCardInstance.h"
#include "../include/WEvent.h" #include "../include/WEvent.h"
#include "../include/AllAbilities.h" #include "../include/AllAbilities.h"
//TODO:better comments this is too cryptic to work on by anyone but original coder.
bool compare_aistats(AIStat * first, AIStat * second){ bool compare_aistats(AIStat * first, AIStat * second){
float damage1 = first->value / first->occurences; float damage1 = first->value / first->occurences;
float damage2 = second->value/ second->occurences; float damage2 = second->value/ second->occurences;
@@ -81,7 +81,7 @@ int AIStats::receiveEvent(WEvent * event){
stats.sort(compare_aistats); //this could be slow, if it is, let's run it only at the end of the turn stats.sort(compare_aistats); //this could be slow, if it is, let's run it only at the end of the turn
return 1; //is this meant to return 0 or 1? return 1; //is this meant to return 0 or 1?
} }
//TODO:what does this do?
bool AIStats::isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue ){ bool AIStats::isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue ){
if (stats.size()<max) return tooSmallCountsForTrue; if (stats.size()<max) return tooSmallCountsForTrue;
unsigned int n = 0; unsigned int n = 0;

View File

@@ -1124,7 +1124,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
} }
//remove poison //remove poison
found = s.find("removepoison:"); found = s.find("alterpoison:");
if (found != string::npos){ if (found != string::npos){
size_t start = s.find(":",found); size_t start = s.find(":",found);
size_t end = s.find(" ",start); size_t end = s.find(" ",start);
@@ -1137,7 +1137,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
Targetable * t = NULL; Targetable * t = NULL;
if (spell) t = spell->getNextPlayerTarget(); if (spell) t = spell->getNextPlayerTarget();
MTGAbility * a = NEW AARemovePoison (id, card, t,poison,NULL,0,who); MTGAbility * a = NEW AAAlterPoison (id, card, t,poison,NULL,0,who);
a->oneShot = 1; a->oneShot = 1;
return a; return a;
} }
@@ -1658,7 +1658,6 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
if (dynamic_cast<AACopier *>(a)) return BAKA_EFFECT_GOOD; if (dynamic_cast<AACopier *>(a)) return BAKA_EFFECT_GOOD;
if (dynamic_cast<AADestroyer *>(a)) return BAKA_EFFECT_BAD; if (dynamic_cast<AADestroyer *>(a)) return BAKA_EFFECT_BAD;
if (dynamic_cast<AStandardRegenerate *>(a)) return BAKA_EFFECT_GOOD; if (dynamic_cast<AStandardRegenerate *>(a)) return BAKA_EFFECT_GOOD;
if (dynamic_cast<AStandardRegenerate *>(a)) return BAKA_EFFECT_BAD;
if (AALifer * abi = dynamic_cast<AALifer *>(a)) return abi->life > 0 ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD; if (AALifer * abi = dynamic_cast<AALifer *>(a)) return abi->life > 0 ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD;
if (dynamic_cast<AADepleter *>(a)) return BAKA_EFFECT_BAD; if (dynamic_cast<AADepleter *>(a)) return BAKA_EFFECT_BAD;
if (dynamic_cast<AADrawer *>(a)) return BAKA_EFFECT_GOOD; if (dynamic_cast<AADrawer *>(a)) return BAKA_EFFECT_GOOD;