Campaign JSON #9

Closed
opened 2019-06-28 06:56:30 +00:00 by kirsle · 0 comments
Owner

For single player campaigns, use a custom JSON format for a "campaign.json" that just simply stitches together the built-in levels.

  • pkg/campaign to have functions to read/write Campaign and Scores files.
  • MenuScene to have a Campaign Picker UI
    • List available campaigns
    • Level Select for each campaign
    • Unlockable levels
    • Enter Password feature to unlock levels early
  • PlayScene support for campaigns
    • Next Level button when completing a level
  • Open/Edit Level can hide levels that are part of certain campaigns

Campaign JSON Format

// assets/campaigns/tutorial.json
{
  "version": 1,
  "campaign": {
    "id": "sketchymaze:tutorial",
    "title": "Tutorial Levels",
    "description": "A set of example levels.",
    "author": "",
    "unlockedLevels": 0,
    "publicLevels": false,
    "levelNames": [
      // The array orders the levels. When the goal is reached
      // in each level you advance to the next one.
      "S1E1.level",
      "S1E2.level",
      "S1E3.level"
    ],
    "priority": 0
  }
}

Definition of interesting campaign properties:

  • ID: a unique and namespaced identifier for your campaign.
  • Unlocked Levels: the number of levels which are unlocked (playable) by default.
    • 0 = All levels unlocked from the start, no level progression needed.
    • 3 = The first 3 levels are unlocked from the start. Completing one level unlocks one additional level.
  • Public Levels: if true then the levels referenced in the campaign JSON can also appear on the "Edit a Level" window.
    • Tutorial levels might want to be available to open for editing, while also being grouped in a single player campaign. They would use publicLevels=true
    • Story mode levels would be built-in to the game, but not visible for editing, accessed only in their campaign which has publicLevels=false.
  • Priority: to handle sorting for display, especially for the built-in campaigns.
    • Arbitrary integer, default zero
    • The higher the number, the higher it sorts (being the 1st campaign shown to the user)
    • Campaigns will sort by priority and then title for campaigns having a common priority.

Save File Format (Scores File)

The user's progress on a campaign is saved within their scores file.

// ~/.config/doodle/scores.json
{
  "version": 1,
  "checksum": "aef65cee9bf99f6c1272ce59153e945e",
  "campaigns": {
  	// Campaign unique ID
  	"sketchymaze:tutorial": {
      "levelsCompleted": [
      	{
          "level": "S1E1.level",
          "password": "ABCD",

          // updated on new high score
          "timeElapsed": 123 // shortest elapsed time playing the level
          "highScoreAt": time.Now(),
          "score": 0,
        }
      ]
    }
  }
}

Checksum: a very low bar for preventing casual cheaters; the "campaigns" object is serialized to stable JSON and hashed with a built-in secret key and that provides the checksum.

Level passwords: the Level JSON already has a Password field that so far is unused as it's intended for this purpose.

As a validation check against the user just editing their scores.json to mark levels as completed by guessing the name of the next level, the scores.json holds the "password" field which should match with the Level.Password field of the named level.

Campaign Selection UI

From the Main Menu screen, an "Adventure Mode" button would be added.

The Adventure Mode menu would show a list of available campaigns to play.

Large buttons arranged vertically for each campaign, showing the campaign title and description within each button.

Clicking a campaign would enter the Level Select screen, where all the levels in the campaign would be listed as a tiled grid, say 3 wide by 2 tall or such, and pagination buttons in case the campaign has more than 6 levels.

Level buttons would show a lock icon until the user completes the prior levels to unlock the later ones. If the level had been completed, it shows the time and details of the best score obtained.

When a level button is unlocked, the Level Password is shown in the button.

There should be a button to enter a password to unlock future levels. If the password matches a level's within the campaign, the levelsCompleted array in their score.json appends an entry with the level's name and password, but no score information. The level button should then appear unlocked and show its password like the other unlocked levels.

Gameplay

Clicking a level plays it as normal. The Play Scene will be given details about the campaign when called, so that it knows it's in the campaign mode.

When the level goal is reached:

  • Buttons are to Next level (default), Play Again, or Save & Quit (return to menu)
  • Clicking the Next Level button would find the next level name on the campaign's list and reinitialize the Play Scene passing the new level and the campaign data.

Open/Edit Level

  • The game bundles a set of levels with the game executable (examples, tutorials, etc.)
  • And some of these levels are part of single player campaigns.
  • The campaign JSON decides whether its levels show up as editable to the player.

So some Tutorial Levels could both be bundled in a Campaign and also editable by the player so they can study them; or a story mode campaign can hide all of its levels so the player only accesses them via the story mode.

For single player campaigns, use a custom JSON format for a "campaign.json" that just simply stitches together the built-in levels. * [ ] pkg/campaign to have functions to read/write Campaign and Scores files. * [ ] MenuScene to have a Campaign Picker UI * [ ] List available campaigns * [ ] Level Select for each campaign * [ ] Unlockable levels * [ ] Enter Password feature to unlock levels early * [ ] PlayScene support for campaigns * [ ] Next Level button when completing a level * [ ] Open/Edit Level can hide levels that are part of certain campaigns ### Campaign JSON Format ```javascript // assets/campaigns/tutorial.json { "version": 1, "campaign": { "id": "sketchymaze:tutorial", "title": "Tutorial Levels", "description": "A set of example levels.", "author": "", "unlockedLevels": 0, "publicLevels": false, "levelNames": [ // The array orders the levels. When the goal is reached // in each level you advance to the next one. "S1E1.level", "S1E2.level", "S1E3.level" ], "priority": 0 } } ``` Definition of interesting campaign properties: * **ID:** a unique and namespaced identifier for your campaign. * **Unlocked Levels:** the number of levels which are unlocked (playable) by default. * 0 = All levels unlocked from the start, no level progression needed. * 3 = The first 3 levels are unlocked from the start. Completing one level unlocks one additional level. * **Public Levels:** if `true` then the levels referenced in the campaign JSON _can also_ appear on the "Edit a Level" window. * Tutorial levels might want to be available to open for editing, while _also_ being grouped in a single player campaign. They would use publicLevels=true * Story mode levels would be built-in to the game, but _not_ visible for editing, accessed only in their campaign which has publicLevels=false. * **Priority:** to handle sorting for display, especially for the built-in campaigns. * Arbitrary integer, default zero * The higher the number, the higher it sorts (being the 1st campaign shown to the user) * Campaigns will sort by priority and then title for campaigns having a common priority. ### Save File Format (Scores File) The user's progress on a campaign is saved within their scores file. ```javascript // ~/.config/doodle/scores.json { "version": 1, "checksum": "aef65cee9bf99f6c1272ce59153e945e", "campaigns": { // Campaign unique ID "sketchymaze:tutorial": { "levelsCompleted": [ { "level": "S1E1.level", "password": "ABCD", // updated on new high score "timeElapsed": 123 // shortest elapsed time playing the level "highScoreAt": time.Now(), "score": 0, } ] } } } ``` **Checksum:** a very low bar for preventing casual cheaters; the "campaigns" object is serialized to stable JSON and hashed with a built-in secret key and that provides the checksum. **Level passwords:** the Level JSON already has a Password field that so far is unused as it's intended for this purpose. As a validation check against the user just editing their scores.json to mark levels as completed by guessing the name of the next level, the scores.json holds the "password" field which should match with the Level.Password field of the named level. ### Campaign Selection UI From the Main Menu screen, an "Adventure Mode" button would be added. The Adventure Mode menu would show a list of available campaigns to play. Large buttons arranged vertically for each campaign, showing the campaign title and description within each button. Clicking a campaign would enter the Level Select screen, where all the levels in the campaign would be listed as a tiled grid, say 3 wide by 2 tall or such, and pagination buttons in case the campaign has more than 6 levels. Level buttons would show a lock icon until the user completes the prior levels to unlock the later ones. If the level had been completed, it shows the time and details of the best score obtained. When a level button is **unlocked**, the Level Password is shown in the button. There should be a button to enter a password to unlock future levels. If the password matches a level's within the campaign, the levelsCompleted array in their score.json appends an entry with the level's name and password, but no score information. The level button should then appear unlocked and show its password like the other unlocked levels. ### Gameplay Clicking a level plays it as normal. The Play Scene will be given details about the campaign when called, so that it knows it's in the campaign mode. When the level goal is reached: * Buttons are to **Next level** (default), Play Again, or Save & Quit (return to menu) * Clicking the Next Level button would find the next level name on the campaign's list and reinitialize the Play Scene passing the new level and the campaign data. ### Open/Edit Level * The game bundles a set of levels with the game executable (examples, tutorials, etc.) * And some of these levels are part of single player campaigns. * The campaign JSON decides whether its levels show up as editable to the player. So some Tutorial Levels could _both_ be bundled in a Campaign and also editable by the player so they can study them; or a story mode campaign can _hide_ all of its levels so the player only accesses them via the story mode.
kirsle added the
enhancement
label 2019-06-28 06:56:33 +00:00
kirsle added this to the First Beta Release MVP milestone 2019-06-28 06:56:40 +00:00
Sign in to join this conversation.
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SketchyMaze/doodle#9
No description provided.