local QteParent = Object:extend()

function QteParent:new(choregraphySystem, arguments)
  self.choregraphy = choregraphySystem
  self.arguments = arguments
  self.timer = 0
  self.origin = nil
  self.isBlocking = nil
end

function QteParent:blockAction(action, blockProcess)
  if (blockProcess) then
    self.isBlocking = action
  end
end

function QteParent:setOrigin(origin)
  self.origin = origin
end

function QteParent:drawButton(x, y, letter)
  local grayValue = .44
  local darkValue = .11
  love.graphics.setColor(grayValue, grayValue, grayValue, 1)
  love.graphics.circle("fill", x, y, 8, 8)
  love.graphics.setColor(darkValue, darkValue, darkValue, 1)
  love.graphics.circle("line", x, y, 8, 8)
  love.graphics.print(letter, x, y)
  utils.graphics.resetColor()
end

function QteParent:updateStep(dt)
  if (not self.isStarted) then
    self:start()
    self.isStarted = true
  else
    self:update(dt)
    self:updateTimer(dt)
  end
end

function QteParent:update(dt)
  --
end

function QteParent:updateTimer(dt)
  if (self.arguments.duration ~= nil) then
    self.timer = self.timer + dt
    if (self.timer > self.arguments.duration) then
      self:fail()
    end
  end
end


function QteParent:succes()
  self:finish(true)
end

function QteParent:fail()
  self:finish(false)
end

function QteParent:finish(success)
  print("action finished")
  self.choregraphy:endQte(success)
  if (self.isBlocking ~= nil) then
    self.isBlocking:finish()
  end
end

return QteParent
