Пример #1
0
	def execute(self, args, sender):
		dbd = save.databaseDaemon()

		thread.start_new_thread(dbd.saveMobile, (sender,))

		msg = 'Save complete.'
		self.appendToCommandBuffer(sender, msg)
Пример #2
0
	def execute(self, args, config):
		sender = config['sender']

		dbd = save.databaseDaemon()

		sender.sendToClient('Initiating save.')

		import thread
		thread.start_new_thread(dbd.saveMobile, (sender,))
		sender.sendToClient('Save complete.')
Пример #3
0
	def loadPlayer(self, message):
		player_id = message

		from lib import save

		dbd = save.databaseDaemon()

		loadedPlayer = dbd.loadMobileById(player_id)

		if loadedPlayer:
			self.player = self.game.registerPlayer(self, loadedPlayer)

			if not self.player:
				# We found a player, but it was rejected by the game - probably because that player is already online and not linkdead
				print 'Rejected attempt to connect to existing player.'
				self.sendToClient({'message': 'Rejected attempt to connect to existing player.'})
				return False
			return True
		else:
			print ('Player ID not found in database.')
			self.sendToClient({'message': 'Player ID not found in database.'})
			return False
Пример #4
0
	def updateGame(self):
		self.clock += self.interval
		self.combatInterval += self.interval
		self.gameUpdateInterval += self.interval
		self.repopInterval += self.interval

		# Restore charges
		if self.clock % 6 * self.interval == 0:
			print ' - Charge Update ' + str(datetime.datetime.now().time())
			for mobile in [m for m in self.mobiles if m.getStat('charges') < m.getStat('maxcharges')]:
				mobile.setStat('charges', mobile.getStat('charges') + 1)

		for mobile in self.mobiles:
			mobile.update(self.interval)

		if self.combatInterval > 2:
			print ' - Combat Update ' + str(datetime.datetime.now().time())
			self.combatInterval = 0
			combat.doGlobalRound(self)

		if self.gameUpdateInterval > 10:
			self.gameUpdateInterval = 0
			latency = ( ( datetime.datetime.now() - self.startTime ).seconds - self.clock ) / self.clock
			print 'Game Update {time} : {latency}'.format(time=str(datetime.datetime.now().time()),latency=latency)

		#repop!  -> every 3 minutes?
		if self.repopInterval > 180:
			self.repopInterval = 0
			print 'autosaving players'
			for mobile in self.mobiles:
				if mobile.is_player:
					dbd = save.databaseDaemon()
					thread.start_new_thread(dbd.saveMobile, (mobile,))
			self.repopulate()

		Timer(self.interval, self.updateGame).start()