import itertools

_GLOBAL_CLIENT_SEQ = itertools.count(10001)
_GLOBAL_OID_SEQ    = itertools.count(101)

class ClientSession(object):
    def __init__(self, conn, addr, cfg):
        self.conn = conn
        self.addr = addr
        self.cfg = cfg
        self.client_id = next(_GLOBAL_CLIENT_SEQ)

        # Account state
        self.user_id = 1000001
        self.user_name = "gm_eric"
        self.role = 7131450362141085952
        self.user_type = 30
        self.pw_hash_step4 = None

        # Active character state (populated on character selection)
        self.char_id = 90000001
        self.char_name = "GM Eric"
        self.corp_id = 216121397
        self.alliance_id = 434243723
        self.station_id = 60014842
        self.solarsystem_id = 30000380
        self.constellation_id = 20000051
        self.region_id = 10000004
        self.ship_id = 100000001
        self.ship_type_id = 9860
        self.gender = 1
        self.race_id = 8
        self.bloodline_id = 19
        self.ancestry_id = 19

        # Per-session caches & bound object registry
        # Maps oid (e.g. "N=1:105") -> dict(type="ship_inv"|"station_inv"|"generic", item_id=...)
        self.bound_objects = {}
        self.skills_cache = None  # Tuple: (skills_dict, free_sp, total_sp)

    def allocate_oid(self, obj_type="generic", item_id=None):
        oid = "N=1:%d" % next(_GLOBAL_OID_SEQ)
        self.bound_objects[oid] = {"type": obj_type, "item_id": item_id}
        return oid

    def get_bound_context(self, oid):
        return self.bound_objects.get(oid, {})