A few gaming features added, e.g. rolling dice, flipping coin, eightball.

This commit is contained in:
Storm Dragon
2026-09-03 13:25:32 -04:00
parent d0f78b1295
commit 77c687b6fe
12 changed files with 871 additions and 11 deletions
+32
View File
@@ -0,0 +1,32 @@
package rtpconn
import (
"crypto/rand"
"encoding/base64"
"time"
"git.stormux.org/storm/skald/hall"
)
func isServerGeneratedChatKind(kind string) bool {
return kind == "dice" || kind == "eightball" || kind == "coin"
}
func broadcastServerChat(g *hall.Hall, name, kind, message string) error {
idBytes := make([]byte, 8)
if _, err := rand.Read(idBytes); err != nil {
return err
}
id := base64.RawURLEncoding.EncodeToString(idBytes)
now := time.Now()
g.AddToChatHistory(id, "", &name, now, kind, message)
return broadcast(g.GetClients(nil), clientMessage{
Type: "chat",
Id: id,
Username: &name,
Privileged: true,
Time: now.Format(time.RFC3339),
Kind: kind,
Value: message,
})
}