<commit_before># -*- coding: UTF-8 -*-

import os

import pygame
from pygame.locals import *

from constants import BLACK, GAME_WIDTH, GAME_HEIGHT
from text import MenuBox


class HelpMenu(object):
    def __init__(self, screen, game):
        self.screen = screen
        self.game = game
        self.select_sound = pygame.mixer.Sound(os.path.join('data', 'audio', 'select.wav'))
        self.state = 'main'
        items = [
            'WEAPONS',
            'BODY ARMOR',
            'HELMETS',
            'TACTICS',
            'ITEMS',
        ]
        self.menu = MenuBox(items, current_choice=0, border=True, title='Help')
        self.menu.focus()

    def draw(self):
        self.screen.fill(BLACK)
        self.screen.blit(self.menu.surface, (0, 0))

    def update(self, dt):
        self.menu.update(dt)

    def handle_input(self, pressed):
        self.menu.handle_input(pressed)
        if pressed[K_x]:
            self.select_sound.play()
            choice = self.menu.get_choice()<commit_msg>added list of weapons to help menu<commit_after># -*- coding: UTF-8 -*-

import os

import pygame
from pygame.locals import *

from constants import BLACK, GAME_WIDTH, GAME_HEIGHT, ITEMS
from text import MenuBox, MenuGrid


class HelpMenu(object):
    def __init__(self, screen, game):
        self.screen = screen
        self.game = game
        self.select_sound = pygame.mixer.Sound(os.path.join('data', 'audio', 'select.wav'))
        self.state = 'main'
        items = [
            'WEAPONS',
            'BODY ARMOR',
            'HELMETS',
            'TACTICS',
            'ITEMS',
        ]
        self.menu = MenuBox(items, current_choice=0, border=True, title='Help')
        self.menu.focus()
        self.weapons_menu = None

    def draw(self):
        self.screen.fill(BLACK)
        self.screen.blit(self.menu.surface, (0, 0))
        if self.weapons_menu:
            self.screen.blit(self.weapons_menu.surface, (48, 0))

    def update(self, dt):
        if self.state == 'main':
            self.menu.update(dt)
        elif self.state == 'weapons':
            self.weapons_menu.update(dt)

    def handle_input(self, pressed):
        if pressed[K_x]:
            self.select_sound.play()
        if self.state == 'main':
            self.menu.handle_input(pressed)
            if pressed[K_x]:
                choice = self.menu.get_choice()
                if choice == 'WEAPONS':
                    self.create_weapons_menu()
        elif self.state == 'weapons':
            self.weapons_menu.handle_input(pressed)
            if pressed[K_x]:
                choice = self.weapons_menu.get_choice().lower()
            elif pressed[K_z]:
                self.weapons_menu = None
                self.menu.focus()
                self.state = 'main'

    def create_weapons_menu(self):
        self.state = 'weapons'
        weapons = [
            {
                'name': name.title(),
                'attack_points': info['attack_points'],
            }
            for name, info in ITEMS.items()
            if info['type'] == 'weapon'
        ]
        sorted_weapons = sorted(weapons, key=lambda k: k['attack_points'])
        gridded_weapons = [
            [w['name'] for w in sorted_weapons[0:10]],
            [w['name'] for w in sorted_weapons[10:]],
        ]
        self.weapons_menu = MenuGrid(gridded_weapons, border=True)
        self.menu.unfocus()
        self.weapons_menu.focus()
{'fraction_non_alphanumeric': 0.12434782608695652, 'fraction_numerical': 0.00463768115942029, 'mean_word_length': 1.8878661087866109, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '573210', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1061, 'n_words': 219}