-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputer.py
executable file
·36 lines (30 loc) · 1.02 KB
/
computer.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
import socket
import time
from typing import List, Tuple
from match import Match
from evaluation import Evaluation
class Computer:
def __init__(self, conn:socket, addr) -> None:
self.conn : socket = conn
self.addr = addr
self.system = ""
self.node = ""
self.cores = ""
self.actual_games : List[Match] = []
self.is_connected = True
self.nbr_game_done = 0
def set_stat(self, system, node, cores):
self.system = system
self.node = node
self.cores = cores
def add_match(self, match:Match):
time.sleep(1)
self.actual_games.append(match)
if self.is_connected:
self.conn.send(match.to_packet())
print(f"Match {match.to_string()} sent to {self.addr}")
def print_match(self):
for game in self.actual_games:
print(f"{self.addr} {game.to_string()}")
def __str__(self) -> str:
return f"{self.addr} {self.node} ({self.system}) [{self.cores}] : {self.nbr_game_done} games"