History loading

This commit is contained in:
Madison Rye Progress
2025-09-14 20:50:00 -07:00
parent 6198c794d5
commit 6b5674308e
4 changed files with 81 additions and 44 deletions

View File

@ -11,7 +11,7 @@ type Point struct {
}
func (p Point) String() string {
return fmt.Sprintf("%d,%d", p.X, p.Y)
return fmt.Sprintf("(%d,%d)", p.X, p.Y)
}
type State struct {
@ -20,7 +20,8 @@ type State struct {
clears, score, factor int
blackout []bool
history string
history string
historyIndex int
sectionSize, cellsPerSection int
cells, sections *field
@ -34,7 +35,7 @@ func New(sectionSize, cellsPerSection int) *State {
sections: newField(sectionSize),
cursor: &Point{0, 0},
}
s.history = fmt.Sprintf("g%d,%d", sectionSize, cellsPerSection)
s.history = fmt.Sprintf("g(%d,%d)", sectionSize, cellsPerSection)
for x := 0; x < sectionSize; x++ {
for y := 0; y < sectionSize; y++ {
s.initSection(Point{x, y})
@ -49,11 +50,6 @@ func (s *State) size() int {
return s.sectionSize * s.cellsPerSection
}
// History returns the gameplay history for replays
func (s *State) History() string {
return s.history
}
func (s *State) String() string {
var buf bytes.Buffer
for x := 0; x < s.sectionSize*s.cellsPerSection; x++ {