Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/EndGameManager.js
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
/** | /** | ||||
* 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( | ||||
* "%(lastPlayer)s has won (game mode).", | * "%(players)s has won (game mode).", | ||||
* "%(players)s and %(lastPlayer)s have won (game mode).", | * "%(players)s have won (game mode).", | ||||
* n)); | * n)); | ||||
*/ | */ | ||||
EndGameManager.prototype.MarkPlayerAndAlliesAsWon = function(playerID, victoryString, defeatString) | EndGameManager.prototype.MarkPlayerAndAlliesAsWon = function(playerID, victoryString, defeatString) | ||||
{ | { | ||||
let state = QueryPlayerIDInterface(playerID).GetState(); | let state = QueryPlayerIDInterface(playerID).GetState(); | ||||
if (state != "active") | if (state != "active") | ||||
{ | { | ||||
warn("Can't mark player " + playerID + " as won, since the state is " + state); | warn("Can't mark player " + playerID + " as won, since the state is " + state); | ||||
Show All 9 Lines | |||||
}; | }; | ||||
/** | /** | ||||
* Sets the given players as won and others as defeated. | * Sets the given players as won and others as defeated. | ||||
* | * | ||||
* @param {array} winningPlayers - The players that should win. | * @param {array} winningPlayers - The players 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( | ||||
* "%(lastPlayer)s has won (game mode).", | * "%(players)s has won (game mode).", | ||||
* "%(players)s and %(lastPlayer)s have won (game mode).", | * "%(players)s have won (game mode).", | ||||
* n)); | * n)); | ||||
*/ | */ | ||||
EndGameManager.prototype.MarkPlayersAsWon = function(winningPlayers, victoryString, defeatString) | EndGameManager.prototype.MarkPlayersAsWon = function(winningPlayers, victoryString, defeatString) | ||||
{ | { | ||||
this.skipAlliedVictoryCheck = true; | this.skipAlliedVictoryCheck = true; | ||||
for (let playerID of winningPlayers) | for (let playerID of winningPlayers) | ||||
{ | { | ||||
let cmpPlayer = QueryPlayerIDInterface(playerID); | let cmpPlayer = QueryPlayerIDInterface(playerID); | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | for (let playerID of allies) | ||||
cmpPlayer.SetState("won", undefined); | cmpPlayer.SetState("won", undefined); | ||||
} | } | ||||
cmpGuiInterface.PushNotification({ | cmpGuiInterface.PushNotification({ | ||||
"type": "won", | "type": "won", | ||||
"players": [allies[0]], | "players": [allies[0]], | ||||
"allies" : allies, | "allies" : allies, | ||||
"message": markForPluralTranslation( | "message": markForPluralTranslation( | ||||
"%(lastPlayer)s has won (last player alive).", | "%(players)s has won (last player alive).", | ||||
"%(players)s and %(lastPlayer)s have won (last players alive).", | "%(players)s have won (last players alive).", | ||||
allies.length) | allies.length | ||||
) | |||||
}); | }); | ||||
} | } | ||||
else | else | ||||
this.lastManStandingMessage = cmpGuiInterface.AddTimeNotification({ | this.lastManStandingMessage = cmpGuiInterface.AddTimeNotification({ | ||||
"message": markForTranslation("Last remaining player wins."), | "message": markForTranslation("Last remaining player wins."), | ||||
"translateMessage": true, | "translateMessage": true, | ||||
}, 12 * 60 * 60 * 1000); // 12 hours | }, 12 * 60 * 60 * 1000); // 12 hours | ||||
}; | }; | ||||
Show All 17 Lines |
Wildfire Games · Phabricator