diff options
author | David Gay <david@davidgay.org> | 2021-05-22 18:10:19 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-22 18:10:19 -0400 |
commit | 44facc2e567eb3c045ce082428f42276e45b0202 (patch) | |
tree | 0b302bfd60a6faae698a63e68e3e1a5bdb9e16c2 /app/models | |
parent | 38f3a39221869483e3468e9f4d8cab5450a70f89 (diff) |
Monsters and basic combat
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/character.rb | 45 | ||||
-rw-r--r-- | app/models/monster.rb | 31 |
2 files changed, 76 insertions, 0 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index 59ed5ae..bad2bb2 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -19,6 +19,22 @@ class Character < ApplicationRecord after_create :create_skills after_create { Hearth.create(character: self) } + def beastslay_level; skill_level("beastslay"); end + def fluxseethe_level; skill_level("fluxseethe"); end + def havencast_level; skill_level("havencast"); end + def hexcarve_level; skill_level("hexcarve"); end + def magiculture_level; skill_level("magiculture"); end + def manatrawl_level; skill_level("manatrawl"); end + def omenbind_level; skill_level("omenbind"); end + def otherforge_level; skill_level("otherforge"); end + def planequarry_level; skill_level("planequarry"); end + def spicework_level; skill_level("spicework"); end + def synthsever_level; skill_level("synthsever"); end + def veilreach_level; skill_level("veilreach"); end + def wealdreap_level; skill_level("wealdreap"); end + def wildscour_level; skill_level("wildscour"); end + def worldcall_level; skill_level("worldcall"); end + def shift_item(item, amount) item = Item.find_by_gid(item) if item.is_a? String CharacterItem.transaction do @@ -70,6 +86,7 @@ class Character < ApplicationRecord end def add_skill_xp(skill, amount) + skill = Skill.find_by_gid(skill) if skill.is_a? String CharacterSkill.find_by(skill: skill).increment!(:xp, amount) end @@ -115,6 +132,34 @@ class Character < ApplicationRecord self.update(activity: activity, activity_started_at: Time.now) if self.can_do_activity?(activity) end + def can_fight? + self.wounds < 1 + end + + def max_hp + 10 + self.beastslay_level + end + + def speed + self.beastslay_level + end + + def accuracy + self.beastslay_level + end + + def power + self.beastslay_level + end + + def evasion + self.beastslay_level + end + + def block + self.beastslay_level + end + private def create_skills Skill.all.each { |skill| self.character_skills.create(skill: skill, xp: 0) } diff --git a/app/models/monster.rb b/app/models/monster.rb new file mode 100644 index 0000000..1b521aa --- /dev/null +++ b/app/models/monster.rb @@ -0,0 +1,31 @@ +class Monster < ApplicationRecord + include HasWhatnot + + def max_hp + self.whatnot[:max_hp][:base] + end + + def speed + self.whatnot[:speed][:base] + end + + def accuracy + self.whatnot[:accuracy][:base] + end + + def power + self.whatnot[:power][:base] + end + + def evasion + self.whatnot[:evasion][:base] + end + + def block + self.whatnot[:block][:base] + end + + def block_value + self.whatnot[:block_value][:base] + end +end |