Dear Globulation 2 gurus, Here is a suggested state machine for the building life cycle. This proposal solves a number of problems with the previous system:
1. It has a clean, less confusing semantics which is likely to lead to fewer bugs (e.g., it would probably have helped avoid the repair crash bug in glob2 version 0.8.22). 2. The user can request direct construction to any desired level without stopping at the intervening levels. 3. There is no need to repair before upgrading (is there now?), as the needed amount of resources will be calculated correctly. 4. Clearing is automatically requested, saving the user from the pain of setting clearing areas and flags before starting construction. 5. It solves the bug where upgrading is silently canceled when resources grow on the larger area needed before all the globules are out of the building and out of the larger area. 6. Visually distracting forbidden/guard/clearing areas are removed from the areas occupied by buildings. 7. Abuse of construction sites is impossible. The technical details follow below. Comments are welcome! Is this a good idea or does it suck? -- Joe ---------------------------------------------------------------------- This proposal has benefited from comments by Eli Dupree, Leo, and Kai. Each building has these parameters: its type T, its state S, two levels C (current) and D (desired), and its number of requested workers W. During ordinary use, C=D. It is only during the construction/upgrade process that C can differ from D. Each building also has two sets of resources: its construction resources (all the resources used so far to build and upgrade it), and its supply resources (the resources gathered for ordinary use of the building). While in any state, as hitpoints are lost due to damage, the construction resources of the building are reduced appropriately. There is a table Work such that Work(T,S,L) gives the number of workers to use for a building of type T in state S at level L. New buildings start with state S=“R”, with C=0 (meaning not yet existing), with no resources (construction or supply), and with the target level D≥1. The possible states are as follows: “R” (clearing resources): While in this state, the building occupies the area of a level C building. (If C=0, this is no area at all, and workers/warriors can walk on it and resources can grow on it. In this case, it is probably desirable to show a ghost of the size D version so the user can see what they have requested and have something to click on to see and adjust the status.) Upon entry into this state, clearing cells are placed and all forbidden or guard cells are removed on the area needed for a level D building. Upon exit from this state, all forbidden/guard/clearing cells are removed on the area needed for a level D building. While in this state, the building site acts like a clearing flag, summoning a number of workers given by W, which is set to Work(T,“R”,D) upon entry into this state. If all the resources are cleared, the building switches to state S=“F”. If construction is canceled, the building switches to state S=“U”, with the value of D changing to be the same as C. “F” (shooing the workers and warriors): While in this state, the building occupies the area of a level C building. (See comment for state R regarding the C=0 case.) Upon entry into this state, forbidden and clearing cells are placed and all guard cells are removed on the area needed for a level D building. Upon exit from this state, all forbidden/guard/clearing cells are removed on the area needed for a level D building. If all the workers and warriors exit the area, the building switches to state S=“B”. If any resources grow on the area, the building switches to state S=“R”. If construction is canceled, the building switches to state S=“U”, with the value of D changing to be the same as C. “B” (building): While in this state, the building occupies the area of a level D building. While in this state, the building increases its construction resources to the level required for a building of type T and level D by summoning the number of workers given by W, which is set to Work(T,“B”,D) upon entry into this state. If all the needed resources arrive, the building switches to state S=“U”, with the value of C changing to be the same as D. If construction is canceled, the building switches to state S=“U”, with the value of D changing to be the same as C. (The construction resources accumulated are remembered, so one can restart an upgrade or repair later and continue from where one left off.) “U” (use): This is the state for normal use. While in this state, the building occupies the area of a level D building. Upon entry to this state, D and C must have the same value. Upon entry to this state, if D=C=0, then the building disappears. (This happens if you cancel construction on a new building before ever entering state U. In this case you lose any resources gathered so far.) While in this state, the building summons to supply it the number of workers given by W, which is set to Work(T,“U”,D) upon entry into this state (and which will only be non-zero for buildings that need workers to supply them during ordinary use). If repair is requested, the building switches to state S=“E” (with no change to D). If upgrade to level L>D is requested, the building switches to state S=“E” with D=L. “E” (emptying): While in this state, the building occupies the area of a level C building. Upon entry into this state, clearing cells are placed and all forbidden or guard cells are removed on the area needed for a level D building. Upon exit from this state, all forbidden/guard/clearing cells are removed on the area needed for a level D building. In this state, the building waits for any globules inside to exit and does not accept any new guests. If the globules all exit, the building switches to state S=“R”. If construction is canceled, the building switches to state S=“U”, with the value of D changing to be the same as C. (How the values in the table Work are determined is outside of the scope of this proposal and is a completely separate issue. I suggest the user interface should allow setting all of them separately. It should be possible to solve problems like the fact that you currently can not set the number of workers for a construction site of a new building until the globules leave the construction location. Or the fact that you can't set the number of workers while waiting for globules to exit the building.) _______________________________________________ glob2-devel mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/glob2-devel
