-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstancia.py
57 lines (42 loc) · 1.79 KB
/
instancia.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
from fdps import nueva_cantidad_de_comandos, nueva_duracion_de_comando
def nuevo_tiempo_uso_del_bot() -> float:
cantidad_comandos: int = nueva_cantidad_de_comandos()
tiempo_de_uso: float = 0
for i in range(cantidad_comandos):
tiempo_de_uso += nueva_duracion_de_comando() #Esto es valido? En la realidad la duracion del comando se deberia saber al ejecutarlo, no al pedir el turno.
return tiempo_de_uso
class Instancia:
id: int
es_premium: bool
proxima_salida: float = float("inf") #High value
tiempo_ocioso: float = 0
inicio_tiempo_ocioso: float = 0
def __init__(self, id, es_premium):
self.id = id
self.es_premium = es_premium
def atender(self, tiempo_actual: float):
self.tiempo_ocioso += tiempo_actual - self.inicio_tiempo_ocioso
self.proxima_salida = tiempo_actual + nuevo_tiempo_uso_del_bot()
def terminarDeAtender(self, tiempo_actual: float):
self.inicio_tiempo_ocioso = tiempo_actual
self.proxima_salida = float("inf")
def texto_tiempo_ocioso(self, tiempo_actual: float):
porcentaje_ocioso: float = round(self.tiempo_ocioso / tiempo_actual * 100, 2)
return str(int(self.tiempo_ocioso)) + ' (' + str(porcentaje_ocioso) + '%)'
def texto_tiempo_salida(self):
if(self.esta_libre()):
return "Libre"
else:
return str(int(self.proxima_salida))
def esta_libre(self):
return self.proxima_salida == float("inf")
def get_proxima_salida(self):
return self.proxima_salida
def get_tiempo_ocioso(self):
return self.tiempo_ocioso
def get_id(self):
return self.id
def get_es_premium(self):
return self.es_premium
def es_comun(self):
return not self.es_premium