Rails
Rails copied to clipboard
Skip "lay token" step when a company does not have enough money
Currently the "lay token" step is only skipped when the company has no more tokens. Additionally it would be nice if the "lay token" step is skipped as well when the company does not have enough money (and no other way) to lay a token.
Agreed.
One detail: this will only work if the token laying cost is fixed (method="sequence"), so that is another necessary condition. Distance based token laying has a variable cost.
OK, this was easy to program, but I had to disable it immediately: most regression tests based upon saved game files fail, because these now contain redundant Skip actions. Removing single actions is simple (with ListAndFixSavedFiles), but the hard part is finding out which Skip actions have become redundant and must be removed.
So, if you want to take that upon you, fine, but otherwise I'm afraid that for the time being this will come to nothing.
One detail: this will only work if the token laying cost is fixed (method="sequence"), so that is another necessary condition. Distance based token laying has a variable cost.
Isn't there already some code to fetch a list of possible token locations? Can we reuse that code to perform the necessary check? As far as I understand it the "Lay token" step can be skipped if the company either has no money or the returned list of possible token locations is empty.
OK, this was easy to program, but I had to disable it immediately: most regression tests based upon saved game files fail, because these now contain redundant Skip actions. Removing single actions is simple (with ListAndFixSavedFiles), but the hard part is finding out which Skip actions have become redundant and must be removed.
So, if you want to take that upon you, fine, but otherwise I'm afraid that for the time being this will come to nothing.
Yes, this makes it difficult to change the current behavior
While we're at it let's skip the "lay token" step if the map does not have any locations highlighted where you can place a token. (It gives me the giggles when Rails offers to let me place one in any of the highlighted locations and there aren't any.)
While we're at it let's skip the "lay token" step if the map does not have any locations highlighted where you can place a token. (It gives me the giggles when Rails offers to let me place one in any of the highlighted locations and there aren't any.)
I have refactored the checks on layable tokens, which include bonus tokens. These checks were done in different ways in no less than four places:
- at the start of the LAY_TOKEN step,
- after laying a normal base token,
- after laying a special property base token,
- after laying a bonus token.
These checks have now been refactored into a separate method, so that in all cases the same checks are done.
I also implemented the idea to allow but ignore now redundant Skip actions during loading games. Perhaps I should add some warning with the advice to resave such a file.
This all caused trouble with two 1856 test files, which I had to fix to make them reusable again. Therefore, old 1856 saved files likely will not survive the next release.
Additionally it would be nice if the "lay token" step is skipped as well when the company does not have enough money (and no other way) to lay a token.
I tried this again, but ran in unsurmountable problems, again with an 1856 saved file. There the following happened in an OR, after implementing the money check:
- CA lays a tile on Woodstock, thereby reaching its destination. But Rails cannot detect that automatically yet; it is a player action.
- In the LAY_TOKEN step CA cannot lay a token because it does not have enough money, so the program skips to SET_DIVIDEND.
- The current player selects the "ReachDestinations" action for CA, which gets $400 from escrow.
- But we are already in SET_DIVIDEND, so CA still cannot lay its token.
There were 10 other files that failed after this change, but I have not researched those: the above case was enough for me to undo the enough-money check. One thing that is required, is automatic detection of reaching destinations. In theory we can do that in the UI, perhaps in a modifier, but that is a project on its own.
Another idea is to prevent skipping token laying if the active company has just laid a tile on its destination. Tried that, it works, but still leaves another 9 test files failing. I'm stopping to work on this issue for now, but leave it open.
maybe we can revisit that if we have a workable checkfordestination routine :)