RanvierMUD / core

Core engine code for Ranvier
https://ranviermud.com
MIT License
45 stars 40 forks source link

Area does not receive channelReceive event #52

Closed shawncplus closed 5 years ago

shawncplus commented 5 years ago

AreaAudience should be refactored. The logic inside getBroadcastTargets() should be moved into Area#getBroadcastTargets() thereby making an Area broadcastable. In doing this the method should also be updated to return the area instance itself as well as the room instances.

When sending a message to an AreaAudience the area, all rooms in the area, all players in the area, and all NPCs in the area should receive the channelReceive event. As such the Area#getBroadcastTargets() should look something like:

getBroadcastTargets() {
 const roomTargets = [...this.rooms].reduce((acc, [, room]) => acc.concat(room.getBroadcastTargets()), []);
 return [this, ...roomTargets];
}