def _release_ship(client): """removes clients ship from battles""" with game._lock: c = game.artemis_clients[client] if not c: game.artemis_clients[client] = c if c.in_combat: #battle is not reset because a clear package can arrive after turn release. x = c.battle.x y = c.battle.y cs = game.map[x][y].client_inside print(cs) if client in cs: del cs[client] updated("map", x, y) c.in_combat = False updated("artemis_clients", client)
def _start_battle(client, sector): with game._lock: t = time.time() c = game.artemis_clients[client] c.in_combat = True c.battle.id = random.randrange(16**4) c.battle.seed = sector.seed c.battle.x = sector.x c.battle.y = sector.y x = c.battle.x y = c.battle.y c.battle.difficulty = max(min(int(sector.get("difficulty", 7)), 11), 1) c.battle.enemies = int(sector.get("enemies", 1)) c.battle.rear_bases = int(sector.get("rear_bases", 0)) c.battle.forward_bases = int(sector.get("forward_bases", 0)) c.battle.fire_bases = int(sector.get("fire_bases", 0)) c.battle.terrain = sector.terrain c.battle.unknown = int(sector.get("unknown", 0)) c.log[t] = ("enter_sector", sector.coordinates) sector.client_inside[client] = c.shipname updated("artemis_clients", client) updated("map", x, y) return copy.deepcopy(c.battle)