Exemplo n.º 1
0
 def test_combat(self):
     hero = Hero()
     villain = Mob()
     lib = Librarian()
     winner = lib.combat_time(hero, villain)
     # print "WINNER WINNER", winner, villain.is_alive(), hero.is_alive(), hero.health
     self.assertTrue(hero.is_alive())
     self.assertEqual(hero, winner)
Exemplo n.º 2
0
class TestHero(unittest.TestCase):
    def setUp(self):
        self.hero = Hero("Anna", 20, Race.GREMLIN, Hero_class.PALADIN)
        self.enemy = Hero("Clay", 20, Race.HUMAN, Hero_class.MAGE)

    def test_use_normal_skill(self):
        self.hero.use_normal_skill(self.enemy)
        self.assertEqual(self.hero.mana, 5)
Exemplo n.º 3
0
Arquivo: game.py Projeto: Dodeo/Pygame
class Game:
  def __init__(self):
        self._running = True
        self._screen = None
        self.size = self.weight, self.height = 640, 400

  def on_init(self):
    pygame.init()
    # Create window and try to do hardware acceleration
    self._screen = pygame.display.set_mode(self.size, pygame.HWSURFACE | pygame.DOUBLEBUF)
    # Set frequence of keyrepeat
    pygame.key.set_repeat(100, 150)
    # Program is running
    self._running = True
    # Get a background
    self.background = pygame.Surface(self._screen.get_size())
    self.background = self.background.convert()
    self.background.fill((250, 250, 250))
    self._screen.blit(self.background, (0, 0))
    # Create Hero
    self.me = Hero('Babouche', 'Rolland', 200, 300)
    # Set transparence in blank color
    self.me.img.set_colorkey((255,255,255))
    self._screen.blit(self.me.img, (self.me.x , self.me.y ))
    #Display change on screen
    pygame.display.flip()

  def on_event(self, event):
    if event.type == pygame.QUIT:
      self._running = False
    if event.type == KEYDOWN:
      if event.key == K_UP:
        self.me.up()
      if event.key == K_DOWN:
        self.me.down()

  def on_loop(self):
    pass

  def on_render(self):
    self._screen.blit(self.background, (0,0))
    self._screen.blit(self.me.img, (self.me.x, self.me.y))
    pygame.display.flip()


  def on_cleanup(self):
    pygame.quit()

  def on_execute(self):
    if self.on_init() == False:
        self._running = False

    while( self._running ):
        for event in pygame.event.get():
            self.on_event(event)
        self.on_loop()
        self.on_render()
    self.on_cleanup()
Exemplo n.º 4
0
 def test_isalive(self):
     hero = Hero(name="Stu")
     self.assertTrue(hero.is_alive())
     hero.health = 0
     self.assertFalse(hero.is_alive())
     hero.health = 100
     self.assertTrue(hero.is_alive())
     hero.take_damage(102)
     self.assertFalse(hero.is_alive())
Exemplo n.º 5
0
def battle_random(char1):
    # name = choice(char_list)
    char_list = ['Hero', 'Medic', 'Shadow', 'Wizard', 'Tank', 'Drunkard', 'Zombie', 'Goblin']
    job_index = randint(0,7)
    # char2 = Character(name,name,randint(30,50), randint(5,7))
    job = char_list[job_index]

    random_health = randint(30, 50)
    random_power = randint(5, 7)

    job_selection_dict = {
        "0":Hero(job, random_health, random_power),
        "1":Medic(job, random_health, random_power),
        "2":Shadow(job, 1, random_power),
        "3":Wizard(job, random_health, random_power),
        "4":Tank(job, random_health, random_power),
        "5":Drunkard(job, random_health, random_power),
        "6":Zombie(job, random_health, randint(1,2)),
        "7":Goblin(job, random_health, randint(3,5))
    }


    char2 = job_selection_dict[str(job_index)]

    print("%s encountered a %s!" % (char1.name, char2.name))
    battle(char1, char2)
Exemplo n.º 6
0
def create_hero():

    print("Time to create your character!")
    name = input("What is your character's name?: ")   
    print() 
    job_selection = input("What is %s's class?\n1. Hero\n2. Medic\n3. Shadow\n4. Wizard\n5. Tank\n6. Drunkard\n: " % name)    
    print()
    health = randint(100,150)
    power = randint(5,10)


    job_selection_dict = {
        "1":Hero(name, health, power),
        "2":Medic(name, health, power),
        "3":Shadow(name, health, power),
        "4":Wizard(name, health, power),
        "5":Tank(name, health, power),
        "6":Drunkard(name, health, power)
    }


    # char = Character(name, job_selection_dict[job_selection], health, power)
    char = job_selection_dict[job_selection]
    print("Your character has been created! %s the %s, with starting stats of %d health and %d power" % (name, char.job, char.health, char.power))
    return char
Exemplo n.º 7
0
Arquivo: game.py Projeto: Dodeo/Pygame
 def on_init(self):
   pygame.init()
   # Create window and try to do hardware acceleration
   self._screen = pygame.display.set_mode(self.size, pygame.HWSURFACE | pygame.DOUBLEBUF)
   # Set frequence of keyrepeat
   pygame.key.set_repeat(100, 150)
   # Program is running
   self._running = True
   # Get a background
   self.background = pygame.Surface(self._screen.get_size())
   self.background = self.background.convert()
   self.background.fill((250, 250, 250))
   self._screen.blit(self.background, (0, 0))
   # Create Hero
   self.me = Hero('Babouche', 'Rolland', 200, 300)
   # Set transparence in blank color
   self.me.img.set_colorkey((255,255,255))
   self._screen.blit(self.me.img, (self.me.x , self.me.y ))
   #Display change on screen
   pygame.display.flip()
Exemplo n.º 8
0
    def __init__(self):
        self.no_of_fields_h = 10
        self.no_of_fields_v = 10
        self.field_size = 72
        self.floor_image = PhotoImage(file="assets/floor.png")
        self.wall_image = PhotoImage(file="assets/wall.png")
        self.canvas = canvas
        self.dice = Dice()

        dice_result_1 = self.dice.roll_the_dice()
        self.hero = Hero(dice_result_1[0], dice_result_1[1], canvas)
        draw_hero(self.hero)

        dice_result_2 = self.dice.roll_the_dice()
        self.boss = Boss(dice_result_2[0], dice_result_2[1], canvas)
        draw_boss(self.boss)

        dice_result_3 = self.dice.roll_the_dice()
        self.skeleton_1 = Skeleton(dice_result_3[0], dice_result_3[1], canvas)
        draw_skeleton_1(self.skeleton_1)

        dice_result_4 = self.dice.roll_the_dice()
        self.skeleton_2 = Skeleton(dice_result_4[0], dice_result_4[1], canvas)
        draw_skeleton_2(self.skeleton_2)

        dice_result_5 = self.dice.roll_the_dice()
        self.skeleton_3 = Skeleton(dice_result_5[0], dice_result_5[1], canvas)
        draw_skeleton_3(self.skeleton_3)

        self.map_1 = [[1,0,0,1,0,1,0,0,0,0],
                    [0,0,0,1,0,1,0,1,1,0],
                    [0,1,1,1,0,1,0,1,1,0],
                    [0,0,0,0,0,1,0,0,0,0],
                    [1,1,1,1,0,1,1,1,1,0],
                    [0,1,0,1,0,0,0,0,1,0],
                    [0,1,0,1,0,0,0,0,1,0],
                    [0,0,0,0,0,1,1,0,1,0],
                    [0,1,1,1,0,0,0,0,1,0],
                    [0,0,0,1,0,1,1,0,1,0],
                    [0,1,0,1,0,1,0,0,0,0]]
Exemplo n.º 9
0
def main():

    player = Hero("King", "The brave king of nowhere!")
    player.Talk = "Who is here?"

    enemy = Enemy("Wizard", "The evil wizard!")
    enemy.Talk = "Your worst enemy!!!!"

    castle = []
    layout(castle)
    current_room = castle[0]

    castle[random.randint(1, len(castle) - 1)].Character = enemy

    print(player)
    print("I'm in:")
    print(current_room)

    print()
    while True:
        direction = input("Where to ? ").upper()
        if direction == "EXIT":
            break
        print()
        if direction in DIRECTIONS:
            current_room = current_room.move_to_direction(direction)
            print(current_room)
            if current_room.Character:
                print(player.Talk)
                print(enemy.Talk)
                if player.fight(current_room.Character):
                    print("\nWell done you have defeated your enemy!\n")
                    break
                print(player.Back)
                player.change_weapon()
        print()
Exemplo n.º 10
0
Arya.inventory.append('Mask')

print(len(Arya.inventory))

# Arya should have a `greet` method
# when i call it with `Arya.greet()`, it should return
# "Hello, I am Arya Stark. I am awesome."
print(Arya.greet())

# Arya should have a `greet` method
# when i call it with `Arya.greet(Jon)`, it should return
# "Hello, Jon Snow, I am Arya Stark. I am awesome."
print(Arya.greet(Jon))

# I should be able to create a hero instance
Bronn = Hero("Bronn of the Blackwater", "bron.png")

# Hero should be able to greet Character
print(Bronn.greet(Arya))
print(Jon.greet(Bronn))
print(Arya.greet(Bronn))

#I should be able to create a Monster instance
White_walker = Monster()

#When I print white_walker.name and white_walker.avatar the name and avatar will be returned
# print(White_walker.name, White_walker.avatar)

# When I call White_walker.greet() it will return
# "Grr, Im a monster"
print(White_walker.greet())
Exemplo n.º 11
0
			"Garden vegetables, pulled from the Earth.", 
			"0", "0", "0", "0", "0", "0")
		
## -------------------------Tests below-------------------------

braided_rope = BraidedRope()
braided_rope.stats()
braided_rope.unlock_effect()
braided_rope.stats()

autumn_herbs = AutumnHerbs()
autumn_herbs.add(2)
autumn_herbs.stats()
autumn_herbs.delete(-1)
autumn_herbs.stats()
newguy = Hero("j")
newguy.stats()
autumn_herbs.use(newguy)
newguy.stats()

spring_water = SpringWater()
spring_water.add(2)
spring_water.stats()
spring_water.delete(-1)
spring_water.stats()
newguy = Hero("j")
newguy.stats()
spring_water.use(newguy)
newguy.stats()

garden_vegetables = GardenVegetables()
Exemplo n.º 12
0
 def __init__(self, *args, **kwargs):
     super(TestCharacter, self).__init__(*args, **kwargs)
     self.hero = Hero("Joe")
     self.villain = Mob("Shmoe")
     self.item_hero = Item(name="Sword of Superiorness", attack_bonus=10, defense_bonus=-1)
     self.item_villain = Item(name="Shield of Losers", attack_bonus=0, defense_bonus=1)
Exemplo n.º 13
0
# after adding 2 items to inventory
# length of inventory should == 2

arya.inventory.append('sword')
arya.inventory.append('mask')

print(len(arya.inventory))

# arya should have  a`greet` method
# when called, it should return:
# "Hello, Jon Stark. I am Arya Stark. I am awesome."
print(arya.greet(jon))
# arya should have  a`greet` method
# when called, it should return:
# "Hello, I am Arya Stark. I am awesome."
print(arya.greet())

# I should be able to create a hero instance
bronn = Hero("Bronn of the Blackwater", "bron.png")
ramsay_snow = Monster("The Bastard of Bolton", "ramsay_snow.png")

# Hero should be able to greet Character
print(bronn.greet(arya))
print(jon.greet(bronn))
print(bronn.attack(ramsay_snow))

#
walker = Monster()
# expects to greet "ugggh"
print(walker.greet())
Exemplo n.º 14
0
class TestCharacter(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super(TestCharacter, self).__init__(*args, **kwargs)
        self.hero = Hero("Joe")
        self.villain = Mob("Shmoe")
        self.item_hero = Item(name="Sword of Superiorness", attack_bonus=10, defense_bonus=-1)
        self.item_villain = Item(name="Shield of Losers", attack_bonus=0, defense_bonus=1)

    def test_check_names(self):
        self.assertEqual(self.hero.name, "Joe")
        self.assertEqual(self.villain.name, "Shmoe")

    def test_blank_name_mob(self):
        my_mob = Mob()
        self.assertEqual(type(my_mob.name), str)
        self.assertGreater(len(my_mob.name), 0)

    def test_get_stats(self):
        hero_stats = [{'name': 'Joe'}, {'items': []}, {'attack_strength': 2}, {'defense': 1}, {'health': 100}, {'exp': 0}, {'isMOB': False}, {'persist': True}]
        mob_stats = [{'name': 'Shmoe'}, {'items': []}, {'attack_strength': 2}, {'defense': 1}, {'health': 100}, {'exp': 0}, {'isMOB': True}, {'persist': False}]
        self.assertGreater(len(self.hero.get_stats()),0)
        self.assertGreater(len(self.villain.get_stats()),0)
        #self.assertEqual(self.hero.get_stats(), hero_stats)
        #self.assertEqual(self.villain.get_stats(), mob_stats)

    def test_attack(self):
        self.assertEqual(self.hero.attack(self.villain), 99)
        self.assertEqual(self.hero.attack(self.villain), 98)
        self.assertEqual(self.hero.attack(self.villain), 97)

        # check if item bonuses work
        self.villain.items.append(self.item_villain)
        self.assertEqual(self.hero.attack(self.villain), 97)
        self.hero.items.append(self.item_hero)
        self.assertEqual(self.hero.attack(self.villain), 87)
        # check multiple item bonuses
        self.hero.items.append(self.item_hero)
        self.assertEqual(self.hero.attack(self.villain), 67)
        # validate hero's health hasn't changed
        self.assertEqual(self.hero.health, 100)
        # check out negative defense
        self.assertEqual(self.villain.attack(self.hero), 97)

    def test_heal(self):
        ''' A basic unit test '''
        self.hero.heal(10)
        self.assertEqual(self.hero.health, 110)

    def test_isalive(self):
        hero = Hero(name="Stu")
        self.assertTrue(hero.is_alive())
        hero.health = 0
        self.assertFalse(hero.is_alive())
        hero.health = 100
        self.assertTrue(hero.is_alive())
        hero.take_damage(102)
        self.assertFalse(hero.is_alive())

    def test_check_items(self):
        self.hero.items.append(self.item_hero)
        self.hero.items.append(self.item_hero)
        self.assertEqual(len(self.hero.items), 2)

    def test_librarian(self):
        lib = Librarian()
        my_mob = lib.create_mob()
        self.assertEqual(type(my_mob.name), str)
        self.assertGreater(len(my_mob.name), 0)

    def test_encoding(self):
        my_mob = MyEncoder().encode(Mob())
        self.assertNotEqual(my_mob, " ")
        self.assertEqual(type(json.loads(my_mob)), dict)

    def test_librarian_flask(self):
        my_mob = MyEncoder().encode(Mob())
        test = Mob(my_mob)
        my_name = json.loads(my_mob)['name']
        new_mob = Mob(name=my_name)

    def test_combat(self):
        hero = Hero()
        villain = Mob()
        lib = Librarian()
        winner = lib.combat_time(hero, villain)
        # print "WINNER WINNER", winner, villain.is_alive(), hero.is_alive(), hero.health
        self.assertTrue(hero.is_alive())
        self.assertEqual(hero, winner)

    def test_librarian_create_mob(self):
        lib = Librarian()
        mob = lib.create_mob()
        self.assertTrue(mob)
    def test_hero_creation(self):
        hero = Hero(attack_strength=100)
        self.assertTrue(hero)
Exemplo n.º 15
0
arya.inventory.append("sword")
arya.inventory.append("mask")
jon.inventory.append("dragon glass")


print(len(arya.inventory))
print(len(jon.inventory))

# arya should hava a `greet` method
# and when I call it with `arya.greet()`, it should return 
# "Hello,I am Arya Stark. You killed my father. Prepare to die."
print(arya.greet())

# arya should hava a `greet` method
# and when I call it with `arya.greet(jon)`, it should return 
# "Hello, Jon Snow, I am Arya Stark. You killed my father. Prepare to die."
print(arya.greet(jon))

# I should be able to create a Hero instance
bronn = Hero("Bronn of the Blackwater", "bron.gif")
mittens = Monster("Mittens the Kitten", "mitten.jpeg")

# Hero should be able to `.greet` Character
print(bronn.greet(arya))
print(jon.greet(bronn))

# Monster should be able to `.groan` a Character or Hero
print(mittens.groan(arya))
print(mittens.groan(bronn))
print(bronn.attack(mittens))
Exemplo n.º 16
0
class DrawMap(object):

    def __init__(self):
        self.no_of_fields_h = 10
        self.no_of_fields_v = 10
        self.field_size = 72
        self.floor_image = PhotoImage(file="assets/floor.png")
        self.wall_image = PhotoImage(file="assets/wall.png")
        self.canvas = canvas
        self.dice = Dice()

        dice_result_1 = self.dice.roll_the_dice()
        self.hero = Hero(dice_result_1[0], dice_result_1[1], canvas)
        draw_hero(self.hero)

        dice_result_2 = self.dice.roll_the_dice()
        self.boss = Boss(dice_result_2[0], dice_result_2[1], canvas)
        draw_boss(self.boss)

        dice_result_3 = self.dice.roll_the_dice()
        self.skeleton_1 = Skeleton(dice_result_3[0], dice_result_3[1], canvas)
        draw_skeleton_1(self.skeleton_1)

        dice_result_4 = self.dice.roll_the_dice()
        self.skeleton_2 = Skeleton(dice_result_4[0], dice_result_4[1], canvas)
        draw_skeleton_2(self.skeleton_2)

        dice_result_5 = self.dice.roll_the_dice()
        self.skeleton_3 = Skeleton(dice_result_5[0], dice_result_5[1], canvas)
        draw_skeleton_3(self.skeleton_3)

        self.map_1 = [[1,0,0,1,0,1,0,0,0,0],
                    [0,0,0,1,0,1,0,1,1,0],
                    [0,1,1,1,0,1,0,1,1,0],
                    [0,0,0,0,0,1,0,0,0,0],
                    [1,1,1,1,0,1,1,1,1,0],
                    [0,1,0,1,0,0,0,0,1,0],
                    [0,1,0,1,0,0,0,0,1,0],
                    [0,0,0,0,0,1,1,0,1,0],
                    [0,1,1,1,0,0,0,0,1,0],
                    [0,0,0,1,0,1,1,0,1,0],
                    [0,1,0,1,0,1,0,0,0,0]]

    def screen_drawer(self):
        for i in range(self.no_of_fields_h):
            for j in range(self.no_of_fields_v):
                if self.map_1[j][i] == 0:
                    self.canvas.create_image(i * self.field_size, j * self.field_size, anchor=NW, image=self.floor_image)
                elif self.map_1[j][i] == 1:
                    self.canvas.create_image(i * self.field_size, j * self.field_size, anchor=NW, image=self.wall_image)

    def draw_hero(dice_result_1):
        if self.map_1.is_obstacle(dice_result_1[0], dice_result_1[1]) == False:
            self.hero = Hero(dice_result_1[0], dice_result_1[1], canvas)
            self.hero.draw()
        else:
            draw_hero(dice_result_1)

    def draw_boss(dice_result_2):
        if self.map_1.is_obstacle(dice_result_2[0], dice_result_2[1]) == False:
            self.boss = Boss(dice_result_2[0], dice_result_2[1], canvas)
            self.boss.draw()
        else:
            draw_boss(dice_result_2)

    def draw_skeleton_1(dice_result_3):
        if self.map_1.is_obstacle(dice_result_3[0], dice_result_3[1]) == False:
            self.skeleton_1 = Skeleton(dice_result_3[0], dice_result_3[1], canvas)
            self.skeleton_1.draw()
        else:
            draw_skeleton_1(dice_result_3)

    def draw_skeleton_2(dice_result_4):
        if self.map_1.is_obstacle(dice_result_4[0], dice_result_4[1]) == False:
            self.skeleton_2 = Skeleton(dice_result_4[0], dice_result_4[1], canvas)
            self.skeleton_2.draw()
        else:
            draw_skeleton_2(dice_result_4)

    def draw_skeleton_3(dice_result_5):
        if self.map_1.is_obstacle(dice_result_5[0], dice_result_5[1]) == False:
            self.skeleton_3 = Skeleton(dice_result_5[0], dice_result_5[1], canvas)
            self.skeleton_3.draw()
        else:
            draw_skeleton_3(dice_result_5)

    def stats_drawer(self):
        self.info_box_height = 80
        self.canvas.create_rectangle(0, self.field_size * self.no_of_fields_v, self.field_size * self.no_of_fields_h, self.field_size * self.no_of_fields_h + self.info_box_height, fill="grey")
        self.canvas.create_rectangle(10, self.field_size * self.no_of_fields_v + 10, self.field_size * self.no_of_fields_h + 10, self.field_size * self.no_of_fields_h + self.info_box_height - 10, fill="white")
        self.canvas.create_text(self.field_size * self.no_of_fields_h/2, self.field_size * self.no_of_fields_h + self.info_box_height/2, text='Hero (Level 1) HP: 8/10 | DP: 8 | SP: 6', font=('Arial', 24, 'bold'))

    def is_obstacle(self, x, y):
        if self.map_1[x][y] == 0:
            return True
        else:
            return False

    def move_down(event):
        self.hero.move_down()
        screen_drawer(no_of_fields_h, no_of_fields_v)

    def move_up(event):
        self.hero.move_up()
        screen_drawer(no_of_fields_h, no_of_fields_v)

    def move_left(event):
        self.hero.move_left()
        screen_drawer(no_of_fields_h, no_of_fields_v)

    def move_right(event):
        self.hero.move_right()
        screen_drawer(no_of_fields_h, no_of_fields_v)
Exemplo n.º 17
0
# these arent real tests
from character import Character
from character import Hero
# Characters can be instantiated with name and avatar

ayra = Character("Ayra Stark", "PHOTO.png")
jon = Character("Jon Snow", "SUPERPHOTO.png")
print(jon.name, jon.avatar, ayra.name, ayra.avatar)

print(jon.inventory)

jon.inventory.append("CAT")
jon.inventory.append("Valayrian steel")

# should print ...
print(jon.inventory)

# it should print ...
print(ayra.greet(jon))

# should print without "hello i am.."
print(ayra.greet())

# i should be able to create a hero instance
Giant_Cat = Hero("Giant Cat from beyond the wall", "cat.png")
Exemplo n.º 18
0
arya.inventory.append('needle')
arya.inventory.append('mask')

print(len(arya.inventory))

# arya should have a `greet` method
# and when I call with `arya.greet(jon)`, it should return
# "Hello, Jon Snow, I am Ayra Stark. I am awesome."
# print(arya.greet(jon))

# arya should have a `greet` method
# and when I call with `arya.greet()`, it should return
# "Hello, I am Ayra Stark. I am awesome."
# print(arya.greet())

# I should be able to create a hero instance
bronn = Hero("Bronn of the Blackwater", "bronn.png")

# Hero should be able to greet Character
# print(bronn.greet(arya))
# print(jon.greet(bronn))

# I should be able to create a monster instance
walker = Monster()

# Expect Monster to make monster sound
print(walker.greet(jon))

# Expect Hero to say "EEEEEEEEEK!"
# when encountering a monster
print(bronn.greet(walker))
Exemplo n.º 19
0
 def draw_hero(dice_result_1):
     if self.map_1.is_obstacle(dice_result_1[0], dice_result_1[1]) == False:
         self.hero = Hero(dice_result_1[0], dice_result_1[1], canvas)
         self.hero.draw()
     else:
         draw_hero(dice_result_1)
from room import Room
from item import Item
from character import Character, Enemy, Hero
from rpginfo import RPGInfo

hero = Hero("Hero")
enemy = Enemy("enemy", "Example enemy")
item = Item("Sword", 25)

print(hero.health)
print(enemy.health)

hero.fight(enemy, item.damage)
hero.fight(enemy, item.damage)
enemy.fight(hero, 5)
print(hero.health)
print(enemy.health)
Exemplo n.º 21
0
arya.inventory.append('mask')

print(len(arya.inventory))

# arya should have a 'greet' method
# and when I call with 'arya.greet(jon)', it should return
# "Hello, Jon Snow, I am Arya Stark. I am awesome."
print(arya.greet(jon))

# arya should have a 'greet' method
# and when I call with 'arya.greet()', it should return
# "Hello, I am Arya Stark. I am awesome."
print(arya.greet())

# I should be able to create a Hero instance
bronn = Hero("Bronn of the Blackwater", "bron.png")

# Hero should be able to greet Character
print(bronn.greet(arya))
print(jon.greet(bronn))

# I should be able to create a Monster instance
pinky = Monster()

# Monster should be able to greet Hero
print(pinky.greet(bronn))
print(bronn.greet(pinky))

# Expect Bronn to say "EEEEEEEK!"
# when encountering a monster
print(bronn.greet(pinky))
Exemplo n.º 22
0
from character import Character
from character import Hero

# Characters can be instantiated with name and avatar
arya = Character("Arya Stark", "arya.png")
jon = Character("Jon Snow", "jon.png")

print(arya.name, arya.avatar)
print(jon.name, jon.avatar)

# After adding 2 items to inventory
# length of inventory should == 2

arya.inventory.append('sword')
arya.inventory.append('mask')

print(len(arya.inventory))

# arya should have a `greet` method
# and when I call with `arya.greet(jon)`, it should return
# "Hello, Jon Snow, I am Arya Stark. I am awesome."
print(arya.greet(jon))

# arya should have a `greet` method
# and when I call with `arya.greet()`, it should return
# "Hello, I am Arya Stark. I am awesome."
print(arya.greet())

# I should be able to create a Hero instance
bronn = Hero("Bronn of the Blackwater", "bron.png")
Exemplo n.º 23
0
 def setUp(self):
     self.hero = Hero("Anna", 20, Race.GREMLIN, Hero_class.PALADIN)
     self.enemy = Hero("Clay", 20, Race.HUMAN, Hero_class.MAGE)
Exemplo n.º 24
0
# characters can be instantiated with name and avatar
arya = Character("Arya Stark", "arya.png")
jon = Character("Jon Snow", "jon.pgn")

print(arya.name, arya.avatar)
print(jon.name, jon.avatar)

# after adding 2 items to inventory, inventory length should = 2
arya.inventory.append('sword')
arya.inventory.append('mask')

print(len(arya.inventory))

# arya should have a 'greet' method
# when i call with arya.greet(jon) it should return "hello, jon snow, i am arya stark, i will destroy you."
print(arya.greet(jon))
# arya should have a 'greet' method
# when i call with arya.greet() it should return "hello, i am arya stark. i will destroy you"
print(arya.greet())

# should be able to create a hero instance.
bronn = Hero("Bronn of the Blackwater", "bron.pgn")

# hero should be able to greet character.
print(bronn.greet(arya))
print(jon.greet(bronn))
# creates monster instance
Dragon = Monster("Scary Dragon", "dragon.img")
print(Dragon.greet(bronn))
print(Dragon.greet(jon))
Exemplo n.º 25
0
# Arya should have a `greet` method and return
# "Hello, I am Arya Stark. I am awesome" when called
print(arya.greet())

# Arya should have a `greet` method that accepts another Character
# Return "Hello, Jon Snow, I am Arya Stark. I am awesome."
print(arya.greet(jon))

# Testing adding, viewing, and removing items to inventory
arya.add_inventory("food")
print(arya.view_inventory())
arya.remove_inventory("sword")
print(arya.view_inventory())

# Hero class
bronn = Hero("Bronn of the Blackwater", "bron.png")
print(bronn.name)

# Hero should be able to greet Character
print(bronn.greet(arya))
print(jon.greet(bronn))

# Monster class
walker = Monster("White Walker")
print(walker.name)

# Hero greets Monster
jon = Hero("Jon Snow", "jon.png")
print(jon.greet(walker))

# Should print "uuuggghhhh"
Exemplo n.º 26
0
# Characters can be instantiated with name and avatar

arya = Character("Arya Stark", "arya.png")
jon = Character("Jon Snow", "jon.png")

print(arya.name, arya.avatar)
print(jon.name, jon.avatar)

# after adding 2 items to inventory
# length of inventory should == 2

arya.inventory.append('sword')
arya.inventory.append('mask')

print("there are %d items in %s's inventory" %
      (len(arya.inventory), arya.name))

# arya should have a `greet` method
# and when I call it with arya.greet(jon), it should return
# "Hello, Jon Snow, I am Arya Stark. I am awesome"

# arya should have a `greet` method
# and when I call it with arya.greet(), it should return
# "Hello, I am Arya Stark. I am awesome"

print(arya.greet(jon))
print(arya.greet())

# I should be able to create a Hero instance
bronn = Hero("Bronn of Blackwater", "bron.jng")
Exemplo n.º 27
0
 def __init__(self, scene_map):
     """Initialize the engine with the map and the hero."""
     self.scene_map = scene_map
     self.hero = Hero('Lancelot', 14)
Exemplo n.º 28
0
def main_character_creation():
    """ Create a Character"""
    char_name = input("Please enter the name of your character: ")
    character = Hero(char_name)
    return character
Exemplo n.º 29
0
jon = Character("Jon Stark", "jon.png")

print(arya.name, arya.avatar)
print(jon.name, jon.avatar)

# After adding stuff two inventory
# length of inventory should == 2

arya.inventory.append('Needle')
arya.inventory.append('Mask')

print(len(arya.inventory))

# aray should have a `greet` method
# and when called should return
# "hello, I am arya start?"
#when i call it with `arya.greet_charactor(jon)
# should return
# 'hello jon snow, i'm arya starK?`
print(arya.greet())
print(arya.greet_character(jon))
print(arya.greet_character())

#I should be able to create a `Hero` instance
bronn = Hero("Broon of the Blackwater", "bron.png")
the_night_king = Monster("The Night King", "night.png")
#Hero should be able to greet Character
print(bronn.greet_character(arya))
print(jon.greet_character(bronn))
print(the_night_king.greet_character(bronn))
Exemplo n.º 30
0
arya.inventory.append('mask')

print("Arya has %d items in her inventory" % len(arya.inventory))

# Arya should have a `greet` method
# and when I call it with `arya.greet(jon)`, it should return ""Hello, Jon Snow. I am Arya Stark. I am awesome""

print(arya.greet(jon))

# Arya should have a `greet` method
# and when I call it with `arya.greet()`, it should return ""Hello. I am Arya Stark. I am awesome""

print(arya.greet())

# I should be able to create a `Hero` instance
bronn = Hero("Bronn of the Blackwater", "bron.png")

# Hero should be able to .greet a Character
print(bronn.greet(arya))
print(jon.greet(bronn))

# I should be able to create  `Monster` instance
night_king = Monster("Night King", "night_king.png")

# Monster should be able to .greet a Character
print(bronn.greet(night_king))
print(night_king.greet(arya))

print(night_king.monster_greet(jon))

# Expect Jon to say "EEEEEEEEEK!"