when using team switch, AI player will now always answers YES if he already lost the game

This commit is contained in:
Mark Vejvoda 2013-11-10 04:26:20 +00:00
parent fd2cc5f66b
commit 856e6fd88e
3 changed files with 26 additions and 11 deletions

View File

@ -355,17 +355,24 @@ void Ai::update() {
voteResult->allowSwitchTeam = false; voteResult->allowSwitchTeam = false;
const GameSettings *settings = aiInterface->getWorld()->getGameSettings(); const GameSettings *settings = aiInterface->getWorld()->getGameSettings();
// Can only ask the AI player 2 times max per game
if(factionSwitchTeamRequestCountCurrent <= 2) { // If AI player already lost game they cannot vote
// x% chance the AI will answer yes if(aiInterface->getWorld()->factionLostGame(aiInterface->getFactionIndex()) == true) {
if(settings->getAiAcceptSwitchTeamPercentChance() >= 100) { voteResult->allowSwitchTeam = true;
voteResult->allowSwitchTeam = true; }
} else {
else if(settings->getAiAcceptSwitchTeamPercentChance() <= 0) { // Can only ask the AI player 2 times max per game
voteResult->allowSwitchTeam = false; if(factionSwitchTeamRequestCountCurrent <= 2) {
} // x% chance the AI will answer yes
else { if(settings->getAiAcceptSwitchTeamPercentChance() >= 100) {
voteResult->allowSwitchTeam = (allowJoinTeam >= (100 - settings->getAiAcceptSwitchTeamPercentChance())); voteResult->allowSwitchTeam = true;
}
else if(settings->getAiAcceptSwitchTeamPercentChance() <= 0) {
voteResult->allowSwitchTeam = false;
}
else {
voteResult->allowSwitchTeam = (allowJoinTeam >= (100 - settings->getAiAcceptSwitchTeamPercentChance()));
}
} }
} }

View File

@ -2762,6 +2762,13 @@ string World::getAllFactionsCacheStats() {
return result; return result;
} }
bool World::factionLostGame(int factionIndex) {
if(this->game != NULL) {
return this->game->factionLostGame(factionIndex);
}
return false;
}
std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const { std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const {
string debugWorldLogFile = Config::getInstance().getString("DebugWorldLogFile","debugWorld.log"); string debugWorldLogFile = Config::getInstance().getString("DebugWorldLogFile","debugWorld.log");

View File

@ -327,6 +327,7 @@ public:
void clearCaches(); void clearCaches();
void refreshAllUnitExplorations(); void refreshAllUnitExplorations();
bool factionLostGame(int factionIndex);
private: private:
void initCells(bool fogOfWar); void initCells(bool fogOfWar);