Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Additional Sizes and simple way to load Hero with custom size and name
Browse files Browse the repository at this point in the history
  • Loading branch information
Gedrovits committed Jun 7, 2016
1 parent f6b4234 commit 5ae07bb
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 6 deletions.
5 changes: 5 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ def reload!
files.each { |file| load file }
end

# FIXME: Load entities for testing
@jon_snow = EternalSoulAsylum::Hero.new(name: 'Jon Snow')
@dog = EternalSoulAsylum::Hero.new(name: 'Dog', size: :small)
@giant = EternalSoulAsylum::Hero.new(name: 'Giant', size: :large)

IRB.start
14 changes: 10 additions & 4 deletions lib/eternal_soul_asylum/hero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ class Hero
attr_accessor :level, :name, :gender, :race, :size, :alignment, :background
# Attributes
attr_accessor :strength, :dexterity, :agility, :vitality, :intellect, :wisdom, :mentality, :charisma, :luck
# Combat
attr_accessor :health, :damage

def initialize
def initialize(args = {})
@level = 1
@name = 'Jon Snow'
@name = args.dig(:name)
@gender = :male
@race = :human
@size = Mechanics::Sizes::Normal.new
@size = Mechanics::Sizes.by_name(args.dig(:size))
@alignment = :true_neutral
@background = :bastard

# Abilities
@strength = Mechanics::Abilities::Strength.new(10)
@strength = Mechanics::Abilities::Strength.new(5)

# Combat
@health = 10
@damage = @strength.base * @size.damage_modifier
end
end
end
11 changes: 11 additions & 0 deletions lib/eternal_soul_asylum/mechanics/sizes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
require_relative "sizes/size"
require_relative "sizes/small"
require_relative "sizes/normal"
require_relative "sizes/large"

module EternalSoulAsylum
module Mechanics
module Sizes
def self.by_name(name)
case name
when :small then Small.new
when :normal then Normal.new
when :large then Large.new
else
Normal.new
end
end
end
end
end
12 changes: 12 additions & 0 deletions lib/eternal_soul_asylum/mechanics/sizes/large.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module EternalSoulAsylum
module Mechanics
module Sizes
class Large < Size
def initialize(damage_modifier = 1.5)
@damage_modifier = damage_modifier
super
end
end
end
end
end
3 changes: 2 additions & 1 deletion lib/eternal_soul_asylum/mechanics/sizes/normal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module EternalSoulAsylum
module Mechanics
module Sizes
class Normal < Size
def initialize
def initialize(damage_modifier = 1)
@damage_modifier = damage_modifier
super
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/eternal_soul_asylum/mechanics/sizes/size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ module EternalSoulAsylum
module Mechanics
module Sizes
class Size
def initialize
attr_accessor :damage_modifier

def initialize(args = {})
# Collosal, Huge, Large, Normal, Small, Very Small, Tiny (?)
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/eternal_soul_asylum/mechanics/sizes/small.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module EternalSoulAsylum
module Mechanics
module Sizes
class Small < Size
def initialize(damage_modifier = 0.5)
@damage_modifier = damage_modifier
super
end
end
end
end
end

0 comments on commit 5ae07bb

Please sign in to comment.