Esempio n. 1
0
    def __init__(self):
        print "New game instance initializing..."
        # Instantiate the body database with the moons adjusted by DAYS_PER_SEC*2 deviated from zero
        self.bodies = BodyDB(DAYS_PER_SEC*2).getBodies()
        # self.OOIs = OOIs()
        # TODO: Replace this with MPO data
        self.NEOs = list()
        for asteroid in asteroidDB.getAsteroidSurvey(SurveyTypes.neo):
            self.NEOs.append(self.cleanAsteroidObject(asteroid))

        self.mainBelt = list()
        for asteroid in asteroidDB.getAsteroidSurvey(SurveyTypes.main_belt):
            self.mainBelt.append(self.cleanAsteroidObject(asteroid))

        self.kuiperBelt = list()
        for asteroid in asteroidDB.getAsteroidSurvey(SurveyTypes.kuiper_belt):
            self.kuiperBelt.append(self.cleanAsteroidObject(asteroid))

        self.OOIs = self.NEOs + self.mainBelt + self.kuiperBelt
        self.id = uuid.uuid4()
        self.players = list()
        self.playerObjects = list()
        self.eventList = getMockEventList()
        self._epoch = int(rTime())  # real-time game start

        probe2 = {
            'ma': -2.47311027,
            'epoch': 2451545.0,
            'a': 1.00000261,
            'e': 0.02671123,
            'i': 0.00001531,
            'w_bar': 102.93768193,
            'w': 102.93768193,
            'L': 100.46457166,
            'om': 0,
            'P': 365.256
        }
        self.addPlayerObject("Probe", "Magellan", probe2, "PyKEP_test")

        self.colors = list()
        self.colors.append({'player': None, 'color': '0xff0000'})
        self.colors.append({'player': None, 'color': '0x00ff00'})
        self.colors.append({'player': None, 'color': '0x0000ff'})
        self.colors.append({'player': None, 'color': '0xffff00'})
        self.colors.append({'player': None, 'color': '0xff00ff'})

        self.date = datetime.date(START_YEAR, 4, 1)

        timer = Timer(1.0, self.timeSync)
        timer.daemon = True
        timer.start()
Esempio n. 2
0
    def __init__(self):
        print "New game instance initializing..."
        # Instantiate the body database with the moons adjusted by DAYS_PER_SEC*2 deviated from zero
        self.bodies = BodyDB(DAYS_PER_SEC*2).getBodies()
        # self.OOIs = OOIs()
        # TODO: Replace this with MPO data
        self.NEOs = list()
        for asteroid in asteroidDB.getAsteroidSurvey('NEO'):
            self.NEOs.append(self.cleanAsteroidObject(asteroid))

        self.mainBelt = list()
        for asteroid in asteroidDB.getAsteroidSurvey('MainBelt'):
            self.mainBelt.append(self.cleanAsteroidObject(asteroid))

        self.kuiperBelt = list()
        for asteroid in asteroidDB.getAsteroidSurvey('KuiperBelt'):
            self.kuiperBelt.append(self.cleanAsteroidObject(asteroid))

        self.OOIs = self.NEOs + self.mainBelt + self.kuiperBelt
        self.id = uuid.uuid4()
        self.players = list()
        self.playerObjects = list()
        self.eventList = getMockEventList()
        self._epoch = int(rTime())  # real-time game start

        probe2 = {
            'ma': -2.47311027,
            'epoch': 2451545.0,
            'a': 1.00000261,
            'e': 0.02671123,
            'i': 0.00001531,
            'w_bar': 102.93768193,
            'w': 102.93768193,
            'L': 100.46457166,
            'om': 0,
            'P': 365.256
        }
        self.addPlayerObject("Probe", "Magellan", probe2, "PyKEP_test")

        self.colors = list()
        self.colors.append({'player': None, 'color': '0xff0000'})
        self.colors.append({'player': None, 'color': '0x00ff00'})
        self.colors.append({'player': None, 'color': '0x0000ff'})
        self.colors.append({'player': None, 'color': '0xffff00'})
        self.colors.append({'player': None, 'color': '0xff00ff'})

        self.date = datetime.date(START_YEAR, 4, 1)

        timer = Timer(1.0, self.timeSync)
        timer.daemon = True
        timer.start()
Esempio n. 3
0
    def timeSync(self, t=None):
        # returns current in-game time representation as a string
        # if t is given, in-game time at given time t
        if t is None:
            t = rTime()

        secsPassed = int(t-self._epoch)  # real-time
        self.date += datetime.timedelta(days=DAYS_PER_SEC)

        if secsPassed % TIME_UPDATE_FREQ == 0:
            for player in self.players:
                message = '{"cmd":"timeSync","data":"'
                message += str({'jed': self.time(jd=True),
                                'gec': self.time(net=True)})
                message += '"}'
                player.sendMessage(message)
Esempio n. 4
0
    def timeSync(self, t=None):
        # returns current in-game time representation as a string
        # if t is given, in-game time at given time t
        if t is None:
            t = rTime()

        secsPassed = int(t-self._epoch)  # real-time
        self.date += datetime.timedelta(days=DAYS_PER_SEC)

        if secsPassed % TIME_UPDATE_FREQ == 0:
            for player in self.players:
                message = '{"cmd":"timeSync","data":"'
                message += str({'jed': self.time(jd=True),
                                'gec': self.time(net=True)})
                message += '"}'
                player.sendMessage(message)