I am writing my first game and have run into a situation where it seems logical to send an Event to a specific Listener. However, this doesn't seem to fit the spirit of the EventManager. It seems that the EventManager is there to receive messages and dispatch them to its subscribed listeners, with no filtering, special cases, etc.
My game is a simple turn-based card game. It is not poker, but that is a good example. My problem is that when I deal cards, I want to send a Deal event containing the player # and the card. However, each player/listener would subscribe to the event and thus receive the cards dealt to everyone. Is this kosher? Should the players just filter the event for their cards? While I am not particularly concerned with security at this point, dealing all cards to everyone doesn't seem right. Another example of the same situation is chat. What if one player wants to send a chat message to a specific opponent?
Should I modify the EventManager to direct events to specific listeners? This solves one problem, but poses another: What do I do with a listener that wants to receive ALL events, like a Scoreboard or Recorder? In that case, those listeners would not receive such events.
A semi-related question: Is the architecture described in the book suitable for a turn-based game? I like it, but maybe it isn't the best choice.
My game is a simple turn-based card game. It is not poker, but that is a good example. My problem is that when I deal cards, I want to send a Deal event containing the player # and the card. However, each player/listener would subscribe to the event and thus receive the cards dealt to everyone. Is this kosher? Should the players just filter the event for their cards? While I am not particularly concerned with security at this point, dealing all cards to everyone doesn't seem right. Another example of the same situation is chat. What if one player wants to send a chat message to a specific opponent?
Should I modify the EventManager to direct events to specific listeners? This solves one problem, but poses another: What do I do with a listener that wants to receive ALL events, like a Scoreboard or Recorder? In that case, those listeners would not receive such events.
A semi-related question: Is the architecture described in the book suitable for a turn-based game? I like it, but maybe it isn't the best choice.