forked from IreneeMichel/MagicCardBattle
-
Notifications
You must be signed in to change notification settings - Fork 2
/
TouchMonsterFiles.py
137 lines (122 loc) · 4.61 KB
/
TouchMonsterFiles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 23 13:26:15 2016
@author: enfants
"""
import os
#import pickle
import glob
#import types
#import time
os.chdir(os.path.dirname(os.path.realpath(__file__)))
#from Card import Card
#from Target import MasseEnemi,MasseEnnemi,Personnel
#from cardPowers import Guerison,GuerisonHeros
#def searchPower(o,max_depth=8) :
# for o2n in dir(o) :
# p=getattr(o,o2n)
# if isinstance(p,MasseEnemi) :
# print " pb found masse enemis"
# setattr(o,o2n,MasseEnnemi())
# """
# if isinstance(p,Personal) :
# print " pb found personel"
# setattr(o,o2n,Personnel())
# if isinstance(p,Guerrison) :
# print " pb found guerison"
# setattr(o,o2n,Guerison())
# getattr(o,o2n).level=p.level
# getattr(o,o2n).target=p.target
# if isinstance(p,GuerrisonHero) :
# print " pb found guerison hero"
# setattr(o,o2n,GuerisonHeros())
# getattr(o,o2n).level=p.level
# """
# for o2n in dir(o) :
# o2=getattr(o,o2n)
# if type(o2)==type([]) :
# #print o2n," is list",o2
# for o3 in o2 :
## if isinstance(o3,Guerrison) :
## print " pb found"
## o2.append(Guerison())
## o2[-1].level=o3.level
## o2[-1].target=o3.target
## o2.remove(o3)
## elif isinstance(o3,GuerrisonHero) :
## print " pb found"
## o2.append(GuerisonHeros())
## o2[-1].level=o3.level
## o2.remove(o3)
## else :
# if type(o3)==types.InstanceType and max_depth>0 :
# searchPower(o3,max_depth-1)
# if type(o2)==types.InstanceType and max_depth>0 and o2n!="card" :
# searchPower(o2,max_depth-1)
#for f in glob.glob("CardFiles/*_monsters.sav"):
# if f in ("CardFiles\\all_monsters.sav","CardFiles\\recup_monsters.sav") :
# continue
# print "** cards in ",f
# with open(f, "rb") as fi:
# mobs = pickle.load( fi)
# for n,m in mobs.items() :
# print "* "+n
# searchPower(m)
# pickle.dump(mobs,open(f,"wb"))
from Card import readMonsters
print "nettoyage unknown_monsters.sav"
monsters = readMonsters(os.path.join("CardFiles","unknown_monsters.sav"))
for f in glob.glob("CardFiles/*_monsters.sav"):
if ("unknown_monsters.sav" in f) or ("all_monsters.sav" in f) or ("recup_monsters.sav" in f) :
continue
print "cards in ",f
good = readMonsters(f)
for m in good :
if m in monsters :
print m
del monsters[m]
open(os.path.join("CardFiles","unknown_monsters.sav"),"w").write("\n".join([m.constructor() for m in monsters.values()]))
all_monsters = readMonsters(os.path.join("CardFiles","all_monsters.sav"))
# monsters.update(good)
#
# pickle.dump(monsters,open( "CardFiles/all_monsters.sav","wb"))
print "recreation toutes images et met Majuscule"
bad_opt={}
problem=[]
for f in glob.glob("CardFiles/*_monsters.sav"):
if ("all_monsters.sav" in f) or ("recup_monsters.sav" in f) :
continue
print "** cards in ",f
mobs = readMonsters( f)
for n,m in mobs.items() :
print "* "+n
try :
goodname=n[0].upper()+n[1:]
if n!=goodname :
m.deleteCreature(n)
if goodname in all_monsters :
continue
try:
if n!=m.name :
m.deleteCreature(m.name)
try:
m.name=goodname
if "CardFiles" not in m.dumping_file :
m.dumping_file=f+" or CardFiles\\"+m.dumping_file
m.save()
try:
co=m.getCost()
if (co-int(co))<0.5 and m.pv>0 :
bad_opt[n]=(co-int(co))
except:
problem.append([f,n,"part 3"])
#time.wait(1)
except Exception as err:
print err
problem.append([f,n,"part 2.5"])
except :
problem.append([f,n,"part 2"])
except:
problem.append([f,n,"part 1"])
print "problem with ",problem
print "\na revoir",bad_opt