-
Notifications
You must be signed in to change notification settings - Fork 3
How to update the static data of the game
The app's phase 1 implementation does not handle different content versions! This means that whenever the content is updated or modified, the previously played games' historical data will be lost for later reviews irreversibly.
Currently, changing the static content's structure or its relations is not possible without changing the underlying database's structure. We highly recommend NOT changing that manually as this will break the application if the corresponding logic is not updated accordingly.
NODE-ENV environment variable: The value of this environment variable decides if the database has to be reset automatically. We introduced this function for avoiding manual database reset on the staging environment where the updates are getting deployed frequently.
In the production environment, the database will NOT be reset in order to ensure data persistence. If it is necessary to reset the database, it has to be done manually.
In the staging environment (or if you would like to reset and reseed the database on every deployment/startup): NODE_ENV=test
For all the other environments, please set the value to anything you would like: NODE_ENV=prod
What happens on database reset?
- Rolling back all the migrations (basically dropping all the tables and their content)
- Re-run of all the migrations (recreating all the tables and relations)
- Inserting the static content from the hardcoded files
The static data in the project is inside the seeds
folder of the CyberSim-Backend repository. Each static data set like injections or mitigations is separated into different javascript
files. These files have a static
prefix, followed by the number and then the name of the data set. To add new data to these sets, open the file using an editor and simply copy and paste an existing data item from the set then modify it accordingly. Each item is written inside curly braces, so in order to add a new action item copy the following code from the static_7_action.js
file:
{
id: 'A14',
description: 'Share Facebook posts from phones',
type: 'local',
cost: 0,
budget_increase: 200,
poll_increase: 0,
required_systems: ['S7', 'S10'],
},
Then paste it to the end of the copied item:
{
id: 'A14',
description: 'Share Facebook posts from phones',
type: 'local',
cost: 0,
budget_increase: 200,
poll_increase: 0,
required_systems: ['S7', 'S10'],
},
{
id: 'A15',
description: 'Share Facebook posts from tablets',
type: 'hq',
cost: 0,
budget_increase: 300,
poll_increase: 0,
required_systems: ['S7', 'S10'],
},
After a new data item is added save the file and run the following commands:
# Add new files to staging.
$ git add .
# Commit new changes.
$ git commit --m "<CUSTOM_COMMIT_MESSAGE>"
# Push changes to the github repository
$ git push origin master
# Reset db and update new seed data.
$ npm run reset-db
Please note that it is important to follow the predefined structures of the data sets upon creating new data items, since incorrect new data may broke the application.
-
id: Unique identifier of the action. Type:
String
-
title: Title presented on the top of the event card. Type:
String
-
description: Description section on the event card. Type:
String
-
trigger_time: Time in milliseconds when the event will become deliverable. Type:
Number
-
location: Name of the branch that can respond to the event. It's value must be either
hq
orlocal
. Type:String
-
type: Type of the event. It's value must be either
Table
,Background
orBoard
. Type:String
-
recipient_role: Recipient who can respond to the event. Type:
String
-
asset_code: Code of the asset that should be delivered to the table when the event occurs. Type:
String
-
poll_change: Change in percent the event will affect the public opinion. Type:
Number
-
systems_to_disable: List of systems (system ids) the event will disable. Type:
String[]
-
skipper_mitigation: Id of the mitigation which if TRUE mitigates the event. Type:
String
-
skipper_mitigation_type: Type of the skipper mitigation. It's value must be either
hq
,local
orparty
. Type:String
-
id: Unique identifier of the mitigation. Type:
String
-
description: Description of the mitigation. Type:
String
-
is_hq: If true, it can be bought by the HQ branch. It's value must be either
true
orfalse
. Type:Boolean
-
is_local: If true, it can be bought by the LOCAL branch. It's value must be either
true
orfalse
. Type:Boolean
-
hq_cost: Cost of the mitigation for the HQ branch. Type:
Number
-
local_cost: Cost of the mitigation for the LOCAL branch. Type:
Number
-
category: Category of the mitigaton. It's value must be either
Operation
,National party voter database
,National party website
,Accounts
,Devices
. Type:String
-
id: Unique identifier of the mitigation. Type:
String
-
description: Description of the response shown under responses of the corresponding event. Type:
String
-
cost:Cost of the response. Type:
Number
-
location: Name of the branch that can take the response. It's value must be either
hq
,local
orparty
. Type:String
-
mitigation_id: Id of the mitigation that taking the response provides. Type:
String
-
mitigation_type: Type of the mitigation that taking the response provides. It's value must be either
hq
,local
orparty
. Type:String
-
systems_to_restore: List of systems (system ids) that taking the response restores. Type:
String[]
-
required_mitigation: Id of the mitigation that is required to take the response. Type:
String
-
required_mitigation_type: Type of the mitigation that is required to take the response. It's value must be either
hq
,local
orparty
. Type:String
-
id: Unique identifier of the system. Type:
String
-
description: Description of the system. Type:
String
-
name: Name of the system shown under technical systems. Type:
String
-
type: Type of the system. It's value must be either
hq
,local
orparty
. Type:String
-
injection_id: Id of the injection. Type:
String
-
response_id: Id of the response. Type:
String
-
injection_to_prevent: Id of the injection taking the corresponding response under the injection will prevent. Type:
String
-
id: Id of the role. Type:
String
-
name: Name of the role. Type:
String
-
id: Id of the action. Type:
String
-
description: Description of the action. Type:
String
-
type: Type of the action. It's value must be either
hq
,local
orparty
. Type:String
-
cost: Cost of the action. Type:
Number
- **budget_change: Amount the event will affect the budget. Type:
Number
-
poll_change: Change in percent the event will affect the public opinion. Type:
Number
-
required_systems: List of systems (system ids) that is required to take the action. Type:
String[]
-
action_id: Id of the action. Type:
String
-
role_id: Id of the role. Type:
String
-
id: Id of the curveball event. Type:
String
-
description: Description of the curveball event. Type:
String
- **budget_change: Amount the event will affect the budget. Type:
Number
-
poll_change: Change in percent the event will affect the public opinion. Type:
Number