local UIAnim = require "widgets/uianim"
local Text = require "widgets/text"
local Widget = require "widgets/widget"

local Miaojilvl = Class(Widget, function(self, owner)
	Widget._ctor(self, "miaoji")
	self.owner = owner
		self.miaoji = self:AddChild(Widget("miaoji"))  
		self.miaoji.lvl = self.miaoji:AddChild(Text(BODYTEXTFONT, 40))
		self.miaoji.lvl:SetHAlign(ANCHOR_MIDDLE)
		self.miaoji.lvl:SetPosition(0, 20, 0)
		self.miaoji.exp = self.miaoji:AddChild(Text(BODYTEXTFONT, 25))
		self.miaoji.exp:SetHAlign(ANCHOR_MIDDLE)
		self.miaoji.exp:SetPosition(0,-5, 0)
	self:StartUpdating()
end)
function Miaojilvl:OnUpdate(dt)
	local current
	if TheSim:GetGameID() == "DST" then
	current = self.owner.currentmiaoji:value()
	else
	current = self.owner.components.miaoji_exp.current
	end
	local lvl =  math.floor(current/100)
	local max = 5000
	self.miaoji.lvl:SetString("LvL:"..tostring(lvl))	
	self.miaoji.exp:SetString(string.format("Exp:%d/%d",current,max))
end
return Miaojilvl

