package game import ( "fmt" "strings" "thehouseoficarus/internal/net" ) func (g *Game) executeSay(sess *net.Session, args []string, rawInput string) { if len(args) == 0 { sess.WriteLine("Say what?") } else { msgStart := strings.Index(strings.ToLower(rawInput), "say ") + 4 if msgStart >= 4 && msgStart < len(rawInput) { g.doSay(sess, rawInput[msgStart:]) } else { g.doSay(sess, strings.Join(args, " ")) } } } func (g *Game) doSay(sess *net.Session, msg string) { p := sess.Player roomID := p.RoomID for _, other := range g.Hub.PlayersInRoom(roomID) { if other == sess { other.WriteLine(fmt.Sprintf("You say: %s", g.colorize(sess, "say", msg))) } else { other.WriteLine(fmt.Sprintf("%s says: %s", g.colorize(other, "player_name", p.Name), g.colorize(other, "say", msg))) } } }