Civ5Save
A Civilization V save file object.
Static Method Summary
Static Public Methods | ||
public static |
Create a Civ5Save object from a file. |
Constructor Summary
Public Constructor | ||
public |
constructor(saveData: DataView) Create a Civ5Save object. |
Member Summary
Public Members | ||
public set |
Always peace. |
|
public get |
Always peace. |
|
public set |
Always war. |
|
public get |
Always war. |
|
public get |
Complete kills. |
|
public set |
Complete kills. |
|
public get |
Cultural victory. |
|
public set |
Cultural victory. |
|
public get |
Current era. |
|
public get |
Current turn. |
|
public get |
Game difficulty. |
|
public set |
Diplomatic victory. |
|
public get |
Diplomatic victory. |
|
public get |
Domination victory. |
|
public set |
Domination victory. |
|
public get |
List of enabled DLC. |
|
public get |
List of enabled mods. |
|
public get |
Game build number. |
|
public get |
Game mode: one of |
|
public get |
Game pace. |
|
public get |
Game version. |
|
public get |
Lock mods. |
|
public set |
Lock mods. |
|
public get |
Map file. |
|
public get |
Map size. |
|
public set |
Max turns. |
|
public get |
Max turns. |
|
public set |
New random seed. |
|
public get |
New random seed. |
|
public set |
No barbarians. |
|
public get |
No barbarians. |
|
public set |
No changing war or peace. |
|
public get |
No changing war or peace. |
|
public set |
No city razing. |
|
public get |
No city razing. |
|
public get |
No cultural overview UI. |
|
public set |
No cultural overview UI. |
|
public set |
No espionage. |
|
public get |
No espionage. |
|
public set |
No happiness. |
|
public get |
No happiness. |
|
public get |
No policies. |
|
public set |
No policies. |
|
public get |
No religion. |
|
public set |
No religion. |
|
public set |
No science. |
|
public get |
No science. |
|
public set |
No world congress. |
|
public get |
No world congress. |
|
public set |
One-city challenge. |
|
public get |
One-city challenge. |
|
public get |
Pitboss. |
|
public set |
Pitboss. |
|
public get |
List of players as objects with their civilization and status as properties. |
|
public get |
Policy saving. |
|
public set |
Policy saving. |
|
public set |
Private setting for multiplayer games. |
|
public get |
Private setting for multiplayer games. |
|
public set |
Promotion saving. |
|
public get |
Promotion saving. |
|
public set |
Raging barbarians. |
|
public get |
Raging barbarians. |
|
public get |
Random personalities. |
|
public set |
Random personalities. |
|
public get |
Science victory. |
|
public set |
Science victory. |
|
public get |
Starting era. |
|
public get |
Time victory. |
|
public set |
Time victory. |
|
public get |
Turn mode: one of |
|
public set |
Turn mode: one of |
|
public get |
Turn timer enabled. |
|
public set |
Turn timer enabled. |
|
public get |
Turn timer length for multiplayer games. |
|
public set |
Turn timer length for multiplayer games. |
Method Summary
Public Methods | ||
public |
toBlob(): Blob Write Civ5Save object to a blob. |
Static Public Methods
public static async fromFile(saveFile: File): Civ5Save source
Create a Civ5Save object from a file.
Reading data from a file needs to be done asynchronously; since the constructor cannot be async, this static factory is provided as an alternative way to instantiate a Civ5Save object from a file (https://stackoverflow.com/a/24686979/399105).
Params:
Name | Type | Attribute | Description |
saveFile | File | A Civilization V save file. |
Throw:
Invalid file signature. |
|
Error while parsing the save file. |
Example:
try {
let save = await Civ5Save.fromFile(saveFile);
...
Public Constructors
public constructor(saveData: DataView) source
Create a Civ5Save object.
As an alternative, a static factory method is available for more convenient instantiation from a file: fromFile
Params:
Name | Type | Attribute | Description |
saveData | DataView | The save file contents. |
Throw:
Invalid file signature. |
|
Error while parsing the save file. |
Public Members
public get culturalVictory: boolean source
Cultural victory.
Throw:
Error while parsing the save file. |
public get diplomaticVictory: boolean source
Diplomatic victory.
Throw:
Error while parsing the save file. |
public get dominationVictory: boolean source
Domination victory.
Throw:
Error while parsing the save file. |
public get enabledMods: Array source
List of enabled mods.
Throw:
Error while parsing the save file. |
public get gameBuild: string source
Game build number.
Note that for games created or saved before build 230620, this will return the game build that was used to create the save file. Starting with build 230620, this will return the game build that was last used to save the save file.
Throw:
Error while parsing the save file. |
public get gameMode: string | undefined source
Game mode: one of Civ5Save.GAME_MODES.SINGLE
, Civ5Save.GAME_MODES.MULTI
, or Civ5Save.GAME_MODES.HOTSEAT
.
Note that this will be undefined
if gameBuild is less than 230620 because the meaning
of its value is unknown. undefined
is used instead of null
because null
might incorrectly imply the value is
empty.
Throw:
Error while parsing the save file. |
public get gameVersion: string | undefined source
Game version.
Note that this will be undefined
if gameBuild is less than 230620. undefined
is used
instead of null
because older save files do not have a spot for this information (null
might incorrectly imply
the spot is there but empty).
Throw:
Error while parsing the save file. |
public get noChangingWarPeace: boolean source
No changing war or peace.
Throw:
Error while parsing the save file. |
public get noCultureOverviewUI: boolean source
No cultural overview UI.
Throw:
Error while parsing the save file. |
public get noWorldCongress: boolean source
No world congress.
Throw:
Error while parsing the save file. |
public get oneCityChallenge: boolean source
One-city challenge.
Throw:
Error while parsing the save file. |
public get players: Array<{civilization: string|undefined, status: number}> source
List of players as objects with their civilization and status as properties.
Civilization will be undefined
if gameBuild is less than 310700.
Status is one of Civ5Save.PLAYER_STATUSES.AI
, Civ5Save.PLAYER_STATUSES.DEAD
, Civ5Save.PLAYER_STATUSES.HUMAN
,
Civ5Save.PLAYER_STATUSES.NONE
.
Throw:
Error while parsing the save file. |
public get privateGame: boolean source
Private setting for multiplayer games.
Note that this will be undefined
if gameBuild is less than 310700 because it isn't
implemented. undefined
is used instead of null
because null
might incorrectly imply the value is empty.
Throw:
Error while parsing the save file. |
public get promotionSaving: boolean source
Promotion saving.
Throw:
Error while parsing the save file. |
public get ragingBarbarians: boolean source
Raging barbarians.
Throw:
Error while parsing the save file. |
public get randomPersonalities: boolean source
Random personalities.
Throw:
Error while parsing the save file. |
public get scienceVictory: boolean source
Science victory.
Throw:
Error while parsing the save file. |
public get turnMode: string source
Turn mode: one of Civ5Save.TURN_MODES.HYBRID
, Civ5Save.TURN_MODES.SEQUENTIAL
, or
Civ5Save.TURN_MODES.SIMULTANEOUS
.
Throw:
Error while parsing the save file. |
public set turnMode: string source
Turn mode: one of Civ5Save.TURN_MODES.HYBRID
, Civ5Save.TURN_MODES.SEQUENTIAL
, or
Civ5Save.TURN_MODES.SIMULTANEOUS
.
public get turnTimerEnabled: boolean source
Turn timer enabled.
Throw:
Error while parsing the save file. |
Public Methods
public toBlob(): Blob source
Write Civ5Save object to a blob.
Return:
Blob | The save file with any changes. |
Example:
let downloadURL = window.URL.createObjectURL(save.toBlob());