Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js
Show First 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | |||||
m.DiplomacyManager.prototype.handleDiplomacyRequest = function(gameState, player, requestType) | m.DiplomacyManager.prototype.handleDiplomacyRequest = function(gameState, player, requestType) | ||||
{ | { | ||||
let response; | let response; | ||||
let requiredTribute; | let requiredTribute; | ||||
let request = this.diplomacyRequests.get(player); | let request = this.diplomacyRequests.get(player); | ||||
let moreEnemiesThanAllies = gameState.getEnemies().length > gameState.getMutualAllies().length; | let moreEnemiesThanAllies = gameState.getEnemies().length > gameState.getMutualAllies().length; | ||||
// For any given diplomacy request be likely to permanently decline | // For any given diplomacy request be likely to permanently decline | ||||
if (!request && gameState.getPlayerCiv() !== gameState.getPlayerCiv(player) && randFloat(0, 1) > 0.4 || | if (!request && gameState.getPlayerCiv() !== gameState.getPlayerCiv(player) && randBool(0.6) || | ||||
elexis: ✓ | |||||
!moreEnemiesThanAllies || gameState.ai.HQ.attackManager.currentEnemyPlayer === player) | !moreEnemiesThanAllies || gameState.ai.HQ.attackManager.currentEnemyPlayer === player) | ||||
{ | { | ||||
this.diplomacyRequests.set(player, { "requestType": requestType, "status": "declinedRequest" }); | this.diplomacyRequests.set(player, { "requestType": requestType, "status": "declinedRequest" }); | ||||
response = "decline"; | response = "decline"; | ||||
} | } | ||||
else if (request && request.status !== "accepted" && request.requestType !== "ally") | else if (request && request.status !== "accepted" && request.requestType !== "ally") | ||||
{ | { | ||||
if (request.status === "declinedRequest") | if (request.status === "declinedRequest") | ||||
response = "decline"; | response = "decline"; | ||||
else if (request.status === "allianceBroken") // Previous alliance was broken, so decline | else if (request.status === "allianceBroken") // Previous alliance was broken, so decline | ||||
response = "declineRepeatedOffer"; | response = "declineRepeatedOffer"; | ||||
else if (request.status === "waitingForTribute") | else if (request.status === "waitingForTribute") | ||||
{ | { | ||||
response = "waitingForTribute"; | response = "waitingForTribute"; | ||||
requiredTribute = request; | requiredTribute = request; | ||||
} | } | ||||
} | } | ||||
else if (requestType === "ally" && gameState.getEntities(player).length < gameState.getOwnEntities().length && | else if (requestType === "ally" && gameState.getEntities(player).length < gameState.getOwnEntities().length && | ||||
randFloat(0, 1) > 0.6 || requestType === "neutral" && moreEnemiesThanAllies && randFloat(0, 1) > 0.2) | randBool(0.4) || requestType === "neutral" && moreEnemiesThanAllies && randBool(0.8)) | ||||
Not Done Inline Actionsaccording to leperstandards, must have the same amount of tabs indentation as the line above, then spaces (even though the same argument didn't make it into aligning object properties yet). elexis: according to leperstandards, must have the same amount of tabs indentation as the line above… | |||||
{ | { | ||||
response = "accept"; | response = "accept"; | ||||
this.changePlayerDiplomacy(gameState, player, requestType); | this.changePlayerDiplomacy(gameState, player, requestType); | ||||
this.diplomacyRequests.set(player, { "requestType": requestType, "status": "accepted" }); | this.diplomacyRequests.set(player, { "requestType": requestType, "status": "accepted" }); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
response = "acceptWithTribute"; | response = "acceptWithTribute"; | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
✓