def shutdown(self, source=None): # Write log files # write_json_file(self.game_logs, LOGS_FILE) # Retrieve and write results information results_information = None if SET_NUMBER_OF_CLIENTS_START == 1: results_information = self.master_controller.return_final_results( self.clients[0], self.tick_number) else: results_information = self.master_controller.return_final_results( self.clients, self.tick_number) if source: results_information['reason'] = source write_json_file(results_information, RESULTS_FILE) # Exit game if source: print(f'\nGame has ended due to {source}.') # Flush standard out sys.stdout.flush() os._exit(1) else: print(f'\nGame has successfully ended.') # Flush standard out sys.stdout.flush() os._exit(0)
def generate(): print('Generating game map...') data = dict() data['world'] = None # Verify logs location exists if not os.path.exists(GAME_MAP_DIR): os.mkdir(GAME_MAP_DIR) # Write game map to file write_json_file(data, GAME_MAP_FILE)
def generate(): print('Generating game map...') data = dict() for x in range(1, MAX_TICKS + 1): data[x] = 'data' # Verify logs location exists if not os.path.exists(GAME_MAP_DIR): os.mkdir(GAME_MAP_DIR) # Write game map to file write_json_file(data, GAME_MAP_FILE)
def generate(): print('Generating game map...') # Verify logs location exists if not os.path.exists(GAME_MAP_DIR): os.mkdir(GAME_MAP_DIR) res = {} # Generates random seeds for turns for i in range(1, MAX_TICKS + 1): res[i] = dict() res[i]["seed"] = random.randint(1, sys.maxsize) write_json_file(res, GAME_MAP_FILE)
def generate(): print('Generating game map...') data = dict() monster_type_list = [MonsterType.slime, MonsterType.minotaur, MonsterType.wisp, MonsterType.vampire, MonsterType.dragon] for floor_number in range(1, GameStats.number_of_floors + 1): type_chosen = random.choice(monster_type_list) data[str(floor_number)] = type_chosen # Verify logs location exists if not os.path.exists(GAME_MAP_DIR): os.mkdir(GAME_MAP_DIR) # Write game map to file write_json_file(data, GAME_MAP_FILE)