е меню.""" gs.custommodeactive = False gs.WIDTH, gs.HEIGHT = configmodule.DEFAULTWIDTH,…
- User
е меню.""" gs.custom_mode_active = False gs.WIDTH, gs.HEIGHT = config_module.DEFAULT_WIDTH, config_module.DEFAULT_HEIGHT gs.update_display_mode()
buttons = [] available_lengths = sorted([length for length, words in gs.WORD_SETS.items() if words])
btn_y_start, btn_spacing = 180, 70
running = True while running: draw_gradient_background(gs.screen, gs.WIDTH, gs.HEIGHT, config_module.COLORS['MENU_BG_GRAD1'], config_module.COLORS['MENU_BG_GRAD2']) draw_text_centered(gs.screen, "Выберите сложность", gs.get_font('main'), config_module.COLORS['BLACK'], gs.WIDTH // 2, 100)
buttons.clear() displayed_btns = 0 for length in available_lengths: if not (3 <= length <= 10) and (len(available_lengths) > 4 and not (4 <= length <= 7)): continue btn_text = f"{length} букв ({len(gs.WORD_SETS.get(length, []))} слов)" rect = pygame.Rect(gs.WIDTH // 2 - 150, btn_y_start + displayed_btns * btn_spacing, 300, 50) pygame.draw.rect(gs.screen, config_module.COLORS['GRAY'], rect, border_radius=12) draw_text_centered(gs.screen, btn_text, gs.get_font('small'), config_module.COLORS['BLACK'], rect.centerx, rect.centery) buttons.append((rect, length)) displayed_btns += 1 if displayed_btns >= 5 and len(available_lengths) > 6: break custom_btn_rect = pygame.Rect(gs.WIDTH // 2 - 100, btn_y_start + displayed_btns * btn_spacing, 200, 50) pygame.draw.rect(gs.screen, config_module.COLORS['GRAY'], custom_btn_rect, border_radius=12) draw_text_centered(gs.screen, "Своя сложность", gs.get_font('custom_difficulty_button'), config_module.COLORS['BLACK'], custom_btn_rect.centerx, custom_btn_rect.centery) buttons.append((custom_btn_rect, 'custom')) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: for rect, choice in buttons: if rect.collidepoint(event.pos): if choice == 'custom': result = prompt_custom_difficulty_settings(gs, config_module) if result is not None: return result elif isinstance(choice, int) and gs.WORD_SETS.get(choice): return choiceиспользуя if else отображайте для 3,4 "буквы", но 5,6,7 букв
Assistant
Вот модифицированный код с использованием условия для правильного склонения слова "буква":
btn_text = f"{length} {'буквы' if length in [3, 4] else 'букв'} ({len(gs.WORD_SETS.get(length, []))} слов)"Это условие использует тернарный оператор:
- Если длина слова 3 или 4, будет использовано "буквы"
- Для 5, 6, 7 и других длин будет использовано "букв"
Полный фрагмент будет выглядеть так:
for length in available_lengths: if not (3 <= length <= 10) and (len(available_lengths) > 4 and not (4 <= length <= 7)): continue btn_text = f"{length} {'буквы' if length in [3, 4] else 'букв'} ({len(gs.WORD_SETS.get(length, []))} слов)" rect = pygame.Rect(gs.WIDTH // 2 - 150, btn_y_start + displayed_btns * btn_spacing, 300, 50) pygame.draw.rect(gs.screen, config_module.COLORS['GRAY'], rect, border_radius=12) draw_text_centered(gs.screen, btn_text, gs.get_font('small'), config_module.COLORS['BLACK'], rect.centerx, rect.centery) buttons.append((rect, length)) displayed_btns += 1 if displayed_btns >= 5 and len(available_lengths) > 6: breakТеперь текст будет корректно склоняться: "3 буквы", "4 буквы", "5 букв" и т.д.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.