-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror_checker.py
More file actions
140 lines (130 loc) · 7.07 KB
/
Copy patherror_checker.py
File metadata and controls
140 lines (130 loc) · 7.07 KB
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
138
139
140
import globe
import time
import _thread
import io
import controlers
import traceback
import sys
from datetime import datetime
class dupe_checker:
all_cards = []
all_piles = []
players = 0
keep_checking = True
displayed = False
def __init__(self):
self.all_cards = []
self.all_piles = []
self.keep_checking = True
self.displayed = False
self.all_piles.append(globe.boss.main_deck)
# print("Main deck",self.all_piles[-1],file = buf)
self.all_piles.append(globe.boss.lineup)
# print("Lineup",self.all_piles[-1],file = buf)
self.all_piles.append(globe.boss.destroyed_stack)
# print("Destroyed",self.all_piles[-1],file = buf)
self.all_piles.append(globe.boss.supervillain_stack)
# print("SV stack",self.all_piles[-1],file = buf)
self.all_piles.append(globe.boss.kick_stack)
# print("Kick stack",self.all_piles[-1],file = buf)
self.all_piles.append(globe.boss.weakness_stack)
# print("Weaknesses",self.all_piles[-1],file = buf)
for i, p in enumerate(globe.boss.players):
self.all_piles.append(p.deck)
# print(f"p{i} deck",self.all_piles[-1],file = buf)
self.all_piles.append(p.hand)
# print(f"p{i} hand",self.all_piles[-1],file = buf)
self.all_piles.append(p.ongoing)
# print(f"p{i} ongoing",self.all_piles[-1],file = buf)
self.all_piles.append(p.discard)
# print(f"p{i} discard",self.all_piles[-1],file = buf)
self.all_piles.append(p.played)
# print(f"p{i} played",self.all_piles[-1],file = buf)
self.all_piles.append(p.under_superhero)
# print(f"p{i} under_superhero",self.all_piles[-1],file = buf)
self.all_piles.append(p.over_superhero)
# print(f"p{i} over_superhero",self.all_piles[-1],file = buf)
for pile in self.all_piles:
self.all_cards.extend(pile.contents)
def check(self):
buf = io.StringIO()
# print("hello",file=buf)
# print(buf.getvalue())
# print("test",flush=True)
if len(globe.boss.supervillain_stack.contents) > 0 and self.displayed == False:
for c in self.all_cards:
count = 0
found = []
for p in self.all_piles:
add = p.contents.count(c)
if add > 0:
found.append(p)
# Ongoing cards can be played by others. Once they are discarded tho, they should
# go back to their owners
# This is done in the 'discard_a_card' area
if p.owner != c.owner and p != globe.boss.players[
globe.boss.whose_turn].played and p.name != "Ongoing":
print(datetime.now().strftime("%m/%d/%Y, %H:%M:%S"), file=buf, flush=True)
print(
"ERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO\nERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO\nERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO\nERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO\nERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO",
flush=True)
print("---Card Debug Info:---", flush=True)
print(c.__dict__, flush=True)
print("---Card Owner Debug Info:---", flush=True)
print(c.owner.__dict__)
print("---Pile Debug Info:---", flush=True)
print(p.__dict__, flush=True)
print("---Pile Owner Debug Info:---", flush=True)
print(p.owner.__dict__)
print(f"Owner not set properly.", c.name, c, c.owner, p.name, p.owner, file=buf, flush=True)
if c.owner != None:
print("card owner:", c.owner.persona.name, file=buf, flush=True)
if p.owner != None:
print("pile owner:", p.owner.persona.name, file=buf)
self.keep_checking = False
count += add
if count != 1:
print(datetime.now().strftime("%m/%d/%Y, %H:%M:%S"), file=buf)
print(
"ERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO\nERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO\nERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO\nERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO\nERRORERRORERRORERRORERRORERRORERRORERRORERRROERRORERRORERRORERRORERRORERRORERRORERRORERRRO",
file=buf)
print("ERROR card number unexpected:", c.name, count, c.owner, file=buf)
for p in globe.boss.players:
print(p.persona.name)
print("---Card Debug Info:---", flush=True)
print(c)
print(c.__dict__, flush=True)
print(c.location_tracking, flush=True)
for p in c.location_tracking:
print(p[0].name, p[1], None if p[3] is None else p[3].persona.name, flush=True)
print("---Card Owner Debug Info:---", flush=True)
print(c.owner.__dict__)
for p in found:
print("pile ", p.name, file=buf)
if p.owner is not None:
print("-", p.owner.persona.name, file=buf)
self.keep_checking = False
if self.keep_checking == False and self.displayed == False:
self.displayed = True
globe.PAUSED_STATE = 0
print(buf.getvalue(), flush=True)
# globe.boss.players[0].controler = controlers.human(globe.boss.players[0], False)
globe.boss.players[0].controler = controlers.human_view(globe.boss.players[0], False)
# return (True,buf.getvalue())
# globe.boss.players[0].controler = controlers.human(globe.boss.players[0],False)
# quit()
return (False, None)
def constant_check(self, thread_name, delay):
while True:
self.check()
time.sleep(0.1)
def setup_checker(self):
print("STARTING ERR CHECKER", flush=True)
try:
_thread.start_new_thread(self.constant_check, ("Error Checker", 2,))
except Exception as e:
print("ERR:", e)
print("Exception in user code:")
print('-' * 60)
traceback.print_exc(file=sys.stdout)
print('-' * 60)