def add_card_to_player_group_random() -> None:
    """Add a card to a group.
    """
    for key in player_card_group:
        if player_card_group[key] == 'Hello world':
            print('action begin')
            possible_choices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

            chosen = random.choice(possible_choices)
            location = ((key - 1) * 2, 7)
            if chosen == 1:
                player_card_group[key] = miniguner(location)
            elif chosen == 2:
                player_card_group[key] = charger(location)
            elif chosen == 3:
                player_card_group[key] = sniper(location)
            elif chosen == 4:
                player_card_group[key] = rocketer(location)
            elif chosen == 5:
                player_card_group[key] = doctor(location)
            elif chosen == 6:
                player_card_group[key] = nijia(location)
            elif chosen == 7:
                player_card_group[key] = fireball(location)
            elif chosen == 8:
                player_card_group[key] = lightening(location)
            elif chosen == 9:
                player_card_group[key] = mine(location)
            elif chosen == 10:
                player_card_group[key] = autogun(location)
            print(player_card_group[key], player_card_group[key].location)
예제 #2
0
def add_card_to_player_group_random() -> None:
    """Add a card to PLAYER_CARD_GROUP.
    """
    for key in PLAYER_CARD_GROUP:
        if PLAYER_CARD_GROUP[key] == 'Hello world':
            possible_choices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

            chosen = random.choice(possible_choices)
            location = ((key - 1) * 2, 7.1)
            if chosen == 1:
                PLAYER_CARD_GROUP[key] = miniguner(location)
            elif chosen == 2:
                PLAYER_CARD_GROUP[key] = charger(location)
            elif chosen == 3:
                PLAYER_CARD_GROUP[key] = sniper(location)
            elif chosen == 4:
                PLAYER_CARD_GROUP[key] = rocketer(location)
            elif chosen == 5:
                PLAYER_CARD_GROUP[key] = doctor(location)
            elif chosen == 6:
                PLAYER_CARD_GROUP[key] = ninja(location)
            elif chosen == 7:
                PLAYER_CARD_GROUP[key] = fireball(location)
            elif chosen == 8:
                PLAYER_CARD_GROUP[key] = lightening(location)
            elif chosen == 9:
                PLAYER_CARD_GROUP[key] = mine(location)
            elif chosen == 10:
                PLAYER_CARD_GROUP[key] = autogun(location)
def set_init_player_card_random() -> None:
    """setup the card group randomly.
    """
    for key in range(1, 7):
        possible_choices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

        chosen = random.choice(possible_choices)
        location = ((key - 1) * 2, 7)
        if chosen == 1:
            player_card_group[key] = miniguner(location)
        elif chosen == 2:
            player_card_group[key] = charger(location)
        elif chosen == 3:
            player_card_group[key] = sniper(location)
        elif chosen == 4:
            player_card_group[key] = rocketer(location)
        elif chosen == 5:
            player_card_group[key] = doctor(location)
        elif chosen == 6:
            player_card_group[key] = nijia(location)
        elif chosen == 7:
            player_card_group[key] = fireball(location)
        elif chosen == 8:
            player_card_group[key] = lightening(location)
        elif chosen == 9:
            player_card_group[key] = mine(location)
        elif chosen == 10:
            player_card_group[key] = autogun(location)
예제 #4
0
def refresh_visual_image(c: Card) -> None:
    """Refresh visual image by input.
    """
    global CLICKED_MAP, TURN_END, CLICKED_CARD, DECISION_ACT, SELECTED_CARD, MONEY
    if DECISION_ACT is True:

        (x, y) = pygame.mouse.get_pos()
        local_x = int(x // SQUARE_SIZE[0])
        local_y = int(y // SQUARE_SIZE[1])
        # is put in 3 square in front of basement on map on x?
        situation_1 = SQUARE_SIZE[0] < pygame.mouse.get_pos(
        )[0] < SQUARE_SIZE[0] * 4
        # is it put in the game_map_graph on y?
        situation_2 = SQUARE_SIZE[1] <= pygame.mouse.get_pos(
        )[1] <= SQUARE_SIZE[1] * 7
        # is the selected_square empty?
        situation_3 = GAME_MAP_GRAPH.get_vertex(
            (local_x, local_y)).item is None
        # is selected_card a magic?
        situation_4 = isinstance(c, (fireball, lightening))
        #
        situation_5 = SQUARE_SIZE[0] < pygame.mouse.get_pos(
        )[0] < SQUARE_SIZE[0] * 11

        if situation_4 is False and situation_1 is False and situation_2 is True:
            print('You put the card out of range! Reput the card')
            DECISION_ACT = False
            CLICKED_MAP = False
            return None

        if situation_4 is False and situation_3 is False:
            print(
                'You put the card on a square which already have one. Reput the card'
            )
            DECISION_ACT = False
            CLICKED_MAP = False
            return None

        CLICKED_MAP = False
        TURN_END = True
        CLICKED_CARD = False

        if situation_1 and situation_2 and situation_3 and not situation_4:
            if isinstance(c, miniguner):
                GAME_MAP_GRAPH.get_vertex((local_x, local_y)).item = miniguner(
                    (local_x, local_y), 'right')
            elif isinstance(c, charger):
                GAME_MAP_GRAPH.get_vertex((local_x, local_y)).item = charger(
                    (local_x, local_y), 'right')
            elif isinstance(c, sniper):
                GAME_MAP_GRAPH.get_vertex((local_x, local_y)).item = sniper(
                    (local_x, local_y), 'right')
            elif isinstance(c, rocketer):
                GAME_MAP_GRAPH.get_vertex((local_x, local_y)).item = rocketer(
                    (local_x, local_y), 'right')
            elif isinstance(c, doctor):
                GAME_MAP_GRAPH.get_vertex((local_x, local_y)).item = doctor(
                    (local_x, local_y), 'right')
            elif isinstance(c, ninja):
                GAME_MAP_GRAPH.get_vertex((local_x, local_y)).item = ninja(
                    (local_x, local_y), 'right')
            elif isinstance(c, mine):
                GAME_MAP_GRAPH.get_vertex((local_x, local_y)).item = mine(
                    (local_x, local_y), 'right')
            elif isinstance(c, autogun):
                GAME_MAP_GRAPH.get_vertex((local_x, local_y)).item = autogun(
                    (local_x, local_y), 'right')
            remove_from_player_group(PLAYER_CARD_GROUP, c.location[0] // 2 + 1)
            GAME_MAP_GRAPH.get_vertex(
                (local_x, local_y)).item.get_real_location()

        elif situation_4 and situation_5:
            if isinstance(c, fireball):
                MAGIC_MAP_GRAPH.get_vertex((local_x, local_y)).item = fireball(
                    (local_x, local_y), 'right')
            elif isinstance(c, lightening):
                MAGIC_MAP_GRAPH.get_vertex(
                    (local_x, local_y)).item = lightening((local_x, local_y),
                                                          'right')
            remove_from_player_group(PLAYER_CARD_GROUP, c.location[0] // 2 + 1)

        all_magic_explode()
        clear_all_dead_body()
        SELECTED_CARD = None
    DECISION_ACT = False