From: Erik V. <eri...@hc...> - 2008-11-06 19:48:06
|
This is almost exactly the solution I have proposed in my discussion earlier this week with Brett. The difference is, that currentPhase is already available, so gameManager does not need to be prepended. > -----Original Message----- > From: Mark Smith [mailto:mar...@gm...] > Sent: Thursday 06 November 2008 02:16 > To: Development list for Rails: an 18xx game > Subject: Re: [Rails-devel] Starting on a client/server > > If this makes sense... then OperatingRound.java class, layTile routine > could be changed from: > > 323 if (!tile.isLayableNow()) { > 324 errMsg = > 325 LocalText.getText("TileNotYetAvailable", > 326 tile.getExternalId()); > 327 break; > 328 } > > to > > 323 if > (!gameManager.getCurrentPhase().isTileColourAllowed > (tile.getColourName())) { > 324 errMsg = > 325 LocalText.getText("TileNotYetAvailable", > 326 tile.getExternalId()); > 327 break; > 328 } > > This would allow the isLayableNow routine to be tossed... and have the > Operating Round which knows about the gameManager to perform the > check. > > I have applied this change to my copy of the code, it compiles without > error. And I then tossed the isLayableNow routine out, and the > abstract reference in Tile as well. > > Mark > > On Wed, Nov 5, 2008 at 7:10 PM, Mark Smith > <mar...@gm...> wrote: > > Hmm... I believe I understand now why my "code-reduction" would not > > work. I have seen cases where you store the instance of an object > > within the object as a static variable, and have a static method to > > return the instance. I generally avoid writing code that depends on > > global variables, and this is one example. If I need a variable down > > in a routine, I attempt to pass it in so there is no ambiguity. > > > > For this example I would have the routine that calls > 'isLayableNow' to > > instead get the tile colour from the Tile Class, then have the Phase > > Class be called asking 'isTileColorAllowed' instead. > > > > You might still have a similar problem of finding the > current phase by > > whatever routine is currently calling 'isLayableNow' but it > would need > > to be examined. Searching for the use of this routine I find one use > > in 'OperatingRound' class, LayTile routine. And it seems to > be just a > > double-check that it did not get selected by mistake, only an error > > message is produced if it is true. > > > > Mark > > > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK & > win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > |