show more help per proof step

This commit is contained in:
Jon Eugster
2023-07-18 15:25:56 +02:00
parent e5b957e0ec
commit 5b8c9a2e89
6 changed files with 51 additions and 19 deletions
+8 -3
View File
@@ -14,7 +14,8 @@ interface Selection {
interface LevelProgressState {
code: string,
selections: Selection[],
completed: boolean
completed: boolean,
help: number[], // A set of rows where hidden hints have been displayed
}
export interface GameProgressState {
@@ -29,7 +30,7 @@ interface ProgressState {
const initialProgressState: ProgressState = loadState() ?? { games: {} }
// TODO: There was some weird unreproducible bug with removing `as LevelProgressState` here...
const initalLevelProgressState: LevelProgressState = {code: "", completed: false, selections: []}
const initalLevelProgressState: LevelProgressState = {code: "", completed: false, selections: [], help: []}
/** Add an empty skeleton with progress for the current level */
function addLevelProgress(state: ProgressState, action: PayloadAction<{game: string, world: string, level: number}>) {
@@ -54,7 +55,7 @@ export const progressSlice = createSlice({
state.games[action.payload.game][action.payload.world][action.payload.level].code = action.payload.code
state.games[action.payload.game][action.payload.world][action.payload.level].completed = false
},
/** TODO: ? */
/** TODO: docstring */
changedSelection(state: ProgressState, action: PayloadAction<{game: string, world: string, level: number, selections: Selection[]}>) {
addLevelProgress(state, action)
state.games[action.payload.game][action.payload.world][action.payload.level].selections = action.payload.selections
@@ -64,6 +65,10 @@ export const progressSlice = createSlice({
addLevelProgress(state, action)
state.games[action.payload.game][action.payload.world][action.payload.level].completed = true
},
/** Set the list of rows where help is displayed */
helpEdited(state: ProgressState, action: PayloadAction<{game: string, world: string, level: number, help: number[]}>) {
state.games[action.payload.game][action.payload.world][action.payload.level].help = action.payload.help
},
/** delete all progress for this game */
deleteProgress(state: ProgressState, action: PayloadAction<{game: string}>) {
state.games[action.payload.game] = {}