• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python monster.Monster类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中monster.Monster的典型用法代码示例。如果您正苦于以下问题:Python Monster类的具体用法?Python Monster怎么用?Python Monster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Monster类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: run

    def run(self):
        self.player = Monster(name='Player')
        self._load_history(self.player)

        monster = random.choice(list(monsters.viewkeys()))
        self.monster = Monster(monsters[monster][0], monster, description=monsters[monster][1])
        self.ui = UI(self.player)
        self.ui.monster = self.monster

        self.ui.welcome()
        
        a = 1
        while a != 0:
            self._load_history(self.monster)

            a = self.run_loop()

            if a != 0:
                self.ui.update_display()

            self._save_history(self.player)
            self._save_history(self.monster)
            
            monster = random.choice(list(monsters.viewkeys()))
            self.monster = Monster(monsters[monster][0], monster, description=monsters[monster][1])
            self.ui.monster = self.monster
开发者ID:schiem,项目名称:ai_project,代码行数:26,代码来源:world.py


示例2: place_objects

    def place_objects(self, room):
        """Place random objects in a room."""
        # Choose random number of monsters
        for i in xrange(SS.map_rand.randrange(cfg.MAX_ROOM_MONSTERS)):
            x = SS.map_rand.randrange(room.x1 + 1, room.x2 - 1)
            y = SS.map_rand.randrange(room.y1 + 1, room.y2 - 1)

            # Don't place monsters on the up stairs, as that's where the player
            # will be placed.
            if not self.blocks_movement(x, y) and (x, y) != self.upstairs:
                if SS.map_rand.randrange(0, 100) < 60:
                    mon = Monster(x, y, 'orc', ai=ai.StupidAI())
                else:
                    mon = Monster(x, y, 'troll', ai=ai.StupidAI())

                mon.place_on_map(self)

        # Choose random number of items
        for i in xrange(SS.map_rand.randrange(cfg.MAX_ROOM_ITEMS)):
            x = SS.map_rand.randrange(room.x1 + 1, room.x2 - 1)
            y = SS.map_rand.randrange(room.y1 + 1, room.y2 - 1)

            if not self.blocks_movement(x, y):
                dice = SS.map_rand.randrange(0, 100)
                if dice < 40:
                    item = Item(x, y, 'healing potion')
                elif dice < 40 + 20:
                    item = Item(x, y, 'scroll of fireball')
                elif dice < 40 + 20 + 20:
                    item = Item(x, y, 'scroll of lightning')
                else:
                    item = Item(x, y, 'scroll of confusion')

                item.place_on_map(self)
开发者ID:aruse,项目名称:Bludgeon,代码行数:34,代码来源:map.py


示例3: test_attack

class test_attack(unittest.TestCase):
    def setUp(self):
        self.monsta = Monster()
        print(self.shortDescription())

    #Tests if heal function works
    def test_attack_live(self):
        self.monsta.health = 6
        expected = 1
        actual = self.monsta.attack(5)
        self.assertEqual(expected, actual)

    #Heal function should not work if total > 10
    def test_attack_die(self):
        self.monsta.health = 4
        expected = -1
        actual = self.monsta.attack(5)
        self.assertEqual(expected, actual)

    #Tests if invalid output was printed
    @patch ('sys.stdout', new_callable=StringIO)
    def test_attack_die_KO(self, mock_stdout):
        health = self.monsta.health(4)

        expected = "K.O.'d"
        actual = self.monsta.attack(6)
        self.assertNotEqual(mock_stdout.getValue(), text)
开发者ID:PDXDevCampJuly,项目名称:daniel_pearl,代码行数:27,代码来源:test_attack.py


示例4: __init__

	def __init__(self):

		Hero.__init__(self)
		Monster.__init__(self)


		self.where = "on shoulders"
开发者ID:PDXCodeGuildJan,项目名称:Shawn-s-Assignments-PDXCode-Guild-16,代码行数:7,代码来源:hero.py


示例5: InTokyoTest

class InTokyoTest(unittest.TestCase):
    """Test the functionality of the Monster class in_tokyo function."""

    def setUp(self):
        self.new_monster = Monster("Cookie")

    def tearDown(self):
        del self.new_monster

    def test_in_tokyo_yes(self):
        """Set status to "In Tokyo" on a Monster class object, new_monster.
        Check that in_tokyo() returns True."""
        self.new_monster.status = "In Tokyo"
        self.assertEqual(self.new_monster.in_tokyo(), True)

    def test_in_tokyo_no(self):
        """Set status to "" on a Monster class object, new_monster.
        Check that in_tokyo() returns False."""
        self.new_monster.status = ""
        self.assertEqual(self.new_monster.in_tokyo(), False)

    def test_in_tokyo_invalid(self):
        """Set status to -78.3 on a Monster class object, new_monster.
        Check that in_tokyo() returns False."""
        self.new_monster.status = -78.3
        self.assertEqual(self.new_monster.in_tokyo(), False)
开发者ID:TheOneTAR,项目名称:atifar,代码行数:26,代码来源:test_in_tokyo.py


示例6: __init__

	def __init__(self):
		# Takes this instance(self) of Monster and adds all init properties from Monster class
		Monster.__init__(self)
		# Takes this instance(self) of Monster and adds all init properties from Monster class
		Hero.__init__(self)
		#MonsterHero to have a second weapon
		self.second_weapon = "second weapon!"
开发者ID:PDXCodeGuildJan,项目名称:KatieCGBootcamp,代码行数:7,代码来源:hero.py


示例7: MonsterResetTest

class MonsterResetTest(unittest.TestCase):

    def setUp(self):
        self.monsta = Monster()
        print(self.shortDescription())

    def test_valid_health_reset(self):
        """
        Tests for valid health reset
        """
        self.monsta.health = 5
        self.monsta.reset()
        expected = 10
        actual = self.monsta.health

        assertEqual(expected, actual)

    def test_valid_victory_reset(self):
        """
        Tests for valid victory point reset
        """
        self.monsta.victory_points = 5
        self.monsta.reset()
        expected = 0
        actual = self.monsta.victory_points

        assertEqual(expected, actual)
开发者ID:PDXDevCampJuly,项目名称:daniel_pearl,代码行数:27,代码来源:test_reset.py


示例8: __init__

	def __init__(self):
		Monster.__init__(self) # we don't use super here because weird things will happen and overlap with multiple
		#inheritance
		Hero.__init__(self) # instead of super, we must specificy each parent class from which MonsterHero
		#is inheriting

		self.second_weapon = None # staying consistent with weapon variable
开发者ID:PDXCodeGuildJan,项目名称:AlexisRepo,代码行数:7,代码来源:hero.py


示例9: main

def main():

	#ogre = Monster(name="Ogre", color="green", weapon="Machine Gun", hit_points=10, sound="Argh! I'm going to eat you!")
	#ogre.present_yourself();

	ogre = Monster(name="Marty the Ogre", color="green", weapon="Light Saber")

	ogre.present_yourself()
开发者ID:IonatanSala,项目名称:Python,代码行数:8,代码来源:ogre.py


示例10: __init__

 def __init__(self, x, y, name, oid=None, ai=None, hp=None, max_hp=None,
              mp=None, max_mp=None, death=None, fov_radius=cfg.TORCH_RADIUS,
              inventory=None):
     if death is None:
         death = player_death
     Monster.__init__(self, x, y, name, oid=oid, ai=ai, hp=hp,
                      max_hp=max_hp, mp=mp, max_mp=max_mp, death=death,
                      fov_radius=fov_radius, inventory=inventory)
开发者ID:aruse,项目名称:Bludgeon,代码行数:8,代码来源:player.py


示例11: make_monsters

 def make_monsters(self):
     #make 2 monster
     for i in range(2):
         monster = Monster(BLUE, 20, 80, self)
         monster.rect.x = self.x + random.randint(0,self.platform.rect.right - 20)
         monster.rect.y = self.y - monster.rect.h
         monster.level = self
         self.monster_group.add(monster)
开发者ID:txcism,项目名称:pygame,代码行数:8,代码来源:level.py


示例12: __init__

    def __init__(self,x,y):
        Monster.__init__(self,x,y,0,BAT_RADIUS,BAT_MOVE_SPEED)

        self._color = BAT_COLOR
        self._hp    = BAT_HP
        self._timer = BAT_TIMER
        self._base_speed = self._speed
        self._boost = self._speed * BAT_BOOST_SPEED
        self._randangle = choice([1,-1])
开发者ID:tc30nguyen,项目名称:pyShotGame,代码行数:9,代码来源:bat.py


示例13: place_monsters

 def place_monsters(self):
     self.monsters = []
     for i in range(0, 30):
         monster = Monster(self.game_map)
         monster.x = random.randint(0, game_map.MAP_WIDTH * game_map.SQUARE_WIDTH)
         monster.y = random.randint(0, game_map.MAP_HEIGHT * game_map.SQUARE_HEIGHT)
         monster.level = int(math.sqrt((self.center.x - monster.x) ** 2 + (self.center.y - monster.y) ** 2) / 50) + 1
         self.monsters.append(monster)
         self.game_map[monster.x][monster.y].units.append(monster)
开发者ID:trid,项目名称:anticivilization,代码行数:9,代码来源:game_data.py


示例14: __init__

   def __init__(self):
      #super is a builtin python function that represents the parent class of
      #this object (parent class = Creature here). This makes a monster inside  
      #the parent class of creature, with all the properties of creature. 

      Monster.__init__(self)
      Hero.__init__(self)
      
      self.weapon2 = None
开发者ID:Pjmcnally,项目名称:teaching,代码行数:9,代码来源:monsterhero.py


示例15: handle_event

    def handle_event(self):
        if self.story["action"] == "death":
            if self.story["sprite"] == "player":
                self.game.story_manager.display_speech(["GAME OVER"], "bottom")
                self.game.story_manager.set_unblockable(False)
                self.game.perso.kill()
            elif self.story["sprite"]:
                sprite_name = self.story["sprite"]
                sprite = self.game.layer_manager.get_sprite(sprite_name)
                time.sleep(2)
                sprite.kill()
        elif self.story["action"] == "spawn":
            if self.story["spawn_type"] == "npc":
                npc = Npc(self.story["name"],
                          os.path.join(self.game.config.get_sprite_dir(),
                                       self.story["sprite_img"]),
                          self.story["destination"],
                          self.game.layer_manager["npcs"])
                npc.definir_position(self.story["destination"][0],
                                     self.story["destination"][1])
            else:
                monster = Monster(self.story["name"],
                                  os.path.join(self.game.config.get_sprite_dir(),
                                               self.story["sprite_img"]),
                                  self.story["destination"],
                                  self.game.layer_manager["monster"])
                monster.definir_position(self.story["destination"][0],
                                         self.story["destination"][1])
        elif self.story["action"] == "speech":
            self.game.story_manager.display_speech(self.story['text'],
                                                   self.story['position'])
        elif self.story["action"] == "move":
            self.game.story_manager.blocking = True
            self.game.story_manager.set_unblockable(False)
            sprite = self.game.layer_manager.get_sprite(self.story["sprite"])
            dest = self.story["destination"]
            sprite.saveLastPos()
            if sprite.collision_rect.x != dest[0]:
                if sprite.collision_rect.x < dest[0]:
                    sprite.move(sprite.speed * sprite.accel, 0, "right")
                else:
                    sprite.move(-(sprite.speed * sprite.accel), 0, "left")
                self.game.story_manager.events.insert(0, self)
                return
            if sprite.collision_rect.y != dest[1]:
                if sprite.collision_rect.y < dest[1]:
                    sprite.move(0, sprite.speed * sprite.accel, "down")
                else:
                    sprite.move(0, -(sprite.speed * sprite.accel), "up")
                self.game.story_manager.events.insert(0, self)
                return

            if self.game.story_manager.blocking:
                self.game.story_manager.set_unblockable(True)
                self.game.story_manager.blocking = False
开发者ID:Projet5001,项目名称:projet5001-pyhton,代码行数:55,代码来源:storymanager.py


示例16: build_mob

 def build_mob(self, monster, location):
     mon = Monster(monster['file'],self)
     mon.rect.x = int(location['x'])*50
     mon.rect.y = int(location['y'])*50
     if mon.is_boss():
         self.boss = True
         if self.boss_beat:
             return False
         else:
             self.boss_mob = mon
     return mon
开发者ID:LordHamu,项目名称:RunNGun,代码行数:11,代码来源:level.py


示例17: __init__

 def __init__(self, move_time, nodes):
     Monster.__init__(self, move_time, nodes)
     self.image = Surface((20, 20)).convert()
     self.image_inside = Surface((18, 18)).convert()
     self.image_inside.fill((255, 255, 0))
     self.image.blit(self.image_inside, (1, 1))
     self.rect = Rect(self.pos, (40, 40))
     self.speed = 4
     self.diag_speed = 3
     self.value = 0.5
     self.health = 50
     self.name = "Fast Monster"
     self.description = "A small monster with very quick movement speed, but low health."
开发者ID:brandonsturgeon,项目名称:Tower_Defense,代码行数:13,代码来源:fast_monster.py


示例18: __init__

  def __init__(self, move_time, nodes):
    Monster.__init__(self, move_time, nodes)
    self.image_inside.fill((142, 163, 12))
    self.image.blit(self.image_inside, (1, 1))
    self.rect = Rect(self.pos, (40, 40))
    self.speed = 1
    self.diag_speed = 3
    self.value = 10
    self.health = 100
    self.armor = 500

    self.name = "Armored Monster"
    self.description = "An armored monster that takes progressively more damage as it is hit"
开发者ID:brandonsturgeon,项目名称:Tower_Defense,代码行数:13,代码来源:armor_monster.py


示例19: __init__

    def __init__(self, width, height):
        self.width = width
        self.height = height

        layout = []
        for _ in range(self.width):
            # To start out, just do a "maze" with doors between all rooms.
            row = []
            for _ in range(self.height):
                room = Room()
                room.doors = [NORTH, SOUTH, EAST, WEST]
                row.append(room)
            layout.append(row)

        # Remove the doors in the outer walls
        for room in layout[0]:
            room.doors.remove(WEST)
        for inner_column in layout:
            inner_column[0].doors.remove(SOUTH)
            inner_column[-1].doors.remove(NORTH)
        for room in layout[-1]:
            room.doors.remove(EAST)

        self.layout = layout

        self._remove_random_doors()

        self.player_location = self.get_random_location()
        self.monster_location = self.get_random_location()

        self.monster = Monster()
开发者ID:xoliver,项目名称:fddojo1,代码行数:31,代码来源:map.py


示例20: load_game

def load_game(save_file):
    """Load a saved game from a file."""
    with open(save_file, 'r') as f:
        exec(f.read())

    # Replace the map structure in the save file with actual cells.
    SS.map = map

    for x in xrange(SS.map.w):
        for y in xrange(SS.map.h):
            SS.map.grid[x][y] = Cell(
                SS.map.grid[x][y]['n'], explored=SS.map.grid[x][y]['e'])

    # Re-create monsters
    for m_str in monster_defs:
        mon = Monster.unserialize(m_str)
        mon.place_on_map()

    # Re-create items
    for i_str in item_defs:
        item = Item.unserialize(i_str)
        item.place_on_map()

    # Re-create the player
    SS.u = Player.unserialize(u)
开发者ID:aruse,项目名称:Bludgeon,代码行数:25,代码来源:saveload.py



注:本文中的monster.Monster类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python web.slugify函数代码示例发布时间:2022-05-27
下一篇:
Python monotonic.now函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap