Fixes a bug which occurs if your first betting win for the day is escargo.
Permissions and credits
Credits and distribution permission
Other user's assetsAll the assets in this file belong to the author, or are from free-to-use modder's resources
Upload permissionYou can upload this file to other sites but you must credit me as the creator of the file
Modification permissionYou are allowed to modify my files and release bug fixes or improve on the features without permission from or credit to me
Conversion permissionYou can convert this file to work with other games as long as you credit me as the creator of the file
Asset use permissionYou are allowed to use the assets in this file without permission or crediting me
Asset use permission in mods/files that are being soldYou are not allowed to use assets from this file in any mods/files that are being sold, for money, on Steam Workshop or other platforms
Asset use permission in mods/files that earn donation pointsYou are allowed to earn Donation Points for your mods if they use my assets
Author notes
This author has not provided any additional notes regarding file permissions
File credits
Reuses some code from baes game that is skipped over.
Donation Points system
Please log in to find out whether this mod is receiving Donation Points
This mod patches OnRaceWon using a harmony prefix to ensure all winner keys exist in the dictionary, which is skipped the first time you win with escargo. This prevents the bug occuring when you collect your prize.
Full details:
In the function OnRaceWon it iterates through the guesses and checks in order:
Was the guess correct
Is this the first winning bet on Escargo of the day for that player
Does the entry in the collection rewardsToCollect exist for this player (and if not creates it set to 0)
And then increments the rewards to collect and adds to the winning farmersImportantly, if the check for the first winning bet for Escargo succeeds, it will move onto the next guess skipping the creation of the entry in the rewardsToCollect collection.
Then, when you go to collect your race prize in the function CollectRacePrizes, it tries to get the value of the non-existent entry in the collection rewardsToCollect, which causes a crash without mods, or an error message to appear in the console on SMAPI and no rewards to be given.
In order for this bug to occur, the win with Escargo must be the first win of the day, otherwise the entry will already exist due to a prior win. This mod fixes this by patching the OnRaceWon method to ensure the entry in rewardsToCollect exists for all winners.