Skip to content

Commit

Permalink
[scripts][combat-trainer] Bring almanac functions in line with almana…
Browse files Browse the repository at this point in the history
…c.lic

Uses the same functions as almanac.lic now.
  • Loading branch information
MahtraDR committed Feb 18, 2024
1 parent 1a77d06 commit 73c1844
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions combat-trainer.lic
Original file line number Diff line number Diff line change
Expand Up @@ -2911,19 +2911,28 @@ class TrainerProcess
def almanac_sort_by_rate_then_rank(skills)
skills
.select { |skill| DRSkill.getxp(skill) < 18 }
.sort_by { |skill| [DRSkill.getxp(skill), DRSkill.getrank(skill)] }.first
.min_by { |skill| [DRSkill.getxp(skill), DRSkill.getrank(skill)] }
end

def skill_with_lowest_mindstate
list = []
DRSkill.list
.map { |skill| [skill.name, skill.exp] }
.select { |element| element[1] }
.reject { |skill, _exp| skill == "Mechanical Lore" }
.select { |skill, exp| list.append [skill, exp] }
skill = list.sort_by(&:last).first[0].sub(/(Lunar|Life|Arcane|Holy|Elemental)\s/, '')
return skill
end

def use_almanac(game_state)
return unless @almanac
return unless Time.now - UserVars.almanac_last_use >= 600
return if DRC.left_hand && !game_state.currently_whirlwinding

unless @almanac_skills.empty?
unless almanac_sort_by_rate_then_rank(@almanac_priority_skills)
training_skill = almanac_sort_by_rate_then_rank(@almanac_skills)
else
training_skill = almanac_sort_by_rate_then_rank(@almanac_priority_skills)
end
training_skill = almanac_sort_by_rate_then_rank(@almanac_priority_skills) || almanac_sort_by_rate_then_rank(@almanac_skills) || skill_with_lowest_mindstate
echo("training skill is #{training_skill}") if $debug_mode_ct
return unless training_skill
end

Expand Down

0 comments on commit 73c1844

Please sign in to comment.