Last active
August 3, 2016 17:55
-
-
Save g2384/62a69ef9c72f3a80dc7cf3817f4f3cc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from termcolor import colored | |
import collections | |
def s_fun(p): | |
n = len(p) | |
s = ' ' + i + ' (' + str(n) + '): ' | |
l = '' | |
if n > 3: | |
p = p[:3] | |
l = ' ...' | |
for k in range(len(p)): | |
p[k] = str(p[k][0]) + '/' + str(p[k][1]) | |
return s + (', ').join(k for k in p) + l | |
a=open('file.txt', 'r') | |
b=a.read() | |
c=re.findall("""Captured ([A-Za-z ]+)! \[CP ([0-9]+)\] \[Potential ([\.0-9]+)\]""",b) | |
d={} | |
for i in c: | |
if i[0] in d.keys(): | |
d[i[0]].append([int(i[1]),float(i[2])]) | |
else: | |
d[i[0]] = [[int(i[1]),float(i[2])]] | |
d = collections.OrderedDict(sorted(d.items())) | |
for i in d.keys(): | |
pp = sorted(d[i],reverse=True) | |
if i in ['Tentacool','Gastly','Drowzee','Jynx','Caterpie','Horsea', | |
'Rattata','Zubat','Spearow','Poliwag','Pidgey','Venonat', | |
'Magnemite','Shellder','Raticate','Seel','Staryu','Goldeen', | |
'Psyduck','Magikarp','Paras','Krabby','Oddish','Bellsprout', | |
'Weedle','golbat','Hypno','Metapod','Pidgeotto','Haunter', | |
'Nidoran F', 'Nidoran M',]: | |
print(s_fun(pp)) | |
else: | |
print(colored(s_fun(pp), 'red')) | |
c_c = len(c) | |
a1 = 'Caught: ' + str(c_c) | |
c=re.findall("""Matching release rule""",b) | |
c_r = len(c) | |
c=re.findall("""Eggs hatched""",b) | |
c_e = len(c) | |
a12 = 'Released: ' + str(c_r) + ', net: ' + str(c_c - c_r + c_e) | |
c=re.findall("""Now at Pokestop:""",b) | |
cc=len(c) | |
a2 = 'Visited: ' + str(cc) | |
c=re.findall("""\[\+([0-9]+) exp\]""",b) | |
n = 0 | |
for i in c: | |
n += int(i) | |
a3 = str(n+50*cc) + ' exp]' | |
print(a1 + ', ' + a2 + ' [' + a3) | |
print('Type: ' + str(len(d.keys())) + ', ' + a12) | |
c=re.compile("""([a-zA-Z ]+) vanished""").finditer(b) | |
co = 0 | |
s3 = [] | |
if c is not None: | |
for i in c: | |
i1 = i.group() | |
i2 = i1.split(' ')[1] | |
i3 = i.span() | |
i4 = b[i3[0]-1000:i3[0]] | |
i5 = re.findall("""\[CP ([0-9]+)\] \[Potential ([\.0-9]+)\]""",i4)[-1] | |
co += 1 | |
s3.append(i2 + '[' + str(i5[0]) + '/' + str(i5[1]) + ']') | |
if co > 0: | |
print('ran away (' + str(co) + '): ' + ', '.join(s3)) | |
if c_e != 0: | |
print('Egg hatched: ' + str(c_e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment