def composite_result_payload(self, context, payload): # ResultJudge if payload.get("rule", None) in ["nawabari"]: scores = context["game"].get("nawabari_scores_pct", None) print("nawabari scores = %s" % scores) if scores is not None: payload["my_team_final_percent"] = scores[0] payload["his_team_final_percent"] = scores[1] if payload.get("rule", None) in ["area", "yagura", "hoko"]: scores = context["game"].get("ranked_scores", None) print("ranked scores = %s" % scores) if scores is not None: payload["my_team_count"] = scores[0] payload["his_team_count"] = scores[1] scores = context["game"].get("earned_scores", None) if 0: # scores is not None: payload["my_team_final_point"] = scores[0] payload["his_team_final_point"] = scores[1] # ResultDetail me = IkaUtils.getMyEntryFromContext(context) if me is None: return payload["result"] = IkaUtils.getWinLoseText( context["game"]["won"], win_text="win", lose_text="lose", unknown_text=None ) if "weapon" in me: weapon = self.encode_weapon_name(me["weapon"]) if weapon: payload["weapon"] = weapon if context["game"]["is_fes"]: payload["gender"] = me["gender_en"] payload["fest_title"] = str(me["prefix_en"]).lower() self._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", "my_point", "score"], ], payload, me, ) players = [] 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" self._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"], ], player, e, ) if "weapon" in e: weapon = self.encode_weapon_name(e["weapon"]) if weapon: player["weapon"] = weapon if payload.get("rule", "nawabari") != "nawabari": if "udemae_pre" in e: player["rank"] = str(e["udemae_pre"]).lower() players.append(player) payload["players"] = players # ResultGears if ("result_gears" in context["scenes"]) and ("gears" in context["scenes"]["result_gears"]): try: gears_list = [] for e in context["scenes"]["result_gears"]["gears"]: primary_ability = e.get("main", None) secondary_abilities = [e.get("sub1", None), e.get("sub2", None), e.get("sub3", None)] gear = {"secondary_abilities": []} if primary_ability is not None: gear["primary_ability"] = primary_ability # when: # "Run Speed Up" "Locked" "Empty" # should be: (json-like) # [ "run_speed_up", null ] # - "Locked": send `null` # - "Empty": not send # - Otherwise: predefined id string ("key") for ability in secondary_abilities: if (ability is None) or (ability == "empty"): continue if ability == "locked": gear["secondary_abilities"].append(None) else: gear["secondary_abilities"].append(ability) gears_list.append(gear) payload["gears"] = {"headgear": gears_list[0], "clothing": gears_list[1], "shoes": gears_list[2]} except: IkaUtils.dprint("%s: Failed in ResultGears payload. Fix me..." % self) IkaUtils.dprint(traceback.format_exc()) # ResultUdemae if payload.get("rule", "nawabari") != "nawabari": self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ["str_lower", "rank", "result_udemae_str_pre"], ["int", "rank_exp", "result_udemae_exp_pre"], ["str_lower", "rank_after", "result_udemae_str"], ["int", "rank_exp_after", "result_udemae_exp"], ], payload, context["game"], ) knockout = context["game"].get("knockout", None) if (payload.get("rule", "nawabari") != "nawabari") and (knockout is not None): payload["knock_out"] = {True: "yes", False: "no"}[knockout] # ResultGears if "result_gears" in context["scenes"]: self._set_values( [["int", "cash_after", "cash"]], # 'type', 'stat.ink Field', 'IkaLog Field' payload, context["scenes"]["result_gears"], ) # ResultFesta if payload.get("lobby", None) == "fest": self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ["int", "fest_exp", "result_festa_exp_pre"], ["int", "fest_exp_after", "result_festa_exp"], ], payload, context["game"], ) if payload.get("fest_title", None) is not None: current_title = payload["fest_title"] if context["game"].get("result_festa_title_changed", False): try: index = fes_rank_titles.index(current_title) current_title = fes_rank_titles[index + 1] except IndexError: IkaUtils.dprint("%s: IndexError at fes_rank_titles" % self) payload["fest_title_after"] = current_title.lower() # Screenshots if self.img_result_detail is not None: img_scoreboard = anonymize(self.img_result_detail, anonOthers=self.anon_others, anonAll=self.anon_all) payload["image_result"] = self.encode_image(img_scoreboard) else: IkaUtils.dprint("%s: img_result_detail is empty." % self) if self.img_judge is not None: payload["image_judge"] = self.encode_image(self.img_judge) else: IkaUtils.dprint("%s: img_judge is empty." % self)
def composite_payload(self, context): payload = {} # Lobby lobby_type = context['lobby'].get('type', None) if lobby_type == 'public': payload['lobby'] = 'standard' elif lobby_type == 'private': payload['lobby'] = 'private' elif context['game']['is_fes'] or (lobby_type == 'festa'): payload['lobby'] = 'fest' elif lobby_type == 'tag': num_members = context['lobby'].get('team_members', None) if num_members in [2, 3, 4]: payload['lobby'] = 'squad_%d' % num_members else: IkaUtils.dprint('%s: invalid lobby key squad_%s' % (self, num_members)) else: IkaUtils.dprint('%s: No lobby information.' % self) # GameStart stage = self.encode_stage_name(context) if stage: payload['map'] = stage rule = self.encode_rule_name(context) if rule: payload['rule'] = rule if self.time_start_at and self.time_end_at: payload['start_at'] = int(self.time_start_at) payload['end_at'] = int(self.time_end_at) # In-game logs if len(context['game']['death_reasons'].keys()) > 0: payload['death_reasons'] = context['game']['death_reasons'].copy() if len(self.events) > 0: payload['events'] = list(self.events) # ResultJudge if payload.get('rule', None) in ['nawabari']: scores = context['game'].get('nawabari_scores_pct', None) print('nawabari scores = %s' % scores) if scores is not None: payload['my_team_final_percent'] = scores[0] payload['his_team_final_percent'] = scores[1] if payload.get('rule', None) in ['area', 'yagura', 'hoko']: scores = context['game'].get('ranked_scores', None) print('ranked scores = %s' % scores) if scores is not None: payload['my_team_count'] = scores[0] payload['his_team_count'] = scores[1] scores = context['game'].get('earned_scores', None) if 0: # scores is not None: payload['my_team_final_point'] = scores[0] payload['his_team_final_point'] = scores[1] # ResultDetail me = IkaUtils.getMyEntryFromContext(context) payload['result'] = IkaUtils.getWinLoseText(context['game']['won'], win_text='win', lose_text='lose', unknown_text=None) if 'weapon' in me: weapon = self.encode_weapon_name(me['weapon']) if weapon: payload['weapon'] = weapon if context['game']['is_fes']: payload['gender'] = me['gender_en'] payload['fest_title'] = str(me['prefix_en']).lower() self._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', 'my_point', 'score'], ], payload, me) players = [] 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' self._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'], ], player, e) if 'weapon' in e: weapon = self.encode_weapon_name(e['weapon']) if weapon: player['weapon'] = weapon if payload.get('rule', 'nawabari') != 'nawabari': if 'udemae_pre' in e: player['rank'] = str(e['udemae_pre']).lower() players.append(player) payload['players'] = players # ResultUdemae if payload.get('rule', 'nawabari') != 'nawabari': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['str_lower', 'rank', 'result_udemae_str_pre'], ['int', 'rank_exp', 'result_udemae_exp_pre'], ['str_lower', 'rank_after', 'result_udemae_str'], ['int', 'rank_exp_after', 'result_udemae_exp'], ], payload, context['game']) knockout = context['game'].get('knockout', None) if (payload.get('rule', 'nawabari') != 'nawabari') and (knockout is not None): payload['knock_out'] = {True: 'yes', False: 'no'}[knockout] # ResultGears if 'result_gears' in context['scenes']: self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'cash_after', 'cash'], ], payload, context['scenes']['result_gears']) # ResultFesta if payload.get('lobby', None) == 'fest': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'fest_exp', 'result_festa_exp_pre'], ['int', 'fest_exp_after', 'result_festa_exp'], ], payload, context['game']) if payload.get('fest_title', None) is not None: current_title = payload['fest_title'] if context['game'].get('result_festa_title_changed', False): try: index = fes_rank_titles.index(current_title) current_title = fes_rank_titles[index + 1] except IndexError: IkaUtils.dprint('%s: IndexError at fes_rank_titles' % self) payload['fest_title_after'] = current_title.lower() # Team colors if ('my_team_color' in context['game']): payload['my_team_color'] = { 'hue': context['game']['my_team_color']['hsv'][0] * 2, 'rgb': context['game']['my_team_color']['rgb'], } payload['his_team_color'] = { 'hue': context['game']['counter_team_color']['hsv'][0] * 2, 'rgb': context['game']['counter_team_color']['rgb'], } # Screenshots if self.img_result_detail is not None: payload['image_result'] = self.encode_image(self.img_result_detail) else: IkaUtils.dprint('%s: img_result_detail is empty.' % self) if self.img_judge is not None: payload['image_judge'] = self.encode_image(self.img_judge) else: IkaUtils.dprint('%s: img_judge is empty.' % self) # Agent Information payload['agent'] = 'IkaLog' payload['agent_version'] = IKALOG_VERSION for field in payload.keys(): if payload[field] is None: IkaUtils.dprint('%s: [FIXME] payload has blank entry %s:%s' % (self, field, payload[field])) return payload
def composite_result_payload(self, context, payload): # ResultJudge if payload.get('rule', None) in ['nawabari']: scores = context['game'].get('nawabari_scores_pct', None) print('nawabari scores = %s' % scores) if scores is not None: payload['my_team_final_percent'] = scores[0] payload['his_team_final_percent'] = scores[1] if payload.get('rule', None) in ['area', 'yagura', 'hoko']: scores = context['game'].get('ranked_scores', None) print('ranked scores = %s' % scores) if scores is not None: payload['my_team_count'] = scores[0] payload['his_team_count'] = scores[1] scores = context['game'].get('earned_scores', None) if 0: # scores is not None: payload['my_team_final_point'] = scores[0] payload['his_team_final_point'] = scores[1] # ResultDetail me = IkaUtils.getMyEntryFromContext(context) if me is None: return payload['result'] = IkaUtils.getWinLoseText(context['game']['won'], win_text='win', lose_text='lose', unknown_text=None) if 'weapon' in me: weapon = self.encode_weapon_name(me['weapon']) if weapon: payload['weapon'] = weapon if context['game']['is_fes']: payload['gender'] = me['gender_en'] payload['fest_title'] = str(me['prefix_en']).lower() self._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', 'my_point', 'score'], ], payload, me) players = [] 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' self._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'], ], player, e) if 'weapon' in e: weapon = self.encode_weapon_name(e['weapon']) if weapon: player['weapon'] = weapon if payload.get('rule', 'nawabari') != 'nawabari': if 'udemae_pre' in e: player['rank'] = str(e['udemae_pre']).lower() players.append(player) payload['players'] = players # ResultGears if ('result_gears' in context['scenes']) and ( 'gears' in context['scenes']['result_gears']): try: gears_list = [] for e in context['scenes']['result_gears']['gears']: primary_ability = e.get('main', None) secondary_abilities = [ e.get('sub1', None), e.get('sub2', None), e.get('sub3', None), ] gear = {'secondary_abilities': []} if primary_ability is not None: gear['primary_ability'] = primary_ability # when: # "Run Speed Up" "Locked" "Empty" # should be: (json-like) # [ "run_speed_up", null ] # - "Locked": send `null` # - "Empty": not send # - Otherwise: predefined id string ("key") for ability in secondary_abilities: if (ability is None) or (ability == 'empty'): continue if (ability == 'locked'): gear['secondary_abilities'].append(None) else: gear['secondary_abilities'].append(ability) gears_list.append(gear) payload['gears'] = { 'headgear': gears_list[0], 'clothing': gears_list[1], 'shoes': gears_list[2], } except: IkaUtils.dprint( '%s: Failed in ResultGears payload. Fix me...' % self) IkaUtils.dprint(traceback.format_exc()) # ResultUdemae if payload.get('rule', 'nawabari') != 'nawabari': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['str_lower', 'rank', 'result_udemae_str_pre'], ['int', 'rank_exp', 'result_udemae_exp_pre'], ['str_lower', 'rank_after', 'result_udemae_str'], ['int', 'rank_exp_after', 'result_udemae_exp'], ], payload, context['game']) knockout = context['game'].get('knockout', None) if (payload.get('rule', 'nawabari') != 'nawabari') and (knockout is not None): payload['knock_out'] = {True: 'yes', False: 'no'}[knockout] # ResultGears if 'result_gears' in context['scenes']: self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'cash_after', 'cash'], ], payload, context['scenes']['result_gears']) # ResultFesta if payload.get('lobby', None) == 'fest': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'fest_exp', 'result_festa_exp_pre'], ['int', 'fest_exp_after', 'result_festa_exp'], ], payload, context['game']) if payload.get('fest_title', None) is not None: current_title = payload['fest_title'] if context['game'].get('result_festa_title_changed', False): try: index = fes_rank_titles.index(current_title) current_title = fes_rank_titles[index + 1] except IndexError: IkaUtils.dprint('%s: IndexError at fes_rank_titles' % self) payload['fest_title_after'] = current_title.lower() # Screenshots if self.img_result_detail is not None: img_scoreboard = anonymize( self.img_result_detail, anonOthers=self.anon_others, anonAll=self.anon_all, ) payload['image_result'] = self.encode_image(img_scoreboard) else: IkaUtils.dprint('%s: img_result_detail is empty.' % self) if self.img_judge is not None: payload['image_judge'] = self.encode_image(self.img_judge) else: IkaUtils.dprint('%s: img_judge is empty.' % self)
def composite_result_payload(self, context, payload): # ResultJudge if payload.get('rule', None) in ['nawabari']: scores = context['game'].get('nawabari_scores_pct', None) print('nawabari scores = %s' % scores) if scores is not None: payload['my_team_final_percent'] = scores[0] payload['his_team_final_percent'] = scores[1] if payload.get('rule', None) in ['area', 'yagura', 'hoko']: scores = context['game'].get('ranked_scores', None) print('ranked scores = %s' % scores) if scores is not None: payload['my_team_count'] = scores[0] payload['his_team_count'] = scores[1] scores = context['game'].get('earned_scores', None) if 0: # scores is not None: payload['my_team_final_point'] = scores[0] payload['his_team_final_point'] = scores[1] # ResultDetail me = IkaUtils.getMyEntryFromContext(context) if me is None: return payload['result'] = IkaUtils.getWinLoseText( context['game']['won'], win_text='win', lose_text='lose', unknown_text=None ) if 'weapon' in me: weapon = self.encode_weapon_name(me['weapon']) if weapon: payload['weapon'] = weapon if context['game']['is_fes']: payload['gender'] = me['gender_en'] payload['fest_title'] = str(me['prefix_en']).lower() self._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', 'my_point', 'score'], ], payload, me) players = [] 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' self._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'], ], player, e) if 'weapon' in e: weapon = self.encode_weapon_name(e['weapon']) if weapon: player['weapon'] = weapon if payload.get('rule') != 'nawabari': if 'udemae_pre' in e: player['rank'] = str(e['udemae_pre']).lower() players.append(player) payload['players'] = players # ResultGears if ('result_gears' in context['scenes']) and ('gears' in context['scenes']['result_gears']): try: gears_list = [] for e in context['scenes']['result_gears']['gears']: primary_ability = e.get('main', None) secondary_abilities = [ e.get('sub1', None), e.get('sub2', None), e.get('sub3', None), ] gear = {'secondary_abilities': []} if primary_ability is not None: gear['primary_ability'] = primary_ability # when: # "Run Speed Up" "Locked" "Empty" # should be: (json-like) # [ "run_speed_up", null ] # - "Locked": send `null` # - "Empty": not send # - Otherwise: predefined id string ("key") for ability in secondary_abilities: if (ability is None) or (ability == 'empty'): continue if (ability == 'locked'): gear['secondary_abilities'].append(None) else: gear['secondary_abilities'].append(ability) gears_list.append(gear) payload['gears'] = { 'headgear': gears_list[0], 'clothing': gears_list[1], 'shoes': gears_list[2], } except: IkaUtils.dprint( '%s: Failed in ResultGears payload. Fix me...' % self) IkaUtils.dprint(traceback.format_exc()) # ResultUdemae if payload.get('rule') != 'nawabari': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['str_lower', 'rank', 'result_udemae_str_pre'], ['int', 'rank_exp', 'result_udemae_exp_pre'], ['str_lower', 'rank_after', 'result_udemae_str'], ['int', 'rank_exp_after', 'result_udemae_exp'], ], payload, context['game']) knockout = context['game'].get('knockout', None) if (payload.get('rule') != 'nawabari') and (knockout is not None): payload['knock_out'] = {True: 'yes', False: 'no'}[knockout] # ResultGears if 'result_gears' in context['scenes']: self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'cash_after', 'cash'], ], payload, context['scenes']['result_gears']) # ResultFesta if payload.get('lobby', None) == 'fest': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'fest_exp', 'result_festa_exp_pre'], ['int', 'fest_exp_after', 'result_festa_exp'], ], payload, context['game']) if payload.get('fest_title', None) is not None: current_title = payload['fest_title'] if context['game'].get('result_festa_title_changed', False): try: index = fes_rank_titles.index(current_title) current_title = fes_rank_titles[index + 1] except IndexError: IkaUtils.dprint( '%s: IndexError at fes_rank_titles' % self) payload['fest_title_after'] = current_title.lower() # Screenshots if self.img_result_detail is not None: img_scoreboard = anonymize( self.img_result_detail, anonOthers = self.anon_others, anonAll = self.anon_all, ) payload['image_result'] = self.encode_image(img_scoreboard) else: IkaUtils.dprint('%s: img_result_detail is empty.' % self) if self.img_judge is not None: payload['image_judge'] = self.encode_image(self.img_judge) else: IkaUtils.dprint('%s: img_judge is empty.' % self)
def composite_payload(self, context): payload = {} # Lobby lobby_type = context['lobby'].get('type', None) if lobby_type == 'public': payload['lobby'] = 'standard' elif lobby_type == 'private': payload['lobby'] = 'private' elif context['game']['is_fes'] or (lobby_type == 'festa'): payload['lobby'] = 'fest' elif lobby_type == 'tag': num_members = context['lobby'].get('team_members', None) if num_members in [2, 3, 4]: payload['lobby'] = 'squad_%d' % num_members else: IkaUtils.dprint('%s: invalid lobby key squad_%s' % (self, num_members)) else: IkaUtils.dprint('%s: No lobby information.' % self) # GameStart stage = self.encode_stage_name(context) if stage: payload['map'] = stage rule = self.encode_rule_name(context) if rule: payload['rule'] = rule if self.time_start_at and self.time_end_at: payload['start_at'] = int(self.time_start_at) payload['end_at'] = int(self.time_end_at) # In-game logs if len(context['game']['death_reasons'].keys()) > 0: payload['death_reasons'] = context['game']['death_reasons'].copy() if len(self.events) > 0: payload['events'] = list(self.events) # ResultJudge if payload.get('rule', None) in ['nawabari']: scores = context['game'].get('nawabari_scores_pct', None) print('nawabari scores = %s' % scores) if scores is not None: payload['my_team_final_percent'] = scores[0] payload['his_team_final_percent'] = scores[1] if payload.get('rule', None) in ['area', 'yagura', 'hoko']: scores = context['game'].get('ranked_scores', None) print('ranked scores = %s' % scores) if scores is not None: payload['my_team_count'] = scores[0] payload['his_team_count'] = scores[1] scores = context['game'].get('earned_scores', None) if 0: # scores is not None: payload['my_team_final_point'] = scores[0] payload['his_team_final_point'] = scores[1] # ResultDetail me = IkaUtils.getMyEntryFromContext(context) payload['result'] = IkaUtils.getWinLoseText( context['game']['won'], win_text='win', lose_text='lose', unknown_text=None ) if 'weapon' in me: weapon = self.encode_weapon_name(me['weapon']) if weapon: payload['weapon'] = weapon if context['game']['is_fes']: payload['gender'] = me['gender_en'] payload['fest_title'] = str(me['prefix_en']).lower() self._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', 'my_point', 'score'], ], payload, me) players = [] 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' self._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'], ], player, e) if 'weapon' in e: weapon = self.encode_weapon_name(e['weapon']) if weapon: player['weapon'] = weapon if payload.get('rule', 'nawabari') != 'nawabari': if 'udemae_pre' in e: player['rank'] = str(e['udemae_pre']).lower() players.append(player) payload['players'] = players # ResultGears if ('result_gears' in context['scenes']) and ('gears' in context['scenes']['result_gears']): try: gears_list = [] for e in context['scenes']['result_gears']['gears']: primary_ability = e.get('main', None) secondary_abilities = [ e.get('sub1', None), e.get('sub2', None), e.get('sub3', None), ] gear = {'secondary_abilities': []} if primary_ability is not None: gear['primary_ability'] = primary_ability # when: # "Run Speed Up" "Locked" "Empty" # should be: (json-like) # [ "run_speed_up", null ] # - "Locked": send `null` # - "Empty": not send # - Otherwise: predefined id string ("key") for ability in secondary_abilities: if (ability is None) or (ability == 'empty'): continue if (ability == 'locked'): gear['secondary_abilities'].append(None) else: gear['secondary_abilities'].append(ability) gears_list.append(gear) payload['gears'] = { 'headgear': gears_list[0], 'clothing': gears_list[1], 'shoes': gears_list[2], } except: IkaUtils.dprint( '%s: Failed in ResultGears payload. Fix me...' % self) IkaUtils.dprint(traceback.format_exc()) # ResultUdemae if payload.get('rule', 'nawabari') != 'nawabari': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['str_lower', 'rank', 'result_udemae_str_pre'], ['int', 'rank_exp', 'result_udemae_exp_pre'], ['str_lower', 'rank_after', 'result_udemae_str'], ['int', 'rank_exp_after', 'result_udemae_exp'], ], payload, context['game']) knockout = context['game'].get('knockout', None) if (payload.get('rule', 'nawabari') != 'nawabari') and (knockout is not None): payload['knock_out'] = {True: 'yes', False: 'no'}[knockout] # ResultGears if 'result_gears' in context['scenes']: self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'cash_after', 'cash'], ], payload, context['scenes']['result_gears']) # ResultFesta if payload.get('lobby', None) == 'fest': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'fest_exp', 'result_festa_exp_pre'], ['int', 'fest_exp_after', 'result_festa_exp'], ], payload, context['game']) if payload.get('fest_title', None) is not None: current_title = payload['fest_title'] if context['game'].get('result_festa_title_changed', False): try: index = fes_rank_titles.index(current_title) current_title = fes_rank_titles[index + 1] except IndexError: IkaUtils.dprint( '%s: IndexError at fes_rank_titles' % self) payload['fest_title_after'] = current_title.lower() # Team colors if ('my_team_color' in context['game']): payload['my_team_color'] = { 'hue': context['game']['my_team_color']['hsv'][0] * 2, 'rgb': context['game']['my_team_color']['rgb'], } payload['his_team_color'] = { 'hue': context['game']['counter_team_color']['hsv'][0] * 2, 'rgb': context['game']['counter_team_color']['rgb'], } # Screenshots if self.img_result_detail is not None: payload['image_result'] = self.encode_image(self.img_result_detail) else: IkaUtils.dprint('%s: img_result_detail is empty.' % self) if self.img_judge is not None: payload['image_judge'] = self.encode_image(self.img_judge) else: IkaUtils.dprint('%s: img_judge is empty.' % self) # Agent Information payload['agent'] = 'IkaLog' payload['agent_version'] = IKALOG_VERSION payload['IKALOG_LANG'] = Localization.get_game_languages()[0] for field in payload.keys(): if payload[field] is None: IkaUtils.dprint('%s: [FIXME] payload has blank entry %s:%s' % ( self, field, payload[field])) return payload
def composite_payload(self, context): payload = {} # Lobby lobby_type = context['lobby'].get('type', None) if lobby_type == 'public': payload['lobby'] = 'standard' elif lobby_type == 'private': payload['lobby'] = 'private' elif context['game']['is_fes'] or (lobby_type == 'festa'): payload['lobby'] = 'fest' elif lobby_type == 'tag': num_members = context['lobby'].get('team_members', None) if num_members in [2, 3, 4]: payload['lobby'] = 'squad_%d' % num_members else: IkaUtils.dprint('%s: invalid lobby key squad_%s' % (self, num_members)) else: IkaUtils.dprint('%s: No lobby information.' % self) # GameStart stage = self.encode_stage_name(context) if stage: payload['map'] = stage rule = self.encode_rule_name(context) if rule: payload['rule'] = rule if self.time_start_at and self.time_end_at: payload['start_at'] = int(self.time_start_at) payload['end_at'] = int(self.time_end_at) # In-game logs if len(context['game']['death_reasons'].keys()) > 0: payload['death_reasons'] = context['game']['death_reasons'].copy() if len(self.events) > 0: payload['events'] = list(self.events) # ResultJudge if payload.get('rule', None) in ['nawabari']: scores = context['game'].get('nawabari_scores_pct', None) print('nawabari scores = %s' % scores) if scores is not None: payload['my_team_final_percent'] = scores[0] payload['his_team_final_percent'] = scores[1] if payload.get('rule', None) in ['area', 'yagura', 'hoko']: scores = context['game'].get('ranked_scores', None) print('ranked scores = %s' % scores) if scores is not None: payload['my_team_count'] = scores[0] payload['his_team_count'] = scores[1] scores = context['game'].get('earned_scores', None) if 0: # scores is not None: payload['my_team_final_point'] = scores[0] payload['his_team_final_point'] = scores[1] # ResultDetail me = IkaUtils.getMyEntryFromContext(context) payload['result'] = IkaUtils.getWinLoseText( context['game']['won'], win_text='win', lose_text='lose', unknown_text=None ) if 'weapon' in me: weapon = self.encode_weapon_name(me['weapon']) if weapon: payload['weapon'] = weapon if context['game']['is_fes']: payload['gender'] = me['gender_en'] payload['fest_title'] = str(me['prefix_en']).lower() self._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', 'my_point', 'score'], ], payload, me) players = [] 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' self._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'], ], player, e) if 'weapon' in e: weapon = self.encode_weapon_name(e['weapon']) if weapon: player['weapon'] = weapon if payload.get('rule', 'nawabari') != 'nawabari': if 'udemae_pre' in e: player['rank'] = str(e['udemae_pre']).lower() players.append(player) payload['players'] = players # ResultUdemae if payload.get('rule', 'nawabari') != 'nawabari': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['str_lower', 'rank', 'result_udemae_str_pre'], ['int', 'rank_exp', 'result_udemae_exp_pre'], ['str_lower', 'rank_after', 'result_udemae_str'], ['int', 'rank_exp_after', 'result_udemae_exp'], ], payload, context['game']) knockout = context['game'].get('knockout', None) if (payload.get('rule', 'nawabari') != 'nawabari') and (knockout is not None): payload['knock_out'] = {True: 'yes', False: 'no'}[knockout] # ResultGears if 'result_gears' in context['scenes']: self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'cash_after', 'cash'], ], payload, context['scenes']['result_gears']) # ResultFesta if payload.get('lobby',None) == 'fest': self._set_values( [ # 'type', 'stat.ink Field', 'IkaLog Field' ['int', 'fest_exp', 'result_festa_exp_pre'], ['int', 'fest_exp_after', 'result_festa_exp'], ], payload, context['game']) if payload.get('fest_title', None) is not None: current_title = payload['fest_title'] if context['game'].get('result_festa_title_changed', False): try: index = fes_rank_titles.index(current_title) current_title = fes_rank_titles[index + 1] except IndexError: IkaUtils.dprint('%s: IndexError at fes_rank_titles' % self) payload['fest_title_after'] = current_title.lower() # Team colors if ('my_team_color' in context['game']): payload['my_team_color'] = { 'hue': context['game']['my_team_color']['hsv'][0] * 2, 'rgb': context['game']['my_team_color']['rgb'], } payload['his_team_color'] = { 'hue': context['game']['counter_team_color']['hsv'][0] * 2, 'rgb': context['game']['counter_team_color']['rgb'], } # Screenshots if self.img_result_detail is not None: payload['image_result'] = self.encode_image(self.img_result_detail) else: IkaUtils.dprint('%s: img_result_detail is empty.' % self) if self.img_judge is not None: payload['image_judge'] = self.encode_image(self.img_judge) else: IkaUtils.dprint('%s: img_judge is empty.' % self) # Agent Information payload['agent'] = 'IkaLog' payload['agent_version'] = IKALOG_VERSION for field in payload.keys(): if payload[field] is None: IkaUtils.dprint('%s: [FIXME] payload has blank entry %s:%s' % ( self, field, payload[field])) return payload