Skip to content

Conversation

@frigoref
Copy link
Member

No description provided.

@Getter private transient TechTracker techTracker = new TechTracker(this);
private final IGameLoader loader = new TripleA();
private History gameHistory = new History(this);
private StateGameData stateGameData = new StateGameData(this);
Copy link
Member

@DanVanAtta DanVanAtta Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StateGameData -> GameDataState

or

Suggested change
private StateGameData stateGameData = new StateGameData(this);
private transient StateGameData state = new StateGameData(this);

@DanVanAtta
Copy link
Member

per discussion:

  • game data becomes a facade class eventually
  • game data has largely 3 data points: map initial state, game changes, and the latest game state (the latter, game state is derived and not stored)

@DanVanAtta DanVanAtta assigned frigoref and unassigned DanVanAtta Sep 28, 2025
@frigoref frigoref changed the title Add StateGameData (extract first History from GameData) Add GameDataState (extract first TechTracker from GameData) Sep 28, 2025
2. Replace History with TechTracker in GameDataState extracted from GameData
3. Add Getter/Setter for GameHistory in GameData
4. postDeSerialize to instantiate GameDataState
@frigoref frigoref requested a review from DanVanAtta September 28, 2025 23:19
@frigoref frigoref assigned DanVanAtta and unassigned frigoref Sep 28, 2025
// Don't ensure the lock is held when getting the history.
// History operations often acquire the write lock, and we can't acquire the write lock if we
// have the read lock.
@Setter @Getter private History gameHistory = new History(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice the new @Setter + @Getter. I think it was actually better with direct variable access before.

If we go with @Getter + @Setter, we should arguably use the least scope possible (eg: private/protected/package default)

Overall, I'd say direct variable access is to be preferred, namely because of inheritance.
(1)With direct variable access, child classes can't make unexpected changes to unrelated methods by overriding setters
(2) the code is more straight forward. When seeing a method access, a person needs to trace that down to the annotation, then confirm any child classes and any overrides. With the direct variable usage, there is no indirection.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is in general correct, but it is pre-step for another PR to get rid of the methods after renaming them. I did not want to include it in this PR as it would have effected >5 other classes.

// History operations often acquire the write lock, and we can't acquire the write lock if we
// have the read lock.
@Setter @Getter private History gameHistory = new History(this);
private GameDataState state = new GameDataState(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private GameDataState state = new GameDataState(this);
private transient GameDataState state = new GameDataState(this);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this value is transient, then we can remove also remove the null check in line 130 and always create a new instance when the game data object loads.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it intentional to leave off transient?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was intentional. I remove the handling in readObject as it is already in postDeSerialized.
See new commit aae6c5c.

@Getter @Setter private transient TechTracker techTracker;

public GameDataState(GameData gameData) {
techTracker = new TechTracker(gameData);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are next iterations going to remove gameData as a parameter here? Specifically we would just pull out whatever data we need and pass that directly to TechTracker.

Removing references to GameData is a good win. Looks like we are on a path to that here 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a todo comment to the class.
See new commit aae6c5c.

@DanVanAtta DanVanAtta assigned frigoref and unassigned DanVanAtta Sep 29, 2025
2. Remove readObject handling of state (already in postDeSerialize)
@frigoref frigoref requested a review from DanVanAtta September 29, 2025 07:34
@frigoref frigoref assigned DanVanAtta and unassigned frigoref Sep 29, 2025
@DanVanAtta DanVanAtta assigned frigoref and unassigned DanVanAtta Nov 18, 2025
@DanVanAtta
Copy link
Member

looks good; @frigoref, back to you to do a one last look over before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants