From a32e05fea88fa4d9b9072f5a7e25189c99b16b9d Mon Sep 17 00:00:00 2001 From: David Gay Date: Tue, 4 May 2021 18:32:33 -0400 Subject: Get XP awards working --- app/models/character.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/models') 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 -- cgit v1.2.3