package game import ( "fmt" "strings" "thehouseoficarus/internal/net" "thehouseoficarus/internal/player" ) func (g *Game) doStyle(sess *net.Session, input string) { p := sess.Player styles := []string{"accurate", "aggressive", "defensive", "balanced"} if input == "" { sess.WriteLine("\nCombat styles:") for _, s := range styles { marker := " " if string(p.AttackStyle) == s { marker = "*" } sess.WriteLine(fmt.Sprintf(" %s %s", marker, s)) } return } input = strings.ToLower(input) var matches []string for _, s := range styles { if strings.HasPrefix(s, input) { matches = append(matches, s) } } if len(matches) == 1 { p.AttackStyle = player.AttackStyle(matches[0]) g.AccountStore.SaveCharacter(p) sess.WriteLine(fmt.Sprintf("\nCombat style set to %s.", matches[0])) return } if len(matches) > 1 { sess.WriteLine(fmt.Sprintf("\nAmbiguous style: %s. Choices: %s", input, strings.Join(matches, ", "))) return } sess.WriteLine(fmt.Sprintf("\nUnknown style: %s. Choices: accurate, aggressive, defensive, balanced", input)) } func (g *Game) executeStyle(sess *net.Session, args []string, rawInput string) { if len(args) == 0 { g.doStyle(sess, "") } else { g.doStyle(sess, args[0]) } }