sloukit / pydew-valley-uzh

Mod of Pydew Valley for an experimental study in Psychology
Creative Commons Zero v1.0 Universal
32 stars 61 forks source link

Bug: Using Emotes crashes the game. #186

Closed bucket91 closed 1 month ago

bucket91 commented 1 month ago

Describe the bug

Bug Description

When using an emote the game game crashes

Expected Behavior

Shouldn't Crash

Steps to Reproduce

  1. Run the game
  2. Emote

https://github.com/user-attachments/assets/3c0fbc83-ece4-4fbe-bd22-ba700117097d

Additional Context

Add any other context about the problem here.

Version

0.1.0

Which aspect(s) of the project is this bug affecting?

game-gameplay

Screenshots

No response

Relevant log output

File "c:\**\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\main.py", line 278, in <module>
    asyncio.run(game.run())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "c:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\main.py", line 249, in run
    self.level.update(dt, self.current_state == GameState.PLAY)
  File "c:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\src\screens\level.py", line 690, in update    
    self.all_sprites.update(dt)
  File "C:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\.venv\Lib\site-packages\pygame\sprite.py", line 554, in update
    sprite.update(*args, **kwargs)
  File "c:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\src\sprites\entities\player.py", line 304, in update
    self.handle_controls()
  File "c:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\src\sprites\entities\player.py", line 236, in handle_controls
    self.emote_manager.show_emote(
  File "c:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\src\gui\interface\emotes.py", line 431, in show_emote
    super().show_emote(obj, emote)
  File "c:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\src\gui\interface\emotes.py", line 151, in show_emote
    self[id(obj)] = EmoteBox((0, 0), self.emotes[emote], *self.groups)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\src\gui\interface\emotes.py", line 54, in __init__
    self._ani_next_frame()
  File "c:\**\New folder (2)\pydew-valley-uzh-main(new)\pydew-valley-uzh-main\src\gui\interface\emotes.py", line 80, in _ani_next_frame
    if self._ani_cframe >= self._ani_total_frames:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'int' and 'AllSprites'

Code of Conduct

DangerousVanilla commented 1 month ago

Looks like this bug is coming from a missing duration argument in line 151 of src\gui\interface\emotes.py. As far as I can tell this would control the default duration of emotes, while there's an explicit check for 'sad_ani' which would have a duration of 30.

@sloukit, Do you know why the sad emote is set to be different here? And what is the desired default animation duration (in seconds is fine, I'll convert)?

HubertReX commented 1 month ago

btw, I might be also a good idea to change the magic number 30 to a global constant

luvdamuzik commented 1 month ago

hey @DangerousVanilla i was the one that made the sad emote have duration of 30 because of testing for leaving the bathhouse. This emote should be the disgusted emote which didnt exist at the time/still doesnt exist.

DangerousVanilla commented 1 month ago

@luvdamuzik, thank you for the explanation! I was able to fix this issue anyway, just forgot to close it after the bug fix. There was just something missing a required parameter.