本文整理汇总了Python中engine.Engine.tower_create方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.tower_create方法的具体用法?Python Engine.tower_create怎么用?Python Engine.tower_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类engine.Engine
的用法示例。
在下文中一共展示了Engine.tower_create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import tower_create [as 别名]
class Replayer:
def __init__(self, actions):
self.actions = actions
self.game = Engine()
def next_action(self):
line = next(self.actions, None)
if line:
return json.loads(line)
else:
return None
def setup_game(self):
while True:
action = self.next_action()
if not action or action['action'] == 'start':
break;
self.play_action(action)
def play_tick(self):
while True:
action = self.next_action()
if not action:
return None
elif action['action'] == 'advance':
return self.game.advance()
self.play_action(action)
return None
def play_action(self, entry):
"""Play an action and returns its type."""
actionType = entry.pop('action')
if actionType == 'start':
pass
elif actionType == 'advance':
self.game.advance()
elif actionType == 'tower_create':
self.game.tower_create(
owner_id=entry['owner_id'],
coords=tuple(entry['coords'])
)
else:
getattr(self.game, actionType)(**entry)
return actionType