Ejemplo n.º 1
0
def create_pokemon(pokemon_numbers, moves):
    pokemon = []
    numbered_pokemon = get_pokemon_info.get_dict("numbered_pokemon.txt")
    i = 0
    all_stats = get_pokemon_info.get_dict("pokemon_stats.txt")

    for num in pokemon_numbers:
        name = numbered_pokemon[get_pokemon_info.pokemon_number(num)]
        pokemon += [battle.Pokemon(name, moves[i], all_stats[name])]
        i += 1

    return pokemon
Ejemplo n.º 2
0
def create_pokemon(pokemon_numbers, moves):
    pokemon = []
    numbered_pokemon = get_pokemon_info.get_dict("numbered_pokemon.txt")
    # TODO:
    # - Get the following placeholder stats from a dict instead
    i = 0
    all_stats = get_pokemon_info.get_dict("pokemon_stats.txt")
    
    for num in pokemon_numbers:
        name = numbered_pokemon[get_pokemon_info.pokemon_number(num)]
        pokemon += [battle.Pokemon(name, moves[i], all_stats[name])]
        i += 1

    return pokemon
Ejemplo n.º 3
0
def get_pokemon_names(pokemon_numbers):
    numbered_pokemon = get_pokemon_info.get_dict("numbered_pokemon.txt")
    names = []
    for num in pokemon_numbers:
        names += [numbered_pokemon[num]]

    return names
Ejemplo n.º 4
0
def calculate_damage(attacker, defender, move):
    # This calculates the damage dealt to the defender
    # EXCEPTIONS:
    # - "Other" attacks in the other_attacks dict
    # - Direct damaging moves (e.g. Dragon Rage, Bide):
    #   http://bulbapedia.bulbagarden.net/wiki/
    #   Category:Moves_that_deal_direct_damage
    #   These moves will be in their own dict and will
    #   either have a constant value (e.g. Dragon Rage - 40)
    #   or will have a custom-calculated value (e.g. Bide, Counter)
    all_moves = get_pokemon_info.get_dict("all_moves.txt")
    move_data = all_moves[move]
    pokemon_types = get_pokemon_info.get_dict("pokemon_types.txt")
    level = 100
    modifier = 1

    if move_data[1] == "physical":
        attack = attacker.stats["ATK"]
        defence = defender.stats["DEF"]
    elif move_data[1] == "special":
        attack = attacker.stats["SP.ATK"]
        defence = defender.stats["SP.DEF"]
    elif move_data[1] == "other":
        attack = 1
        defence = 1
    else:
        print("\nError with move type of: " + move_data[1])
        attack = 1
        defence = 1

    if move_data[3] == "--":
        power = 0
    else:
        power = int(move_data[3])
    damage = power * (attack / defence) / 50
    damage *= (2 * level / 5 + 2)

    # STAB multiplier
    if move_data[0] in pokemon_types[attacker.name]:
        modifier *= 1.5

    damage *= modifier
    damage = round(damage)

    return damage
Ejemplo n.º 5
0
def load_resources(screen=None, my_pk=None, opp_pk=None):
    """my_pk and opp_pk must be the national dex numbers
    of the pokemon"""

    # State machine functions
    res["show moves logic"] = show_moves_logic
    res["show moves display"] = show_moves_display
    res["first attack logic"] = attack_logic
    res["first attack display"] = attack_display
    res["second attack logic"] = attack_logic
    res["second attack display"] = attack_display
    res["game over logic"] = game_over_logic
    res["game over display"] = game_over_display

    res["font"] = pygame.font.Font("Resources\\Pokemon Fonts\\pkmnrs.ttf", 30)
    res["black"] = (0, 0, 0)
    res["red"] = (255, 0, 0)
    res["green"] = (0, 255, 0)
    res["yellow"] = (255, 255, 0)
    res["blue"] = (0, 0, 255)
    res["text colour"] = res["black"]
    res["anti alias"] = True
    res["size"] = 720, 480

    # Don't think the following if/else are necessary, may remove later
    if screen:
        res["screen"] = screen
    else:
        res["screen"] = pygame.display.set_mode(res["size"])

    number_of_pokemon = 2
    pokemon_numbers = get_random_pokemon(number_of_pokemon)

    if my_pk:
        my_pk = get_pokemon_info.pokemon_number(my_pk)
        pokemon_numbers[0] = my_pk
    if opp_pk:
        opp_pk = get_pokemon_info.pokemon_number(opp_pk)
        pokemon_numbers[1] = opp_pk

    pokemon_names = get_pokemon_names(pokemon_numbers)
    pokemon_1 = pokemon_numbers[0]
    pokemon_2 = pokemon_numbers[1]

    res["my moves"] = get_moves(pokemon_names[0])
    res["opp moves"] = get_moves(pokemon_names[1])
    res["all moves"] = get_pokemon_info.get_dict("all_moves.txt")
    res["physical moves"] = get_pokemon_info.get_dict("physical_moves.txt")
    res["special moves"] = get_pokemon_info.get_dict("special_moves.txt")
    res["other moves"] = get_pokemon_info.get_dict("other_moves.txt")
    res["pokemon"] = create_pokemon(pokemon_numbers,
                                    [res["my moves"], res["opp moves"]])
    p0 = res["pokemon"][0]
    p1 = res["pokemon"][1]

    # Original size: 96 x 96, scaled size = 288, 288
    f2 = pygame.image.load("Resources\\bw-001n\\" + pokemon_2 + ".png")
    pokemon_position = get_opponent_position(pokemon_2)
    res["positions"] = [(60, 150), pokemon_position]
    f2 = pygame.transform.scale(f2, (192, 192))
    f1 = pygame.image.load("Resources\\bwback-001n\\" + pokemon_1 + ".png")
    f1 = pygame.transform.scale(f1, (288, 288))
    res["opp pokemon sprite"] = f2
    res["my pokemon sprite"] = f1
    res["bg"] = pygame.image.load(
        "Resources\\battle_screen_with_moves_blank.png")
    res["type icons"] = load_pokemon_type_icons()
    res["moves bar"] = pygame.image.load("Resources\\moves_bar.png")
    res["move selection"] = pygame.image.load("Resources\\move_selection.png")
    res["text bar"] = pygame.image.load("Resources\\text_bar.png")
    res["my hp bar"] = pygame.image.load("Resources\\hp_bar_01.png")
    res["opp hp bar"] = pygame.image.load("Resources\\hp_bar_02.png")
    res["my green hp"] = pygame.image.load("Resources\\hp_bars\\green.png")
    res["opp green hp"] = pygame.image.load("Resources\\hp_bars\\green.png")
    res["my yellow hp"] = pygame.image.load("Resources\\hp_bars\\yellow.png")
    res["opp yellow hp"] = pygame.image.load("Resources\\hp_bars\\yellow.png")
    res["my red hp"] = pygame.image.load("Resources\\hp_bars\\red.png")
    res["opp red hp"] = pygame.image.load("Resources\\hp_bars\\red.png")
    res["my empty hp"] = pygame.image.load("Resources\\hp_bars\\empty.png")
    res["opp empty hp"] = pygame.image.load("Resources\\hp_bars\\empty.png")
    res["hp bars pos"] = [(380, 225), (30, 43)]
    res["hp colour pos"] = [(res["hp bars pos"][1][0] + 95,
                             res["hp bars pos"][1][0] + 61)]
    res["hp colour pos"] += [(res["hp bars pos"][1][0] + 459,
                              res["hp bars pos"][1][0] + 242)]
    res["hp max colour width"] = 144
    res["hp widths"] = [144, 144]
    res["hp percent"] = [p0.stats["HP"] / p0.original_stats["HP"]]
    res["hp percent"] += [p1.stats["HP"] / p1.original_stats["HP"]]
    res["my hp bar status"] = {
        "colour": "green",
        "width": 144 * res["hp percent"][0]
    }
    res["opp hp bar status"] = {
        "colour": "green",
        "width": 144 * res["hp percent"][1]
    }
    res["hp bars"] = [{
        "green": res["my green hp"],
        "yellow": res["my yellow hp"],
        "red": res["my red hp"],
        "empty": res["my empty hp"]
    }]
    res["hp bars"] += [{
        "green": res["opp green hp"],
        "yellow": res["opp yellow hp"],
        "red": res["opp red hp"],
        "empty": res["opp empty hp"]
    }]

    res["prev hp"] = [p1.original_stats["HP"], p0.original_stats["HP"]]

    res["move surfaces"] = []
    for move in res["my moves"]:
        res["move surfaces"] += [
            get_move_surface(move, res["anti alias"], res["text colour"])
        ]

    res["quadrants"] = initialise_display()
    res["move selection pos"] = []
    for quadrant in res["quadrants"]:
        res["move selection pos"] += [(quadrant[0] + 3, quadrant[1] + 3)]

    #res["battle music"] =
    load_sound("FRLG_Battle_01.mp3")
Ejemplo n.º 6
0
def get_pokemon_names():
    return get_pokemon_info.get_dict("numbered_pokemon.txt")
Ejemplo n.º 7
0
pokemon_position = (420, 50)
if pokemon_1 == "632": pokemon_position = (380, 20)
# Test pokemon
# Original size: 96 x 96, scaled size = 288, 288
f2 = pygame.image.load("Resources\\bw-001n\\" + pokemon_2 + ".png")
#f2 = pygame.transform.scale(f2, (288, 288))
f2 = pygame.transform.scale(f2, (192, 192))
f1 = pygame.image.load("Resources\\bwback-001n\\" + pokemon_1 + ".png")
f1 = pygame.transform.scale(f1, (288, 288))
bg = pygame.image.load("Resources\\battle_screen_with_moves_blank.png")
moves_bar = pygame.image.load("Resources\\moves_bar.png")

# Get moves
#move_1 = input("Enter move 1: ")
moves = ["Scratch", "Water Gun", "Bite", "Ice Fang"]
physical_moves = get_pokemon_info.get_dict("physical_moves.txt")
special_moves = get_pokemon_info.get_dict("special_moves.txt")
all_moves = {**physical_moves, **special_moves}
movesets = get_pokemon_info.get_dict("pokemon_movesets.txt")
poke_1 = "Totodile"
poke_2 = "Charizard"
moves = get_pokemon_info.get_random_moves(poke_1)

# Note that positions are in (width, height) or (x, y) rather than (row, col)
move_1_surface = myfont.render(moves[0], anti_alias, text_colour)
move_2_surface = myfont.render(moves[1], anti_alias, text_colour)
move_3_surface = myfont.render(moves[2], anti_alias, text_colour)
move_4_surface = myfont.render(moves[3], anti_alias, text_colour)
move_power = myfont.render('Move Power', anti_alias, text_colour)
#screen.blit(textsurface,(0,0))
Ejemplo n.º 8
0
    anti_alias = True

    size = width, height = 720, 480

    screen = pygame.display.set_mode(size)

    number_of_pokemon = 2
    pokemon_numbers = get_random_pokemon(number_of_pokemon)
    #pokemon_numbers[1] = "007"
    pokemon_names = get_pokemon_names(pokemon_numbers)
    pokemon_1 = pokemon_numbers[0]
    pokemon_2 = pokemon_numbers[1]
    #pokemon_position = (420, 50)
    moves = get_moves(pokemon_names[0])
    opponent_moves = get_moves(pokemon_names[1])
    all_moves = get_pokemon_info.get_dict("all_moves.txt")
    pokemon = create_pokemon(pokemon_numbers, [moves, opponent_moves])
    p0 = pokemon[0]
    p1 = pokemon[1]
    #if pokemon_1 == "632": pokemon_position = (380, 20)
    # Test pokemon
    # Original size: 96 x 96, scaled size = 288, 288
    f2 = pygame.image.load("Resources\\bw-001n\\" + pokemon_2 + ".png")
    pokemon_position = get_opponent_position(pokemon_2)
    #f2 = pygame.transform.scale(f2, (288, 288))
    f2 = pygame.transform.scale(f2, (192, 192))
    f1 = pygame.image.load("Resources\\bwback-001n\\" + pokemon_1 + ".png")
    f1 = pygame.transform.scale(f1, (288, 288))
    bg = pygame.image.load("Resources\\battle_screen_with_moves_blank.png")
    type_icons = load_pokemon_type_icons()
    moves_bar = pygame.image.load("Resources\\moves_bar.png")