本文整理匯總了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)