Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpcount command #210

Merged
merged 3 commits into from
Nov 4, 2023
Merged

gpcount command #210

merged 3 commits into from
Nov 4, 2023

Conversation

Wexos
Copy link
Contributor

@Wexos Wexos commented Oct 20, 2023

Description

Adds a gpcount command, which allows a user to change the number of gps after a war has been started. Have tested with offline testing rooms, but not on live rooms from Wiimmfi.

Checklist

  • If code changes were made, they have been tested
  • This PR fixes an issue
  • This PR is not a code change (ie. documentation, typehinting, comments, etc.)

commands.py Outdated Show resolved Hide resolved
commands.py Outdated Show resolved Hide resolved
@BadWolf1023
Copy link
Owner

BadWolf1023 commented Nov 3, 2023

Sorry the review took so long to do. I only saw the PR just now.

Also, please test with the gpsize or size command. Please test how this affects race edits (eg race order, score edits, changing place, etc) for races that "fall off" the end of the table when gp size is changed to 2 gps with 12 races played, and those edits occurred on Race 9-12.

TIA and thanks for the contribution!

@Wexos
Copy link
Contributor Author

Wexos commented Nov 3, 2023

That should fix the issues. Let me know if there are more.

I noticed the /gpsize slash command didn't work, so I fixed it as well.

If running /gpsize 1 followed by gpcount 1, it will display 4 columns (=1gp = 4 races). Imo this is how it should work, because the /gpsize command only change the display size in table, not the actual size of an gp. Though of course one could argue that it should only display only 1 column. Change display size after gp count and inverse worked fine for me.

I tried /rr, /changeraceorder, /editrace and qe for races past the gp count, and it worked as expected. So one can run commands on races not displayed in the table, and if gp count is changed to include those races, the edits are still there.

Another comment, I got this stack trace if trying to run after install:

  File "X:\Development\MKW-Table-Bot\tablebotvenv\lib\site-packages\discord\ui\view.py", line 416, in _scheduled_task
    return await self.on_error(e, item, interaction)
  File "X:\Development\MKW-Table-Bot\Components.py", line 167, in on_error
    await InteractionUtils.on_component_error(error, interaction, self.prefix, self.bot)
  File "X:\Development\MKW-Table-Bot\InteractionUtils.py", line 199, in on_component_error
    await handle_component_exception(error, message, prefix, channel_bot)
  File "X:\Development\MKW-Table-Bot\InteractionUtils.py", line 207, in handle_component_exception
    await common.client.handle_exception(error,message,server_prefix, channel_bot)
  File "X:\Development\MKW-Table-Bot\BadWolfBot.py", line 706, in handle_exception
    raise e
  File "X:\Development\MKW-Table-Bot\BadWolfBot.py", line 644, in handle_exception
    raise error
  File "X:\Development\MKW-Table-Bot\tablebotvenv\lib\site-packages\discord\ui\view.py", line 414, in _scheduled_task
    await item.callback(interaction)
  File "X:\Development\MKW-Table-Bot\Components.py", line 121, in callback
    await commands.TablingCommands.after_start_war_command(message, self.view.bot, [self.cat], self.view.prefix, self.view.is_lounge)
  File "X:\Development\MKW-Table-Bot\commands.py", line 2273, in after_start_war_command
    await TablingCommands.war_picture_command(message, this_bot, ['wp'], server_prefix, is_lounge_server)
  File "X:\Development\MKW-Table-Bot\commands.py", line 2621, in war_picture_command
    footer_combine_success = ImageCombine.add_miis_to_table(this_bot, table_sorted_data, table_image_path=table_image_path, out_image_path=table_image_path)
  File "X:\Development\MKW-Table-Bot\ImageCombine.py", line 140, in add_miis_to_table
    extension_reflect, mii_footer = get_footer_with_miis(channel_bot, table_data)
  File "X:\Development\MKW-Table-Bot\ImageCombine.py", line 160, in get_footer_with_miis
    team_footers.append((team_tag, generate_footer_section_for_team(available_miis, team_tag, add_left_border=should_add_left_border)))
  File "X:\Development\MKW-Table-Bot\ImageCombine.py", line 230, in generate_footer_section_for_team
    if mii_font.getsize(mii_name)[0] > (actual_mii_picture_width - MII_NAME_WIDTH_PADDING) and mii_font.getsize(mii_name)[1] <= max_mii_name_height:
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'```

The fix is found here: https://github.com/ultralytics/yolov5/issues/11838#issuecomment-1630008890

@BadWolf1023
Copy link
Owner

I agree that's how it should work. I think doing the other way would actually introduce a lot of bugs.

Noted on the Pillow. I believe I ran into the issue myself and forgot to update the requirements.txt.

PR looks good. Thanks for testing. Will merge in now and go live in a few minutes.

@BadWolf1023 BadWolf1023 self-requested a review November 4, 2023 02:38
@BadWolf1023 BadWolf1023 merged commit e3f94f8 into BadWolf1023:main Nov 4, 2023
2 checks passed
@BadWolf1023
Copy link
Owner

If you want to type up an announcement of how to use the command, I will post in Table Bot server.

@Wexos
Copy link
Contributor Author

Wexos commented Nov 4, 2023

Thanks for merging. Maybe something like:

The bot now allows changing the number of gps after a table has been started with /sw. This is done with the command gpcount. As an example, if a table was started with 3 gps and one wants to change it to 4 gps, one would run '@MKW Table Bot gpcount 4' or '/gpcount 4'.

Feel free to edit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants