Commits

n8 committed 26fdc25

added racial modifiers

Comments (0)

Files changed (3)

persona_gen/data/races.yaml

 --- 
 Human: 
-  :strength: :"0"
-  :dexterity: :"0"
-  :constitution: :"0"
-  :insight: :"0"
-  :presence: :"0"
-  :any: :"2"
+  :strength: "0"
+  :dexterity: "0"
+  :constitution: "0"
+  :insight: "0"
+  :presence: "0"
+  :any: "2"
   :frequency: 0.7
 Elf: 
-  :strength: :"0"
-  :dexterity: :"2"
-  :constitution: :"-2"
-  :insight: :"2"
-  :presence: :"0"
-  :any: :"0"
+  :strength: "0"
+  :dexterity: "2"
+  :constitution: "-2"
+  :insight: "2"
+  :presence: "0"
+  :any: "0"
   :frequency: 0.1
 Dwarf: 
-  :strength: :"0"
-  :dexterity: :"0"
-  :constitution: :"2"
-  :insight: :"2"
-  :presence: :"-2"
-  :any: :"0"
+  :strength: "0"
+  :dexterity: "0"
+  :constitution: "2"
+  :insight: "2"
+  :presence: "-2"
+  :any: "0"
   :frequency: 0.05
 Halfling: 
-  :strength: :"-2"
-  :dexterity: :"2"
-  :constitution: :"0"
-  :insight: :"0"
-  :presence: :"2"
-  :any: :"0"
+  :strength: "-2"
+  :dexterity: "2"
+  :constitution: "0"
+  :insight: "0"
+  :presence: "2"
+  :any: "0"
   :frequency: 0.01
 Gnome: 
-  :strength: :"-2"
-  :dexterity: :"0"
-  :constitution: :"2"
-  :insight: :"0"
-  :presence: :"2"
-  :any: :"0"
+  :strength: "-2"
+  :dexterity: "0"
+  :constitution: "2"
+  :insight: "0"
+  :presence: "2"
+  :any: "0"
   :frequency: 0.01
 Half-Elf: 
-  :strength: :"0"
-  :dexterity: :"0"
-  :constitution: :"0"
-  :insight: :"0"
-  :presence: :"0"
-  :any: :"2"
+  :strength: "0"
+  :dexterity: "0"
+  :constitution: "0"
+  :insight: "0"
+  :presence: "0"
+  :any: "2"
   :frequency: 0.19
 Half-Orc: 
-  :strength: :"0"
-  :dexterity: :"0"
-  :constitution: :"0"
-  :insight: :"0"
-  :presence: :"0"
-  :any: :"2"
+  :strength: "0"
+  :dexterity: "0"
+  :constitution: "0"
+  :insight: "0"
+  :presence: "0"
+  :any: "2"
   :frequency: 0.048

persona_gen/persona_gen.rb

      ## handle race
      rg = RaceGenerator.new(hints)
      rg.select_race(p)
-
-
-     #p.personalia[:record] = p.s.to_s 
-     #p.personalia[:description][:appearance].each do |a|
-     #  p.personalia[:record] += '_'+a.to_s
-     #end
+     rg.apply_racial_modifiers(p)
+     
 
      return p
    end

persona_gen/race_gen.rb

     @races=YAML.load_file("data/races.yaml")
   end
 
+  def apply_racial_modifiers(p)
+    race = p.personalia[:race]
+    attrs = p.stats.keys.sort
+    attrs.each do |a|
+      mod = self.races[race][a]
+      p.stats[a][:base] += mod.to_i
+    end
+    att = attrs.shuffle.pop()
+    mod = self.races[race][:any]
+    p.stats[att][:base] += mod.to_i
+  end
+
+
   def select_race(p)
 
     ## should do case insensitive match here probably