Ejemplo n.º 1
0
class SpellTest(unittest.TestCase):
    def setUp(self):
        self.my_spell = Spell(name="Fireball",
                              damage=30,
                              mana_cost=50,
                              cast_range=2)

    def test_create_spell(self):
        self.assertTrue(isinstance(self.my_spell, Spell))

    def test_get_name(self):
        self.assertEqual(self.my_spell.get_name(), "Fireball")

    def test_get_damage(self):
        self.assertEqual(self.my_spell.get_damage(), 30)

    def test_get_mana_cost(self):
        self.assertEqual(self.my_spell.get_mana_cost(), 50)

    def test_get_cast_range(self):
        self.assertEqual(self.my_spell.get_cast_range(), 2)

    def test_dunder_str(self):
        self.assertEqual(str(self.my_spell), "Fireball")

    def test_dunder_repr(self):
        self.assertEqual(repr(self.my_spell), "Fireball")
Ejemplo n.º 2
0
 def __init__(self, name, manaCost, power, tough, ctype, subtype=""):
     Spell.__init__(self, name, manaCost)
     self.power = power
     self.tough = tough
     self.ctype = ctype
     self.subtype = subtype
     self.summoningSickness = True
     self.attacking = False
     self.blocking = False
Ejemplo n.º 3
0
class WeaponTest(unittest.TestCase):
    def setUp(self):
        self.spell = Spell("Abracadabra", 100, 11, 15)

    def test_damage(self):
        self.assertEqual(self.spell.get_damage(), 100)

    def test_name(self):
        self.assertEqual(self.spell.get_name(), 'Abracadabra')

    def test_mana_cost(self):
        self.assertEqual(self.spell.get_mana_cost(), 11)

    def test_cast_range(self):
        self.assertEqual(self.spell.get_cast_range(), 15)
Ejemplo n.º 4
0
 def __str__(self):
     ret = Spell.__str__(self)
     sub = ""
     if self.subtype != "":
         sub = " " + self.subtype
     ret = ret + " | Creature - %s%s | %d/%d"%(self.ctype, sub, self.power, self.tough)
     return ret
Ejemplo n.º 5
0
    def __init__(self, group_inst, callback):

        builder = gtk.Builder()
        builder.add_from_file(GLADE_GTXT)
        self.callback = callback
        self.group_doc = builder.get_object('group_text')
        self.group_title = builder.get_object('group_title')
        self.group_inst = group_inst
        self.buffer = builder.get_object('overview1').get_buffer()
        pango_font = pango.FontDescription("monospace")
        builder.get_object('overview1').modify_font(pango_font)

        self.__prj_preview = PreviewEditor(
            self.buffer, builder.get_object('scroll_webkit1'))

        self.buffer.set_text(group_inst.docs)
        self.group_title.set_text(group_inst.title)

        builder.get_object("overview1").connect("key-press-event",
                                                self.on_key_press_event)
        builder.get_object("button2").connect("button-press-event", self._save)
        builder.get_object("button3").connect("button-press-event",
                                              self._cancel)
        builder.get_object('title').set_text(group_inst.name)
        if PREVIEW_ENABLED:
            self.__prj_preview.enable()
        else:
            self.__prj_preview.disable()
        self.__spell = Spell(builder.get_object('overview1'))

        self.group_doc.connect('delete-event', self.on_delete_event)
        self.group_doc.connect('destroy-event', self.on_destroy_event)
        self.group_doc.show()
Ejemplo n.º 6
0
class QueryHandler:
    def __init__(self):
        self.sp = Spell(settings.SPELL_WORDS_NUM)
        self.index = DirectIndex(settings.DIRECT_INDEX_PATH)
        self.searcher = Searcher(os.path.join(settings.INVERSE_INDEX_DIR, "index.txt"),
                                 os.path.join(settings.INVERSE_INDEX_DIR, "dict.txt"),
                                 os.path.join(settings.INVERSE_INDEX_DIR, "urls.txt"))
        self.snippet_builder = SnippetBuilder()

    def get_search_results(self, query):
        index = self.index
        searcher = self.searcher
        query_result_ids = searcher.search(query.encode("utf-8"), return_urls_only=True)
        query_result = list()

        for url_id in query_result_ids[10]:
            record = index.record_by_id(randrange(300))
            try:
                snippet = self.snippet_builder.build_snippet(record, query.encode("utf-8"))
            except Exception as e:
                snippet = u" SnipetBuilder упал" + e.message

            query_result.append({"url": url_id[1],
                                 "snippet": snippet,
                                 "image": record.img_url,
                                 "title": record.title})
        return query_result

    def spell(self, query):
        return self.sp.spell(query)
 def setUp(self):
     self.spell = Spell(0, 200, 200, 200)
     self.caster = Character(1000, 1000, 'Horde')
     self.victime = Character(1000, 1000, 'Aliance')
     self.health_spell_on_caster = 1200
     self.mana_after_cast = 800
     self.health_spell_on_target = 800
Ejemplo n.º 8
0
 def __init__(self):
     self.sp = Spell(settings.SPELL_WORDS_NUM)
     self.index = DirectIndex(settings.DIRECT_INDEX_PATH)
     self.searcher = Searcher(os.path.join(settings.INVERSE_INDEX_DIR, "index.txt"),
                              os.path.join(settings.INVERSE_INDEX_DIR, "dict.txt"),
                              os.path.join(settings.INVERSE_INDEX_DIR, "urls.txt"))
     self.snippet_builder = SnippetBuilder()
Ejemplo n.º 9
0
class GroupDocEditor(object):
    def __init__(self, group_inst):

        builder = gtk.Builder()
        builder.add_from_file(GLADE_GTXT)
        self.group_doc = builder.get_object('group_text')
        self.group_title = builder.get_object('group_title')
        self.group_inst = group_inst
        self.buffer = builder.get_object('overview1').get_buffer()
        pango_font = pango.FontDescription("monospace")
        builder.get_object('overview1').modify_font(pango_font)

        self.__prj_preview = PreviewEditor(
            self.buffer, builder.get_object('scroll_webkit1'))

        self.buffer.set_text(group_inst.docs)
        self.group_title.set_text(group_inst.title)

        builder.get_object("button2").connect("button-press-event", self._save)
        builder.get_object("button3").connect("button-press-event",
                                              self._cancel)
        builder.get_object('title').set_text(group_inst.name)
        if PREVIEW_ENABLED:
            self.__prj_preview.enable()
        else:
            self.__prj_preview.disable()
        self.__spell = Spell(builder.get_object('overview1'))

        self.group_doc.connect('delete-event', self.on_delete_event)
        self.group_doc.connect('destroy-event', self.on_destroy_event)
        self.group_doc.show()

    def on_destroy_event(self, obj):
        self.__spell.detach()

    def on_delete_event(self, obj, event):
        self.__spell.detach()

    def _cancel(self, obj, data):
        self.group_doc.destroy()

    def _save(self, obj, data):
        self.group_inst.docs = self.buffer.get_text(
            self.buffer.get_start_iter(), self.buffer.get_end_iter(), False)
        self.group_inst.title = self.group_title.get_text()
        self.group_doc.destroy()
class TestSpell(unittest.TestCase):
    def setUp(self):
        self.spell = Spell(0, 200, 200, 200)
        self.caster = Character(1000, 1000, 'Horde')
        self.victime = Character(1000, 1000, 'Aliance')
        self.health_spell_on_caster = 1200
        self.mana_after_cast = 800
        self.health_spell_on_target = 800

    def test_spell_on_self(self):
        self.spell.cast(self.caster, self.caster)
        self.assertEqual(self.caster.health, self.health_spell_on_caster)
        self.assertEqual(self.caster.mana, self.mana_after_cast)

    def test_spell_on_victime(self):
        self.spell.cast(self.caster, self.victime)
        self.assertEqual(self.caster.mana, self.mana_after_cast)
        self.assertEqual(self.victime.health, self.health_spell_on_target)
Ejemplo n.º 11
0
 def parseList(self):
     content = urlopen(self.parseurl).read().decode()
     soup = BeautifulSoup(content, 'html.parser')
     spells = soup.find_all('input',attrs={'name':'select_sorts[]'})
     for s in spells:
         matches = re.match('^(\d+)-(.+)$', s.parent.text.strip())
         if matches:
             lvl = matches.group(1)
             name = matches.group(2).strip()
             slug = s['value'].strip().replace('\'', '')
             spell = Spell(slug, lvl, self.sPath)
             self.list.add(spell)
     
     for spell in self.list:
         try:
             spell.parseSpell()
         except:
             print('parseSpell Error: the spell '+ spell.slug +' parsing raised an Error : ', sys.exc_info()[0])
Ejemplo n.º 12
0
 def setUp(self):
     self.hero = Hero(name="Bron",
                      title="Dragonslayer",
                      health=100, mana=100,
                      mana_regeneration_rate=2)
     self.weapon = Weapon(name="The Axe of Destiny", damage=20)
     self.spell = Spell(name="Fireball",
                        damage=30,
                        mana_cost=50,
                        cast_range=2)
Ejemplo n.º 13
0
class SpellTest(unittest.TestCase):

    def setUp(self):
        self.spell = Spell("Froze", 20, 10, 3)

    def test_is_instance(self):
        self.assertTrue(isinstance(self.spell, Spell))

    def test_valid_members(self):
        self.assertEqual(self.spell.name, "Froze")
        self.assertEqual(self.spell.damage, 20)
        self.assertEqual(self.spell.mana_cost, 10)
        self.assertEqual(self.spell.cast_range, 3)

    def test_str(self):
        name = self.spell.name
        damage = self.spell.damage
        mana_cost = self.spell.mana_cost
        cast_range = self.spell.cast_range

        expected = "{} with damage: {}, mana_cost: {}, cast_range: {}"
        expected = expected.format(name, damage, mana_cost, cast_range)
        self.assertEqual(str(self.spell), expected)

    def test_get_functions(self):
        self.assertEqual(self.spell.get_name(), "Froze")
        self.assertEqual(self.spell.get_damage(), 20)
        self.assertEqual(self.spell.get_mana_cost(), 10)
        self.assertEqual(self.spell.get_cast_range(), 3)

    def test_prepare_json(self):
        data = {
            "name": "Froze",
            "damage": 20,
            "mana_cost": 10,
            "cast_range": 3
        }
        self.assertEqual(self.spell.prepare_json(), data)
Ejemplo n.º 14
0
def select_all_library_spells():
    conn = create_connection()
    cur = conn.cursor()
    cur.execute("SELECT * FROM spell_library")
    query_result = cur.fetchall()
    conn.close()
    spellList = []
    for row in query_result:
        spell = Spell(row[0], row[1], row[2], row[3], row[4], row[5], row[6],
                      row[7], row[8], row[9], row[10], row[11], row[12],
                      row[13])
        spellList.append(spell)
        # print(row)
    return spellList
Ejemplo n.º 15
0
 def __init__(self, map_file, treasure_file, enemy_file):
     with open(map_file, 'r') as f:
         self.map = f.readlines()
         self.map = [list(x[:-1]) for x in self.map]
         self.hero = None
     with open(treasure_file, 'r') as f2:
         treasure_dictionary = json.load(f2)
         self.weapons = treasure_dictionary["weapons"]
         self.weapons = [Weapon(**weapon) for weapon in self.weapons]
         self.spells = treasure_dictionary["spells"]
         self.spells = [Spell(**spell) for spell in self.spells]
     with open(enemy_file, 'r') as f3:
         enemy_dictionary = json.load(f3)
         self.enemies = [Enemy(**enemy) for enemy in enemy_dictionary["enemies"]]
Ejemplo n.º 16
0
    def test_hero_attack(self):
        w = Weapon('noj', 20)
        self.hero.equip(w)
        self.hero.attack(by='weapon')
        self.assertTrue(self.hero.can_attack())
        self.assertEqual(self.hero.damage,
                         self.hero.phisical_damage + self.hero.damage)

        s = Spell("BatkaAttack", 30, 50, 2)
        self.hero.learn(s)
        self.hero.attack(by='magic')
        self.assertEqual(self.hero.damage, self.hero.magic_damage)

        self.hero.attack(by='RKO')
        self.assertRaises(Exception)
Ejemplo n.º 17
0
 def test_hero_move_with_as_and_learned_spell_should_return_true_and_as(
         self):
     h = Hero(name="Bron",
              title="Dragonslayer",
              health=100,
              mana=100,
              mana_regeneration_rate=2)
     s = Spell('fireball', 25, 15, 3)
     h.learn(s)
     enemy = Enemy(health=100, mana=40, damage=60)
     enemy.x = 3
     enemy.y = 3
     fight = Fight(enemy)
     status = fight.hero_move(h, 'as')
     self.assertTrue(status)
Ejemplo n.º 18
0
 def test_hero_move_with_as_and_learned_spell_but_not_enough_mana_should_return_false_and_not_enough_mana(
         self):
     h = Hero(name="Bron",
              title="Dragonslayer",
              health=100,
              mana=50,
              mana_regeneration_rate=2)
     enemy = Enemy(health=100, mana=40, damage=60)
     spell = Spell(name='Test Magiq', damage=40, mana_cost=60, cast_range=1)
     enemy.x = 3
     enemy.y = 3
     h.learn(spell)
     fight = Fight(enemy)
     status, error = fight.hero_move(h, 'as')
     self.assertFalse(status)
     self.assertEqual(error, 'not enough mana')
Ejemplo n.º 19
0
 def __init__(self, game, tx, ty, group):
   super().__init__(game, tx, ty, group, True)
   for i in range(2):
     self.init_sprite('character_d_'+str(i)+'.png', group)
   self.particle_hitbox = (2,-1,14,16)
   self.hitbox = (0,0,7,3)
   self.target_min_dist = 1.5
   self.target_max_dist = 4
   self.health = 8
   self.attack_dt = 1.6
   self.speed = random.random() * 0.4 + 0.3
   self.attack_period = 1.2
   self.anim_dead = 0
   self.target = self.game.world.character
   self.override_enemy = True
   self.spells = [Spell(game, i) for i in list(Spell.TYPE.keys())]
Ejemplo n.º 20
0
 def test_enemy_move_with_same_x_level_as_hero_and_y_in_range_to_attack_with_spell_should_reduce_hero_health(
         self):
     h = Hero(name="Bron",
              title="Dragonslayer",
              health=100,
              mana=100,
              mana_regeneration_rate=2)
     s = Spell('fireball', damage=45, mana_cost=15, cast_range=3)
     enemy = Enemy(health=100, mana=40, damage=20)
     enemy.x = 3
     enemy.y = 2
     enemy.learn(s)
     fight = Fight(enemy)
     h.x = 3
     h.y = 3
     fight.enemy_move(h)
     self.assertEqual(h.health, 55)
Ejemplo n.º 21
0
 def get_treasure(cls, treasure):  # treasure is the treasure as string
     kind = treasure.split(':')[0].rstrip(
         ' ')  # ':' splits the kind of treasure and it's description
     descr = treasure.split(':')[1]
     if kind == "weapon":
         from weapon import Weapon
         return Weapon.create_weapon(descr)
     if kind == "spell":
         from spell import Spell
         return Spell.create_spell(descr)
     elif kind == "mana":
         from mana import Mana
         return Mana(int(descr))
     elif kind == "health":
         from health import Health
         return Health(int(descr))
     else:
         raise ValueError("Not correct kind of treasure.")
Ejemplo n.º 22
0
    def hero_attack(self, by):
        if by == "spell":
            if Spell.in_range():
                if Hero.can_cast() == True and self.fattack == True:
                    self.fattack = False  # след боя трябва да стане пак True
                    print(self.msg1)
                    Enemies(take_damege())
                    # Трябва да се добави боя
                elif Hero.can_cast():
                    # Трябва да се добави боя
                else:
                    return self.hero_attack("weapon")  # Май така беше да се испълни функцията

            else:
                print("Nothing in casting range {}".format(self.cast_range))
        if by == "weapon":
            # Трябва да се добави боя
            pass
Ejemplo n.º 23
0
 def test_enemy_with_same_x_as_hero_and_y_in_range_to_attack_choose_normal_attack_reduces_hero_health_2(
         self):
     # test with spell only and enemy dmg > spell dmg
     h = Hero(name="Bron",
              title="Dragonslayer",
              health=100,
              mana=100,
              mana_regeneration_rate=2)
     enemy = Enemy(health=100, mana=40, damage=60)
     enemy.x = 3
     enemy.y = 2
     s = Spell('fireball', damage=45, mana_cost=15, cast_range=3)
     enemy.learn(s)
     fight = Fight(enemy)
     h.x = 3
     h.y = 3
     fight.enemy_move(h)
     self.assertEqual(h.health, 40)
Ejemplo n.º 24
0
 def test_enemy_move_with_same_x_as_hero_and_y_in_range_to_attack_choose_spell_not_weapon_reduces_hero_health(
         self):
     h = Hero(name="Bron",
              title="Dragonslayer",
              health=100,
              mana=100,
              mana_regeneration_rate=2)
     s = Spell('fireball', damage=55, mana_cost=15, cast_range=3)
     enemy = Enemy(health=100, mana=40, damage=20)
     weapon = Weapon(name='Pruchka', damage=50)
     enemy.x = 3
     enemy.y = 2
     enemy.learn(s)
     enemy.equip(weapon)
     fight = Fight(enemy)
     h.x = 3
     h.y = 3
     fight.enemy_move(h)
     self.assertEqual(h.health, 45)
Ejemplo n.º 25
0
def test_from_engl393_ritual_end():
    test_info = {
        'level_and_type': "1st-level divination (Ritual)",
        'cast_time': "1 action",
        'range': "10 feet",
        'components': "V, S",
        'duration': "30 minutes",
        'descr_n': "This is my description",
    }
    spell = Spell.from_engl393("testName", test_info)
    assert spell.Level == 1
    assert spell.School == "Divination"
    assert spell.CastTime == "1 action"
    assert spell.Range == "10 feet"
    assert spell.Components == ['V', 'S']
    assert spell.Duration == "30 minutes"
    assert spell.Description == "This is my description"
    assert spell.AtHigherLevels == ""
    assert spell.Ritual == True
Ejemplo n.º 26
0
 def test_enemy_with_same_y_as_hero_and_x_in_range_to_attack_choose_normal_attack_reduces_hero_health_5(
         self):
     # test with weapon and spell and enemy dmg > spell dmg > weapon dmg
     h = Hero(name="Bron",
              title="Dragonslayer",
              health=100,
              mana=100,
              mana_regeneration_rate=2)
     enemy = Enemy(health=100, mana=40, damage=60)
     enemy.x = 2
     enemy.y = 3
     weapon = Weapon(name='Pruchka', damage=50)
     s = Spell('fireball', damage=45, mana_cost=15, cast_range=3)
     enemy.learn(s)
     enemy.equip(weapon)
     fight = Fight(enemy)
     h.x = 3
     h.y = 3
     fight.enemy_move(h)
     self.assertEqual(h.health, 40)
Ejemplo n.º 27
0
 def test_enemy_with_bigger_weapon_dmg_and_not_enough_range_should_change_x_to_hero(
         self):
     # hero is on the right side of enemy and in the same y level
     h = Hero(name="Bron",
              title="Dragonslayer",
              health=100,
              mana=100,
              mana_regeneration_rate=2)
     enemy = Enemy(health=100, mana=40, damage=20)
     enemy.x = 1
     enemy.y = 3
     weapon = Weapon(name='Pruchka', damage=50)
     s = Spell('fireball', damage=45, mana_cost=15, cast_range=1)
     enemy.learn(s)
     enemy.equip(weapon)
     fight = Fight(enemy)
     h.x = 3
     h.y = 3
     fight.enemy_move(h)
     self.assertEqual(enemy.x, 2)
Ejemplo n.º 28
0
 def test_enemy_with_bigger_basic_dmg_and_not_enough_range_should_change_y_to_hero_2(
         self):
     # hero is on the same x as enemy but on higher y level
     h = Hero(name="Bron",
              title="Dragonslayer",
              health=100,
              mana=100,
              mana_regeneration_rate=2)
     enemy = Enemy(health=100, mana=40, damage=20)
     enemy.x = 3
     enemy.y = 5
     weapon = Weapon(name='Pruchka', damage=0)
     s = Spell('fireball', damage=0, mana_cost=15, cast_range=1)
     enemy.learn(s)
     enemy.equip(weapon)
     fight = Fight(enemy)
     h.x = 3
     h.y = 3
     fight.enemy_move(h)
     self.assertEqual(enemy.y, 4)
Ejemplo n.º 29
0
    def get_random_treasure(creature):
        treasure_types = ["health", "mana", "weapon", "spell"]
        random_treasure = random.choice(treasure_types)

        if random_treasure == "health":
            health_treasure = random.randint(-10, creature.max_health)
            creature.take_healing(health_treasure)

            if creature.health == 0:
                message = "Found potion with {} health. Our hero is dead!"
                message = message.format(health_treasure)
                print(message)
            elif creature.health != 0:
                message = "Found potion with {} health. Now health is {}"
                message = message.format(health_treasure, creature.health)
                print(message)

        elif random_treasure == "mana":
            mana_treasure = random.randint(-10, creature.max_mana)
            creature.take_mana(mana_treasure)

            if creature.mana == 0:
                message = "Found potion with {} mana. Our hero have not mana!"
                message = message.format(mana_treasure)
                print(message)
            elif creature.mana != 0:
                message = "Found potion with {} mana. Now mana is {}"
                message = message.format(mana_treasure, creature.mana)
                print(message)

        elif random_treasure == "weapon":
            weapon_treasure = Weapon.load("weapons.json")
            creature.equip(weapon_treasure)
            print("Our hero equipped: {}".format(str(weapon_treasure)))

        elif random_treasure == "spell":
            spell_treasure = Spell.load("spells.json")
            creature.equip(spell_treasure)
            print("Our hero equipped: {}".format(str(spell_treasure)))
Ejemplo n.º 30
0
def play_game():
    battle_map = Dungeon(map_file="level1.txt",
                         treasure_file="treasures_file.json",
                         enemy_file="enemies.json")
    hero_name = input('ENTER YOUR BATTLE NAME: ')
    hero_title = input('ENTER YOUR TITLE: ')
    hero = Hero(name=hero_name,
                title=hero_title,
                health=100,
                mana=50,
                mana_regeneration_rate=5)
    name = hero.known_as()
    print(
        'Welcome {} to level1. Wish you luck, you will need it!'.format(name))
    start_weapon = Weapon(name='Pruchka', damage=25)
    start_spell = Spell(name='Vqtur', damage=30, mana_cost=35, cast_range=2)
    hero.equip(start_weapon)
    hero.learn(start_spell)
    battle_map.spawn(hero)
    battle_map.print_map()
    print(colored('TUTORIAL', 'cyan', attrs=['bold']))
    commands()
    print(colored('To see the commands use "help"', 'cyan', attrs=['bold']))
    game_cycle_level(battle_map, hero)

    if hero.is_alive() is False:
        return 0
    start_level2 = input('Do you want to play on level2? [y/n] ').lower()

    if start_level2[0] == 'y':
        battle_map = Dungeon(map_file="level2.txt",
                             treasure_file="treasures_file.json",
                             enemy_file="enemies.json")
        battle_map.spawn(hero)
        battle_map.print_map()
        game_cycle_level(battle_map, hero)
        print('GOOD JOB! YOU BEAT THE WHOLE GAME!')
    else:
        print('Ha,ha,ha. You are a coward')
Ejemplo n.º 31
0
class Player:
    def __init__(self, renderer, factory):

        self.renderer = renderer
        self.factory = factory

        self.sprite_size = 128

        x = int((WindowSize.WIDTH / 2) - (self.sprite_size / 2))
        y = int((WindowSize.HEIGHT / 2) - (self.sprite_size / 2))

        self.sprite_position = x, y

        self.player_sprites = [
            RESOURCES.get_path("player_standing.png"),
            RESOURCES.get_path("player_walking.png"),
            RESOURCES.get_path("player_casting.png")
        ]

        self.sprite_sheets = {}
        self.sprites = []

        self.facing = Facing.LEFT_DOWN
        self.last_facing = self.facing

        self.motion_type = MotionType.STANDING
        self.last_motion_type = self.motion_type

        self.frame_index = 0

        self.player_pos = [0, 0]

        self.init_sprite_sheet()
        self.spell = None
        self.spell_max_life = 100
        self.spell_life = 0

        self.inventory = None

    def init_sprite_sheet(self):

        for motion_type in range(MotionType.COUNT):
            self.loads_image(self.player_sprites[motion_type], motion_type)

    def loads_image(self, file_path, motion_type):
        sprite_sheets = self.sprite_sheets.get(file_path)
        if not sprite_sheets:
            sprite_surface = self.factory.from_image(file_path)
            self.sprite_sheets[motion_type] = sprite_surface

    def update(self, motion_type, facing, elapsed_time):
        self.sprites.clear()
        self.motion_type = motion_type
        self.facing = facing

        if (self.motion_type
                == MotionType.CASTING) and (self.frame_index >= 29):
            if not self.spell_life:
                self.spell_life = self.spell_max_life
                self.spell = Spell(self.renderer, self.factory, "fireball",
                                   self.facing)
        else:
            self.frame_index += 1

        if self.spell_life:
            self.spell_life -= 1
            self.spell.update(elapsed_time)
            self.sprites.append(self.spell.get_sprite())
        else:
            self.spell = None

        if self.inventory:
            self.inventory.update(elapsed_time)
            self.inventory.draw()

        if (self.facing != self.last_facing) or (self.motion_type !=
                                                 self.last_motion_type):
            self.frame_index = 0

        if self.frame_index == (self.sprite_sheets[self.motion_type].size[0] /
                                self.sprite_size):
            self.frame_index = 0

        self.last_facing = self.facing
        self.last_motion_type = self.motion_type

        sprite_sheet = self.sprite_sheets[self.motion_type]

        sprite_crop = [
            self.frame_index * self.sprite_size,
            self.facing * self.sprite_size, self.sprite_size, self.sprite_size
        ]

        sprite = sprite_sheet.subsprite(sprite_crop)
        sprite.position = self.sprite_position
        self.sprites.append(sprite)
        """
        renderer = self.renderer

        src_rect = SDL_Rect()

        src_rect.x = frame_index * sprite_size
        src_rect.y = facing * sprite_size
        src_rect.w = sprite_size
        src_rect.h = sprite_size

        dest_rect = SDL_Rect()

        dest_rect.x = int((WindowSize.WIDTH / 2) - (sprite_size / 2))
        dest_rect.y = int((WindowSize.HEIGHT / 2) - (sprite_size / 2))
        dest_rect.w = sprite_size
        dest_rect.h = sprite_size

        SDL_RenderCopy(renderer, sprite.texture, src_rect, dest_rect)
        """

    def toggle_inventory(self):
        if self.inventory:
            self.inventory = None
        else:
            renderer = self.renderer
            self.inventory = Inventory(renderer)

    def get_sprites(self):
        return self.sprites
Ejemplo n.º 32
0
 def castSpell(self, rx, ry, color):
     direction = vecFromDirection(self.getDirection())
     x, y = (self.pos.x + self.gfx.rect.width / 2,
             self.pos.y + self.gfx.rect.height / 2)
     self.castedSpells.append(Spell(x, y, rx, ry, direction, color))
Ejemplo n.º 33
0
class FightTests(unittest.TestCase):
    def setUp(self):
        self.spell = Spell(name="Fireball",
                           damage=5,
                           mana_cost=20,
                           cast_range=1)
        self.weapon = Weapon(name="The Axe of Destiny", damage=10)
        self.hero = Hero(name="Bron",
                         title="Dragonslayer",
                         health=100,
                         mana=100,
                         mana_regeneration_rate=2)
        self.map = [['.', '.', '#', '#', '.', 'S', '.', '.', '.', 'T'],
                    ['#', 'T', '#', '#', '.', '.', '#', '#', '#', '.'],
                    ['#', '.', '#', '#', '#', 'E', '#', '#', '#', 'E'],
                    ['#', '.', 'E', '.', '.', '.', '#', '#', '#', '.'],
                    ['#', '#', '#', 'T', '#', 'T', '#', '#', '#', 'G']]

        self.enemies = {
            "2,5": {
                "damage": 10,
                "health": 40,
                "mana": 20,
                "weapon": None,
                "spell": self.spell.to_json()
            },
            "2,9": {
                "damage": 10,
                "health": 40,
                "mana": 20,
                "weapon": self.weapon.to_json(),
                "spell": None
            },
            "3,2": {
                "damage": 10,
                "health": 40,
                "mana": 20,
                "weapon": None,
                "spell": None
            }
        }

        self.treasures = {
            "1,1": {
                "class": "Potion",
                "type": "mana",
                "amount": 50
            },
            "0,9": {
                "class": "Potion",
                "type": "health",
                "amount": 50
            },
            "4,3": {
                "class": "Weapon",
                "name": "The Axe of Destiny",
                "damage": 10
            },
            "4,5": {
                'class': "Spell",
                'name': 'Fireball',
                'damage': 5,
                'mana_cost': 20,
                'cast_range': 1
            }
        }

        self.json_data = {
            "map": self.map,
            "enemies": self.enemies,
            "treasures": self.treasures
        }

        self.dungeon = Dungeon(self.json_data)
        self.dungeon.spawn(self.hero)

        self.fight = Fight(dungeon=self.dungeon, enemy_pos=(2, 5))

    def test_init_initializing_correctly(self):
        self.assertEqual(self.fight.dungeon, self.dungeon)
        self.assertEqual(self.fight.enemy,
                         Enemy.from_json(self.enemies['2,5']))
        self.assertEqual(self.fight.enemy_pos, (2, 5))

    def test_init_raises_Assertion_error_when_there_is_no_enemy_on_the_given_pos(
            self):
        with self.assertRaises(AssertionError):
            Fight(dungeon=self.dungeon, enemy_pos=(0, 1))

    def test__range_between(self):
        self.assertEqual(self.fight._range_between(), 2)

    def test__direction_to_enemy_without_arguments(self):
        with self.subTest('Hero is up from enemy'):
            self.assertEqual(self.fight._direction_to_enemy(), (1, 0))

        with self.subTest('Hero is down from enemy'):
            self.fight.dungeon._hero_pos = (3, 5)

            self.assertEqual(self.fight._direction_to_enemy(), (-1, 0))

    def test__direction_to_enemy_with_argument(self):
        self.fight.enemy_pos = (3, 2)
        with self.subTest('Hero is left from enemy'):
            self.fight.dungeon._hero_pos = (3, 1)
            self.assertEqual(self.fight._direction_to_enemy(False), (0, 1))

        with self.subTest('Hero is right from enemy'):
            self.fight.dungeon._hero_pos = (3, 5)

            self.assertEqual(self.fight._direction_to_enemy(False), (0, -3))

    def test_hero_move_moves_hero_on_the_map_towards_enemy(self):
        self.fight.hero_move()

        self.assertEqual(self.fight.dungeon._map[1][5], self.hero)

    def test_enemy_move_moves_enemy_on_the_map_towards_hero(self):
        self.fight.enemy_move()

        self.assertEqual(self.fight.dungeon._map[1][5], self.fight.enemy)
        self.assertEqual(self.fight.enemy_pos, (1, 5))

    def test_player_makes_move_one_of_the_players_move_when_hero_has_to_move(
            self):
        self.fight.player_makes_move(self.dungeon._hero)

        self.assertEqual(self.fight.dungeon._map[1][5], self.hero)

    def test_player_makes_move_one_of_the_players_move_when_enemy_has_to_move(
            self):
        self.fight.player_makes_move(self.fight.enemy)

        self.assertEqual(self.fight.dungeon._map[1][5], self.fight.enemy)

    def test_player_makes_move_hero_attacks(self):
        self.fight.dungeon._hero.learn(self.spell)
        self.fight.enemy_move()
        self.fight.player_makes_move(self.fight.dungeon._hero)

        self.assertEqual(self.fight.enemy.get_health(), 35)

    def test_player_makes_move_enemy_attacks(self):
        self.fight.hero_move()
        self.fight.player_makes_move(self.fight.enemy)

        self.assertEqual(self.fight.dungeon._hero.get_health(), 85)

    def test_fight(self):
        spell = Spell(name="Fireball", damage=20, mana_cost=4, cast_range=1)
        self.fight.dungeon._hero.learn(spell)
        print()
        self.fight.dungeon.print_map()
        self.fight.fight()

        self.assertEqual(self.fight.dungeon._hero.get_health(), 85)
        self.assertEqual(self.fight.dungeon._hero_pos, (1, 5))
        self.assertFalse(self.fight.enemy.is_alive())

    def test_fight_hero_is_dead(self):
        self.hero._health = 10
        with self.assertRaises(HeroIsDeadError):
            self.fight.fight()
Ejemplo n.º 34
0
    def setUp(self):
        self.spell = Spell(name="Fireball",
                           damage=5,
                           mana_cost=20,
                           cast_range=1)
        self.weapon = Weapon(name="The Axe of Destiny", damage=10)
        self.hero = Hero(name="Bron",
                         title="Dragonslayer",
                         health=100,
                         mana=100,
                         mana_regeneration_rate=2)
        self.map = [['.', '.', '#', '#', '.', 'S', '.', '.', '.', 'T'],
                    ['#', 'T', '#', '#', '.', '.', '#', '#', '#', '.'],
                    ['#', '.', '#', '#', '#', 'E', '#', '#', '#', 'E'],
                    ['#', '.', 'E', '.', '.', '.', '#', '#', '#', '.'],
                    ['#', '#', '#', 'T', '#', 'T', '#', '#', '#', 'G']]

        self.enemies = {
            "2,5": {
                "damage": 10,
                "health": 40,
                "mana": 20,
                "weapon": None,
                "spell": self.spell.to_json()
            },
            "2,9": {
                "damage": 10,
                "health": 40,
                "mana": 20,
                "weapon": self.weapon.to_json(),
                "spell": None
            },
            "3,2": {
                "damage": 10,
                "health": 40,
                "mana": 20,
                "weapon": None,
                "spell": None
            }
        }

        self.treasures = {
            "1,1": {
                "class": "Potion",
                "type": "mana",
                "amount": 50
            },
            "0,9": {
                "class": "Potion",
                "type": "health",
                "amount": 50
            },
            "4,3": {
                "class": "Weapon",
                "name": "The Axe of Destiny",
                "damage": 10
            },
            "4,5": {
                'class': "Spell",
                'name': 'Fireball',
                'damage': 5,
                'mana_cost': 20,
                'cast_range': 1
            }
        }

        self.json_data = {
            "map": self.map,
            "enemies": self.enemies,
            "treasures": self.treasures
        }

        self.dungeon = Dungeon(self.json_data)
        self.dungeon.spawn(self.hero)

        self.fight = Fight(dungeon=self.dungeon, enemy_pos=(2, 5))
Ejemplo n.º 35
0
class EnemyTests(unittest.TestCase):
    def setUp(self):
        self.e = Enemy(health=100, mana=100, damage=50)
        self.w = Weapon(name='The Axe of Destiny', damage=20)
        self.s = Spell(name='Fireball', damage=30, mana_cost=60, cast_range=2)

        self.e.equip(self.w)
        self.e.learn(self.s)

    def test_can_cast(self):
        self.assertTrue(self.e.can_cast())
        self.e._mana = 29
        self.assertFalse(self.e.can_cast())

    def test_attack(self):
        self.assertEqual(self.e.attack(by='weapon'), 70)
        self.assertEqual(self.e.attack(by='spell'), 80)
        with self.assertRaises(NotEnoughManaError):
            self.e.attack(by='spell')

    def test_take_mana(self):
        self.assertFalse(self.e.take_mana())

    def test_eq_returns_false_when_enemy1_super_different_than_enemy2_super(self):
        enemy1 = Enemy(health=100, mana=100, damage=50)
        enemy2 = Enemy(health=200, mana=100, damage=50)

        self.assertNotEqual(enemy1, enemy2)

    def test_eq_returns_false_when_enemy1_damage_different_than_enemy2_damage(self):
        enemy1 = Enemy(health=100, mana=100, damage=50)
        enemy2 = Enemy(health=100, mana=100, damage=75)

        self.assertNotEqual(enemy1, enemy2)

    def test_eq_returns_true_when_supers_are_equal_and_damages_are_equal(self):
        enemy1 = Enemy(health=100, mana=100, damage=50)
        enemy2 = Enemy(health=100, mana=100, damage=50)

        self.assertEqual(enemy1, enemy2)

    def test_to_json(self):
        expected = {
            'damage': 50,
            'health': 100,
            'mana': 100,
            'weapon': self.w.to_json(),
            'spell': self.s.to_json()
        }

        self.assertDictEqual(self.e.to_json(), expected)

    def test_from_json(self):
        json_dict = {
            'damage': 50,
            'health': 100,
            'mana': 100,
            'weapon': self.w.to_json(),
            'spell': self.s.to_json()
        }

        self.assertEqual(self.e, Enemy.from_json(json_dict))
Ejemplo n.º 36
0
class TestsHero(unittest.TestCase):
    def setUp(self):
        self.hero1 = Hero(
            name='Toni',
            title='Pythonslayer',
            health=250,
            mana=1000,
            mana_regeneration_rate=25,
        )

        self.hero2 = Hero(name="Bron",
                          title="Dragonslayer",
                          health=100,
                          mana=100,
                          mana_regeneration_rate=2)

        self.spell = Spell(name="Fireball",
                           damage=30,
                           mana_cost=110,
                           cast_range=2)
        self.weapon = Weapon(name="The Axe of Destiny", damage=20)

    def test_init_working_correctly(self):
        with self.subTest('hero1'):
            self.assertEqual(self.hero1._name, 'Toni')
            self.assertEqual(self.hero1._title, 'Pythonslayer')
            self.assertEqual(self.hero1._health, 250)
            self.assertEqual(self.hero1._max_health, 250)
            self.assertEqual(self.hero1._mana, 1000)
            self.assertEqual(self.hero1._max_mana, 1000)
            self.assertEqual(self.hero1._mana_regeneration_rate, 25)
            self.assertEqual(self.hero1._weapon, None)
            self.assertEqual(self.hero1._spell, None)

    def test_known_as(self):
        with self.subTest('hero1'):
            self.assertEqual(self.hero1.known_as(), 'Toni the Pythonslayer')

        with self.subTest('hero2'):
            self.assertEqual(self.hero2.known_as(), 'Bron the Dragonslayer')

    def test_can_cast(self):
        with self.subTest('spell is None'):
            self.assertFalse(self.hero1.can_cast())

        with self.subTest('when mana is not enough'):
            self.hero2._spell = self.spell

            self.assertFalse(self.hero2.can_cast())

        with self.subTest('when mana is not enough'):
            self.hero1._spell = self.spell

            self.assertTrue(self.hero1.can_cast())

    def test_attack_raises_exceptions_correctly(self):
        with self.subTest('when by == weapon and hero\'s weapon is None'):
            with self.assertRaises(NotEquippedError):
                self.hero1.attack(by='weapon')

        with self.subTest('when by == spell and hero\'s spell is None'):
            with self.assertRaises(NotEquippedError):
                self.hero1.attack(by='spell')

        with self.subTest('when by is not \'weapon\' or \'spell\''):
            with self.assertRaises(TypeError):
                self.hero1.attack(by='foot')

        with self.subTest('when spell costs more then current mana'):
            with self.assertRaises(NotEnoughManaError):
                self.hero1.learn(self.spell)
                for x in range(0, 20):
                    self.hero1.attack(by='spell')

    def test_attack_returns_correct_damage(self):
        with self.subTest('\'by\' == \'spell\''):
            self.hero1._spell = self.spell
            damage = self.hero1.attack(by='spell')

            self.assertEqual(damage, 30)
            self.assertEqual(self.hero1._mana, 890)

        with self.subTest('\'by\' == \'weapon\''):
            self.hero2._weapon = self.weapon
            damage = self.hero2.attack(by='weapon')

            self.assertEqual(damage, 20)

    def test_eq_returns_false_when_hero1_super_different_than_hero2_super(
            self):
        hero3 = Hero(name="Bron",
                     title="Dragonslayer",
                     health=100,
                     mana=100,
                     mana_regeneration_rate=2)

        hero3.learn(self.spell)

        self.assertNotEqual(self.hero2, hero3)

    def test_eq_returns_false_when_hero1_has_different_attr_than_hero2_super(
            self):
        hero3 = Hero(name="Toni",
                     title="Dragonslayer",
                     health=100,
                     mana=100,
                     mana_regeneration_rate=2)

        self.assertNotEqual(self.hero2, hero3)

    def test_eq_returns_true_when_super_and_all_attrs_are_the_same(self):
        hero3 = Hero(name="Bron",
                     title="Dragonslayer",
                     health=100,
                     mana=100,
                     mana_regeneration_rate=2)

        self.assertEqual(self.hero2, hero3)

    def test_to_json(self):
        self.hero1.learn(self.spell)
        expected = {
            'name': 'Toni',
            'title': 'Pythonslayer',
            'mana_regeneration_rate': 25,
            'health': 250,
            'mana': 1000,
            'weapon': None,
            'spell': self.spell.to_json()
        }

        self.assertDictEqual(self.hero1.to_json(), expected)

    def test_from_json(self):
        self.hero1.equip(self.weapon)
        json_dict = {
            'name': 'Toni',
            'title': 'Pythonslayer',
            'mana_regeneration_rate': 25,
            'health': 250,
            'mana': 1000,
            'weapon': self.weapon.to_json(),
            'spell': None
        }

        self.assertEqual(self.hero1, Hero.from_json(json_dict))
Ejemplo n.º 37
0
 def setUp(self):
     self.spell = Spell("Froze", 20, 10, 3)
Ejemplo n.º 38
0
	def __init__(self, showbase):
		self.showbase=showbase
		
		self.ready=False
		
		self.showbase.num_warlocks=1
		self.showbase.which=0
		
		# this will have its own chat i guess, just game server only (no channels or anything just the one chat, all to all)
		# also i guess all the players data (usernames, maybe others) will need to be collected here from the server for the chat/scoreboard/whatever
		# and whenever a new person joins/leaves an update will be sent to all the clients (like with the all chat i guess)
		# these will need to be created in here from data passed from the server (where it will be procedurally generated)
		
		# once it receives a 'preround' state change it should create all the required shit (warlocks per person and the Game() class and whatnot)
		# then client will switch to preround state
		
		# spell0
		spell0=Spell()
		
		spell0.damage=10
		spell0.target_knockback=20
		spell0.self_knockback=0
		spell0.range=25
		spell0.speed=15
		spell0.aoe=False
		spell0.aoe_range=0
		spell0.targeting=False
		spell0.casting_time=0
		spell0.interruptable=False
		spell0.model="media/spells/blockyball"
		
		# spell1
		spell1=Spell()
		
		spell1.damage=25
		spell1.target_knockback=10
		spell1.self_knockback=0
		spell1.range=50
		spell1.speed=25
		spell1.aoe=False
		spell1.aoe_range=0
		spell1.targeting=False
		spell1.casting_time=0
		spell1.interruptable=False
		spell1.model="media/spells/pointyball"
		
		# spell2
		spell2=Spell()
		
		spell2.damage=50
		spell2.target_knockback=10
		spell2.self_knockback=30
		spell2.range=50
		spell2.speed=15
		spell2.aoe=False
		spell2.aoe_range=0
		spell2.targeting=False
		spell2.casting_time=0
		spell2.interruptable=False
		spell2.model="media/spells/blockyball"
		
		# spell3
		spell3=Spell()
		
		spell3.model="media/spells/pointyball"
		
		showbase.spells=[]
		showbase.spells.append(spell0)
		showbase.spells.append(spell1)
		showbase.spells.append(spell2)
		showbase.spells.append(spell3)
		
		self.background = OnscreenImage(
			image  = 'media/gui/lobby/lobby.png',
			parent = render2d
		)
		
		# Send Message Button
		self.send_button = DirectButton(
			command   = self.send_message,
			frameSize = (-3, 3, -.5, 1),
			pos       = (0.0, 0.0, .3),
			scale     = .1,
			text      = "Send",
		)
		# Text box for message entry
		self.entry = DirectEntry(
			focusInCommand = self.clearText,
			frameSize   = (-3, 3, -.5, 1),
			initialText = "Chat:",
			parent      = self.send_button,
			pos         = (0, 0, -1.5),
			text        = "" ,
			text_align  = TextNode.ACenter,
		)
		# button to tell server client is ready
		self.ready_button = DirectButton(
			command   = self.toggle_ready,
			frameSize = (-3, 3, -.5, 1),
			pos       = (0.0, 0.0, -.3),
			scale     = .1,
			text      = "Ready?",
		)
		# button to tell server client is not ready
		self.unready_button = DirectButton(
			command   = self.toggle_unready,
			frameSize = (-3, 3, -.5, 1),
			pos       = (0.0, 0.0, -.3),
			scale     = .1,
			text      = "Unready?",
		)
		# hide unready button until ready
		self.unready_button.hide()
		
		# button to quit game
		self.quit_button = DirectButton(
			command   = showbase.quit,
			frameSize = (-4,-1,0,0),#-3, 3, -.5, 1),
			pos       = (-1.0, 0.0, -1.0),
			scale     = .1,
			text      = "QUIT!",
		)
		
		# Add the game loop procedure to the task manager.
		taskMgr.doMethodLater(1.0, self.update_lobby, 'Update Lobby')
Ejemplo n.º 39
0
    def __init__(self, dbase, register, bit_field, modified, top_builder):
        self.__db = dbase
        self.__modified = modified
        self.__register = register
        self.__bit_field = bit_field
        self.__builder = gtk.Builder()
        self.__top_builder = top_builder
        self.__builder.add_from_file(GLADE_BIT)
        self.__top_window = self.__builder.get_object("editfield")
        self.__control_obj = self.__builder.get_object('control')
        self.__name_obj = self.__builder.get_object("field_name")
        self.__register_obj = self.__builder.get_object("register_name")
        self.__output_obj = self.__builder.get_object("output")
        self.__type_obj = self.__builder.get_object('type')
        self.__input_obj = self.__builder.get_object("input")
        self.__reset_obj = self.__builder.get_object("reset_value")
        self.__static_obj = self.__builder.get_object('static')
        self.__text_buffer = self.__builder.get_object("descr").get_buffer()
        self.__value_tree_obj = self.__builder.get_object('values')
        self.__output_enable_obj = self.__builder.get_object("outen")
        self.__side_effect_obj = self.__builder.get_object("side_effect")
        self.__verilog_obj = self.__builder.get_object('verilog_code')
        self.__volatile_obj = self.__builder.get_object('volatile')
        self.__col = None
        self.__top_window.set_title(
            "Edit Bit Field - [%02x] %s" % (register.address,
                                            register.register_name))

        self.__spell = Spell(self.__builder.get_object("descr"))

        self.__top_window.set_icon_from_file(
            os.path.join(INSTALL_PATH, "media", "flop.svg"))
        (input_enb, control_enb) = TYPE_TO_ENABLE[bit_field.field_type]
        self.__input_obj.set_sensitive(input_enb)
        self.__control_obj.set_sensitive(control_enb)

        pango_font = pango.FontDescription("monospace")
        self.__builder.get_object("descr").modify_font(pango_font)

        self.build_values_list()

        self.__list_model = gtk.ListStore(str, str, str)
        self.__model_selection = self.__value_tree_obj.get_selection()
        self.__value_tree_obj.set_model(self.__list_model)

        self.__used_tokens = set()
        for value in self.__bit_field.values:
            self.__used_tokens.add(value[1])
            self.__list_model.append(row=value)

        self.__initialize_from_data(bit_field)
        self.__output_obj.set_sensitive(self.__output_enable_obj.get_active())
        self.__check_data()

        self.__text_buffer.connect('changed', self.__description_changed)

        try:
            edge = "posedge" if self.__db.reset_active_level else "negedge"
            condition = "" if self.__db.reset_active_level else "~"
            be_level = "" if self.__db.byte_strobe_active_level else "~"

            name_map = {'MODULE': self.__db.module_name,
                        'BE_LEVEL': be_level,
                        'RESET_CONDITION': condition,
                        'RESET_EDGE': edge }
            text = REG[TYPE_TO_ID[bit_field.field_type].lower()] % name_map
        except KeyError:
            text = ""

        if USE_HIGHLIGHT:
            buff = CodeBuffer(lang=SyntaxLoader("verilog"))
            self.__verilog_obj.set_buffer(buff)
        else:
            self.__verilog_obj.modify_font(pango_font)
            buff = self.__verilog_obj.get_buffer()

        buff.set_text(text)
        self.__builder.connect_signals(self)
        self.__top_window.show_all()
Ejemplo n.º 40
0
	def preround_loop(self,task):
		print "Preround State"
		self.game_time=0
		self.tick=0
		self.showbase.num_warlocks=len(self.users)
		
		# i guess this shit should be in the pregame part, so people can choose their spells based of these
		# also it will need to be created in there from data passed from the server (where it will be procedurally generated)
		# spell0
		spell0=Spell()
		
		spell0.damage=10
		spell0.target_knockback=20
		spell0.self_knockback=0
		spell0.range=25
		spell0.speed=15
		spell0.aoe=False
		spell0.aoe_range=0
		spell0.targeting=False
		spell0.casting_time=0
		spell0.interruptable=False
		spell0.model="media/spells/blockyball"
		
		# spell1
		spell1=Spell()
		
		spell1.damage=25
		spell1.target_knockback=10
		spell1.self_knockback=0
		spell1.range=50
		spell1.speed=25
		spell1.aoe=False
		spell1.aoe_range=0
		spell1.targeting=False
		spell1.casting_time=0
		spell1.interruptable=False
		spell1.model="media/spells/pointyball"
		
		# spell2
		spell2=Spell()
		
		spell2.damage=50
		spell2.target_knockback=10
		spell2.self_knockback=30
		spell2.range=50
		spell2.speed=15
		spell2.aoe=False
		spell2.aoe_range=0
		spell2.targeting=False
		spell2.casting_time=0
		spell2.interruptable=False
		spell2.model="media/spells/blockyball"
		
		# spell3
		spell3=Spell()
		
		spell3.model="media/spells/pointyball"
		
		# maybe this shit too, or this can stay here and just pass in an array of spells 
		self.showbase.spell_man=SpellManager(self.showbase.num_warlocks) # until the Game() class is created in here which i think it should
		self.showbase.spell_man.add_spell(spell0)
		self.showbase.spell_man.add_spell(spell1)
		self.showbase.spell_man.add_spell(spell2)
		self.showbase.spell_man.add_spell(spell3)
		
		self.game=Game(self.showbase,game_tick)
		for u in range(self.showbase.num_warlocks):
			self.users[u]['warlock']=self.game.warlock[u]
		taskMgr.doMethodLater(0.5, self.game_loop, 'Game Loop')
		return task.done
Ejemplo n.º 41
0
class BitFieldEditor(object):
    """
    Bit field editing class.
    """

    def __init__(self, dbase, register, bit_field, modified, top_builder):
        self.__db = dbase
        self.__modified = modified
        self.__register = register
        self.__bit_field = bit_field
        self.__builder = gtk.Builder()
        self.__top_builder = top_builder
        self.__builder.add_from_file(GLADE_BIT)
        self.__top_window = self.__builder.get_object("editfield")
        self.__control_obj = self.__builder.get_object('control')
        self.__name_obj = self.__builder.get_object("field_name")
        self.__register_obj = self.__builder.get_object("register_name")
        self.__output_obj = self.__builder.get_object("output")
        self.__type_obj = self.__builder.get_object('type')
        self.__input_obj = self.__builder.get_object("input")
        self.__reset_obj = self.__builder.get_object("reset_value")
        self.__static_obj = self.__builder.get_object('static')
        self.__text_buffer = self.__builder.get_object("descr").get_buffer()
        self.__value_tree_obj = self.__builder.get_object('values')
        self.__output_enable_obj = self.__builder.get_object("outen")
        self.__side_effect_obj = self.__builder.get_object("side_effect")
        self.__verilog_obj = self.__builder.get_object('verilog_code')
        self.__volatile_obj = self.__builder.get_object('volatile')
        self.__col = None
        self.__top_window.set_title(
            "Edit Bit Field - [%02x] %s" % (register.address,
                                            register.register_name))

        self.__spell = Spell(self.__builder.get_object("descr"))

        self.__top_window.set_icon_from_file(
            os.path.join(INSTALL_PATH, "media", "flop.svg"))
        (input_enb, control_enb) = TYPE_TO_ENABLE[bit_field.field_type]
        self.__input_obj.set_sensitive(input_enb)
        self.__control_obj.set_sensitive(control_enb)

        pango_font = pango.FontDescription("monospace")
        self.__builder.get_object("descr").modify_font(pango_font)

        self.build_values_list()

        self.__list_model = gtk.ListStore(str, str, str)
        self.__model_selection = self.__value_tree_obj.get_selection()
        self.__value_tree_obj.set_model(self.__list_model)

        self.__used_tokens = set()
        for value in self.__bit_field.values:
            self.__used_tokens.add(value[1])
            self.__list_model.append(row=value)

        self.__initialize_from_data(bit_field)
        self.__output_obj.set_sensitive(self.__output_enable_obj.get_active())
        self.__check_data()

        self.__text_buffer.connect('changed', self.__description_changed)

        try:
            edge = "posedge" if self.__db.reset_active_level else "negedge"
            condition = "" if self.__db.reset_active_level else "~"
            be_level = "" if self.__db.byte_strobe_active_level else "~"

            name_map = {'MODULE': self.__db.module_name,
                        'BE_LEVEL': be_level,
                        'RESET_CONDITION': condition,
                        'RESET_EDGE': edge }
            text = REG[TYPE_TO_ID[bit_field.field_type].lower()] % name_map
        except KeyError:
            text = ""

        if USE_HIGHLIGHT:
            buff = CodeBuffer(lang=SyntaxLoader("verilog"))
            self.__verilog_obj.set_buffer(buff)
        else:
            self.__verilog_obj.modify_font(pango_font)
            buff = self.__verilog_obj.get_buffer()

        buff.set_text(text)
        self.__builder.connect_signals(self)
        self.__top_window.show_all()

    def __initialize_from_data(self, bit_field):
        """
        Initializes the dialog's data fields from the object
        """
        self.__register_obj.set_text("<b>%s</b>" %
                                     self.__register.register_name)
        self.__register_obj.set_use_markup(True)

        start = self.__bit_field.start_position
        stop = self.__bit_field.stop_position
        if start == stop:
            name = bit_field.field_name
        else:
            name = "%s[%d:%d]" % (bit_field.field_name, stop, start)

        self.__name_obj.set_text(name)
        self.__type_obj.set_text(TYPE_TO_DESCR[bit_field.field_type])

        if bit_field.reset_type == BitField.RESET_NUMERIC:
            self.__reset_obj.set_text("%x" % bit_field.reset_value)
        else:
            self.__reset_obj.set_text(bit_field.reset_parameter)

        (input_enb, control_enb) = TYPE_TO_ENABLE[bit_field.field_type]
        if input_enb and not bit_field.input_signal:
            bit_field.input_signal = "%s_DATA_IN" % bit_field.field_name

        if control_enb and not bit_field.control_signal:
            bit_field.control_signal = "%s_LOAD" % bit_field.field_name

        self.__output_obj.set_text(bit_field.output_signal)
        self.__input_obj.set_text(bit_field.input_signal)

        self.__volatile_obj.set_active(bit_field.volatile)

        self.__static_obj.set_active(bit_field.output_is_static)
        self.__side_effect_obj.set_active(bit_field.output_has_side_effect)
        self.__text_buffer.set_text(bit_field.description)
        self.__output_enable_obj.set_active(bit_field.use_output_enable)
        self.__control_obj.set_text(self.__bit_field.control_signal)

    def on_help_clicked(self, obj):
        HelpWindow(self.__top_builder, "bitfield_value_help.rst")

    def on_property_help_clicked(self, obj):
        HelpWindow(self.__top_builder, "bitfield_signal_prop_help.rst")

    def on_signal_help_clicked(self, obj):
        HelpWindow(self.__top_builder, "bitfield_signal_help.rst")

    def on_output_changed(self, obj):
        self.__bit_field.output_signal = obj.get_text()
        self.__check_data()
        self.__modified()

    def on_input_changed(self, obj):
        self.__bit_field.input_signal = obj.get_text()
        self.__check_data()
        self.__modified()

    def on_volatile_changed(self, obj):
        self.__bit_field.volatile = obj.get_active()
        self.__modified()

    def on_static_toggled(self, obj):
        self.__bit_field.output_is_static = obj.get_active()
        self.__modified()

    def on_control_changed(self, obj):
        self.__bit_field.control_signal = obj.get_text()
        self.__check_data()
        self.__modified()

    def build_values_list(self):
        """
        Builds the columns associated with the list view
        """
        render = gtk.CellRendererText()
        render.set_property('editable', True)
        render.connect('edited', self.__change_val)
        column = gtk.TreeViewColumn('Value', render, text=0)
        column.set_min_width(50)
        self.__value_tree_obj.append_column(column)
        self.__col = column

        render = gtk.CellRendererText()
        render.set_property('editable', True)
        render.connect('edited', self.__change_text)
        column = gtk.TreeViewColumn('Token', render, text=1)
        column.set_min_width(100)
        self.__value_tree_obj.append_column(column)

        render = gtk.CellRendererText()
        render.set_property('editable', True)
        render.connect('edited', self.__change_description)
        column = gtk.TreeViewColumn('Description', render, text=2)
        self.__value_tree_obj.append_column(column)

    def on_add_clicked(self, obj):
        """
        Called with the add button is clicked. Search the existing values
        in the list, finding the next highest value to use as the default.
        """

        start = self.__bit_field.start_position
        stop = self.__bit_field.stop_position
        last = len(self.__list_model)
        max_values = 2 ** (stop - start + 1)

        if last >= max_values:
            ErrorMsg("Maximum number of values reached",
                     "The width of the field only allows for %d values" % last)
            return

        try:
            largest = max([int(val[0], 16) for val in self.__list_model
                           if val[0] != ""])
        except ValueError:
            largest = -1

        last -= 1
        if (last == -1 or self.__list_model[last][0] or
            self.__list_model[last][1] or self.__list_model[last][2]):
            if largest >= max_values:
                new_val = ""
            else:
                new_val = "%x" % (largest + 1,)
            node = self.__list_model.append(row=(new_val, '', ''))
            path = self.__list_model.get_path(node)
        else:
            path = (last, )

        self.__value_tree_obj.set_cursor(path, focus_column=self.__col,
                                         start_editing=True)
        self.__modified()

    def on_remove_clicked(self, obj):  # IGNORE:W0613 - obj is unused
        """
        Called with the remove button is clicked
        """
        self.__list_model.remove(self.__model_selection.get_selected()[1])
        self.__update_values()
        self.__modified()

    def __change_val(self, text, path, new_text):  # IGNORE:W0613
        """
        Called with the value has changed value field. Checks to make sure that
        value is a valid hex value, and within the correct range.
        """
        new_text = new_text.strip()

        start = self.__bit_field.start_position
        stop = self.__bit_field.stop_position
        maxval = (2 ** (stop - start + 1)) - 1

        try:
            if new_text == "" or int(new_text, 16) > maxval:
                return
        except ValueError:
            return

        node = self.__list_model.get_iter(path)
        self.__list_model.set_value(node, 0, new_text)
        self.__update_values()
        self.__modified()

    def on_side_effect_toggled(self, obj):
        self.__bit_field.output_has_side_effect = obj.get_active()
        self.__modified()

    def __update_values(self):
        new_list = []
        for row in self.__list_model:
            new_list.append((row[0], row[1], row[2]))
        self.__bit_field.values = new_list

    def __change_text(self, text, path, new_text):
        """
        Updates the data model when the text value is changed in the model.
        """
        if new_text in self.__used_tokens:
            ErrorMsg("Duplicate token",
                     'The token "%s" has already been used' % new_text)
        else:
            node = self.__list_model.get_iter(path)
            old_text = self.__list_model.get_value(node, 1)
            self.__list_model.set_value(node, 1, new_text)

            if old_text and old_text in self.__used_tokens:
                self.__used_tokens.remove(old_text)
            if new_text:
                self.__used_tokens.add(new_text)
            self.__update_values()
            self.__modified()

    def __change_description(self, text, path, new_text):
        """
        Updates the data model when the text value is changed in the model.
        """
        node = self.__list_model.get_iter(path)
        try:
            new_text.decode("ascii")
        except:
            ErrorMsg("Invalid ASCII characters detected",
                     "Look for strange punctuations, like dashs and "
                     "quotes that look valid, but are not actual "
                     "ascii characters.")
        self.__list_model.set_value(node, 2, new_text)
        self.__update_values()
        self.__modified()

    def on_output_enable_toggled(self, obj):
        """
        Enables the output field based on the output enable field
        """
        active = self.__output_enable_obj.get_active()
        self.__bit_field.use_output_enable = active
        self.__output_obj.set_sensitive(obj.get_active())
        self.__check_data()
        self.__modified()

    def on_descr_key_press_event(self, obj, event):
        """
        Called on a double click event. If we detect a double click with
        the first button, we call the edit_register method.
        """
        if event.keyval == gtk.keysyms.F10:
            bounds = self.__text_buffer.get_selection_bounds()
            if bounds:
                old_text = self.__text_buffer.get_text(bounds[0], bounds[1])
                new_text = " ".join(old_text.replace("\n", " ").split())
                self.__text_buffer.delete(bounds[0], bounds[1])
                self.__text_buffer.insert(bounds[0], new_text)
                self.__modified()
            return True
        return False

    def on_destroy_event(self, obj):
        self.__spell.detach()

    def on_delete_event(self, obj, event):
        self.__spell.detach()

    def on_close_clicked(self, obj):
        """
        Saves the data from the interface to the internal BitField structure
        """
        self.__top_window.destroy()

    def __description_changed(self, obj):
        self.__bit_field.description = self.__text_buffer.get_text(
            self.__text_buffer.get_start_iter(),
            self.__text_buffer.get_end_iter(), False)
        self.__modified()

    def __check_data(self):
        """
        Checks the input signal validity
        """
        input_error = False
        output_error = False
        control_error = False

        if control_error is False:
            clear_error(self.__control_obj)
        if input_error is False:
            clear_error(self.__input_obj)
        if output_error is False:
            clear_error(self.__output_obj)
Ejemplo n.º 42
0
 def setUp(self):
     self.my_spell = Spell(name="Fireball",
                           damage=30,
                           mana_cost=50,
                           cast_range=2)
Ejemplo n.º 43
0
class GroupDocEditor(object):
    def __init__(self, group_inst, callback):

        builder = gtk.Builder()
        builder.add_from_file(GLADE_GTXT)
        self.callback = callback
        self.group_doc = builder.get_object('group_text')
        self.group_title = builder.get_object('group_title')
        self.group_inst = group_inst
        self.buffer = builder.get_object('overview1').get_buffer()
        pango_font = pango.FontDescription("monospace")
        builder.get_object('overview1').modify_font(pango_font)

        self.__prj_preview = PreviewEditor(
            self.buffer, builder.get_object('scroll_webkit1'))

        self.buffer.set_text(group_inst.docs)
        self.group_title.set_text(group_inst.title)

        builder.get_object("overview1").connect("key-press-event",
                                                self.on_key_press_event)
        builder.get_object("button2").connect("button-press-event", self._save)
        builder.get_object("button3").connect("button-press-event",
                                              self._cancel)
        builder.get_object('title').set_text(group_inst.name)
        if PREVIEW_ENABLED:
            self.__prj_preview.enable()
        else:
            self.__prj_preview.disable()
        self.__spell = Spell(builder.get_object('overview1'))

        self.group_doc.connect('delete-event', self.on_delete_event)
        self.group_doc.connect('destroy-event', self.on_destroy_event)
        self.group_doc.show()

    def on_key_press_event(self, obj, event):
        if event.keyval == gtk.keysyms.F12:
            clean_format_if_needed(obj)
            return True
        return False

    def on_destroy_event(self, obj):
        self.__spell.detach()

    def on_delete_event(self, obj, event):
        self.__spell.detach()

    def _cancel(self, obj, data):
        self.group_doc.destroy()

    def _save(self, obj, data):

        new_docs = self.buffer.get_text(
            self.buffer.get_start_iter(), self.buffer.get_end_iter(), False)
        new_title = self.group_title.get_text()

        if self.group_inst.docs != new_docs:
            self.group_inst.docs = new_docs
            self.callback(True)
        if self.group_inst.title != new_title:
            self.group_inst.title = new_title
            self.callback(True)
        self.group_doc.destroy()
Ejemplo n.º 44
0
from spellbook import Spellbook
from spell import Spell


if __name__ == "__main__":
	testSpellbook = Spellbook()
	spell = Spell()
	spell.name = "Fireball"
	spell.magic_cost = 10
	spell.effect = 'Healing'
	spell.description = "A firey ball of fire fly from you hands."
	spell2 = Spell()
	spell2.name = "Heading Hands"
	spell2.description = "Your hands tingle with healing energy and stuff"
	testSpellbook.inventory.add(spell)
	testSpellbook.inventory.add(spell2)
	choice = testSpellbook.chooseSpell()
Ejemplo n.º 45
0
 def setUp(self):
     self.spell = Spell("Abracadabra", 100, 11, 15)
Ejemplo n.º 46
0
def train(run_name, speaker, start_epoch, stop_epoch, img_c, img_w, img_h,
          frames_n, absolute_max_string_len, minibatch_size):
    DATASET_DIR = os.path.join(CURRENT_PATH, speaker, 'datasets')
    OUTPUT_DIR = os.path.join(CURRENT_PATH, speaker, 'results')
    LOG_DIR = os.path.join(CURRENT_PATH, speaker, 'logs')

    curriculum = Curriculum(curriculum_rules)
    lip_gen = BasicGenerator(dataset_path=DATASET_DIR,
                             minibatch_size=minibatch_size,
                             img_c=img_c,
                             img_w=img_w,
                             img_h=img_h,
                             frames_n=frames_n,
                             absolute_max_string_len=absolute_max_string_len,
                             curriculum=curriculum,
                             start_epoch=start_epoch).build()

    lipnet = LipNet(img_c=img_c,
                    img_w=img_w,
                    img_h=img_h,
                    frames_n=frames_n,
                    absolute_max_string_len=absolute_max_string_len,
                    output_size=lip_gen.get_output_size())
    lipnet.summary()

    adam = Adam(lr=0.0001, beta_1=0.9, beta_2=0.999, epsilon=1e-08)

    # the loss calc occurs elsewhere, so use a dummy lambda func for the loss
    lipnet.model.compile(loss={
        'ctc': lambda y_true, y_pred: y_pred
    },
                         optimizer=adam)

    # load weight if necessary
    if start_epoch > 0:
        weight_file = os.path.join(
            OUTPUT_DIR,
            os.path.join(run_name, 'weights%02d.h5' % (start_epoch - 1)))
        lipnet.model.load_weights(weight_file)

    spell = Spell(path=PREDICT_DICTIONARY)
    decoder = Decoder(greedy=PREDICT_GREEDY,
                      beam_width=PREDICT_BEAM_WIDTH,
                      postprocessors=[labels_to_text, spell.sentence])

    # define callbacks
    statistics = Statistics(lipnet,
                            lip_gen.next_val(),
                            decoder,
                            256,
                            output_dir=os.path.join(OUTPUT_DIR, run_name))
    visualize = Visualize(os.path.join(OUTPUT_DIR, run_name),
                          lipnet,
                          lip_gen.next_val(),
                          decoder,
                          num_display_sentences=minibatch_size)
    tensorboard = TensorBoard(log_dir=os.path.join(LOG_DIR, run_name))
    csv_logger = CSVLogger(os.path.join(
        LOG_DIR, "{}-{}.csv".format('training', run_name)),
                           separator=',',
                           append=True)
    checkpoint = ModelCheckpoint(os.path.join(OUTPUT_DIR, run_name,
                                              "weights{epoch:02d}.h5"),
                                 monitor='val_loss',
                                 save_weights_only=True,
                                 mode='auto',
                                 period=1)

    lipnet.model.fit_generator(generator=lip_gen.next_train(),
                               steps_per_epoch=lip_gen.default_training_steps,
                               epochs=stop_epoch,
                               validation_data=lip_gen.next_val(),
                               validation_steps=2,
                               callbacks=[
                                   checkpoint, statistics, visualize, lip_gen,
                                   tensorboard, csv_logger
                               ],
                               initial_epoch=start_epoch,
                               verbose=1,
                               max_q_size=5,
                               workers=2,
                               pickle_safe=True)
Ejemplo n.º 47
0
    def test_string_representation_with_spell(self):
        from spell import Spell
        self.hero.learn_spell(Spell("Fire", 20, 4, 2))
        expected_string = """Bron the Dragonslayer: \
health 100, mana 100\nspell: Fire: damage 20, mana 4, range 2\n"""
        self.assertEqual(str(self.hero), expected_string)
Ejemplo n.º 48
0
 def init_spells(self):
     return [Spell(Inventory(2, 0, 0, 0)),
             Spell(Inventory(-1, 1, 0, 0)),
             Spell(Inventory(0, -1, 1, 0)),
             Spell(Inventory(0, 0, -1, 1))]
Ejemplo n.º 49
0
class HeroTest(unittest.TestCase):

    def setUp(self):
        self.hero = Hero(name="Bron",
                         title="Dragonslayer",
                         health=100, mana=100,
                         mana_regeneration_rate=2)
        self.weapon = Weapon(name="The Axe of Destiny", damage=20)
        self.spell = Spell(name="Fireball",
                           damage=30,
                           mana_cost=50,
                           cast_range=2)

    def test_exists_class(self):
        self.assertTrue(isinstance(self.hero, Hero))

    def test_hero_known_as(self):
        self.assertTrue(self.hero.known_as(), "Bron the DragonSlayer")

    def test_hero_is_alive(self):
        self.assertTrue(self.hero.is_alive(), True)

    def test_is_hero_not_alive(self):
        self.hero.reduce_health(100)
        self.assertFalse(self.hero.is_alive())

    def test_hero_can_cast(self):
        self.assertTrue(self.hero.can_cast(), True)

    def test_hero_can_cast_false(self):
        self.hero.reduce_mana(100)
        self.assertFalse(self.hero.can_cast())

    def test_mana_regeneration_rate(self):
        self.assertEqual(self.hero.mana_regeneration_rate(), 2)

    def test_hero_take_damage(self):
        damage_points = 20
        self.hero.take_damage(damage_points)
        self.assertEqual(self.hero.get_health(), 80)

    def test_hero_take_healing(self):
        healing_points = 20
        damage_points = 90
        self.hero.take_damage(damage_points)
        self.hero.take_healing(healing_points)
        self.assertTrue(self.hero.get_health(), 30)

    def test_hero_take_mana(self):
        damage_points = 50
        mana_points = 40
        new_mana_points = 20
        self.hero.take_damage(damage_points)
        self.hero.reduce_mana(mana_points)
        self.assertTrue(self.hero.take_mana(new_mana_points), 80)

    def test_hero_weapon(self):
        weapon_equipment = []
        weapon_equipment.append(self.weapon)
        self.assertEqual(weapon_equipment[0], self.weapon)

    def test_hero_can_equip_with_weapon(self):
        self.hero.equip(self.weapon)
        self.assertEqual(str(self.hero.weapon_equipment[0]),
                         self.weapon.get_name())

    def test_hero_spell(self):
        learned_spell = []
        learned_spell.append(self.spell)
        self.assertEqual(learned_spell[0], self.spell)

    def test_hero_can_learn_new_spell(self):
        self.hero.learn(self.spell)
        self.assertEqual(str(self.hero.learned_spell[0]),
                         self.spell.get_name())

    def test_hero_attack_with_spell(self):
        self.hero.learn(self.spell)
        self.assertEqual(self.hero.attack(by="spell"),
                         self.spell.get_damage())

    def test_hero_attack_with_weapon(self):
        self.hero.equip(self.weapon)
        self.assertEqual(self.hero.attack(by="weapon"),
                         self.weapon.get_damage())
Ejemplo n.º 50
0
 def __init__(self, name, color):
     Spell.__init__(self, name, None)
     self.color = color
Ejemplo n.º 51
0
 def test_can_cast_not_enough_mana(self):
     self.setUp()
     n = self.test_soldier
     n.learn_spell(Spell('Fireball', damage=50, mana_cost=120, cast_range=3))
     self.assertFalse(n.can_cast())
Ejemplo n.º 52
0
 def test_get_damage_source_weapon_and_spell(self):
     self.setUp()
     n = self.test_soldier
     n.equip_weapon(self.default_weapon)
     n.learn_spell(Spell(name='asd', damage=20, mana_cost=30, cast_range=2))
     self.assertEqual(n.get_damage_source(), 'spell')
Ejemplo n.º 53
0
def _startSpell(conn):
    spell = Spell(conn)
    spell.main()
Ejemplo n.º 54
0
 def setUp(self):
     self.test_soldier = Unit(health=200, mana=100)
     self.default_weapon = Weapon()
     self.default_spell = Spell()
Ejemplo n.º 55
0
from spell import Spell
# from <file> import <Class>

cat_summoned = "You reach into your pocket for a can of tuna and " \
        "crack it open.  A cat pops into existence beside you in a puff of smoke!"

summon = Spell("Summon Cat", "Conjuration", 1, 4, cat_summoned)
# The spell "Summon Cat" belongs to the school of "Conjuration",
# has a level of 1 and can be cast 4 times per day.

cat_effects = "You throw a bag of catnip at a nearby, unfortunate soul, " \
        "and a giant cat comes crashing down on them from the heavens above!"

cataclysm = Spell("Cataclysm", "Conjuration", 6, 2, cat_effects)
# The spell "Cataclysm" belongs to the school of "Conjuration",
# has a level of 6 and can be cast 2 times per day.

# use the spells
summon.cast()
cataclysm.cast()
from dungeon import Dungeon
from hero import Hero
from fight import Fight
from weapon import Weapon
from spell import Spell
from enemy import Enemy
from time import sleep

h = Hero(name="Bron", title="Dragonslayer", health=20, mana=100)
weapon = Weapon("weapon", 30)
h.equip(weapon)
spell = Spell()
h.learn(spell)
enemy = Enemy(health=100, mana=100, damage=20)

map = Dungeon('level1.txt')

# print('Prepare the map for the final fight')
# sleep(2)
print('A long time ago our hero {} was born in Sofia.'.format(h.name))
print()
sleep(4)
print('At the same time evil was born in the northwest.')
print()
sleep(4)
print('And now we have to prepare the map for the final fight')
sleep(4)
print()

print('The map')
map.print_map()
Ejemplo n.º 57
0
 def current_position(self):
     Spell.position(self.dungeon, self.rol, self.col)