package game import ( "fmt" "strings" "thehouseoficarus/internal/net" ) func (g *Game) executeGlobal(sess *net.Session, args []string, rawInput string) { if len(args) == 0 { sess.WriteLine("Usage: global — sends a message to everyone on the world.") return } msgStart := strings.Index(strings.ToLower(rawInput), "global ") + 7 if msgStart >= 7 && msgStart < len(rawInput) { g.doGlobal(sess, rawInput[msgStart:]) } else { g.doGlobal(sess, strings.Join(args, " ")) } } func (g *Game) doGlobal(sess *net.Session, msg string) { p := sess.Player for _, other := range g.Hub.AllSessions() { if other.Player == nil { continue } other.WriteLine(fmt.Sprintf("%s%s: %s", g.colorize(other, "global", "[Global] "), g.colorize(other, "player_name", p.Name), g.colorize(other, "global", msg))) } }