本文整理汇总了Python中compositecore.Composite.set_child方法的典型用法代码示例。如果您正苦于以下问题:Python Composite.set_child方法的具体用法?Python Composite.set_child怎么用?Python Composite.set_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类compositecore.Composite
的用法示例。
在下文中一共展示了Composite.set_child方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_children_with_tag_may_return_spoofed_children_with_tag
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
def test_get_children_with_tag_may_return_spoofed_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.add_spoof_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))
示例2: test_when_adding_component_of_existing_type_old_component_should_be_removed
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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)
示例3: test_get_children_with_tag_returns_all_children_with_tag
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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))
示例4: test_get_children_with_does_not_return_removed_children
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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))
示例5: test_get_children_with_tag_should_not_return_removed_spoofed_children
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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))
示例6: test_when_a_component_is_removed_by_type_it_should_not_be_gettable_by_tag
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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"))
示例7: test_get_relative_of_type_should_return_sibling_if_sibling_matches
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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)
示例8: new_explosion_cloud
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
def new_explosion_cloud(game_state, density):
explosion = Composite()
set_cloud_components(game_state, explosion, density)
explosion.graphic_char.color_fg = colors.YELLOW
explosion.set_child(Description("Explosion", "Don't go near it."))
explosion.set_child(DisappearCloudActor())
explosion.set_child(ExplosionDamageShareTileEffect())
explosion.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_explosion_cloud))
explosion.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.EXPLOSION))
return explosion
示例9: test_when_a_component_is_overwritten_it_should_not_be_gettable_by_tag
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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"))
示例10: new_fire_cloud
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
def new_fire_cloud(game_state, density):
fire = Composite()
set_cloud_components(game_state, fire, density)
set_non_flying_cloud_components(fire)
fire.graphic_char.icon = icon.FIRE
fire.graphic_char.color_fg = colors.RED
fire.set_child(Description("Fire", "Don't get burnt."))
fire.set_child(SpreadToFlammableDisappearActor())
fire.set_child(FireDamageShareTileEffect())
fire.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_fire_cloud))
fire.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.FIRE))
return fire
示例11: test_when_composite_should_be_able_to_get_children_of_tag
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
def test_when_composite_should_be_able_to_get_children_of_tag(self):
c = Composite()
component1 = DummyComponent("x", "a")
component2 = DummyComponent("y", "a")
component3 = DummyComponent("z", "a")
component4 = DummyComponent("Q", "Q")
c.set_child(component1)
c.set_child(component2)
c.set_child(component3)
c.set_child(component4)
self.assertFalse(component4 in c.get_children_with_tag("a"))
self.assertTrue(component1 in c.get_children_with_tag("a"))
self.assertTrue(component2 in c.get_children_with_tag("a"))
self.assertTrue(component3 in c.get_children_with_tag("a"))
示例12: test_get_children_with_tag_should_also_get_grandchildren_with_tag
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
def test_get_children_with_tag_should_also_get_grandchildren_with_tag(self):
parent = Composite()
child_1 = TestComponent(id_1, [])
child_2 = Composite("test")
grandchild_1 = TestComponent(id_1, [tag_1])
grandchild_2 = TestComponent(id_2, [tag_2])
parent.set_child(child_1)
parent.set_child(child_2)
child_2.set_child(grandchild_1)
child_2.set_child(grandchild_2)
children_with_tag_1 = parent.get_children_with_tag(tag_1)
self.assertFalse(grandchild_2 in children_with_tag_1, "Grandchild with wrong tag is returned.")
self.assertTrue(grandchild_1 in children_with_tag_1, "Grandchild is not found.")
示例13: new_poison_cloud
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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
示例14: new_frost_cloud
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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
示例15: new_dust_cloud
# 需要导入模块: from compositecore import Composite [as 别名]
# 或者: from compositecore.Composite import set_child [as 别名]
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