37 lines
732 B
Go
37 lines
732 B
Go
package play
|
|
|
|
import (
|
|
"gitea.konchin.com/ytshih/inp2025/game/plays"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var RootCmd = &cobra.Command{
|
|
Use: "play",
|
|
Short: "Play game",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
landing:
|
|
landing, err := tea.NewProgram(plays.NewLanding()).Run()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
switch landing.(*plays.Landing).Choice {
|
|
case "Register":
|
|
case "Login":
|
|
login, err := tea.NewProgram(plays.NewLogin()).Run()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if login.(*plays.Login).User == nil {
|
|
_, err := tea.NewProgram(
|
|
plays.NewRedirect("User did not login")).Run()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
goto landing
|
|
}
|
|
}
|
|
},
|
|
}
|