From: Erik V. <eri...@xs...> - 2010-07-17 11:55:39
|
Subject: Re: [Rails-devel] 1856 bugs in Rails 1.3 -- undo during CGR formation hangs game Date: Monday 21 June 2010 From: Stefan Frey <ste...@we...> To: "Development list for Rails: an 18xx game" <rai...@li...> 1) The BuyCertificates action stores certificate by id 2) The SellShares action only stores percentages sold The main issue is mixing addressing interchangeable objects once by ids and in the other case by type. This can only work, if evey selection by type works deterministically (thus never from unordered collections etc.) and the undo mechanism strictly restores the previous ordering. Stefan [EV] IIRC, in a follow-up you suggested to always use certificate IDs in the share buying and selling action. However, there is a reason behind this difference. Whereas you always buy *certificates* (normally one), you don't sell certificates but *shares*. The share/certificate distinction makes no difference except in the case where you sell half a president's certificate. Say player A has a 20% presidency and player B has 2 10% shares. Player A can then sell a 10% share - even if he does not own a 10% certificate. That's why I think selling can be done in no other way than by selling *shares*. Although certificates are normally bought one by one, the 1830 brown zone case requires enabling more than one cert at a time. As you say, the cert type is passed around via its ID, but this ID is not actually used when the purchase is executed: one (or more) certs are then searched afresh in the selling portfolio. I have not yet fully grasped why you conclude that this difference between selling and buying logic did contribute to the Undo-caused save/restore problem that has (hopefully) just been fixed. Could it be the possibility that a share offered for buying is not the share actually bought (as explained above)? If so, that should be easy to fix: just buy the share with the ID that has been passed around, and then (in the brown case) search for additional shares if requested. (It might even have been that way originally; I vaguely remember having changed this to simplify the code - that might then have been a misguided simplification.) If there would be a real need (or strong wish) to align buying and selling on this aspect, I think we should go for using shares (rather than certificates) all the way. But I'm not yet convinced that there is a strong case for such a change. In any case, such a change would need careful precautions to avoid invalidating all current saved files. Erik |