local h=require("\105\110\118\111\107\097\116\105\111\110\046\076\111\103\103\101\114")local Y=require("\112\108\046\099\108\097\115\115")local q=require("\109\111\115\101\115")local t=Y()local I="\099\111\109\098\111"h.Extend(t)t.ERR_NOT_IMPLEMENTED="\078\111\116 \105\109\112\108\101\109\101\110\116\101\100"function t._init(t,h,Y)Y=Y or{}q.extend(t,h)t.started=false t.failed=false t.preFinished=false t.finished=false t.count=0 t.damage=0 if Y.logger then t.logger=Y.logger:Child(I)end end function t.CurrentStepId(h)error(t.ERR_NOT_IMPLEMENTED)end function t.CurrentStep(h)error(t.ERR_NOT_IMPLEMENTED)end function t.NextStepsIds(h)error(t.ERR_NOT_IMPLEMENTED)end function t.NextSteps(h)error(t.ERR_NOT_IMPLEMENTED)end function t.Progress(Y,h)error(t.ERR_NOT_IMPLEMENTED)end function t.Fail(h)h.failed=true end function t.PreFinish(h)error(t.ERR_NOT_IMPLEMENTED)end function t.Finish(h)error(t.ERR_NOT_IMPLEMENTED)end function t.IncrementDamage(Y,h)Y.damage=Y.damage+h return Y.damage end return t
--- BaseCombo is a base class for combos.
-- @classmod invokation.combos.BaseCombo
local Logger = require("invokation.Logger")
local class = require("pl.class")
local moses = require("moses")

local M = class()

local LOGGER_PROGNAME = "combo"

Logger.Extend(M)

M.ERR_NOT_IMPLEMENTED = "Not implemented"

--- Combo specification.
-- @table Spec
-- @tfield string id id
-- @tfield string specialty Specialty
-- @tfield string stance Stance
-- @tfield int heroLevel Hero level
-- @tfield int damageRating Damage rating
-- @tfield int difficultyRating Difficulty rating
-- @tfield int gold Hero starting gold
-- @tfield {string,...} tags Tags
-- @tfield {string,...} items Array of required items names
-- @tfield {int,...} orbs Array of recommended orb abilities levels (`{quas, wex, exort}`)
-- @tfield int talents Bitmap of recommended talent abilities
-- @tfield {ComboStep.Spec,...} sequence Array of steps data

--- Constructor.
-- @tparam Spec spec Combo data
-- @tparam[opt] table options Options
-- @tparam Logger options.logger Logger instance
function M:_init(spec, options)
  options = options or {}

  moses.extend(self, spec)

  self.started = false
  self.failed = false
  self.preFinished = false
  self.finished = false
  self.count = 0
  self.damage = 0

  if options.logger then
    self.logger = options.logger:Child(LOGGER_PROGNAME)
  end
end

--- Returns the current step id.
-- @treturn ?int The current step id or `nil`
-- @abstract Subclasses must override it.
function M:CurrentStepId()
  error(M.ERR_NOT_IMPLEMENTED)
end

--- Returns the current step.
-- @treturn ?combos.ComboStep The current step or `nil`
-- @abstract Subclasses must override it.
function M:CurrentStep()
  error(M.ERR_NOT_IMPLEMENTED)
end

--- Returns the current next steps ids.
-- @treturn {int,...} Array of next steps ids
-- @abstract Subclasses must override it.
function M:NextStepsIds()
  error(M.ERR_NOT_IMPLEMENTED)
end

--- Returns the current next steps.
-- @treturn {ComboStep,...} Array of next steps
-- @abstract Subclasses must override it.
function M:NextSteps()
  error(M.ERR_NOT_IMPLEMENTED)
end

--- Progresses the combo with the given ability if possible.
-- @tparam dota2.Ability ability Ability instance
-- @treturn bool `true` if succeeded, `false` otherwise
-- @abstract Subclasses must override it.
function M:Progress(_ability)
  error(M.ERR_NOT_IMPLEMENTED)
end

--- Marks the combo as failed.
function M:Fail()
  self.failed = true
end

--- Progresses combo to pre finish if possible.
-- @treturn bool `true` if succeeded, `false` otherwise
-- @abstract Subclasses must override it.
function M:PreFinish()
  error(M.ERR_NOT_IMPLEMENTED)
end

--- Finishes the combo if possible.
-- @treturn bool `true` if succeeded, `false` otherwise
-- @abstract Subclasses must override it.
function M:Finish()
  error(M.ERR_NOT_IMPLEMENTED)
end

--- Increments the total amount of damage dealt during this combo session.
-- @tparam int amount Damage amount
-- @treturn int Accumulated damage amount
function M:IncrementDamage(amount)
  self.damage = self.damage + amount
  return self.damage
end

return M
