local BasicPage = Object:extend()

local menu = require "game.modules.menus.fancy"
local gui = require "game.modules.gui"
local const = require "scenes.overworld.screens.mainmenu.const"

function BasicPage:new(view, character)
  self.view = view
  self.character = game.characters.list[character]

  self.statBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 48+8)
  self.nameBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 40)
end

function BasicPage:getMenuWidgets()

end

function BasicPage:update(dt)

end

function BasicPage:draw()
  self:drawIdentity(const.X, const.Y)
  self:drawLevel(const.X, 100)
  self:drawStats(const.X, 160)
  --self:drawWeakStrong(const.X, 160)
end

function BasicPage:drawIdentity(x, y)
  local identityString = self.character.fullname .. "\n"
  identityString = identityString .. "Class: " .. self.character.data.class

  love.graphics.draw(self.nameBox, x, y)
  self.view.scene.assets.fonts["small"]:draw(identityString, x + 6, y + 4, -1, "left")
end

function BasicPage:drawLevel(x, y)
  local levelString = "Level: " .. self.character.level .. "\n"
  local levelString = levelString .. "Current exp: " .. self.character.exp .. "\n"
  local levelString = levelString .. "Next level: " .. self.character.exp_next

  love.graphics.draw(self.statBox, x, y)
  self.view.scene.assets.fonts["small"]:draw(levelString, x + 6, y + 4, -1, "left")
end

function BasicPage:drawStats(x, y)
  local statString = "ATK " .. self.character.stats.attack .. "0" .. "\n"
  statString = statString .. "DEF " .. self.character.stats.defense .. "0" .. "\n"

  local statString2 = "POW " .. self.character.stats.power .. "0" .. "\n"
  statString2 = statString2 .. "MND " .. self.character.stats.mind .. "0" .. "\n"

  local statString3 = "SPD " .. self.character.stats.speed .. "0" .. "\n"
  statString3 = statString3 .. "TEK " .. self.character.stats.technic .. "0"

  local pos1 = const.CHARPAGESIZE * (1/3)
  local pos2 = const.CHARPAGESIZE * (2/3)

  love.graphics.draw(self.nameBox, x, y)

  self.view.scene.assets.fonts["small"]:draw(statString,  x + 6,        y + 4, -1, "left")
  self.view.scene.assets.fonts["small"]:draw(statString2, x + 6 + pos1, y + 4, -1, "left")
  self.view.scene.assets.fonts["small"]:draw(statString3, x + 6 + pos2, y + 4, -1, "left")
end

function BasicPage:drawWeakStrong(x, y)
  local weakString = "Weak to: Earth, Lightning"
  local strongString = "Resist To: Fire"

  love.graphics.draw(self.nameBox, x, y)
  self.view.scene.assets.fonts["small"]:draw(weakString .. "\n" .. strongString, x + 6, y + 4, -1, "left")
end

return BasicPage
