本文整理汇总了Python中ikalog.utils.IkaUtils.getMyEntryFromContext方法的典型用法代码示例。如果您正苦于以下问题:Python IkaUtils.getMyEntryFromContext方法的具体用法?Python IkaUtils.getMyEntryFromContext怎么用?Python IkaUtils.getMyEntryFromContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ikalog.utils.IkaUtils
的用法示例。
在下文中一共展示了IkaUtils.getMyEntryFromContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getMyEntryFromContext
# 需要导入模块: from ikalog.utils import IkaUtils [as 别名]
# 或者: from ikalog.utils.IkaUtils import getMyEntryFromContext [as 别名]
def test_getMyEntryFromContext(self):
context = {'game': {}}
self.assertIsNone(IkaUtils.getMyEntryFromContext(context))
context['game']['players'] = [
{'me': False, 'team': 1, 'rank_in_team': 1},
{'me': False, 'team': 1, 'rank_in_team': 2},
{'me': False, 'team': 2, 'rank_in_team': 1},
{'me': False, 'team': 2, 'rank_in_team': 2},
]
self.assertIsNone(IkaUtils.getMyEntryFromContext(context))
context['game']['players'][2]['me'] = True
me = IkaUtils.getMyEntryFromContext(context)
self.assertEqual(2, me['team'])
self.assertEqual(1, me['rank_in_team'])
示例2: composite_payload
# 需要导入模块: from ikalog.utils import IkaUtils [as 别名]
# 或者: from ikalog.utils.IkaUtils import getMyEntryFromContext [as 别名]
def composite_payload(self, context):
payload = {
# 'id': game_id,
#'recognition_source': filename,
'recognition_at': int(time.time()),
'agent': 'IkaLog re-recognition',
'agent_version': IKALOG_VERSION,
'players': [],
}
me = IkaUtils.getMyEntryFromContext(context)
for e in context['game']['players']:
player = {}
player['team'] = 'my' if (e['team'] == me['team']) else 'his'
player['is_me'] = 'yes' if e['me'] else 'no'
player['weapon'] = e['weapon']
payload['players'].append(player)
_set_values(
[ # 'type', 'stat.ink Field', 'IkaLog Field'
['int', 'rank_in_team', 'rank_in_team'],
['int', 'kill', 'kills'],
['int', 'death', 'deaths'],
['int', 'level', 'rank'],
['int', 'point', 'score'],
['str_lower', 'rank', 'udemae_pre'],
], player, e)
return payload