Skip to content

Commit

Permalink
feat: combine ultra & marathon models into 'single' model
Browse files Browse the repository at this point in the history
  • Loading branch information
Broderick-Westrope committed Aug 20, 2024
1 parent 53dc357 commit 3fa0c17
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 459 deletions.
4 changes: 2 additions & 2 deletions cmd/tetrigo/subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ type PlayCmd struct {
func (c *PlayCmd) Run(globals *GlobalVars) error {
switch c.GameMode {
case "marathon":
return launchStarter(globals, common.ModeMarathon, common.NewMarathonInput(c.Level, c.Name))
return launchStarter(globals, common.ModeUltra, common.NewSingleInput(common.ModeMarathon, c.Level, c.Name))
case "ultra":
return launchStarter(globals, common.ModeUltra, common.NewUltraInput(c.Level, c.Name))
return launchStarter(globals, common.ModeUltra, common.NewSingleInput(common.ModeUltra, c.Level, c.Name))
default:
return fmt.Errorf("invalid game mode: %s", c.GameMode)
}
Expand Down
10 changes: 6 additions & 4 deletions internal/tui/common/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ func NewMarathonInput(level uint, playerName string) *MarathonInput {

func (in *MarathonInput) isSwitchModeInput() {}

type UltraInput struct {
type SingleInput struct {
Mode Mode
Level uint
PlayerName string
}

func NewUltraInput(level uint, playerName string) *UltraInput {
return &UltraInput{
func NewSingleInput(mode Mode, level uint, playerName string) *SingleInput {
return &SingleInput{
Mode: mode,
Level: level,
PlayerName: playerName,
}
}

func (in *UltraInput) isSwitchModeInput() {}
func (in *SingleInput) isSwitchModeInput() {}

type MenuInput struct {
}
Expand Down
29 changes: 20 additions & 9 deletions internal/tui/common/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ import (
tea "github.com/charmbracelet/bubbletea"
)

type Mode int

const (
ModeMenu = Mode(iota)
ModeMarathon
ModeUltra
ModeLeaderboard
)

type SwitchModeMsg struct {
Target Mode
Input SwitchModeInput
Expand All @@ -30,3 +21,23 @@ func SwitchModeCmd(target Mode, in SwitchModeInput) tea.Cmd {
}
}
}

type Mode int

const (
ModeMenu = Mode(iota)
ModeMarathon
ModeUltra
ModeLeaderboard
)

var modeToStrMap = map[Mode]string{
ModeMenu: "Menu",
ModeMarathon: "Marathon",
ModeUltra: "Ultra",
ModeLeaderboard: "Leaderboard",
}

func (m Mode) String() string {
return modeToStrMap[m]
}
Loading

0 comments on commit 3fa0c17

Please sign in to comment.