Skip to content

How to set up a new expansion

Robert Konigsberg edited this page Dec 10, 2021 · 9 revisions

How to create a new Game Expansion.

I've set up four game expansions, and it's really a lot of work. This list will probably change over time, but at least having some of this written down will help for the next time. For the sake of discussion, let's call the new module "Aliens". At times the docs suggest changing in several places in one file. You can look at one of the existing expansions. I recommend using one of the less intrusive expansions.

  1. Add entry to GameModule.ts with this line: Aliens = 'aliens',

  2. Create the directory src/cards/aliens

  3. Create a manifest src/cards/aliens/AliensManifest.ts

  4. Add the manifest to AllCards.ts.

  5. If you're creating Global Events, update GlobalEventDealer.ts

  6. Define the option.

  • In src/Game.ts, update GameOptions, DEFAULT_GAME_OPTIONS

  • Add line in Game.deserialize, below const gameOptions = d.gameOptions

`gameOptions.aliensExpansion = d.gameOptions.aliensExpansion ?? false;`

This will maintain backward compatibility for old games. You can remove that some time long after you no longer have games on your server that didn't have that variable defined.

  • Add the option to src/models/ServerModel.ts

  • Define the option in src/models/GameOptionModel.ts

  • Add a default value to src/tools/analyze_ma.ts

  • Update ApiGame.spec.ts

  1. Register the manifest in src/CardLoader.ts, in both manifests and possibly expansions.

  2. Update the UI components.

  • In src/styles/cards.less, add .aliens-icon:after and expansion-icon-aliens

    • Consider adding any assets to assets/aliens rather than assets.
  • Create an entry for the icon in src/client/components/card/CardExpansion.vue

  • Update src/client/components/DebugUI.vue. There are many places to change within that file.

  • Update GameSetupDetail.ts There are a few places you need to make changes, including

    • The check box
    • CreateGameModel
    • NewPlayerModel
    • data()
    • serializeSettings
    • dataToSend
  • The server-end of this change has to be changed in src/routes/Game.ts

  • It is possible you will need to hook up into GameEnd.vue, SpectatorHome.vue and PlayerHome.vue

  1. If you want to create additional data to be stored as part of the game, that's something else, but here's two steps you'll need to take:
  • In src/SerializedGame.ts add the matching field in GameOptions.

  • In src/Game.ts, update methods serialize and deserialize.

    • If you are concerned about existing games' backward compatibility, add tests that ensure old games can load even without the serialized data.
  1. Update CreateGameForm.vue and CustomCorporationsFilter to make the new expansion selectable.