clone

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

feat/app-decomposition
puzzletea / games / spellpuzzle / gamemode.go
gamemode.go 2.0K
1package spellpuzzle23import (4 _ "embed"5 "math/rand/v2"67 "github.com/FelineStateMachine/puzzletea/game"8 "github.com/FelineStateMachine/puzzletea/gameentry"9 "github.com/FelineStateMachine/puzzletea/puzzle"10)1112//go:embed help.md13var HelpContent string1415type SpellPuzzleMode struct {16 game.BaseMode17 BankSize int18 BoardWordCount int19 MinBonusWords int20}2122var (23 _ game.Mode = SpellPuzzleMode{}24 _ game.Spawner = SpellPuzzleMode{}25 _ game.SeededSpawner = SpellPuzzleMode{}26)2728func NewMode(title, description string, bankSize, boardWords, minBonusWords int) SpellPuzzleMode {29 return SpellPuzzleMode{30 BaseMode: game.NewBaseMode(title, description),31 BankSize: bankSize,32 BoardWordCount: boardWords,33 MinBonusWords: minBonusWords,34 }35}3637func (m SpellPuzzleMode) Spawn() (game.Gamer, error) {38 puzzle, err := GeneratePuzzle(m)39 if err != nil {40 return nil, err41 }42 return New(m, puzzle)43}4445func (m SpellPuzzleMode) SpawnSeeded(rng *rand.Rand) (game.Gamer, error) {46 puzzle, err := GeneratePuzzleSeeded(m, rng)47 if err != nil {48 return nil, err49 }50 return New(m, puzzle)51}5253var Modes = []game.Mode{54 NewMode("Beginner", "6 letters, 4 board words, gentle intro.", 6, 4, 3),55 NewMode("Easy", "7 letters, 6 board words, balanced start.", 7, 6, 4),56 NewMode("Medium", "8 letters, 8 board words, denser layout.", 8, 8, 6),57 NewMode("Hard", "9 letters, 9 board words, largest launch board.", 9, 9, 8),58}5960var ModeDefinitions = gameentry.BuildModeDefs(Modes)6162var Definition = puzzle.NewDefinition(puzzle.DefinitionSpec{63 Name: "Spell Puzzle",64 Description: "Connect letters to fill a crossword with bonus anagrams.",65 Aliases: []string{"spell", "spellpuzzle"},66 Modes: ModeDefinitions,67 DailyModeIDs: puzzle.SelectModeIDsByIndex(ModeDefinitions, 0),68})6970var Entry = gameentry.NewEntry(gameentry.EntrySpec{71 Definition: Definition,72 Help: HelpContent,73 Import: game.AdaptImport(ImportModel),74 Modes: Modes,75 Print: PDFPrintAdapter,76})