clone

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

patch

Dami committed 29af4f0
commit
29af4f0757dca79265bedf3ffcabb4a752d4fa61
parent
87f57c3c7a24fb0f825cbbcacd22e573828d3f04
author
Dami <dami.etoile@gmail.com>
11 files changed, +32 -32
Mdaily.go6+++++-
Mgame/style.go7+++++++
Mhashiwokakero/style.go6++----
Mhitori/Export.go1+
Mhitori/Model.go9+++++++--
Mhitori/style.go5+----
Mlightsout/style.go5+----
Mmodel.go12++++--------
Mnonogram/style.go5+----
Mstore/store.go3++-
Mtakuzu/style.go5+----
M daily.go +5 -1
M game/style.go +7 -0
M hashiwokakero/style.go +2 -4
M hitori/Export.go +1 -0
M hitori/Model.go +7 -2
@@ -17,6 +17,7 @@ type Model struct {
1717 numbers grid1818 marks [][]cellMark1919 initialMarks [][]cellMark20+ conflicts [][]bool2021 cursor game.Cursor2122 solved bool2223 keys KeyMap
@@ -51,6 +52,7 @@ func New(mode HitoriMode, numbers grid) (game.Gamer, error) {
5152 modeTitle: mode.Title(),5253 }5354 m.solved = m.checkSolved()55+ m.conflicts = computeConflicts(m.numbers, m.marks, m.size)5456 return m, nil5557 }5658
@@ -65,6 +67,7 @@ func (m Model) Update(msg tea.Msg) (game.Gamer, tea.Cmd) {
6567 case game.ResetMsg:6668 m.marks = cloneMarks(m.initialMarks)6769 m.solved = m.checkSolved()70+ m.conflicts = computeConflicts(m.numbers, m.marks, m.size)6871 m.cursor = game.Cursor{}6972 case tea.KeyMsg:7073 switch {
@@ -80,6 +83,7 @@ func (m Model) Update(msg tea.Msg) (game.Gamer, tea.Cmd) {
8083 if !m.solved {8184 m.marks[m.cursor.Y][m.cursor.X] = unmarked8285 m.solved = m.checkSolved()86+ m.conflicts = computeConflicts(m.numbers, m.marks, m.size)8387 }8488 default:8589 m.cursor.Move(m.keys.CursorKeyMap, msg, m.size-1, m.size-1)
@@ -98,12 +102,12 @@ func (m *Model) toggleMark(mark cellMark) {
98102 m.marks[m.cursor.Y][m.cursor.X] = mark99103 }100104 m.solved = m.checkSolved()105+ m.conflicts = computeConflicts(m.numbers, m.marks, m.size)101106 }102107 103108 func (m Model) View() string {104109 title := game.TitleBarView("Hitori", m.modeTitle, m.solved)105- conflicts := computeConflicts(m.numbers, m.marks, m.size)106- grid := gridView(m.numbers, m.marks, m.cursor, m.solved, conflicts)110+ grid := gridView(m.numbers, m.marks, m.cursor, m.solved, m.conflicts)107111 status := statusBarView(m.showFullHelp)108112 return lipgloss.JoinVertical(lipgloss.Center, title, grid, status)109113 }
@@ -120,6 +124,7 @@ func (m Model) IsSolved() bool {
120124 func (m Model) Reset() game.Gamer {121125 m.marks = cloneMarks(m.initialMarks)122126 m.solved = m.checkSolved()127+ m.conflicts = computeConflicts(m.numbers, m.marks, m.size)123128 m.cursor = game.Cursor{}124129 return m125130 }
M hitori/style.go +1 -4
M lightsout/style.go +1 -4
M model.go +4 -8
@@ -306,7 +306,7 @@ func (m model) handleDailyPuzzle() (tea.Model, tea.Cmd) {
306306 log.Printf("failed to import daily game: %v", err)307307 return m, nil308308 }309- m.game = g.SetTitle(dailyTitle(rec.Name))309+ m.game = g.SetTitle(rec.Name)310310 m.game, _ = m.game.Update(game.HelpToggleMsg{Show: m.showFullHelp})311311 m.activeGameID = rec.ID312312 m.state = gameView
@@ -330,12 +330,6 @@ func (m model) handleDailyPuzzle() (tea.Model, tea.Cmd) {
330330 return m, tea.Batch(m.spinner.Tick, spawnSeededCmd(spawner, rng))331331 }332332 333-// dailyTitle returns the display title for a daily game.334-// The name already starts with "Daily", so no extra prefix is needed.335-func dailyTitle(name string) string {336- return name337-}338-339333 func (m model) handleGameSelectEnter() (tea.Model, tea.Cmd) {340334 cat, ok := m.gameSelectList.SelectedItem().(game.Category)341335 if !ok {
@@ -368,6 +362,8 @@ func spawnCmd(spawner game.Spawner) tea.Cmd {
368362 }369363 370364 // spawnSeededCmd returns a tea.Cmd that runs SpawnSeeded() off the main goroutine.365+// The caller must not use rng after this call — *rand.Rand is not goroutine-safe366+// and ownership is transferred to the spawned goroutine.371367 func spawnSeededCmd(spawner game.SeededSpawner, rng *rand.Rand) tea.Cmd {372368 return func() tea.Msg {373369 g, err := spawner.SpawnSeeded(rng)
@@ -400,7 +396,7 @@ func (m model) handleSpawnComplete(msg game.SpawnCompleteMsg) (tea.Model, tea.Cm
400396 name = m.dailyName401397 gameType = m.dailyGameType402398 modeTitle = m.dailyModeTitle403- m.game = msg.Game.SetTitle(dailyTitle(name))399+ m.game = msg.Game.SetTitle(name)404400 } else {405401 name = generateUniqueName(m.store)406402 gameType = m.selectedCategory.Name
M nonogram/style.go +1 -4
M store/store.go +2 -1
M takuzu/style.go +1 -4