Commit db6d7aad authored by 陈俊羽's avatar 陈俊羽
Browse files

增加了尾刀记录和刀均伤害

parent 15630439
......@@ -15,7 +15,7 @@ jobs:
- name: Build exec file
uses: JackMcKew/pyinstaller-action-windows@main
with:
path: src
path: .
spec: KnightReport.spec
- name: Upload asset to release
......
......@@ -4,7 +4,7 @@
block_cipher = None
a = Analysis(['..\\src\\main.py', '..\\src\\ctrl.py', '..\\src\\constants.py', '..\\src\\utils.py'],
a = Analysis(['src\\main.py', 'src\\ctrl.py', 'src\\constants.py', 'src\\utils.py'],
pathex=[],
binaries=[],
datas=[],
......
......@@ -34,8 +34,6 @@ class Ctrl:
self.combat: Union[Combat, None] = None
self.all_uid: Set = set()
def exec(self):
r"""
execute the whole generating stream
......@@ -120,11 +118,10 @@ class Ctrl:
hits = person_attack['damage_num']
# check abnormal hits today
if hits > 3:
logging.warning("玩家uid {:d}于日期{:s} 对boss{:s} 异常出刀数{:d}"
.format(uid, self.dates[index], boss_name,
self.person_info[uid].boss_hits[boss_name]))
logging.warning("玩家uid {:d}于日期{:s} 异常出刀数{:d}"
.format(uid, self.dates[index], hits))
logging.warning("记录当日战斗日志")
logging.warning(f"{json.dumps(attack_status)}")
logging.warning(attack_status)
damage = person_attack['damage_total']
self.person_info[uid].hits += hits
self.person_info[uid].damage += damage
......@@ -135,7 +132,13 @@ class Ctrl:
boss_name = damage_once['boss_name']
self.combat.add_boss(boss_name)
damage = damage_once['damage']
self.person_info[uid].add_hit(boss_name, damage)
killed = damage_once['is_kill']
if killed != 0 and killed != 1:
logging.error("玩家uid {:d}于日期{:s} 异常尾刀数{:d}"
.format(uid, self.dates[index], killed))
logging.error("记录当日战斗日志")
logging.error(attack_status)
self.person_info[uid].add_hit(boss_name, damage, killed)
# People don't join combat today
for uid in self.all_uid.difference(uid_today):
self.person_info[uid].omission[index] = -3
import csv
import logging
from typing import Sequence, Dict, List
......@@ -8,7 +7,9 @@ class Info:
self.uid: int = uid
self.name: str = name
self.hits: int = 0
self.kill: int = 0
self.damage: int = 0
self.not_killed_damage: int = 0
self.boss_hits: Dict[str, int] = {}
self.boss_damage: Dict[str, int] = {}
# omit can be [-3, 0], -x equals omit x hit one day
......@@ -21,7 +22,13 @@ class Info:
else:
return str(x)
def add_hit(self, boss_target: str, damage: int):
def add_hit(self, boss_target: str, damage: int, killed: int):
if killed == 0:
self.not_killed_damage += damage
elif killed == 1:
self.kill += 1
else:
raise ValueError
if not self.boss_hits.__contains__(boss_target):
self.boss_hits[boss_target] = 1
self.boss_damage[boss_target] = damage
......@@ -39,7 +46,9 @@ class Info:
date_status = [self.omit_mapping(omit) for omit in self.omission]
status = [self.uid, self.name, self.hits, self.damage]
avg_damage = '{:d}'.format(
self.not_killed_damage // (self.hits - self.kill)) if self.hits - self.kill > 0 else '-'
status = [self.uid, self.name, self.hits, self.damage, self.kill, avg_damage]
status.extend(boss_status)
status.extend(date_status)
return status
......@@ -70,7 +79,7 @@ class Combat:
self._boss_set.add(name)
def marshal(self, person_list: Sequence[Info], filename: str):
headers = ["uid", "玩家", "出刀", "伤害"]
headers = ["uid", "玩家", "出刀", "伤害", "尾刀", "均伤(除尾刀)"]
for boss in self.boss_name:
headers.extend(["{:s}出刀".format(boss), "{:s}伤害".format(boss)])
......
from random import randint
from typing import Dict
class TestData:
user_id_range = [1000000000, 2000000000]
provided_names = ['一方通行', '未元物质', '超电磁炮', '原子崩坏', '心理掌握',
'存在缺失', '倚云桑', 'ろい', '皓烁', '是你的嘉云呀',
'潍胤', '无影惜梦', '乌雅乐家', '日允', '骞暄',
'第七绮文', '乐羊楠楠', '彬彬', '阿伟', '杰哥',
'陈少龙', '东仙队长', '人类高质量男性', '你', 'FBI',
'na@na', '42', '田所浩二', '福瑞控', '蒙古上单']
def __init__(self):
# generate num user
self.num = 30
self.ids = set()
self.names = set()
while len(self.ids) < self.num:
self.ids.add(randint(self.user_id_range[0], self.user_id_range[1]))
while len(self.names) < self.num:
if len(self.names) < len(self.provided_names):
self.names.add(self.provided_names[len(self.names)])
else:
self.names.add(str(randint(10000, 99999)))
self.ids = list(self.ids)
self.names = list(self.names)
@property
def attack_data(self) -> Dict:
from template import template_attack_data
attack_data = template_attack_data
for i in range(len(attack_data['data'])):
attack_data['data'][i]['user_id'] = self.ids[i]
attack_data['data'][i]['user_name'] = self.names[i]
return attack_data
@property
def guild_data(self) -> Dict:
from template import template_guild_data
guild_data = template_guild_data
for i in range(len(guild_data['data']['member'])):
guild_data['data']['member'][i]['id'] = self.ids[i]
guild_data['data']['member'][i]['name'] = self.names[i]
return guild_data
import os
import sys
import unittest
sys.path.append(os.path.join(__file__, '../../src'))
from src.ctrl import Ctrl
from testcase.data import TestData
class TestCtrl(unittest.TestCase):
def setUp(self):
self.data = TestData()
def test_extract_guild(self):
ctrl = Ctrl()
ctrl.extract_guild_info(self.data.guild_data)
self.assertEqual(ctrl.uid_name, dict(zip(self.data.ids, self.data.names)))
self.assertEqual(ctrl.all_uid, set(self.data.ids))
def test_extract_attack(self):
ctrl = Ctrl()
ctrl.extract_guild_info(self.data.guild_data)
ctrl.extract_date_info(0, self.data.attack_data)
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment