-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobal.py
More file actions
494 lines (405 loc) · 12.1 KB
/
Copy pathGlobal.py
File metadata and controls
494 lines (405 loc) · 12.1 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
import threading
class Global:
def __init__(self):
self.lock_op = threading.Lock() #para gestionar la concurrencia en otherPlayers
self.lock_cp = threading.Lock() #para currentPlayers
self.lock_rs = threading.Lock() #para refreshScreen
self.lock_to = threading.Lock() #para timeout
self.lock_np = threading.Lock() #para gestionar las salidas de la partida
self.lock_cs = threading.Lock() #para gestionar la currentScreen
self.lock_lph = threading.Lock() #para gestionar la lista de personajes en el host
self.lock_text = threading.Lock() #para gestionar el texto que va a mostrar el DM
self.lock_image = threading.Lock() #para gestionar la imagen que va a mostrar el DM
self.lock_openChest = threading.Lock()
self.lock_canTalk = threading.Lock()
self.lock_canBreak = threading.Lock()
def initialize(self):
global otherPlayers
otherPlayers = {}
global currentPlayers
currentPlayers = 1
global refreshScreen
refreshScreen = None
global timeout
timeout = None
global noEnPartida
noEnPartida = True
global currentScreen
currentScreen = "menu"
global listaPersonajesHost
listaPersonajesHost = {}
global actualPartidaState
actualPartidaState = None #por defecto es none
global tokenDePalabra
tokenDePalabra = None
global texto_DM
texto_DM = ""
global imagenPartida
imagenPartida = ""
global canStart
canStart = False
global showImage
showImage = False
global imagenPartidaBkg
imagenPartidaBkg = ""
global viewMap
viewMap = False
global m
m = None
global actionDoor
actionDoor = [0,[None,None]]
global crossedDoor
crossedDoor = [[False],[None,None]]
global canGoOutFirst
canGoOutFirst = True #cambiar cuando se haga la parte de diálogo con el NPC
global DMTalking
DMTalking = False
global canTalk
canTalk = False
global finishedStart
finishedStart = False
global canOpenChest
canOpenChest = [False,[None,None]]
global canBreak
canBreak = [False,[None,None]]
global showNombreNPC
showNombreNPC = ""
global modoHabla
modoHabla = False
global textoMensaje
textoMensaje = ""
global lista
lista = list()
global searchingSong
searchingSong = False
global textWriten
textWriten = True
# Estadísticas
global mobsDiscovered
mobsDiscovered = 0
global roomsVisited
roomsVisited = 0
global openedChests
openedChests = 0
global brokenObjects
brokenObjects = 0
global endingTime
endingTime = 0
global numSalas
numSalas = 0
def setTextWriten(self,v):
global textWriten
textWriten = v
def getTextWriten(self):
global textWriten
return textWriten
def setNumSalas(self,v):
global numSalas
numSalas = v
def getNumSalas(self):
global numSalas
return numSalas
def setEndingTime(self,v):
global endingTime
endingTime = v
def getEndingTime(self):
global endingTime
return endingTime
def resetMob(self):
global mobsDiscovered
mobsDiscovered = 0
def resetRooms(self):
global roomsVisited
roomsVisited = 0
def resetOpened(self):
global openedChests
openedChests = 0
def resetBroken(self):
global brokenObjects
brokenObjects = 0
def addMob(self):
global mobsDiscovered
mobsDiscovered+=1
def getMobsDiscoverder(self):
global mobsDiscovered
return mobsDiscovered
def addRoomVisited(self):
global roomsVisited
roomsVisited+=1
def getRoomsVisited(self):
global roomsVisited
return roomsVisited
def addBrokenObject(self):
global brokenObjects
brokenObjects+=1
def getBrokenObjects(self):
global brokenObjects
return brokenObjects
def addOpenedChest(self):
global openedChests
openedChests+=1
def getOpenedChest(self):
global openedChests
return openedChests
def setSearchingSong(self,v):
global searchingSong
searchingSong = v
def getSearchingSong(self):
global searchingSong
return searchingSong
def addElementToListaAndRemoveFirst(self,i):
global lista
lista.append(i)
if(len(lista) > 10):
lista.pop(0)
def getLista(self):
global lista
return lista
def setTextoMensaje(self,v):
global textoMensaje
textoMensaje = v
def getTextoMensaje(self):
global textoMensaje
return textoMensaje
def setModoHabla(self,v):
global modoHabla
modoHabla = v
def getModoHabla(self):
global modoHabla
return modoHabla
def setShowNombreNPC(self,v):
global showNombreNPC
showNombreNPC = v
def getShowNombreNPC(self):
global showNombreNPC
return showNombreNPC
def setCanBreak(self,v):
global canBreak
self.lock_canBreak.acquire()
canBreak = v
self.lock_canBreak.release()
def getCanBreak(self):
global canBreak
return canBreak
def setCanOpenChest(self,v):
global canOpenChest
self.lock_openChest.acquire()
canOpenChest = v
self.lock_openChest.release()
def getCanOpenChest(self):
global canOpenChest
return canOpenChest
def setFinishedStart(self,v):
global finishedStart
finishedStart = v
def getFinishedStart(self):
global finishedStart
return finishedStart
def setCanTalkToNPC(self,v):
global canTalk
self.lock_canTalk.acquire()
canTalk = v
self.lock_canTalk.release()
def getCanTalkToNPC(self):
global canTalk
return canTalk
def setDMTalking(self,v):
global DMTalking
DMTalking = v
def getDMTalking(self):
global DMTalking
return DMTalking
def canGoOutFirst(self):
global canGoOutFirst
return canGoOutFirst
def setCanGoOutFirst(self,v):
global canGoOutFirst
canGoOutFirst = v
def getCrossedDoor(self):
global crossedDoor
return crossedDoor
def setCrossedDoor(self,v):
global crossedDoor
crossedDoor = v
def getActionDoor(self):
global actionDoor
return actionDoor
def setActionDoor(self,v):
global actionDoor
actionDoor = v
def getViewMap(self):
global viewMap
return viewMap
def setMAPA(self, m):
global mapa
mapa = m
def getMapa(self):
global mapa
return mapa
def setViewMap(self,v):
global viewMap
viewMap = v
def getImagePartidaBkg(self):
global imagenPartidaBkg
return imagenPartidaBkg
def setImagePartidaBkg(self,v):
global imagenPartidaBkg
imagenPartidaBkg = v
def setShowImage(self,v):
global showImage
showImage = v
def getShowImage(self):
global showImage
return showImage
def setCanStart(self,v):
global canStart
canStart = v
def getCanStart(self):
global canStart
return canStart
def setImagePartida(self,path):
global imagenPartida
self.lock_image.acquire()
imagenPartida = path
self.lock_image.release()
def getImagePartida(self):
global imagenPartida
self.lock_image.acquire()
img = imagenPartida
imagenPartida = ""
self.lock_image.release()
return img
def setTextoDM(self,texto):
global texto_DM
self.lock_text.acquire()
texto_DM = texto
self.lock_text.release()
def extractAndRemoveTextoDM(self):
global texto_DM
self.lock_text.acquire()
aux = texto_DM
texto_DM = ""
self.lock_text.release()
return aux
def setTokenDePalabra(self,id_usuario):
global tokenDePalabra
tokenDePalabra = id_usuario
def getTokenDePalabra(self):
global tokenDePalabra
return tokenDePalabra
def setActualPartidaState(self,state):
global actualPartidaState
actualPartidaState = state
def getActualPartidaState(self):
global actualPartidaState
return actualPartidaState
def setCurrentScreen(self,s):
global currentScreen
self.lock_cs.acquire()
currentScreen = s
self.lock_cs.release()
def setListaPersonajesHost(self,l):
global listaPersonajesHost
self.lock_lph.acquire()
listaPersonajesHost = l
self.lock_lph.release()
def getListaPersonajeHost(self):
global listaPersonajesHost
return listaPersonajesHost
def setListaPersonajeHostIndex(self,index,personaje):
global listaPersonajesHost
self.lock_lph.acquire()
listaPersonajesHost[index] = personaje
self.lock_lph.release()
def getListaPersonajeHostIndex(self,index):
global listaPersonajesHost
personaje = listaPersonajesHost.get(index)
if(personaje != None):
return personaje
else:
return -1
def getCurrentScreen(self):
global currentScreen
return currentScreen
def setOtherPlayers(self,list):
global otherPlayers
#print('antes',otherPlayers)
self.lock_op.acquire()
otherPlayers = list
#print('despues',otherPlayers)
self.lock_op.release()
def getOtherPlayersTotalRegistered(self):
global otherPlayers
cont = 0
if (otherPlayers != {}):
for i,player in otherPlayers.items():
if player != None:
cont +=1
return cont
def getTimeout(self):
global timeout
return timeout
def setEnPartida(self):
global noEnPartida
self.lock_np.acquire()
noEnPartida = False
self.lock_np.release()
def getNoEnPartida(self):
global noEnPartida
return noEnPartida
def setNoEnPartida(self):
global noEnPartida
self.lock_np.acquire()
noEnPartida = True
self.lock_np.release()
def setTimeout(self,v):
global timeout
self.lock_to.acquire()
timeout = v
self.lock_to.release()
def decreaseTimeout(self):
global timeout
self.lock_to.acquire()
timeout = timeout - 1
self.lock_to.release()
def getTimeoutIndex(self,i):
global timeout
return timeout[i]
def decreaseTimeoutIndex(self,i):
global timeout
self.lock_to.acquire()
timeout[i] = timeout[i] - 1
self.lock_to.release()
def setTimeoutIndex(self,i,v):
global timeout
self.lock_to.acquire()
timeout[i] = v
self.lock_to.release()
def setRefreshScreen(self,screenToRefresh):
global refreshScreen
self.lock_rs.acquire()
refreshScreen = screenToRefresh
self.lock_rs.release()
def getRefreshScreen(self):
global refreshScreen
return refreshScreen
def setOtherPlayersIndex(self,i,v):
global otherPlayers
self.lock_op.acquire()
otherPlayers[i] = v
self.lock_op.release()
#print(otherPlayers)
def setCurrentPlayers(self,i):
global currentPlayers
self.lock_cp.acquire()
currentPlayers = i
self.lock_cp.release()
def getOtherPlayers(self):
global otherPlayers
return otherPlayers
def getOtherPlayersIndex(self,i):
global otherPlayers
return otherPlayers[i]
def getCurrentPlayers(self):
global currentPlayers
return currentPlayers