-
Notifications
You must be signed in to change notification settings - Fork 56
Game
Cheng20010201 edited this page Apr 13, 2020
·
7 revisions
In coordination with https://github.com/source-academy/cadet-frontend/pull/1058, this project aims to extend the cadet backend to allow storage of game data in backend.
Improvent: Previously the user's game data (story to play, collectibles, status of game inside a story...) is stored in local storage, making it troublesome for user to change another device to play the game. Now the cadet backend is enabled to store user's game data.
Achieved by:
- Studying the structure of the database. Found out that the story to play for a user is bound with the table "assessments" and the relevant data can be retrieved from the index.json file. To keep track of the user's current story, we only need to make relevant modifications in the frontend.
- Using migration to extend the field of table "user" by one additional column. Namely "game_states".
- game_states, being a new attribute of the table "user", is a map. Inside the map, there are another map called "collectibles" and an array of strings called completed_quests.
- collectibles is a map, this is for the convenience of frontend. A collectible is a picture in frontend. The picture has a nick_name, which we would like to call in the process of game developing. The nick_name is the key of the map. The picture has a real name, which is the name of the picture source file in the assets server. The real name is the value of the map.
- completed_quests is an array of strings. The purpose of this is to better fit the game process. When the user plays the game, an action_sequence, which is an array of strings, is generated to represent the user's state inside the game. To save users' game states by generalising this idea, we call this array by the name "completed_quests" and save it in backend along with the user.
- Added functionality for the backend to retrieve, update, reset users' game_states.
- Properly adjust other parts of the backend to fit the new functionality.
- Modified