Adds a custom view (button to game bottom bar tab) with inner html set to innerHtml
Gets a flag in the user's local storage. Can be used for unlockables in mods, persisting data. Does not save between accounts. Only works if the scenario has already been loaded in (should always work) Safer than accessing localStorage yourself (handles edgecases, makes sure the flag name is unique to your scenario)
Sets a flag in the user's local storage. Can be used for unlockables in mods, persisting data. Does not save between accounts. Only works if the scenario has already been loaded in (should always work) Safer than accessing localStorage yourself (handles edgecases, makes sure the flag name is unique to your scenario)
The question to insert
The index before the question you want to insert. For example if you are on index 3 and you want to insert a question at index 6, put index 5
Inserts question as the next question the player will see
The question to insert
Applies all the answer effects of an AnswerModel and then updates each state in the scenario
The answer to apply
Called when calculating the results of a game, returns an EndingModel to create slides out of
for editor, when user changes electoral votes, changes the ending based on the ev
for editor, when user changes popular votes, changes ending based on pv
Returns a FinalResultsModel for the final results of a game
Loads a ScenarioModel into the engine
The ScenarioModel to load
If this is true, then the margins are also loaded and the GameState is set to Election. Used for when you want to view the map without actually playing the game
Finalizes loading the scenario after loadScenario is called. Sets which candidate is the player and who their running mate is.
Used to lookup a side in the ScenarioModel's scenarioSides. Loads that sides questions into the game.
The id of the running mate of the player.
Calls the onAchievementUnlocked method with the achievementName and the current ScenarioController. The Engine does not handle the logic of if an achivement is already unlocked, or storing achievements. That is left to the host site.
Get the id of the candidate with the most ev
Get the id of the candidate with the most pv
The results of the election
The player candidate's number of electoral votes, if player candidate is undefined then returns 0
The results of the election
The player candidate's number of popular votes, if player candidate is undefined then returns 0
The results of the election
The ratio of PV the player got (range [0, 1])
true if no one got >= total EV / 2
The results of the election
Was the player's # of electoral votes >= amount?
The results of the election
Is player EV > total EV / 2
The results of the election
Did the player have the most PV (note not > 50%, just the most)
Holds the display names for counters, if a display name is not defined it defaults to the counter's key + value
Any variable in counters will be shown on screen. Only supports number variables. Use setCounter, setCounter methods
Called when the game ends and ending slides/results are calculated. Is set from the method of the same name in a scenario's logic.js
Index of current question
Display number of current question, also how many questions the player has actually answered
Currently loaded ScenarioModel
To be hooked into from a host site to know when an achievement is unlocked.
Called when the an answer is chosen. Is set from the method of the same name in a scenario's logic.js. Used for CYOA purposes.
Called when the user presses "next"
Called when the scenario side is first set (played has chose their running mate and pressed start game)
Range of RNG.
Id of the player's running mate. -1 if unset.
How much a running mate contributes to opinion (1 is the same as a normal candidate)
Index of current side
How much visiting a state boosts that state's opinion of you
Is the player currently waiting to pick a state before moving on to the next question?
Returns the QuestionModel of the current question, if the currentQuestionIndex is invalid, returns null
Set a string you want to be rendered in game as another string. May not work for all strings in game, but will be updated until it does. You probably want to call all these in onScenarioStarted or the optional "onCandidateSelectionStarted" function.
Returns a FinalResultsModel for the defined historical results
The main engine that runs the logic for the game. Should be entirely separate from the View and should have no knowledge of how the player is using it.