diff options
| author | historia <[not public]> | 2026-06-10 04:44:31 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-10 04:44:31 -0400 |
| commit | 69d8757ad983697cdc9182fdcc1cdb612a77fb41 (patch) | |
| tree | 348c26d1f6defe3aef64f5aa9e7cefed0e764214 /internal/game/game.go | |
| parent | a226d72e51eecb768b13600303f73483118d9104 (diff) | |
| download | thehouseoficarus-69d8757ad983697cdc9182fdcc1cdb612a77fb41.tar.gz | |
feat: yaml architecture for complex object interaction
Diffstat (limited to 'internal/game/game.go')
| -rw-r--r-- | internal/game/game.go | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/internal/game/game.go b/internal/game/game.go index d793516..08096b4 100644 --- a/internal/game/game.go +++ b/internal/game/game.go @@ -87,6 +87,8 @@ func (g *Game) HandleSession(sess *net.Session, input string) { g.handleDescriptionChange(sess, input) case net.StateTalk: g.handleTalkInput(sess, input) + case net.StateDropAllConfirm: + g.handleDropAllConfirm(sess, input) } } @@ -100,6 +102,24 @@ func (g *Game) handleGameCommand(sess *net.Session, input string) { g.cancelRest(p.Name) } + if sess.Account != nil && sess.Account.Aliases != nil { + firstSpace := strings.Index(input, " ") + var firstWord, rest string + if firstSpace > 0 { + firstWord = input[:firstSpace] + rest = strings.TrimLeft(input[firstSpace:], " ") + } else { + firstWord = input + } + if expansion, ok := sess.Account.Aliases[strings.ToLower(firstWord)]; ok { + if rest != "" { + input = expansion + " " + rest + } else { + input = expansion + } + } + } + parts := strings.Fields(strings.ToLower(input)) cmd := parts[0] args := parts[1:] @@ -144,7 +164,12 @@ func (g *Game) handleGameCommand(sess *net.Session, input string) { if len(args) == 0 { sess.WriteLine("Say what?") } else { - g.doSay(sess, strings.Join(parts[1:], " ")) + msgStart := strings.Index(strings.ToLower(input), "say ") + 4 + if msgStart >= 4 && msgStart < len(input) { + g.doSay(sess, input[msgStart:]) + } else { + g.doSay(sess, strings.Join(args, " ")) + } } case "sc", "score": g.doScore(sess) @@ -183,6 +208,12 @@ func (g *Game) handleGameCommand(sess *net.Session, input string) { g.StartAction(sess, "talk", strings.Join(args, " ")) return } + case "alias": + g.doAlias(sess, args) + return + case "unalias": + g.doUnalias(sess, args) + return default: sess.WriteLine("Unknown command.") } |
