Home Reference Source
import Civ5Save from 'civ5save/src/Civ5Save.js'
public class | source

Civ5Save

A Civilization V save file object.

Static Method Summary

Static Public Methods
public static

async fromFile(saveFile: File): Civ5Save

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 Civ5Save.GAME_MODES.SINGLE, Civ5Save.GAME_MODES.MULTI, or Civ5Save.GAME_MODES.HOTSEAT.

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

players: Array<{civilization: string|undefined, status: number}>

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 Civ5Save.TURN_MODES.HYBRID, Civ5Save.TURN_MODES.SEQUENTIAL, or Civ5Save.TURN_MODES.SIMULTANEOUS.

public set

Turn mode: one of Civ5Save.TURN_MODES.HYBRID, Civ5Save.TURN_MODES.SEQUENTIAL, or Civ5Save.TURN_MODES.SIMULTANEOUS.

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:

NameTypeAttributeDescription
saveFile File

A Civilization V save file.

Return:

Civ5Save

A Civ5Save object.

Throw:

InvalidSignatureError

Invalid file signature.

ParseError

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:

NameTypeAttributeDescription
saveData DataView

The save file contents.

Throw:

InvalidSignatureError

Invalid file signature.

ParseError

Error while parsing the save file.

Public Members

public set alwaysPeace: boolean source

Always peace.

public get alwaysPeace: boolean source

Always peace.

Throw:

ParseError

Error while parsing the save file.

public set alwaysWar: boolean source

Always war.

public get alwaysWar: boolean source

Always war.

Throw:

ParseError

Error while parsing the save file.

public get completeKills: boolean source

Complete kills.

Throw:

ParseError

Error while parsing the save file.

public set completeKills: boolean source

Complete kills.

public get culturalVictory: boolean source

Cultural victory.

Throw:

ParseError

Error while parsing the save file.

public set culturalVictory: boolean source

Cultural victory.

public get currentEra: string source

Current era.

Throw:

ParseError

Error while parsing the save file.

public get currentTurn: number source

Current turn.

Throw:

ParseError

Error while parsing the save file.

public get difficulty: string source

Game difficulty.

Throw:

ParseError

Error while parsing the save file.

public set diplomaticVictory: boolean source

Diplomatic victory.

public get diplomaticVictory: boolean source

Diplomatic victory.

Throw:

ParseError

Error while parsing the save file.

public get dominationVictory: boolean source

Domination victory.

Throw:

ParseError

Error while parsing the save file.

public set dominationVictory: boolean source

Domination victory.

public get enabledDLC: Array source

List of enabled DLC.

Throw:

ParseError

Error while parsing the save file.

public get enabledMods: Array source

List of enabled mods.

Throw:

ParseError

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:

ParseError

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:

ParseError

Error while parsing the save file.

public get gamePace: string source

Game pace.

Throw:

ParseError

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:

ParseError

Error while parsing the save file.

public get lockMods: boolean source

Lock mods.

Throw:

ParseError

Error while parsing the save file.

public set lockMods: boolean source

Lock mods.

public get mapFile: string source

Map file.

Throw:

ParseError

Error while parsing the save file.

public get mapSize: string source

Map size.

Throw:

ParseError

Error while parsing the save file.

public set maxTurns: number source

Max turns.

public get maxTurns: number source

Max turns.

Throw:

ParseError

Error while parsing the save file.

public set newRandomSeed: boolean source

New random seed.

public get newRandomSeed: boolean source

New random seed.

Throw:

ParseError

Error while parsing the save file.

public set noBarbarians: boolean source

No barbarians.

public get noBarbarians: boolean source

No barbarians.

Throw:

ParseError

Error while parsing the save file.

public set noChangingWarPeace: boolean source

No changing war or peace.

public get noChangingWarPeace: boolean source

No changing war or peace.

Throw:

ParseError

Error while parsing the save file.

public set noCityRazing: boolean source

No city razing.

public get noCityRazing: boolean source

No city razing.

Throw:

ParseError

Error while parsing the save file.

public get noCultureOverviewUI: boolean source

No cultural overview UI.

Throw:

ParseError

Error while parsing the save file.

public set noCultureOverviewUI: boolean source

No cultural overview UI.

public set noEspionage: boolean source

No espionage.

public get noEspionage: boolean source

No espionage.

Throw:

ParseError

Error while parsing the save file.

public set noHappiness: boolean source

No happiness.

public get noHappiness: boolean source

No happiness.

Throw:

ParseError

Error while parsing the save file.

public get noPolicies: boolean source

No policies.

Throw:

ParseError

Error while parsing the save file.

public set noPolicies: boolean source

No policies.

public get noReligion: boolean source

No religion.

Throw:

ParseError

Error while parsing the save file.

public set noReligion: boolean source

No religion.

public set noScience: boolean source

No science.

public get noScience: boolean source

No science.

Throw:

ParseError

Error while parsing the save file.

public set noWorldCongress: boolean source

No world congress.

public get noWorldCongress: boolean source

No world congress.

Throw:

ParseError

Error while parsing the save file.

public set oneCityChallenge: boolean source

One-city challenge.

public get oneCityChallenge: boolean source

One-city challenge.

Throw:

ParseError

Error while parsing the save file.

public get pitboss: boolean source

Pitboss.

Throw:

ParseError

Error while parsing the save file.

See:

public set pitboss: boolean source

Pitboss.

See:

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:

ParseError

Error while parsing the save file.

public get policySaving: boolean source

Policy saving.

Throw:

ParseError

Error while parsing the save file.

public set policySaving: boolean source

Policy saving.

public set privateGame: boolean source

Private setting for multiplayer games.

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:

ParseError

Error while parsing the save file.

public set promotionSaving: boolean source

Promotion saving.

public get promotionSaving: boolean source

Promotion saving.

Throw:

ParseError

Error while parsing the save file.

public set ragingBarbarians: boolean source

Raging barbarians.

public get ragingBarbarians: boolean source

Raging barbarians.

Throw:

ParseError

Error while parsing the save file.

public get randomPersonalities: boolean source

Random personalities.

Throw:

ParseError

Error while parsing the save file.

public set randomPersonalities: boolean source

Random personalities.

public get scienceVictory: boolean source

Science victory.

Throw:

ParseError

Error while parsing the save file.

public set scienceVictory: boolean source

Science victory.

public get startingEra: string source

Starting era.

Throw:

ParseError

Error while parsing the save file.

public get timeVictory: boolean source

Time victory.

Throw:

ParseError

Error while parsing the save file.

public set timeVictory: boolean source

Time victory.

public get turnMode: string source

Turn mode: one of Civ5Save.TURN_MODES.HYBRID, Civ5Save.TURN_MODES.SEQUENTIAL, or Civ5Save.TURN_MODES.SIMULTANEOUS.

Throw:

ParseError

Error while parsing the save file.

See:

public set turnMode: string source

Turn mode: one of Civ5Save.TURN_MODES.HYBRID, Civ5Save.TURN_MODES.SEQUENTIAL, or Civ5Save.TURN_MODES.SIMULTANEOUS.

See:

public get turnTimerEnabled: boolean source

Turn timer enabled.

Throw:

ParseError

Error while parsing the save file.

public set turnTimerEnabled: boolean source

Turn timer enabled.

public get turnTimerLength: number source

Turn timer length for multiplayer games. If pitboss is enabled, this value represents turn timer in hours. Otherwise, it is in minutes.

Throw:

ParseError

Error while parsing the save file.

public set turnTimerLength: number source

Turn timer length for multiplayer games. If pitboss is enabled, this value represents turn timer in hours. Otherwise, it is in minutes.

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());