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,17 +355,24 @@ void Ai::update() {
|
|||
voteResult->allowSwitchTeam = false;
|
||||
|
||||
const GameSettings *settings = aiInterface->getWorld()->getGameSettings();
|
||||
// Can only ask the AI player 2 times max per game
|
||||
if(factionSwitchTeamRequestCountCurrent <= 2) {
|
||||
// x% chance the AI will answer yes
|
||||
if(settings->getAiAcceptSwitchTeamPercentChance() >= 100) {
|
||||
voteResult->allowSwitchTeam = true;
|
||||
}
|
||||
else if(settings->getAiAcceptSwitchTeamPercentChance() <= 0) {
|
||||
voteResult->allowSwitchTeam = false;
|
||||
}
|
||||
else {
|
||||
voteResult->allowSwitchTeam = (allowJoinTeam >= (100 - settings->getAiAcceptSwitchTeamPercentChance()));
|
||||
|
||||
// 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
|
||||
if(factionSwitchTeamRequestCountCurrent <= 2) {
|
||||
// x% chance the AI will answer yes
|
||||
if(settings->getAiAcceptSwitchTeamPercentChance() >= 100) {
|
||||
voteResult->allowSwitchTeam = true;
|
||||
}
|
||||
else if(settings->getAiAcceptSwitchTeamPercentChance() <= 0) {
|
||||
voteResult->allowSwitchTeam = false;
|
||||
}
|
||||
else {
|
||||
voteResult->allowSwitchTeam = (allowJoinTeam >= (100 - settings->getAiAcceptSwitchTeamPercentChance()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2762,6 +2762,13 @@ string World::getAllFactionsCacheStats() {
|
|||
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 {
|
||||
|
||||
string debugWorldLogFile = Config::getInstance().getString("DebugWorldLogFile","debugWorld.log");
|
||||
|
|
|
@ -327,6 +327,7 @@ public:
|
|||
void clearCaches();
|
||||
void refreshAllUnitExplorations();
|
||||
|
||||
bool factionLostGame(int factionIndex);
|
||||
private:
|
||||
|
||||
void initCells(bool fogOfWar);
|
||||
|
|
Loading…
Reference in New Issue