Erwan
- Lords are now taken into account in AI statistics. (To display information, uncomment RENDER_AI_STATS in config.h) - fixed a potential segfault with NoFizzle
This commit is contained in:
@@ -69,6 +69,7 @@ class AIPlayer: public Player{
|
|||||||
void End(){};
|
void End(){};
|
||||||
virtual int displayStack() {return 0;};
|
virtual int displayStack() {return 0;};
|
||||||
int receiveEvent(WEvent * event);
|
int receiveEvent(WEvent * event);
|
||||||
|
void Render();
|
||||||
AIStats * stats;
|
AIStats * stats;
|
||||||
ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
|
ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
|
||||||
AIPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
AIPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
#define STATS_PLAYER_MULTIPLIER 15
|
#define STATS_PLAYER_MULTIPLIER 15
|
||||||
#define STATS_CREATURE_MULTIPLIER 10
|
#define STATS_CREATURE_MULTIPLIER 10
|
||||||
#define STATS_AURA_MULTIPLIER 9
|
|
||||||
|
//floats
|
||||||
|
#define STATS_AURA_MULTIPLIER 0.9
|
||||||
|
#define STATS_LORD_MULTIPLIER 0.5
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
using std::list;
|
using std::list;
|
||||||
@@ -38,6 +42,7 @@ class AIStats{
|
|||||||
bool isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue = true );
|
bool isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue = true );
|
||||||
void updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, float multiplier = 1.0);
|
void updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, float multiplier = 1.0);
|
||||||
int receiveEvent(WEvent * event);
|
int receiveEvent(WEvent * event);
|
||||||
|
void Render();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ class AAFizzler:public ActivatedAbility{
|
|||||||
|
|
||||||
int resolve(){
|
int resolve(){
|
||||||
Spell * _target = (Spell *) target;
|
Spell * _target = (Spell *) target;
|
||||||
if(_target->source->has(Constants::NOFIZZLE))
|
if(target && _target->source->has(Constants::NOFIZZLE))
|
||||||
return 0;
|
return 0;
|
||||||
game->mLayers->stackLayer()->Fizzle(_target);
|
game->mLayers->stackLayer()->Fizzle(_target);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class Player: public Damageable{
|
|||||||
string deckFileSmall;
|
string deckFileSmall;
|
||||||
|
|
||||||
virtual int receiveEvent(WEvent * event){return 0;};
|
virtual int receiveEvent(WEvent * event){return 0;};
|
||||||
|
virtual void Render(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
class HumanPlayer: public Player{
|
class HumanPlayer: public Player{
|
||||||
|
|||||||
@@ -37,4 +37,9 @@
|
|||||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Debug options - comment/uncomment as needed
|
||||||
|
#ifdef _DEBUG
|
||||||
|
//#define RENDER_AI_STATS
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -743,6 +743,12 @@ int AIPlayer::receiveEvent(WEvent * event){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AIPlayer::Render(){
|
||||||
|
#ifdef RENDER_AI_STATS
|
||||||
|
if (getStats()) getStats()->Render();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int AIPlayerBaka::Act(float dt){
|
int AIPlayerBaka::Act(float dt){
|
||||||
GameObserver * g = GameObserver::GetInstance();
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../include/Player.h"
|
#include "../include/Player.h"
|
||||||
#include "../include/MTGCardInstance.h"
|
#include "../include/MTGCardInstance.h"
|
||||||
#include "../include/WEvent.h"
|
#include "../include/WEvent.h"
|
||||||
|
#include "../include/AllAbilities.h"
|
||||||
|
|
||||||
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;
|
||||||
@@ -59,6 +60,24 @@ int AIStats::receiveEvent(WEvent * event){
|
|||||||
updateStatsCard(aura,damage, STATS_AURA_MULTIPLIER);
|
updateStatsCard(aura,damage, STATS_AURA_MULTIPLIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
//Lords
|
||||||
|
map<MTGCardInstance *, int> lords;
|
||||||
|
for (int i = 1; i < g->mLayers->actionLayer()->mCount; i++){ //0 is not a mtgability...hackish
|
||||||
|
MTGAbility * a = ((MTGAbility *)g->mLayers->actionLayer()->mObjects[i]);
|
||||||
|
if (ALord * al = dynamic_cast<ALord*>(a)) {
|
||||||
|
if (al->cards.find(card)!= al->cards.end() && opponentZone->hasCard(al->source)){
|
||||||
|
lords[al->source] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (size_t nb = lords.size()){
|
||||||
|
for (map<MTGCardInstance *, int>::iterator it = lords.begin();it !=lords.end();++it){
|
||||||
|
updateStatsCard(it->first,damage, STATS_LORD_MULTIPLIER/nb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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?
|
||||||
}
|
}
|
||||||
@@ -126,3 +145,27 @@ void AIStats::save(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AIStats::Render(){
|
||||||
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
float x0 = 10;
|
||||||
|
if (player == g->players[1]) x0 = 280;
|
||||||
|
JRenderer::GetInstance()->FillRoundRect(x0,10,200,180,5,ARGB(50,0,0,0));
|
||||||
|
|
||||||
|
JLBFont * f = resources.GetJLBFont("simon");
|
||||||
|
int i = 0;
|
||||||
|
char buffer[512];
|
||||||
|
list<AIStat *>::iterator it;
|
||||||
|
for (it = stats.begin(); it !=stats.end(); ++it){
|
||||||
|
if (i>10) break;
|
||||||
|
AIStat * stat = *it;
|
||||||
|
if (stat->value > 0){
|
||||||
|
MTGCard * card = GameApp::collection->getCardById(stat->source);
|
||||||
|
if (card) {
|
||||||
|
sprintf(buffer, "%s %i", card->getName().c_str(), stat->value);
|
||||||
|
f->DrawString(buffer,x0+5,10 + 16 *i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -298,6 +298,9 @@ void GameObserver::Render()
|
|||||||
JRenderer::GetInstance()->DrawRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(255,255,0,0));
|
JRenderer::GetInstance()->DrawRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(255,255,0,0));
|
||||||
if (waitForExtraPayment)
|
if (waitForExtraPayment)
|
||||||
waitForExtraPayment->Render();
|
waitForExtraPayment->Render();
|
||||||
|
for (int i = 0; i < nbPlayers; ++i){
|
||||||
|
players[i]->Render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user