Skip to content

Commit

Permalink
Prevent creation of 0 gold Letters of Credit
Browse files Browse the repository at this point in the history
Forums: https://forums.dfworkshop.net/viewtopic.php?t=6299

This can be verified to be correct by first splitting the amount <= loc.value case in two

```
                    } else if (amount < loc.value) {
                        loc.value -= amount;
                        amount = 0;
                    } else if (amount == loc.value) {
                        loc.value -= amount;
                        amount = 0;
                        items.RemoveItem(loc);
                    } else {
                        amount -= loc.value;
                        items.RemoveItem(loc);
                    }
```
then with some refactos to verify than the "equal" case can be merged into the default one
  • Loading branch information
petchema committed May 29, 2023
1 parent 8b1eb83 commit 21ea64e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Assets/Scripts/Game/Entities/PlayerEntity.cs
Expand Up @@ -1331,7 +1331,7 @@ public int DeductGoldAmount(int amount)
DaggerfallUnityItem loc = items.GetItem(ItemGroups.MiscItems, (int)MiscItems.Letter_of_credit);
if (loc == null) {
break;
} else if (amount <= loc.value) {
} else if (amount < loc.value) {
loc.value -= amount;
amount = 0;
} else {
Expand Down

0 comments on commit 21ea64e

Please sign in to comment.