import Core, Base
from Base import Database
from Core.Handlers.Penguin import Penguin

import requests, json

class Player():
	def __init__(self):
		self.DB = Database.Database()
		
	def handleGetPlayerInventory(self, line):
		Inventory = self.Penguin['inventory']
		self.send("%xt%gi%-1%"+str(Inventory)+"%")
	
	def handleHeartBeat(self, line):
		self.send("%xt%h%"+str(self.IntID)+"%")

	def handleGetLastRevision(self, line):
		self.send("%xt%glr%-1%%") ##No Idea what's this!

	def handleGetABCms(self, line):
		abcCPdata = '%xt%gabcms%-1%{"FurnitureCatalogueLocationTest":{"variant":0},"PreActivatedPlay":{"num_seconds_play":604800,"num_seconds_grace":172800,"variant":1},"MapTest":{"MapSettingId":0,"variant":0},"PuffleOopsMemberVsFree":{"variant":2},"BOGO":{"pageId":0},"HelloRockhopperTest":{"YarrDescription":"Arrr matey! Ye missed Yarr!"},"MembershipUpsell":{"free":"Limited Play","membership":"Unlimited Play"},"JustForTest":{"Last":"Smith","First":"John"},"NewPlayerLoginRoom":{"roomId":100,"variant":1},"FurnitureCatalogTest":{"catalogID":0,"variant":0},"XDayTrialOffers":{"TrialMembershipSettingID":1,"variant":1},"PenguinStyleTest":{"catalogID":"0"},"ClientConfigTest":{"ShowLevelAccessPopup":true,"ClassName":"MemberGameLevel5","BonusPoints":1000},"EndGameScreenTest":{"variant":1},"DinosaurTransformTest":{"variant":0},"QuestTest":{"startRoom":100,"isControl":false,"variant":1},"TeenBeachItems":{"CatalogID":"0"}}%'
		self.send(abcCPdata)

	def handleqPlayerAwards(self, line)	:
		self.send("%xt%qpa%-1%"+str(self.id)+"%")

	def handleSendPlayer(self, line):
		packet = line.split("%")
		
		self.Penguin['x'] = packet[5]
		self.Penguin['y'] = packet[6]

		self.send("%xt%sp%-1%"+str(self.id)+"%"+str(packet[5])+"%"+str(packet[6])+"%", 1)	

	def handleSendMessage(self, line):
			msg = line.split("%")[6]

			self.send("%xt%sm%"+str(self.IntID)+"%"+ str(self.id) + "%" +str(msg)+"%", 3)
			