when using team switch, AI player will now always answers YES if he already lost the game
This commit is contained in:
parent
fd2cc5f66b
commit
856e6fd88e
|
@ -355,6 +355,12 @@ void Ai::update() {
|
||||||
voteResult->allowSwitchTeam = false;
|
voteResult->allowSwitchTeam = false;
|
||||||
|
|
||||||
const GameSettings *settings = aiInterface->getWorld()->getGameSettings();
|
const GameSettings *settings = aiInterface->getWorld()->getGameSettings();
|
||||||
|
|
||||||
|
// If AI player already lost game they cannot vote
|
||||||
|
if(aiInterface->getWorld()->factionLostGame(aiInterface->getFactionIndex()) == true) {
|
||||||
|
voteResult->allowSwitchTeam = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Can only ask the AI player 2 times max per game
|
// Can only ask the AI player 2 times max per game
|
||||||
if(factionSwitchTeamRequestCountCurrent <= 2) {
|
if(factionSwitchTeamRequestCountCurrent <= 2) {
|
||||||
// x% chance the AI will answer yes
|
// x% chance the AI will answer yes
|
||||||
|
@ -368,6 +374,7 @@ void Ai::update() {
|
||||||
voteResult->allowSwitchTeam = (allowJoinTeam >= (100 - settings->getAiAcceptSwitchTeamPercentChance()));
|
voteResult->allowSwitchTeam = (allowJoinTeam >= (100 - settings->getAiAcceptSwitchTeamPercentChance()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"AI for faction# %d voted %s [%d] CountCurrent [%d] PercentChance [%d]",aiInterface->getMyFaction()->getIndex(),(voteResult->allowSwitchTeam ? "Yes" : "No"),allowJoinTeam,factionSwitchTeamRequestCountCurrent,settings->getAiAcceptSwitchTeamPercentChance());
|
snprintf(szBuf,8096,"AI for faction# %d voted %s [%d] CountCurrent [%d] PercentChance [%d]",aiInterface->getMyFaction()->getIndex(),(voteResult->allowSwitchTeam ? "Yes" : "No"),allowJoinTeam,factionSwitchTeamRequestCountCurrent,settings->getAiAcceptSwitchTeamPercentChance());
|
||||||
|
|
|
@ -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");
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user