clone

fifteen puzzle games for the terminal, with daily puzzles, weekly ladders and xp, built on bubble tea

patch

Dami committed fb793ef
commit
fb793ef69726e5d279757061353472fd0243b4ca
parent
7471ee00ebe17f1659a5ad8a7600f262b2495b81
author
Dami <dami.etoile@gmail.com>
9 files changed, +70 -59
Mfillomino/Export.go32+++++++++++++++++++----------
Mfillomino/fillomino_test.go14++++++++++++
Mfillomino/generator.go12-----------
Mfillomino/solver.go21-------------------
Mfillomino/style.go7------
Mhitori/style.go1+
Mshikaku/Export.go1-
Mshikaku/shikaku_test.go34++++++++++++++++++++++++++++++
Mshikaku/style.go7------
M fillomino/Export.go +21 -11
@@ -8,20 +8,22 @@ import (
88 )99 1010 type Save struct {11- Width int `json:"width"`12- Height int `json:"height"`13- State string `json:"state"`14- Provided string `json:"provided"`15- ModeTitle string `json:"mode_title"`11+ Width int `json:"width"`12+ Height int `json:"height"`13+ State string `json:"state"`14+ Provided string `json:"provided"`15+ ModeTitle string `json:"mode_title"`16+ MaxCellValue int `json:"max_cell_value,omitempty"`1617 }1718 1819 func (m Model) GetSave() ([]byte, error) {1920 save := Save{20- Width: m.width,21- Height: m.height,22- State: encodeGrid(m.grid),23- Provided: serializeProvided(m.provided),24- ModeTitle: m.modeTitle,21+ Width: m.width,22+ Height: m.height,23+ State: encodeGrid(m.grid),24+ Provided: serializeProvided(m.provided),25+ ModeTitle: m.modeTitle,26+ MaxCellValue: m.maxCellValue,2527 }2628 data, err := json.Marshal(save)2729 if err != nil {
@@ -61,12 +63,20 @@ func ImportModel(data []byte) (*Model, error) {
6163 cursor: game.Cursor{},6264 keys: DefaultKeyMap,6365 modeTitle: save.ModeTitle,64- maxCellValue: max(9, maxCellValue(state)),66+ maxCellValue: restoredMaxCellValue(save.MaxCellValue, state),6567 }6668 m.recompute()6769 return m, nil6870 }6971 72+func restoredMaxCellValue(savedMax int, state grid) int {73+ if savedMax > 0 {74+ return savedMax75+ }76+77+ return max(1, maxCellValue(state))78+}79+7080 func initialGridForImport(state grid, provided [][]bool) grid {7181 initial := newGrid(len(state[0]), len(state))7282 for y := range len(state) {
M fillomino/fillomino_test.go +14 -0
M fillomino/generator.go +0 -12
M fillomino/solver.go +0 -21
M fillomino/style.go +0 -7
M hitori/style.go +1 -0
M shikaku/Export.go +0 -1
M shikaku/shikaku_test.go +34 -0
M shikaku/style.go +0 -7