Rails-18xx / Rails

Rails 18xx Java Application Main Repository
GNU General Public License v2.0
36 stars 22 forks source link

18EU tile lay issue in 2.4.6 #432

Closed jdgalt closed 2 years ago

jdgalt commented 3 years ago

If I try to lay a tile in a space restricted for the benefit of one minor company with another company (which per rule 4.6, requires the consent of that company's owner) the tile lay is not allowed at all -- even if the two companies have the same owner. There is no prompt for permission and no workaround. For example if Minor1's first tile is straight to Minor2's home hex because they are cooperating, Minor1 can't use its second lay to place Minor2's home tile. I have to wait until Minor2's turn and have it lay the tile itself.

erik-vos commented 3 years ago

Confirmed. Even in map correction mode this is currently not allowed.

A relatively easy fix could be to ask the current player if the other player has given consent, which then has to be obtained off-game. Would that do for you?

Handing over the turn to that other player to ask for consent would be a more complex affair. I remember that, when I implemented 18EU in the days of yore, I deliberately avoided such complexities. I'm not aware of any other examples in the current code base of such intermittent turn handovers in an OR; if there are, I would like to hear about those.

erik-vos commented 3 years ago

I have enabled laying such tiles in Correction Mode. This is a generic feature.

The validation methods in TileHexUpgrade can now take an additional EnumSet<Invalids> argument that specifies the checks to be bypassed. This currently only works for the HEX_RESERVED and HEX_BLOCKED enum values, but can easily be extended in TileHexUpgrade.validate().

This new feature is now used by ORUIManager.addCorrectionTileLays(), but currently only specifies the HEX_RESERVED check to be skipped.

So 18EU minor 1 can now lay in Brussels using Correction mode. Will this do? If so, I will add this commit to the currently open PR (or a future one).

erik-vos commented 3 years ago

This new feature is now also used by ORUIManager.addConnectedTileLays(), and allows tile lays on reserved hexes where the company presidents are the same player. This happened to be the case in my example saved file, where 18EU minor 1 can now lay a tile in Brussels without need to set Correction mode.

jdgalt commented 3 years ago

Thank you, that gets the job done.

Can this be used in other games with tile lay restrictions? (1826, or company OBB in 1835)

erik-vos commented 3 years ago

It's generic, so it should work everywhere - provided that the same mechanism is used to reserve hexes for specific companies, which seems likely to me. Why not try it, and keep me posted?

erik-vos commented 3 years ago

While at it, I decided to add the "have you got permission" query as well. The permission check has now moved to just after the click on the reserved hex.

This should be enough for normal play. A pull request follows.

erik-vos commented 2 years ago

By the way, the OBB hexes in 1835 are not reserved and should not be. At the end of English rule VI: "Hexes containing private railways may be built on." In the German version rule 5.5.1.13.

jdgalt commented 2 years ago

By the way, the OBB hexes in 1835 are not reserved and should not be. At the end of English rule VI: "Hexes containing private railways may be built on." In the German version rule 5.5.1.13.

I know they are not reserved, but the existing app does not allow them both to be laid in one turn. (The way the restriction is supposed to work is that you may lay them both in one turn, but if you do then only one of them is free of terrain cost and only one is an extra build. While if laid in separate turns then each one gets both of these advantages.) So I would like the override to work to allow the build.

erik-vos commented 2 years ago

I just tested it, both with 2.4.6 and with my newest code, and for me it works as it should: if there is a connection (route), then both tiles can be laid in the same turn, in any sequence, but only one of these can use the OBB free lay. So I'm not sure what your problem is.

The only deficiency I noticed is, that the OBB does not close this way.

When I worked on 1835, more than 10 years ago, I did shy away from attacking the OBB closure problem, and instead provided a manual "Close Private" command in the "Special" menu. Others have worked on it since, but apparently not managed to solve this problem entirely.

I will look into this issue. In the meantime, you still can use the manual "Close Private" command.

jdgalt commented 2 years ago

My bad, then.

erik-vos commented 2 years ago

We have drifted away from this topic's title, because 1835 is rather a different game than 18EU.

That said, the last remaining issue was that the OBB does not close if at least one of these hexes is laid upon in the normal way, not using the OBB. In testing that, I found another issue: if the first tile laid is the rightmost one, using the OBB, then using the OBB is still offered for a second lay on ther leftmost hex, although using that offer is not accepted.

I'll look into this once I'm finished with the 18EU variants that I'm currently working on.

erik-vos commented 2 years ago

OBB problems fixed. Commit added to the open PR #452. Closing this issue.