Compare commits

...

6 Commits

Author SHA1 Message Date
Nate Smith 49ae1125d3
Merge pull request #51 from marado/corrupt
Check if the save file isn't corrupted
2024-04-04 15:29:38 -04:00
Nate Smith df01d7397c
Merge pull request #54 from noelleleigh/growth-rate-rounding
Round growth rate to single decimal
2024-04-04 15:26:07 -04:00
Nate Smith ccc08316fe
Merge pull request #53 from noelleleigh/Python-3.12
Support Python 3.12
2024-04-04 15:14:58 -04:00
Noelle Leigh 43333db825 Round growth rate to single decimal
At generation 8, the growth rate in the "look" message is displayed as:

> 2.4000000000000004x

To make it display "2.4x" instead, I used the [format specification][0]
to display growth rate with only a single decimal place.

[0]: https://docs.python.org/3/library/string.html#format-specification-mini-language
2024-03-03 17:52:03 -05:00
Noelle Leigh c6aed375da Support Python 3.12
Python 3.12 no longer supports using non-integer values as arguments for
random functions (see [Changes in the Python API for 3.12][0]). This PR
casts `CONST_RARITY_MAX` to an integer to prevent a `TypeError` from
being raised.

[0]: https://docs.python.org/3/whatsnew/3.12.html#changes-in-the-python-api
2024-03-03 17:20:32 -05:00
Marcos Marado 1fffd41783 Check if the save file isn't corrupted
If the save file is empty, then it will not be loadable, and it is best
act as if none existed.
2023-09-13 15:38:08 +00:00
3 changed files with 3 additions and 3 deletions

View File

@ -81,7 +81,7 @@ class DataManager(object):
def check_plant(self):
# check for existing save file
if os.path.isfile(self.savefile_path):
if os.path.isfile(self.savefile_path) and os.path.getsize(self.savefile_path) > 0:
return True
else:
return False

View File

@ -564,7 +564,7 @@ class CursedMenu(object):
# get plant description before printing
output_string = self.get_plant_description(this_plant)
growth_multiplier = 1 + (0.2 * (this_plant.generation-1))
output_string += "Generation: {}\nGrowth rate: {}x".format(self.plant.generation, growth_multiplier)
output_string += "Generation: {}\nGrowth rate: {:.1f}x".format(self.plant.generation, growth_multiplier)
self.draw_info_text(output_string)
self.infotoggle = 1
else:

View File

@ -164,7 +164,7 @@ class Plant:
def rarity_check(self):
# Generate plant rarity
CONST_RARITY_MAX = 256.0
rare_seed = random.randint(1,CONST_RARITY_MAX)
rare_seed = random.randint(1,int(CONST_RARITY_MAX))
common_range = round((2.0/3)*CONST_RARITY_MAX)
uncommon_range = round((2.0/3)*(CONST_RARITY_MAX-common_range))
rare_range = round((2.0/3)*(CONST_RARITY_MAX-common_range-uncommon_range))