From: Erik V. <eri...@xs...> - 2010-06-27 15:08:58
|
Thinking about it, I realised that such a trigger mechanism already exists and is widely used in Rails: the Observer pattern. All States and several other object types are also ModelObjects, which extends Observable, so any other object implementing Observer can register at any State to be informed about any value changes. This is mainly used to update the UI, but IIRC there are already some server-internal Observer/Observable pairs. I think this existing mechanism fulfills your need, and it works at the proper level (using States/ModelObjects in stead of Moves). In the example case of destination checks: each MapHex is an Observable that updates its Observers (which currently only are the corresponding GUIHex objects) each time a new tile is laid. If MapManager would register itself with any MapHex it is creating (this isn't done yet), it will get called on every tile lay, passing the new tile and its rotation (perhaps the hex id should be added). So, whenever called, the MapManager can inititate any destination checks or anything else that is needed. Erik. -----Original Message----- From: Erik Vos [mailto:eri...@xs...] Sent: Sunday 27 June 2010 00:33 To: 'Development list for Rails: an 18xx game' Subject: Re: [Rails-devel] 1856 bugs in Rails 1.3 --undoduringCGRformationhangs game * My own first idea was to use a specific trigger interface and require triggers to be explicitly defined. But I realized that the moves are excellent triggers and the Moveset a very good place to pass the messages. Moveset could still delegate the task to a TriggerManager, if a better separation is required. And I want low-level triggers, to avoid that every (high-level) implementation has to remember to call the trigger. [EV] I still don't like at all to use the Move/MoveSets. I'd much prefer to keep these clean. How are you going to tell an object Move that it is a trigger and what it must call if it is? Or should all object moves always call all triggerables, or the TriggerManager (and how can it find that one)? I completely don't understand how you see this working, and what's the benefit of using the Moves. Take the example: A candidate in the long run ist the function that checks if a company is floated. Every (high-level) method that moves shares out of IPO has to check if the company has floated. If the trigger is used, this is done automatically. This would also cover special cases in games, which are not yet implemented. [EV] What is exactly registering to what in this example? And what is triggering what? And how can both the registerer and the triggerer find their callees? Erik. ---------------------------------------------------------------------------- -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Rails-devel mailing list Rai...@li... https://lists.sourceforge.net/lists/listinfo/rails-devel |