Ejemplo n.º 1
0
def random_char(gold, m, w, x, a=1, b=8, c=12):
    char_name = choice(first_name) + " " + choice(last_name)
    r_str = randint(b, c)
    r_int = randint(b, c)
    r_dex = randint(b, c)
    r_wis = randint(b, c)
    r_cha = randint(b, c)
    r_con = randint(b, c)
    rand_char = Character(char_name, r_str, r_int, r_dex, r_wis, r_cha, r_con, m, w, money=gold, lvl=a, _id=x)
    rand_char.get_xp(5 * a)
    return rand_char
Ejemplo n.º 2
0
def choose_party(party :list):
    """Let's the player choose their party"""
    walking_left = [pygame.image.load("src/Sprites/stand_left.png")]
    walking_right = [pygame.image.load("src/Sprites/stand_right.png")]
    walking_top = [pygame.image.load("src/Sprites/stand_top.png")]
    walking_down = [pygame.image.load("src/Sprites/stand_bot.png")]

    for _ in range(7):
        walking_left.append(pygame.image.load("src/Sprites/step_left.png"))
        walking_right.append(pygame.image.load("src/Sprites/step_right.png"))
        walking_top.append(pygame.image.load("src/Sprites/step_top.png"))
        walking_down.append(pygame.image.load("src/Sprites/step_bot.png"))
    for _ in range(7):
        walking_left.append(pygame.image.load("src/Sprites/stand_left.png"))
        walking_right.append(pygame.image.load("src/Sprites/stand_right.png"))
        walking_top.append(pygame.image.load("src/Sprites/stand_top.png"))
        walking_down.append(pygame.image.load("src/Sprites/stand_bot.png"))
    for _ in range(7):
        walking_left.append(pygame.image.load("src/Sprites/step_left2.png"))
        walking_right.append(pygame.image.load("src/Sprites/step_right2.png"))
        walking_top.append(pygame.image.load("src/Sprites/step_top2.png"))
        walking_down.append(pygame.image.load("src/Sprites/step_bot2.png"))
    for _ in range(7):
        walking_left.append(pygame.image.load("src/Sprites/stand_left.png"))
        walking_right.append(pygame.image.load("src/Sprites/stand_right.png"))
        walking_top.append(pygame.image.load("src/Sprites/stand_top.png"))
        walking_down.append(pygame.image.load("src/Sprites/stand_bot.png"))

    walking_animation = [walking_left, walking_right, walking_top, walking_down]
    sprite = pygame.image.load("src/Sprites/main_character.png")

    main_character = Character("Leon", sprite, walking_animation)
    give_items(main_character)

    sprite = pygame.image.load("src/Sprites/knight.png")
    knight = Character("Knight", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/archer.png")
    archer = Character("Archer", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/wizard.png")
    wizard = Character("Wizard", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/assassin.png")
    assassin = Character("Assassin", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/monk.png")
    monk = Character("Monk", sprite, sprite)

    main_character.choose_character(party)
    left = [assassin,archer,knight,monk,wizard]
    while len(party) < 4:
        render_character_screen(left)
        while True:
            choice = choose_action("party")
            if choice <= len(left):
                break
        left[choice-1].choose_character(party)
        left.remove(left[choice-1])
Ejemplo n.º 3
0
    def clear_decoration(self, screen, background):
        """
        Clear circle.
        """

        if self._hit_counter > 0:
            screen.blit(background, self._dec_hit_rect, self._dec_hit_rect)
        elif self._invincible_counter > 0:
            screen.blit(background, self._dec_invinc_rect,
                        self._dec_invinc_rect)
        else:
            Character.clear_decoration(self, screen, background)
Ejemplo n.º 4
0
    def draw_decoration(self, screen):
        """
        Draw a circle around the Player to indicate being hit.
        """

        if self._hit_counter > 0:
            self._dec_hit_rect.centerx = self.rect.centerx
            self._dec_hit_rect.centery = self.rect.centery
            screen.blit(self._dec_hit_surf, self._dec_hit_rect)
        elif self._invincible_counter > 0:
            self._dec_invinc_rect.centerx = self.rect.centerx
            self._dec_invinc_rect.centery = self.rect.centery
            screen.blit(self._dec_invinc_surf, self._dec_invinc_rect)
        else:
            Character.draw_decoration(self, screen)
Ejemplo n.º 5
0
def initial_player():
    player_first = str(input("What is your first name, adventurer? "))
    player_last = str(input("What is your last name, adventurer? "))
    player_name = player_first + " " + player_last
    char = Character(player_name, 10, 10, 10, 10, 10, 10, player_magic, player_items, money=100)
    c = 1
    for i in profs:
        print("{}. {}".format(c, i))
        c += 1
    val = input("What is your profession, {}?".format(player_name))
    while val == "":
        val = input("'Well?'")
    while not val.isdigit():
        val = input("'Well?' ")
    while int(val) < 1:
        val = input("'Well?' ")
    while int(val) > 3:
        val = input("Well? ")
    val = int(val) - 1
    char.profession(val)
    return char
Ejemplo n.º 6
0
    def setUp(self):
        self.fireball = Skill("Fireball")
        self.fireball.multiplier = 2
        self.holy = Skill("Holy Light")
        self.holy.multiplier = 2
        self.atk = Skill("Raise Attack")
        self.atk.multiplier = 2
        self.df = Skill("Raise Defense")
        self.df.multiplier = 2
        self.mdef = Skill("Raise Magic Defense")
        self.mdef.multiplier = 2
        self.meditate = Skill("Meditate")
        self.meditate.multiplier = 1
        self.resurrect = Skill("Resurrect")
        self.poison = Skill("Poison")

        self.archer = Character("Archer","sprite","sprite")
        self.archer.atk = 40
        self.archer.df = 30
        self.archer.mdef = 30
        self.archer.hp = 400
        self.archer.mp = 50
Ejemplo n.º 7
0
def level_player(char):
    new_lvl = char.lvl + 1
    if char.prof == "Spellsword":
        n_str = char.str + 0.25
        n_int = char.int + 0
        n_dex = char.dex + 1
        n_wis = char.wis + 0.5
        n_cha = char.cha + 0
        n_con = char.con + 0.25
        new = Character(char.name, n_str, n_int, n_dex, n_wis, n_cha, n_con, char.magic, char.items,
                        money=char.money,
                        lvl=new_lvl, prof="Spellsword")
        new.quest = char.quest
        return new
    elif char.prof == "Warden":
        n_str = char.str + 0.5
        n_int = char.int + 0
        n_dex = char.dex + 0.25
        n_wis = char.wis + 0.25
        n_cha = char.cha + 0
        n_con = char.con + 1
        new = Character(char.name, n_str, n_int, n_dex, n_wis, n_cha, n_con, char.magic, char.items,
                        money=char.money,
                        lvl=new_lvl, prof="Warden")
        new.quest = char.quest
        return new
    elif char.prof == "Sorceror":
        n_str = char.str + 0.25
        n_int = char.int + 0
        n_dex = char.dex + 0.25
        n_wis = char.wis + 1
        n_cha = char.cha + 0
        n_con = char.con + 0.5
        new = Character(char.name, n_str, n_int, n_dex, n_wis, n_cha, n_con, char.magic, char.items,
                        money=char.money,
                        lvl=new_lvl, prof="Sorceror")
        new.quest = char.quest
        return new
Ejemplo n.º 8
0
def generate_map(pick):
    """Generates the chosen map by creating and linking all the areas in it. Returns the starting room and the boss in a list."""
    if pick == 1:
        boss = Character("Necromancer",
                         pygame.image.load("src/Sprites/necromancer2.png"),
                         pygame.image.load("src/Sprites/necromancer1.png"))
        boss.boss = True
        boss.monster = True
        boss.x = screen_width / 2 - boss.over_sprite.get_width() / 2
        boss.y = screen_height - wall - boss.over_sprite.get_height()
        start = Area(pygame.image.load("src/Sprites/background_top.png"))
        area1 = Area(
            pygame.image.load("src/Sprites/background_left_right_bottom.png"))
        area2 = Area(pygame.image.load("src/Sprites/background_right_top.png"))
        area3 = Area(
            pygame.image.load("src/Sprites/background_left_right.png"))
        area4 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area5 = Area(pygame.image.load("src/Sprites/background_left_top.png"))
        area6 = Area(pygame.image.load("src/Sprites/background_full.png"))
        area7 = Area(
            pygame.image.load("src/Sprites/background_right_top_bottom.png"))
        area8 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area9 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area10 = Area(pygame.image.load("src/Sprites/background_left.png"))
        area11 = Area(
            pygame.image.load("src/Sprites/background_right_bottom.png"))
        area12 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area13 = Area(
            pygame.image.load("src/Sprites/background_left_right.png"))
        area14 = Area(
            pygame.image.load("src/Sprites/background_left_bottom.png"))
        area15 = Area(
            pygame.image.load("src/Sprites/background_left_bottom.png"))
        area16 = Area(
            pygame.image.load("src/Sprites/background_left_right.png"))
        area17 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area18 = Area(
            pygame.image.load("src/Sprites/background_right_bottom.png"))
        area19 = Area(pygame.image.load("src/Sprites/background_left_top.png"))
        area20 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area21 = Area(
            pygame.image.load("src/Sprites/background_left_top_bottom.png"))
        area22 = Area(
            pygame.image.load("src/Sprites/background_right_top_bottom.png"))
        area23 = Area(
            pygame.image.load("src/Sprites/background_left_right.png"))
        area24 = Area(pygame.image.load("src/Sprites/background_left_top.png"))
        area25 = Area(
            pygame.image.load("src/Sprites/background_left_right.png"))
        area26 = Area(
            pygame.image.load("src/Sprites/background_left_right_bottom.png"))
        area27 = Area(
            pygame.image.load("src/Sprites/background_right_bottom.png"))
        area28 = Area(
            pygame.image.load("src/Sprites/background_right_top.png"))
        area29 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area30 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area31 = Area(
            pygame.image.load("src/Sprites/background_left_right.png"))
        boss_room = Area(pygame.image.load("src/Sprites/background_top.png"))

        start.set_neighbours(None, None, area1, None)
        area1.set_neighbours(area2, area3, None, start)
        area2.set_neighbours(None, area1, area4, None)
        area3.set_neighbours(area1, area5, None, None)
        area4.set_neighbours(None, None, area6, area2)
        area5.set_neighbours(area3, None, area7, None)
        area6.set_neighbours(area23, area10, area8, area4)
        area7.set_neighbours(None, area31, area9, area5)
        area8.set_neighbours(None, None, area12, area6)
        area9.set_neighbours(None, None, area11, area7)
        area10.set_neighbours(area6, None, None, None)
        area11.set_neighbours(None, area13, None, area9)
        area12.set_neighbours(None, None, area14, area8)
        area13.set_neighbours(area11, area15, None, None)
        area14.set_neighbours(area16, None, None, area12)
        area15.set_neighbours(area13, None, None, area17)
        area16.set_neighbours(area18, area14, None, None)
        area17.set_neighbours(None, None, area15, area19)
        area18.set_neighbours(None, area16, None, area20)
        area19.set_neighbours(area31, None, area17, None)
        area20.set_neighbours(None, None, area18, area21)
        area21.set_neighbours(area25, None, area20, area22)
        area22.set_neighbours(None, area23, area21, area24)
        area23.set_neighbours(area22, area6, None, None)
        area24.set_neighbours(area26, None, area22, None)
        area25.set_neighbours(area27, area21, None, None)
        area26.set_neighbours(area28, area24, None, area30)
        area27.set_neighbours(None, area25, None, area29)
        area28.set_neighbours(None, area26, area29, None)
        area29.set_neighbours(None, None, area27, area28)
        area30.set_neighbours(None, None, area26, boss_room)
        area31.set_neighbours(area7, area19, None, None)
        boss_room.set_neighbours(None, None, area30, None)

        start.set_start_location()
        boss_room.set_boss_room()
        return (start, boss)

    if pick == 2:
        boss = Character("Red Dragon",
                         pygame.image.load("src/Sprites/dragon.png"),
                         pygame.image.load("src/Sprites/dragon.png"))
        boss.boss = True
        boss.monster = True
        boss.x = screen_width - wall - boss.over_sprite.get_width()
        boss.y = screen_height - wall - boss.over_sprite.get_height()
        start = Area(pygame.image.load("src/Sprites/background_right.png"))
        area1 = Area(pygame.image.load("src/Sprites/background_full.png"))
        area2 = Area(
            pygame.image.load("src/Sprites/background_right_top_bottom.png"))
        area3 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area4 = Area(pygame.image.load("src/Sprites/background_bottom.png"))
        area5 = Area(
            pygame.image.load("src/Sprites/background_right_top_bottom.png"))
        area6 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area7 = Area(pygame.image.load("src/Sprites/background_top.png"))
        area8 = Area(pygame.image.load("src/Sprites/background_full.png"))
        area9 = Area(
            pygame.image.load("src/Sprites/background_right_bottom.png"))
        area10 = Area(
            pygame.image.load("src/Sprites/background_left_right_bottom.png"))
        area11 = Area(
            pygame.image.load("src/Sprites/background_left_right_top.png"))
        area12 = Area(
            pygame.image.load("src/Sprites/background_left_right.png"))
        area13 = Area(pygame.image.load("src/Sprites/background_full.png"))
        area14 = Area(pygame.image.load("src/Sprites/background_full.png"))
        area15 = Area(pygame.image.load("src/Sprites/background_top.png"))
        area16 = Area(pygame.image.load("src/Sprites/background_left.png"))
        area17 = Area(
            pygame.image.load("src/Sprites/background_left_bottom.png"))
        area18 = Area(pygame.image.load("src/Sprites/background_full.png"))
        area19 = Area(
            pygame.image.load("src/Sprites/background_left_right_bottom.png"))
        area20 = Area(
            pygame.image.load("src/Sprites/background_left_bottom.png"))
        area21 = Area(pygame.image.load("src/Sprites/background_left_top.png"))
        area22 = Area(
            pygame.image.load("src/Sprites/background_left_right_bottom.png"))
        area23 = Area(
            pygame.image.load("src/Sprites/background_left_right_top.png"))
        area24 = Area(
            pygame.image.load("src/Sprites/background_right_bottom.png"))
        area25 = Area(pygame.image.load("src/Sprites/background_top.png"))
        area26 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area27 = Area(pygame.image.load("src/Sprites/background_full.png"))
        area28 = Area(pygame.image.load("src/Sprites/background_right.png"))
        area29 = Area(pygame.image.load("src/Sprites/background_top.png"))
        area30 = Area(
            pygame.image.load("src/Sprites/background_top_bottom.png"))
        area31 = Area(pygame.image.load("src/Sprites/background_top.png"))
        area32 = Area(
            pygame.image.load("src/Sprites/background_left_right.png"))
        area33 = Area(pygame.image.load("src/Sprites/background_left.png"))
        boss_room = Area(pygame.image.load("src/Sprites/background_left.png"))

        start.set_neighbours(None, area1, None, None)
        area1.set_neighbours(start, area13, area2, area5)
        area2.set_neighbours(None, area8, area3, area1)
        area3.set_neighbours(None, None, area4, area2)
        area4.set_neighbours(None, None, None, area3)
        area5.set_neighbours(None, area14, area1, area6)
        area6.set_neighbours(None, None, area5, area7)
        area7.set_neighbours(None, None, area6, None)
        area8.set_neighbours(area2, area33, area9, area13)
        area9.set_neighbours(None, area10, None, area8)
        area10.set_neighbours(area9, area17, None, area11)
        area11.set_neighbours(area12, area18, area10, None)
        area12.set_neighbours(area13, area11, None, None)
        area13.set_neighbours(area1, area12, area8, area14)
        area14.set_neighbours(area5, area16, area13, area15)
        area15.set_neighbours(None, None, area14, None)
        area16.set_neighbours(area14, None, None, None)
        area17.set_neighbours(area10, None, None, area18)
        area18.set_neighbours(area11, area19, area17, area30)
        area19.set_neighbours(area18, area20, None, area31)
        area20.set_neighbours(area19, None, None, area21)
        area21.set_neighbours(area22, None, area20, None)
        area22.set_neighbours(area23, area21, None, area26)
        area23.set_neighbours(area24, area22, area30, None)
        area24.set_neighbours(None, area23, None, area25)
        area25.set_neighbours(None, None, area24, None)
        area26.set_neighbours(None, None, area22, area27)
        area27.set_neighbours(area28, area32, area26, area29)
        area28.set_neighbours(None, area27, None, None)
        area29.set_neighbours(None, None, area27, None)
        area30.set_neighbours(None, None, area18, area23)
        area31.set_neighbours(None, None, area19, None)
        area32.set_neighbours(area27, boss_room, None, None)
        area33.set_neighbours(area8, None, None, None)
        boss_room.set_neighbours(area32, None, None, None)

        start.set_start_location()
        boss_room.set_boss_room()
        return (start, boss)
Ejemplo n.º 9
0
from Functions.game import battle
from Functions.generate_character import player_items, player_magic, check_xp
from Classes.maps import q9_dung
from Classes.character import Character

player = Character("Aeric Greene",
                   50,
                   50,
                   50,
                   50,
                   50,
                   50,
                   player_magic,
                   player_items,
                   money=100)
player.maxhp = 1000
player.maxmp = 1000
player.reset()

battle(q9_dung, player)
Ejemplo n.º 10
0
 def setUp(self):
     self.map = None
     self.archer = Character("Archer", "sprite", "sprite")
Ejemplo n.º 11
0
    def __init__(self, kwargs):

        Character.__init__(self, kwargs)

        self._populate_images()

        # TODO: Move animation cycling to PSprite?
        self._walk_ctr = 0  # Walk cycle counter
        self._fpi = kwargs["fpi"]
        self._prev_image_series = "none"  # Name of previous animation

        # Signal that this Player has died
        self.dead = False
        # Number of frames to display dead animation
        self._dead_ctr = 60

        # Platform the player is standing on
        self._floor = None

        # Player control characteristics
        self._max_vx = kwargs["horizontal_speed"]
        self._ix = kwargs["horizontal_inertia"]
        # _mx: current momentum in x-direction
        self._mx = 0.0
        self._j_multi = kwargs["multi_jumps"]
        # _jumps: current number of consecutive jumps without landing
        self._jumps = 0
        # Is SPACE pressed? Don't jump again w/out SPACE being released
        # Defaults to True to prevent jump on spawn
        self._k_space = True
        # Vertical velocity at jump time _j_t is given by
        #   v = _j_a * (_j_t + _j_o) + _j_b
        # _j_t keeps track of how far into a jump the sprite is
        # _j_t == None means that a jump is not in progress
        # _j_o is an offset that ensures that _j_t == 0 is the apogee (useful
        #   for determining speed when falling of floors)
        self._j_a = kwargs["vertical_acceleration"]
        self._j_b = kwargs["jump_velocity"]
        self._j_t = None
        self._j_o = -self._j_b / self._j_a
        # Vertical point direction ((-1, 0, 1) == (down, forward, up))
        self._point_v = 0
        # Horizontal point direction ((-1, 1) == (left, right))
        self._point_h = 1

        # Make sure control characteristics make sense
        if self._max_vx <= 0.0:
            raise ValueError("horizontal_speed must be > 0.0")
        if self._ix <= 0.0:
            raise ValueError("horizontal_inertia must be > 0.0")
        if self._j_multi <= 0:
            raise ValueError("multi_jumps must be > 0")
        if self._j_a <= 0.0:
            raise ValueError("vertical_acceleration must be > 0.0")
        if self._j_b >= 0.0:
            raise ValueError("jump_velocity must be < 0.0")

    # Set targets
        targets = kwargs["targets"]
        if targets is None:
            targets = pygame.sprite.RenderPlain()

    # Set up default Projectile container
        self.fired_projectiles = kwargs["fired_projectiles"]
        b_kwargs = {
            "owner": self,
            "floors": kwargs["floors"],
            "l_walls": kwargs["l_walls"],
            "r_walls": kwargs["r_walls"],
            "ceilings": kwargs["ceilings"],
            "projectile_class": kwargs["projectile_class"],
            "fired_projectiles": self.fired_projectiles,
            "max_in_flight": kwargs["max_in_flight"],
            "max_shots": -1,
            "targets": targets,
            "centerx": 0,
            "centery": 0,
            "decoration_list": kwargs["decoration_list"]
        }
        self._box = ProjectileBox(b_kwargs)

        # Stack of Boxes
        self._box_stack = []

        # Invincibility counter after being hit
        self._invincible_counter = 0

        # Decorations
        # Invincibility
        r = math.ceil(max(self.rect.width, self.rect.height) * 0.75)
        self._dec_invinc_surf = \
            pygame.Surface((r*2, r*2), flags=SRCALPHA).convert_alpha()
        self._dec_invinc_rect = self._dec_invinc_surf.get_rect()
        pygame.draw.circle(self._dec_invinc_surf, (0, 80, 0), (r, r), r - 1, 1)
        # Got hit
        self._hit_counter = 0
        self._dec_hit_surf = \
            pygame.Surface((r*2, r*2), flags=SRCALPHA).convert_alpha()
        self._dec_hit_rect = self._dec_invinc_surf.get_rect()
        pygame.draw.circle(self._dec_hit_surf, (255, 0, 0), (r, r), r - 1, 0)
Ejemplo n.º 12
0
class TestSkill(unittest.TestCase):
    def setUp(self):
        self.fireball = Skill("Fireball")
        self.fireball.multiplier = 2
        self.holy = Skill("Holy Light")
        self.holy.multiplier = 2
        self.atk = Skill("Raise Attack")
        self.atk.multiplier = 2
        self.df = Skill("Raise Defense")
        self.df.multiplier = 2
        self.mdef = Skill("Raise Magic Defense")
        self.mdef.multiplier = 2
        self.meditate = Skill("Meditate")
        self.meditate.multiplier = 1
        self.resurrect = Skill("Resurrect")
        self.poison = Skill("Poison")

        self.archer = Character("Archer","sprite","sprite")
        self.archer.atk = 40
        self.archer.df = 30
        self.archer.mdef = 30
        self.archer.hp = 400
        self.archer.mp = 50

    
    def test_attacking_skills_work(self):
        self.fireball.activate(self.archer,self.archer)
        self.assertEqual(self.archer.hp,330)

    def test_recovery_skills_work(self):
        self.archer.take_dmg(100)
        self.holy.activate(self.archer,self.archer)
        self.assertEqual(self.archer.hp,360)
        self.archer.used_mp = 50
        self.meditate.activate(self.archer,self.archer)
        self.assertEqual(self.archer.mp,100)

    def test_recovery_skills_work_with_all_stats(self):
        self.holy.stat = "attack"
        self.archer.take_dmg(100)
        self.holy.activate(self.archer,self.archer)
        self.assertEqual(self.archer.hp,380)

        self.holy.stat = "mdef"
        self.archer.take_dmg(80)
        self.holy.activate(self.archer,self.archer)
        self.assertEqual(self.archer.hp,360)

        self.holy.stat = "hp"
        self.archer.take_dmg(260)
        self.holy.activate(self.archer,self.archer)
        self.assertEqual(self.archer.hp,300)


    def test_resurrecting_skills_work(self):
        self.archer.alive = False
        self.resurrect.activate(self.archer,self.archer)
        self.assertEqual(self.archer.alive,True)

    def test_buffing_skills_work(self):
        self.atk.activate(self.archer,self.archer)
        #original attack at level 1 is 21
        self.assertEqual(self.archer.atk,82)
        self.atk.deactivate([self.archer])
        self.assertEqual(self.archer.atk,40)

        self.df.activate(self.archer,self.archer)
        #original defense at level 1 is 6
        self.assertEqual(self.archer.df,42)
        self.df.deactivate([self.archer])
        self.assertEqual(self.archer.df,30)

        self.mdef.activate(self.archer,self.archer)
        #original mdef at level 1 is 7
        self.assertEqual(self.archer.mdef,44)
        self.mdef.deactivate([self.archer])
        self.assertEqual(self.archer.mdef,30)

    def test_deactivating_single_target_skills_work(self):
        self.atk.aoe = 0
        self.atk.user = "******"
        self.atk.activate(self.archer,self.archer)
        self.atk.deactivate([self.archer])
        self.assertEqual(self.archer.atk,40)

        self.df.aoe = 0
        self.df.user = "******"
        self.df.activate(self.archer,self.archer)
        self.df.deactivate([self.archer])
        self.assertEqual(self.archer.df,30)

        self.mdef.aoe = 0
        self.mdef.user = "******"
        self.mdef.activate(self.archer,self.archer)
        self.mdef.deactivate([self.archer])
        self.assertEqual(self.archer.mdef,30)

    def test_poisoning_works(self):
        self.poison.activate(self.archer,self.archer)
        self.assertEqual(self.archer.status,["Poison",3])
        self.archer.boss = True
        self.archer.status = [None,0]
        self.poison.activate(self.archer,self.archer)
        self.assertEqual(self.archer.status,[None,0])
Ejemplo n.º 13
0
    def __init__(self, kwargs):

        Character.__init__(self, kwargs)

        self._populate_images()

        self.points = kwargs["points"]

        # Location and default movement characteristics
        # True x- and y-coordinates are calculated and stored in floats to
        #   allow for sub-pixel motion, but collision detection, drawing, etc.
        #   are done on integers
        self._xf = float(self.rect.centerx)
        self._yf = float(self.rect.centery)
        # Useful for Baddies that just float and bounce around
        self._speed = 1.0
        self._dir = 0.0

        # Animation-related variables
        # TODO: Move animation cycling to PSprite?
        self._walk_ctr = 0
        self._fpi = kwargs["fpi"]
        self._prev_image_series = "none"

        # Whether to draw hit decoration
        self._hit_counter = 0

        # Number of frames to display dead animation
        self._dead_ctr = 30

        # Set targets
        targets = kwargs["targets"]
        if targets is None:
            targets = pygame.sprite.RenderPlain()

    # Set up Projectiles
    # Use fired_projectiles from owner so Projectiles can outlive the
    #   Baddie
        b_kwargs = {
            "owner": self,
            "floors": kwargs["floors"],
            "l_walls": kwargs["l_walls"],
            "r_walls": kwargs["r_walls"],
            "ceilings": kwargs["ceilings"],
            "projectile_class": kwargs["projectile_class"],
            "fired_projectiles": kwargs["fired_projectiles"],
            "max_in_flight": kwargs["max_in_flight"],
            "max_shots": -1,
            "targets": kwargs["targets"],
            "centerx": 0,
            "centery": 0,
            "decoration_list": kwargs["decoration_list"]
        }
        self._box = ProjectileBox(b_kwargs)

        # Decorations
        # Invincibility
        r = math.ceil(max(self.rect.width, self.rect.height) * 0.75)
        self._dec_invinc_surf = \
            pygame.Surface((r*2, r*2), flags=SRCALPHA).convert_alpha()
        self._dec_invinc_rect = self._dec_invinc_surf.get_rect()
        pygame.draw.circle(self._dec_invinc_surf, (255, 0, 0), (r, r), r - 1,
                           0)
Ejemplo n.º 14
0
def generate_monsters(monsters :list):
    """Adds monsters to the monster-list"""
    sprite = pygame.image.load("src/Sprites/demon.png")
    demon = Character("Demon Assassin", sprite, sprite)
    demon2 = Character("Demon Assassin", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/eyeball.png")
    beholder = Character("Beholder", sprite, sprite)
    beholder2 = Character("Beholder", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/goblin.png")
    goblin = Character("Goblin Soldier", sprite, sprite)
    goblin2 = Character("Goblin Soldier", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/skeleton.png")
    skeleton = Character("Skeleton Warrior", sprite, sprite)
    skeleton2 = Character("Skeleton Warrior", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/warlock.png")
    warlock = Character("Warlock", sprite, sprite)
    warlock2 = Character("Warlock", sprite, sprite)

    sprite = pygame.image.load("src/Sprites/dragonling.png")
    dragonling = Character("Dragonling", sprite, sprite)
    dragonling2 = Character("Dragonling", sprite, sprite)

    monsters.append(Monster([demon,beholder],4))
    monsters.append(Monster([demon,demon2],5))
    monsters.append(Monster([demon],6))
    monsters.append(Monster([demon,warlock,goblin,beholder],2))
    monsters.append(Monster([beholder,warlock,warlock2,beholder2],2))
    monsters.append(Monster([skeleton,warlock,skeleton2],2))
    monsters.append(Monster([dragonling],5))
    monsters.append(Monster([dragonling,dragonling2],5))
    monsters.append(Monster([demon,dragonling],5))
    monsters.append(Monster([skeleton,warlock,goblin],3))
    monsters.append(Monster([goblin,beholder,goblin2],2))
    monsters.append(Monster([beholder,skeleton,warlock],2))
    for group in monsters:
        for monster in group.monsters:
            monster.monster = True
Ejemplo n.º 15
0
#from Classes.statblock import *
from Classes.character import Character
from Classes.races import Race

player = Character("jordan")
player.create_character()