日志
国庆前上线了签到送奖励类新功能,收假后收到反馈有几个玩家为实际签到了却没有收到奖励,遂对游戏记录进行分析。使用的是 python ,大致记录下。
由日至文件分析筛选出两种类型的日志
其一是 签到记录,玩家实际签到的信息,需要的信息有,日期,玩家id,文件 depositcheckin.log
[2018-09-30 23:52:55.82 INF *agent*] @server/agent/camps/deposit.lua:140::[pid:1001dbd,uid:Aaa294159] deposit checkin {open_ts=1538321892,last=1538322775,lose={},with_today=true,status=1,days=1,has_mail=true}
[2018-09-30 23:52:59.17 INF *agent*] @server/agent/camps/deposit.lua:140::[pid:1001dc5,uid:Aaa294624] deposit checkin {open_ts=1538321950,last=1538322779,lose={},with_today=true,status=1,days=1,has_mail=true}
其二是查询记录,包括玩家漏签的信息,需要的信息有,玩家id,漏签日期 lose 后的数组既是,文件 depositlose.log
[2018-10-03 01:07:45.95 INF *agent*] @server/agent/main.lua:336::[pid:1004d8c,uid:Naa126591] client response: query_deposit, ret:{open_ts=1538293842,lose={"2018-10-02"},with_today=false,status=1,days=364}
[2018-10-03 01:08:23.31 INF *agent*] @server/agent/main.lua:336::[pid:1004d8c,uid:Naa126591] client response: query_deposit, ret:{open_ts=1538293842,lose={"2018-10-02"},with_today=false,status=1,days=364}
分析代码
- 打开文件读取每行日志
- 正则表达式匹配出需要的信息
- 统计每个玩家漏签,签到,并对比得到出错的漏签日期
- 代码还是很暴力哈
import re
lose,checkin = {},{}
def scan_lose():
f = open("./depositlose.log","r")
for l in f.readlines():
m = re.match(".*uid:([A-Z]+[a-z]+[0-9]+)]",l)
if not m :continue
uid = m.group(1)
if uid not in lose:
lose[uid] = []
m = re.match(".*lose={(.*)}.*}",l)
if not m :continue
ret = m.group(1)
for date in ret.split(","):
if not date or date=='""':continue
if date[1:-1] not in lose[uid]:
lose[uid].append(date[1:-1])
f.close()
def scan_checkin():
f = open("./depositcheckin.log","r")
for l in f.readlines():
m = re.match(".*uid:([A-Z]+[a-z]+[0-9]+)]",l)
if not m :continue
uid = m.group(1)
if uid not in checkin:
checkin[uid] = []
date = l[1:11]
if date not in checkin[uid]:
checkin[uid].append(date)
f.close()
def analyse():
for uid,it in lose.items():
if not it : continue
fake = []
ck = checkin.get(uid,[])
for date in it:
if date in ck and date not in fake:
fake.append(date)
if not fake:continue
print(uid,fake,len(fake))
def main():
scan_lose()
scan_checkin()
analyse()
main()
后续
虽然有反馈的玩家仅有几个,统计出来有 70 多个出错的玩家,罪过罪过!! 各个玩家漏掉的天数 1 2 3 4 天不等,旧有的补发奖励的借口,只能单次给一个人发送,遂改为可发送多人,以便使用。
网友评论