diff options
author | David Gay <david@davidgay.org> | 2021-05-04 18:32:33 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-04 18:32:33 -0400 |
commit | a32e05fea88fa4d9b9072f5a7e25189c99b16b9d (patch) | |
tree | 60b4f3cc3f77c91a0aa82c499d1c700d9ae7ab28 /app/models | |
parent | 8e2f4d6f10a18a662880c0d4c1ee79fdb6a8b3f2 (diff) |
Get XP awards working
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/character.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index aa434ef..df4938d 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -13,12 +13,16 @@ class Character < ApplicationRecord def shift_item(gid, amount) CharacterItem.transaction do - item = self.character_items.find_or_initialize_by(item: Item.find_by_gid(gid)) + item = self.character_items.find_or_initialize_by(item: Item.find_by_gid(gid.to_s)) item.increment(:quantity, amount) item.save end end + def add_skill_xp(skill, amount) + CharacterSkill.find_by(skill: skill).increment!(:xp, amount) + end + def skill_level(gid) self.character_skills.find_by(skill: Skill.find_by_gid(gid.to_s)).level end |