From: Erik V. <eri...@hc...> - 2007-05-30 20:44:56
|
I have updated Start Round processing, which had long been left untouched, by implementing all the new ideas that we have developed over time. These include: - The whole start round is now fully un/redoable. I think I have catched all state variables in this type of round, and embedded these in a State object. - Model/View communication about actions is now completely done via PossibleAction subclasses. A new subclass NullAction is used for actions like Pass, Done, Undo and Redo (who knows a better name for this class?). New is, that the GUI now lets the player select one PossibleAction object and sends that back to the Model (possibly with added info, such as the selected bid value or the B&O share price). I believe this pattern will make it easier to accomplish the future client/server aplit. - As in the OR, all fields are now kept up to date via the Observer pattern. - I have found a generic way to apply the Observer pattern to calculated values (such as player worth) by using reflection. I am using this now for the "free cash" amount shown in the 1830 start round window. This is calculated by subtracting blocked cash (the total of all outstanding bids) from the actual player cash. I have added a new class public CalculatedMoneyModel (Object object, String methodName) which calls the (parameterless) method with the provided name in the provided object. The free cash model object is now created by the statement freeCash = new CalculatedMoneyModel (this, "getFreeCash"); where 'this' is the current Player object which has a method called freeCash(). This method is then called each time the model is updated (by calling its update() method). This works nicely (and I have learned a new Java trick along the way). This way we can also avoid specialized ModelObject subclasses (like WorthModel) for similar-looking values that are calculated in different ways. I have tested the 1830 and 1835 start rounds fairly extensively, but I would not be surprised if glitches would still be found. Bug reports welcome, as always. Next I will start applying the Java 1.5 generics and for/in loop (in fact there is already one ArrayList<String>). So, anyone compiling this code should now use at least a 1.5 (or 5.0) JDK. Erik Vos |