aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_say.go
blob: 35ec5fae702a6774edefb07e8a6764825e5e0dc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package game

import (
	"fmt"

	"thirdcollapse/internal/net"
	"thirdcollapse/internal/player"
)

func (g *Game) doSay(sess *net.Session, msg string) {
	p := sess.Player.(*player.Player)
	roomID := p.RoomID

	for _, other := range g.Hub.PlayersInRoom(roomID) {
		if other == sess {
			other.WriteLine(fmt.Sprintf("You say: %s", msg))
		} else {
			other.WriteLine(fmt.Sprintf("\n%s says: %s", p.Name, msg))
		}
	}
}