def __init__(self): # other super().__init__() self.oneUse = True # _modules self.iConfigParser = ConfigParser() self.config = self.iConfigParser.parser() self.iGlobalTimer = GlobalTimer() self.iCommands = Commands(self) # modules self.iAntiSpam = AntiSpam(self) self.iServerStatus = ServerStatus(self) self.iGiveRoles = GiveRoles(self) self.iAdmMSG = AdmMSG(self) self.iChecks = Checks(self) self.iTimeVoice = TimeVoice(self) self.iDuels = Duels(self) self.iNullCheck = NullCheck(self) self.iLevels = Levels(self) self.iStatistics = Statistics(self) self.iEconomy = Economy(self) self.iBuyRole = BuyRole(self) self.iPVC = PersonalVoiceChannels(self) self.iTimeRoles = TimeRoles(self) self.iLaV = LevelsAndVoiceRewards(self) self.iMusic = Music(self)
def test_saving_the_winner_of_a_game(save_path): """Test the saving and retrieval of game rankings.""" # First, create a completely new statistics object stats = Statistics(save_path=save_path) # Save the results of two consecutive games stats.save(ranking=["gold1", "bronze1", "silver1", "loser1"]) stats.save(ranking=["gold2", "bronze2", "silver2", "loser2"]) # Check if the results are immediatly retrievable expected_rankings = [ ["gold1", "bronze1", "silver1", "loser1"], ["gold2", "bronze2", "silver2", "loser2"], ] assert stats.data.all_rankings == expected_rankings # And then check if the same data can be retrieved after a "restart" del stats new_stats = Statistics(save_path=save_path) assert new_stats.data.all_rankings == expected_rankings
def __init__(self, buffer_size=65535, threads_count=os.cpu_count() * 2, verbose=False, show_logs=True): self.server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.buffer_size = buffer_size self.threads_count = threads_count self.stats = Statistics() self.stats_lock = threading.RLock() self.show_logs = show_logs self.verbose = verbose self.executor = ThreadPoolExecutor(max_workers=self.threads_count - 1)
def test_creation_of_save_file(save_path): """Statistics object should automatically create save file.""" stats = Statistics(save_path=save_path) save_path = stats.save_path assert save_path.exists()
def stats(save_path): """Return a statistics object which will be recycled after the test.""" return Statistics(save_path=save_path)
def __init__(self, generator_code, prev_screen): self.generator = self.GENERATOR_MAPPER[generator_code] self.result = dict() self.prev_screen = prev_screen self.statistics = Statistics()
def __init__(self) -> None: """Initialize the game with all the components.""" pg.init() pg.font.init() self.screen: graphics.Screen = graphics.Screen() # Statistics self.statistics = Statistics() # Sliders self.slides: List[graphics.Slider] = [ graphics.Slider(Slider("Drag coefficient", 50, 0, 100, 1150, 820)), graphics.Slider(Slider("Friction", 10000, 0, 30000, 1150, 880)), graphics.Slider(Slider('Player 1 mass', 1, 0.01, 2, 1300, 820)), graphics.Slider(Slider('Player 2 mass', 1, 0.01, 2, 1300, 880)), ] # Players self.players: List[player.Player] = [ player.Player(200, 200, ps.Player1Settings, mass=self.slides[2], phone=ConnectPhone()), player.Player(300, 300, ps.Player2Settings, mass=self.slides[3]), ] # Plots self.graphs: List[graphics.Graph] = [ graphics.Graph(self.players, "v"), graphics.Graph(self.players, "a", position=(1100, 400)) ] # Buttons self.buttons: List[graphics.Button] = [ graphics.Button( Button("Start!", 700, 600, 100, 50, Colors.GREEN.value, Colors.BLUE.value)) ] # End screen buttons self.end_btn: List[graphics.Button] = [ graphics.Button( Button("Retry", 600, 600, 100, 50, Colors.GREEN.value, Colors.BLUE.value)), graphics.Button( Button("Quit", 800, 600, 100, 50, Colors.RED.value, Colors.BLUE.value)), ] # Layers self.layers: List[arena.ArenaLayer] = [ arena.FrictionLayer(np.ones((ArenaSettings.x, ArenaSettings.y)), self.slides[1].get_value), arena.AirResistanceLayer(self.slides[0].get_value), ] # Arena self.arena: arena.Arena = arena.Arena(ArenaSettings.x, ArenaSettings.y, layers=self.layers) # Physic engine self.physics: Physics = Physics(self) # Input boxes self.input_boxes = [ graphics.InputBox(500, 400, 200, 32, text='player 1 name'), graphics.InputBox(800, 400, 200, 32, text='player 2 name') ] # Score self.score_table = [ graphics.Text( Texts("Win and draw probabilities", ScreenSettings.width / 2, 200, 115)), graphics.Text(Texts('', ScreenSettings.width / 2, 260, 80)), graphics.Text(Texts('', ScreenSettings.width / 2, 320, 80)), graphics.Text(Texts('', ScreenSettings.width / 2, 380, 80)), ]