當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。