aboutsummaryrefslogtreecommitdiff
path: root/internal/game/core_utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/core_utils.go')
-rw-r--r--internal/game/core_utils.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/game/core_utils.go b/internal/game/core_utils.go
index 409422e..c169580 100644
--- a/internal/game/core_utils.go
+++ b/internal/game/core_utils.go
@@ -104,6 +104,22 @@ func formatPickupList(sess *net.Session, picked []string) {
}
}
+func (g *Game) broadcastAction(sess *net.Session, format string, args ...interface{}) {
+ if g.Hub == nil {
+ return
+ }
+ p := sess.Player
+ if p == nil {
+ return
+ }
+ msg := fmt.Sprintf(format, args...)
+ for _, other := range g.Hub.PlayersInRoom(p.RoomID) {
+ if other != sess && other.Player != nil {
+ other.WriteLine(g.colorize(other, "broadcast", msg))
+ }
+ }
+}
+
func (g *Game) newInventorySlot(itemID string, qty int) *player.InventorySlot {
slot := &player.InventorySlot{ItemID: itemID, Quantity: qty}
if def, err := g.ItemStore.Load(itemID); err == nil && def.MaxQuality > 0 {