diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.08k stars 795 forks source link

Setters and Getters: Players #7401

Closed kphoenix137 closed 2 months ago

kphoenix137 commented 2 months ago

Adds setters and getters for things related to the player, setting up the previously established structs as classes, ready for member variables to be made private once functions have been updated to use the new methods.

This is a step towards finishing: https://github.com/diasurgical/devilutionX/pull/7397

Currently I'm having difficulty getting Lua to be able to access and modify the Player struct. I believe by accessing members with setters and getters, we can avoid this problem utilizing a core aspect of object oriented programming.

I've begun to apply usage of these setters and getters within player.cpp, but decided to rather submit this with just the header files changes first so changes can be applied incrementally to avoid having a 100,000 line count diff 🗡️

StephenCWills commented 2 months ago

Currently I'm having difficulty getting Lua to be able to access and modify the Player struct. I believe by accessing members with setters and getters, we can avoid this problem utilizing a core aspect of object oriented programming.

Can you help me to believe it as well by sharing examples of code or something? What's the nature of the difficulty you ran into, and how is it going to be made easier by introducing a bunch of getters and setters?