working lobby-ish

This commit is contained in:
Beric Bearnson
2024-08-23 11:59:19 -06:00
parent e90b9c26b1
commit e5df746e7f
6 changed files with 94 additions and 35 deletions
+8 -3
View File
@@ -8,9 +8,14 @@ import (
"strings"
)
var help = fmt.Errorf("use invite <player name> to invite a player\nchat or / to send a message to the lobby\nq or quit to leave the game")
func HandleUserInput(buf []byte) (*netwrk.LobbyMessage, error) {
input := string(buf)
args := strings.Fields(input)
if len(args) == 0 {
return nil, help
}
switch args[0] {
case "invite":
if args[1] != "" {
@@ -40,11 +45,11 @@ func HandleUserInput(buf []byte) (*netwrk.LobbyMessage, error) {
case "q":
return nil, io.EOF
case "help":
return nil, fmt.Errorf("use invite <player name> to invite a player\nchat or / to send a message to the lobby\nq or quit to leave the game")
return nil, help
case "h":
return nil, fmt.Errorf("use invite <player name> to invite a player\nchat or / to send a message to the lobby\nq or quit to leave the game")
return nil, help
default:
return nil, fmt.Errorf("use invite <player name> to invite a player\nchat or / to send a message to the lobby\nq or quit to leave the game")
return nil, help
}
return nil, nil
}