当前位置: 首页>>代码示例>>Python>>正文


Python compositecore.Composite类代码示例

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


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

示例1: test_get_children_with_tag_returns_all_children_with_tag

 def test_get_children_with_tag_returns_all_children_with_tag(self):
     c = Composite()
     component_1 = TestComponent(id_1, [tag_1])
     component_2 = TestComponent(id_2, [tag_1])
     c.set_child(component_1)
     c.set_child(component_2)
     self.assertIn(component_1, c.get_children_with_tag(tag_1))
     self.assertIn(component_2, c.get_children_with_tag(tag_1))
开发者ID:co,项目名称:TheLastRogue,代码行数:8,代码来源:composite_test.py

示例2: test_when_adding_component_of_existing_type_old_component_should_be_removed

 def test_when_adding_component_of_existing_type_old_component_should_be_removed(self):
     c = Composite()
     component_first = DummyComponent("x")
     component_second = DummyComponent("x")
     c.set_child(component_first)
     c.set_child(component_second)
     self.assertFalse(c.x is component_first)
     self.assertTrue(c.x is component_second)
开发者ID:co,项目名称:TheLastRogue,代码行数:8,代码来源:compositecore_test.py

示例3: test_get_relative_of_type_should_return_sibling_if_sibling_matches

 def test_get_relative_of_type_should_return_sibling_if_sibling_matches(self):
     c = Composite()
     component1 = DummyComponent("A")
     component2 = DummyComponent("B")
     c.set_child(component1)
     c.set_child(component2)
     self.assertTrue(component1.has_relative_of_type("B"),
                     "No relative with component " + component1.component_type + " was found.")
     self.assertTrue(component1.get_relative_of_type("B") is component2)
开发者ID:co,项目名称:TheLastRogue,代码行数:9,代码来源:compositecore_test.py

示例4: test_when_a_component_is_removed_by_type_it_should_not_be_gettable_by_tag

 def test_when_a_component_is_removed_by_type_it_should_not_be_gettable_by_tag(self):
     c = Composite()
     component1 = DummyComponent("x", "a")
     c.set_child(component1)
     self.assertEqual(len(c.get_children_with_tag("a")), 1)
     self.assertTrue(component1 in c.get_children_with_tag("a"))
     c.remove_component_of_type("x")
     self.assertEqual(len(c.get_children_with_tag("a")), 0)
     self.assertFalse(component1 in c.get_children_with_tag("a"))
开发者ID:co,项目名称:TheLastRogue,代码行数:9,代码来源:compositecore_test.py

示例5: new_plant

def new_plant():
    plant = Composite()
    set_dungeon_feature_components(plant)
    plant.set_child(GraphicChar(None, colors.GREEN_D, icon.PLANT))
    plant.set_child(Flag("is_opaque"))
    plant.set_child(Flag(Flags.FLAMMABLE))
    plant.set_child(UpdateDungeonMaskWhenRemoved())

    return plant
开发者ID:co,项目名称:TheLastRogue,代码行数:9,代码来源:dungeonfeature.py

示例6: new_frost_cloud

def new_frost_cloud(game_state, density):
    cloud = Composite()
    set_cloud_components(game_state, cloud, density)
    cloud.graphic_char.color_fg = colors.LIGHT_BLUE
    cloud.set_child(CloudActor())
    cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_frost_cloud))
    cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.FROST))
    cloud.set_child(FrostCloudShareTileEffect())
    return cloud
开发者ID:co,项目名称:TheLastRogue,代码行数:9,代码来源:cloud.py

示例7: new_poison_cloud

def new_poison_cloud(game_state, density):
    cloud = Composite()
    set_cloud_components(game_state, cloud, density)
    cloud.graphic_char.color_fg = colors.GREEN
    cloud.set_child(CloudActor())
    cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_poison_cloud))
    cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.POISON))
    cloud.set_child(PoisonCloudShareTileEffect())
    return cloud
开发者ID:co,项目名称:TheLastRogue,代码行数:9,代码来源:cloud.py

示例8: new_dust_cloud

def new_dust_cloud(game_state, density):
    cloud = Composite()
    set_cloud_components(game_state, cloud, density)
    cloud.graphic_char.color_fg = colors.LIGHT_ORANGE
    cloud.set_child(CloudActor())
    cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_dust_cloud))
    cloud.set_child(DustLowerHitOfEntityShareTileEffect())
    cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.DUST))
    return cloud
开发者ID:co,项目名称:TheLastRogue,代码行数:9,代码来源:cloud.py

示例9: test_get_children_with_tag_should_not_return_removed_spoofed_children

 def test_get_children_with_tag_should_not_return_removed_spoofed_children(self):
     c = Composite()
     component_1 = TestComponent(id_1, [tag_1])
     component_2 = TestComponent(id_2, [tag_1])
     c.set_child(component_1)
     c.add_spoof_child(component_2)
     c.reset_spoofed_children()
     self.assertIn(component_1, c.get_children_with_tag(tag_1))
     self.assertNotIn(component_2, c.get_children_with_tag(tag_1))
开发者ID:co,项目名称:TheLastRogue,代码行数:9,代码来源:composite_test.py

示例10: test_get_relative_of_type_should_return_sibling_if_both_uncle_and_sibling_matches

 def test_get_relative_of_type_should_return_sibling_if_both_uncle_and_sibling_matches(self):
     parent = Composite("X")
     grandparent = Composite("Y")
     uncle = Composite("C")
     component1 = DummyComponent("Z")
     component2 = DummyComponent("W")
     component3 = DummyComponent("C")
     grandparent.set_child(parent)
     grandparent.set_child(uncle)
     parent.set_child(component1)
     parent.set_child(component2)
     parent.set_child(component3)
     self.assertTrue(component1.has_relative_of_type("C"),
                     "No relative with component " + component1.component_type + " was found.")
     self.assertTrue(component1.get_relative_of_type("C") is component3)
开发者ID:co,项目名称:TheLastRogue,代码行数:15,代码来源:compositecore_test.py

示例11: new_spider_web

def new_spider_web():
    """
    Spider web the player or other entities can get caught in.
    """
    web = Composite()
    set_dungeon_feature_components(web)
    web.set_child(Description("Spider Web",
                              "A spider made this web, touch it and you might get stuck"))
    web.set_child(GraphicChar(None, colors.WHITE, icon.SPIDER+2))
    web.set_child(DataPoint(DataTypes.STRENGTH, 10))
    web.set_child(StuckInSpiderWebShareTileEffect())
    web.set_child(Flag(Flags.FLAMMABLE))
    return web
开发者ID:co,项目名称:TheLastRogue,代码行数:13,代码来源:dungeonfeature.py

示例12: new_stairs_down

def new_stairs_down():
    """
    Stairs Down allows the player to descend to the next level.
    """
    stairs = Composite()
    set_dungeon_feature_components(stairs)
    stairs.set_child(Description("Stairs Down",
                                 ("A dark pass way downward.",
                                  "what horrors awaits there?")))
    stairs.set_child(GraphicChar(None, colors.WHITE, icon.STAIRS_DOWN))
    stairs.set_child(DescendStairsAction())
    stairs.set_child(Flag("is_stairs_down"))
    return stairs
开发者ID:co,项目名称:TheLastRogue,代码行数:13,代码来源:dungeonfeature.py

示例13: new_steam_cloud

def new_steam_cloud(game_state, density):
    cloud = Composite()
    set_cloud_components(game_state, cloud, density)
    cloud.graphic_char.color_fg = colors.WHITE
    cloud.set_child(CloudActor())
    cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_steam_cloud))
    cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.STEAM))
    return cloud
开发者ID:co,项目名称:TheLastRogue,代码行数:8,代码来源:cloud.py

示例14: test_when_a_component_is_overwritten_it_should_not_be_gettable_by_tag

 def test_when_a_component_is_overwritten_it_should_not_be_gettable_by_tag(self):
     c = Composite()
     component1 = DummyComponent("x", "a")
     component2 = DummyComponent("x", "a")
     component3 = DummyComponent("x", "a")
     c.set_child(component1)
     c.set_child(component2)
     c.set_child(component3)
     self.assertEqual(len(c.get_children_with_tag("a")), 1)
     self.assertFalse(component1 in c.get_children_with_tag("a"))
     self.assertFalse(component2 in c.get_children_with_tag("a"))
     self.assertTrue(component3 in c.get_children_with_tag("a"))
开发者ID:co,项目名称:TheLastRogue,代码行数:12,代码来源:compositecore_test.py

示例15: test_get_children_with_does_not_return_removed_children

 def test_get_children_with_does_not_return_removed_children(self):
     c = Composite()
     component_1 = TestComponent(id_1, [tag_1])
     component_2 = TestComponent(id_2, [tag_1])
     c.set_child(component_1)
     c.set_child(component_2)
     c.remove_component(component_1)
     self.assertNotIn(component_1, c.get_children_with_tag(tag_1))
     self.assertIn(component_2, c.get_children_with_tag(tag_1))
开发者ID:co,项目名称:TheLastRogue,代码行数:9,代码来源:composite_test.py


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