
PART_MISSING = 0
PART_BROKEN = 1
PART_VALID = 2
PART_SHUNT = 3
PART_CONTROLNODE = 4
PART_FLUXMOD = 5
PART_PHOTON = 6
PART_STDISTORT = 7
PART_CRYOFUSE = 8
PART_PLASMATUBE = 9
PART_SCANNER = 10
PART_JJUNCMODULE = 11


class Ship:
    """Singleton object for the ship.

       This object keeps track of all of the various elements of the ship
       and then can be called by any of the other classes to check on the
       current status.

    """

    class __impl:
        
        cloaked = False
        hull = 100

        # XXX - how much fuel is the sundog going to carry?
        fuel = 199

        warp = [[PART_CONTROLNODE, PART_FLUXMOD, PART_MISSING, PART_STDISTORT],
                [PART_CONTROLNODE, PART_FLUXMOD, PART_PHOTON, PART_STDISTORT],
                [PART_CONTROLNODE, PART_SHUNT, PART_PHOTON, PART_STDISTORT],
                [PART_CONTROLNODE, PART_SHUNT, PART_SHUNT, PART_SHUNT]]

        subc = [[PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID]]

        guns = [[PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID]]

        tac = [[PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID]]

        shields = [[PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID]]

        pilot = [[PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID],
                [PART_VALID, PART_VALID, PART_VALID, PART_VALID]]

    __instance = None

    def __init__(self):
        if Ship.__instance is None:
            Ship.__instance = Ship.__impl()

            self.__dict__['_Ship__instance'] = Ship.__instance

    def __getattr__(self, attr):
        return getattr(self.__instance, attr)

    def __setattr__(self, attr, value):
        return setattr(self.__instance, attr, value)


