日志
國慶前上線了簽到送獎勵類新功能,收假后收到反饋有幾個玩家為實際簽到了卻沒有收到獎勵,遂對游戲記錄進行分析。使用的是 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 天不等,舊有的補發獎勵的借口,只能單次給一個人發送,遂改為可發送多人,以便使用。