Changeset View
Standalone View
binaries/data/mods/public/simulation/components/EndGameManager.js
/** | /** | ||||
* System component to store the gametype, gametype settings and | * System component to store the gametype, gametype settings and | ||||
* check for allied victory / last-man-standing. | * check for allied victory / last-man-standing. | ||||
*/ | */ | ||||
function EndGameManager() {} | function EndGameManager() {} | ||||
EndGameManager.prototype.Schema = | EndGameManager.prototype.Schema = | ||||
"<a:component type='system'/><empty/>"; | "<a:component type='system'/><empty/>"; | ||||
EndGameManager.prototype.Init = function() | EndGameManager.prototype.Init = function() | ||||
{ | { | ||||
this.gameType = "conquest"; | |||||
// Contains settings specific to the victory condition, | // Contains settings specific to the victory condition, | ||||
// for example wonder victory duration. | // for example wonder victory duration. | ||||
this.gameTypeSettings = {}; | this.gameSettings = {}; | ||||
elexis: victoryConditionSettings? | |||||
Not Done Inline ActionsIt doesn't only carry the victorycondition data, but all data from gamesetup bb: It doesn't only carry the victorycondition data, but all data from gamesetup
(only the… | |||||
Not Done Inline ActionsOk then, you are right. elexis: Ok then, you are right.
But it seems wrong that the component has to carry that around when… | |||||
// Allied victory means allied players can win if victory conditions are met for each of them | // Allied victory means allied players can win if victory conditions are met for each of them | ||||
// False for a "last man standing" game | // False for a "last man standing" game | ||||
this.alliedVictory = true; | this.alliedVictory = true; | ||||
// Don't do any checks before the diplomacies were set for each player | // Don't do any checks before the diplomacies were set for each player | ||||
// or when marking a player as won. | // or when marking a player as won. | ||||
this.skipAlliedVictoryCheck = true; | this.skipAlliedVictoryCheck = true; | ||||
this.lastManStandingMessage = undefined; | this.lastManStandingMessage = undefined; | ||||
this.endlessGame = false; | this.endlessGame = false; | ||||
elexisUnsubmitted Not Done Inline ActionsAs mentioned in #4323, I had the thought to move the "flag last remaining ones as winner" logic to Conquest and have Regicide only a defeat condition. then the endless hardcoding can be removed here. But it is true that victory conditions should also establish a winner, so ok, at least until further notice. elexis: As mentioned in #4323, I had the thought to move the "flag last remaining ones as winner" logic… | |||||
}; | }; | ||||
EndGameManager.prototype.GetGameType = function() | EndGameManager.prototype.GetGameSettings = function() | ||||
{ | { | ||||
return this.gameType; | return this.gameSettings; | ||||
}; | }; | ||||
EndGameManager.prototype.GetGameTypeSettings = function() | EndGameManager.prototype.GetVictoryConditions = function() | ||||
{ | { | ||||
return this.gameTypeSettings; | return this.gameSettings.victoryConditions; | ||||
}; | }; | ||||
EndGameManager.prototype.SetGameType = function(newGameType, newSettings = {}) | EndGameManager.prototype.SetGameSettings = function(newSettings = {}) | ||||
{ | { | ||||
this.gameType = newGameType; | this.gameSettings = newSettings; | ||||
this.gameTypeSettings = newSettings; | |||||
this.skipAlliedVictoryCheck = false; | this.skipAlliedVictoryCheck = false; | ||||
this.endlessGame = newGameType == "endless"; | this.endlessGame = !this.gameSettings.victoryConditions.length; | ||||
Engine.BroadcastMessage(MT_GameTypeChanged, {}); | Engine.BroadcastMessage(MT_VictoryConditionsChanged, {}); | ||||
}; | }; | ||||
/** | /** | ||||
* Sets the given player (and the allies if allied victory is enabled) as a winner. | * Sets the given player (and the allies if allied victory is enabled) as a winner. | ||||
* | * | ||||
* @param {number} playerID - The player that should win. | * @param {number} playerID - The player that should win. | ||||
* @param {function} victoryReason - Function that maps from number to plural string, for example | * @param {function} victoryReason - Function that maps from number to plural string, for example | ||||
* n => markForPluralTranslation( | * n => markForPluralTranslation( | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |
victoryConditionSettings?