clone

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

feat/app-decomposition
puzzletea / games / fillomino / gamemode.go
gamemode.go 2.0K
1package fillomino23import (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 Mode struct {16 game.BaseMode17 Size int18 MaxRegion int19 GivenRatio float6420}2122var (23 _ game.Mode = Mode{}24 _ game.Spawner = Mode{}25 _ game.SeededSpawner = Mode{}26)2728func NewMode(title, description string, size, maxRegion int, givenRatio float64) Mode {29 return Mode{30 BaseMode: game.NewBaseMode(title, description),31 Size: size,32 MaxRegion: maxRegion,33 GivenRatio: givenRatio,34 }35}3637func (m Mode) Spawn() (game.Gamer, error) {38 puzzle, err := GeneratePuzzle(m.Size, m.Size, m.MaxRegion, m.GivenRatio)39 if err != nil {40 return nil, err41 }42 return New(m, puzzle)43}4445func (m Mode) SpawnSeeded(rng *rand.Rand) (game.Gamer, error) {46 puzzle, err := GeneratePuzzleSeeded(m.Size, m.Size, m.MaxRegion, m.GivenRatio, rng)47 if err != nil {48 return nil, err49 }50 return New(m, puzzle)51}5253var Modes = []game.Mode{54 NewMode("Mini 5x5", "Small board with generous clues.", 5, 5, 0.70),55 NewMode("Easy 6x6", "Compact board with simple regions.", 6, 6, 0.66),56 NewMode("Medium 8x8", "Balanced deduction and region growth.", 8, 7, 0.60),57 NewMode("Hard 10x10", "Larger board with denser interactions.", 10, 8, 0.56),58 NewMode("Expert 12x12", "Wide board with long deduction chains.", 12, 9, 0.52),59}6061var ModeDefinitions = gameentry.BuildModeDefs(Modes)6263var Definition = puzzle.NewDefinition(puzzle.DefinitionSpec{64 Name: "Fillomino",65 Description: "Grow the numbered regions to their exact sizes.",66 Aliases: []string{"polyomino", "regions"},67 Modes: ModeDefinitions,68 DailyModeIDs: puzzle.SelectModeIDsByIndex(ModeDefinitions, 1, 2, 3),69})7071var Entry = gameentry.NewEntry(gameentry.EntrySpec{72 Definition: Definition,73 Help: HelpContent,74 Import: game.AdaptImport(ImportModel),75 Modes: Modes,76 Print: PDFPrintAdapter,77})