本文整理汇总了Python中entity.Entity方法的典型用法代码示例。如果您正苦于以下问题:Python entity.Entity方法的具体用法?Python entity.Entity怎么用?Python entity.Entity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity
的用法示例。
在下文中一共展示了entity.Entity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_game_variables
# 需要导入模块: import entity [as 别名]
# 或者: from entity import Entity [as 别名]
def get_game_variables(constants):
fighter_component = Fighter(hp=100, defense=1, power=2)
inventory_component = Inventory(26)
level_component = Level()
equipment_component = Equipment()
player = Entity(0, 0, '@', libtcod.white, 'Player', blocks=True, render_order=RenderOrder.ACTOR,
fighter=fighter_component, inventory=inventory_component, level=level_component,
equipment=equipment_component)
entities = [player]
equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2)
dagger = Entity(0, 0, '-', libtcod.sky, 'Dagger', equippable=equippable_component)
player.inventory.add_item(dagger)
player.equipment.toggle_equip(dagger)
game_map = GameMap(constants['map_width'], constants['map_height'])
game_map.make_map(constants['max_rooms'], constants['room_min_size'], constants['room_max_size'],
constants['map_width'], constants['map_height'], player, entities)
message_log = MessageLog(constants['message_x'], constants['message_width'], constants['message_height'])
game_state = GameStates.PLAYERS_TURN
return player, entities, game_map, message_log, game_state
示例2: __init__
# 需要导入模块: import entity [as 别名]
# 或者: from entity import Entity [as 别名]
def __init__(self, entity):
if isinstance(entity, Entity):
self.entity = entity
self.table = entity.table
elif isinstance(entity, str):
self.entity = None
self.table = entity
else:
raise ValueError("Invalid argument type.")
示例3: place_entities
# 需要导入模块: import entity [as 别名]
# 或者: from entity import Entity [as 别名]
def place_entities(room, entities, max_monsters_per_room, colors):
"""
Randomly places entities.
:param room: Rect
:param entities: list<Entity>
:param max_monsters_per_room: int
:param colors: dict<tuple<int>(r, g, b)>>
"""
# Get a random number of monsters
number_of_monsters = randint(0, max_monsters_per_room)
for i in range(number_of_monsters):
# Choose a random location in the room
x = randint(room.x1 + 1, room.x2 - 1)
y = randint(room.y1 + 1, room.y2 - 1)
if not any([entity for entity in entities if entity.x == x and entity.y == y]):
if randint(0, 100) < 80:
fighter_component = Fighter(hp=10, defense=0, power=3)
ai_component = BasicMonster()
monster = Entity(x, y, 'o', colors.get('desaturated_green'), 'Orc', blocks=True,
render_order=RenderOrder.ACTOR, fighter=fighter_component, ai=ai_component)
else:
fighter_component = Fighter(hp=16, defense=1, power=4)
ai_component = BasicMonster()
monster = Entity(x, y, 'T', colors.get('darker_green'), 'Troll', blocks=True,
render_order=RenderOrder.ACTOR, fighter=fighter_component, ai=ai_component)
entities.append(monster)
示例4: get_game_variables
# 需要导入模块: import entity [as 别名]
# 或者: from entity import Entity [as 别名]
def get_game_variables(constants):
fighter_component = Fighter(hp=100, defense=1, power=2)
inventory_component = Inventory(26)
level_component = Level()
equipment_component = Equipment()
player = Entity(0, 0, '@', (255, 255, 255), 'Player', blocks=True, render_order=RenderOrder.ACTOR,
fighter=fighter_component, inventory=inventory_component, level=level_component,
equipment=equipment_component)
entities = [player]
equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2)
dagger = Entity(0, 0, '-', constants['colors'].get('sky'), 'Dagger', equippable=equippable_component)
player.inventory.add_item(dagger, constants['colors'])
player.equipment.toggle_equip(dagger)
game_map = GameMap(constants['map_width'], constants['map_height'])
make_map(game_map, constants['max_rooms'], constants['room_min_size'],
constants['room_max_size'], constants['map_width'], constants['map_height'], player, entities,
constants['colors'])
message_log = MessageLog(constants['message_x'], constants['message_width'],
constants['message_height'])
game_state = GameStates.PLAYERS_TURN
return player, entities, game_map, message_log, game_state
示例5: createEntity
# 需要导入模块: import entity [as 别名]
# 或者: from entity import Entity [as 别名]
def createEntity(namestr, parentstr, childstr):
name = namestr.split(' ')
parent = parentstr.split(' ')
child = childstr.split(' ')
entity = Entity(name, parent, child)
entity.displayEntity()
return entity
示例6: __init__
# 需要导入模块: import entity [as 别名]
# 或者: from entity import Entity [as 别名]
def __init__(self, pkt: pyshark.packet.packet.Packet):
self.packets = []
self.protocols = Counter()
self.logger = Logger(self.__class__.__name__)
is_packet_upstream = check_if_packet_is_upstream(pkt)
if is_packet_upstream is not None:
self.start_time = float(pkt.sniff_timestamp)
self.end_time = float(pkt.sniff_timestamp)
self.ingest(pkt)
self.client = Entity(pkt, is_packet_upstream)
self.server = Entity(pkt, not is_packet_upstream)
else:
self.logger.error("Packet does not include client configured IP. Packet number: " + pkt.number)
示例7: mapToPXF
# 需要导入模块: import entity [as 别名]
# 或者: from entity import Entity [as 别名]
def mapToPXF(samples):
# Add Entity(s)
sample_1 = Entity(
id = "http://ga4gh.org/samples/1",
type = EntityType.sample)
# sample_2 = Entity(
# id = "http://ga4gh.org/samples/2",
# type = EntityType.sample)
# phenopacket_entities = [sample_1, sample_2]
phenopacket_entities = [sample_1]
environment = Environment()
severity = ConditionSeverity()
onset = TemporalRegion()
offset = TemporalRegion()
phenotype_1_1 = Phenotype(
environment=environment,
severity=severity,
onset=onset,
offset=offset)
#phenotype_1_1.onset = TemporalRegion()
phenotype_1_1.types = [OntologyClass()]
phenotype_1_1.types[0].id = "HP:0003593"
phenotype_1_1.types[0].label = "Infantile onset"
phenotype_association_1_1 = PhenotypeAssociation(
entity = sample_1.id,
evidence_list = [], # Sequence[Evidence]=[],
# created = "!!date 2016 2 9"
phenotype = phenotype_1_1)
phenotype_profile_1 = [phenotype_association_1_1] # : Sequence[PhenotypeAssociation]=[]
phenopacket = PhenoPacket(
packet_id = "packet1",
title = "Biosample export",
entities = phenopacket_entities,
# schema = "journal-example-level-1",
# '@context = "http://phenopacket.github.io/context/context.jsonld",
phenotype_profile = phenotype_profile_1)
print(phenopacket)