cataclysmbnteam / Cataclysm-BN

Cataclysm: Bright Nights, A fork/variant of Cataclysm:DDA by CleverRaven.
https://docs.cataclysmbn.org
Other
698 stars 272 forks source link

fix: remove `cash` property from `player` class to use `cash` from `Character` for Lua #5751

Open AluminumAlman opened 7 hours ago

AluminumAlman commented 7 hours ago

Required

Purpose of change

Lua currently only binds the cash property of Character, not player, therefore Lua cannot access the actual cash value of NPCs and avatar. Removing the duplicate cash from player will make C++ use Character's cash and for the Lua to work.

Describe alternatives you've considered

Testing

  1. Testing whether existing characters retain their cash:
    1. Made a new character with a version of the game prior to this change;
    2. Placed an ATM terrain and spawned a cash card item;
    3. Deposited some cash into the ATM;
    4. Saved and exited the game;
    5. Loaded the character in a version with the changes;
    6. Checked the ATM;
    7. The cash amount displayed by the ATM didn't change.
  2. Testing whether LUA can change the cash amount now:
    1. Loaded a character;
    2. Placed an ATM terrain;
    3. Checked the current cash amount through the ATM;
    4. Opened the Lua console;
    5. Changed the cash amount through Lua to be different, e.g. gapi.get_avatar().cash = 50;
    6. Checked the current cash amount through the ATM and found it to be the new value.

Additional context

autofix-ci[bot] commented 7 hours ago

Autofix has formatted code style violation in this PR.

I edit commits locally (e.g: git, github desktop) and want to keep autofix 1. Run `git pull`. this will merge the automated commit into your local copy of the PR branch. 2. Continue working.
I do not want the automated commit 1. [Format your code locally](https://docs.cataclysmbn.org/en/contribute/contributing/#code-style), then commit it. 2. Run `git push --force` to force push your branch. This will overwrite the automated commit on remote with your local one. 3. Continue working.

If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT.