| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-02-26 13:52:29 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-02-26 13:52:29 +0100 | 
| commit | fd4d031ab5b31763d376c663cc049f62ee389243 (patch) | |
| tree | cd09a29bb888acf772fa1aee59fe95e8bd75fe4e /src/struct/weapon.erl | |
| parent | 66ec11ce5d2e227846d6e6b2899cda851a70fc04 (diff) | |
Got it to run, at last.
Diffstat (limited to 'src/struct/weapon.erl')
| -rw-r--r-- | src/struct/weapon.erl | 27 | 
1 files changed, 25 insertions, 2 deletions
| diff --git a/src/struct/weapon.erl b/src/struct/weapon.erl index add445a..ca74ada 100644 --- a/src/struct/weapon.erl +++ b/src/struct/weapon.erl @@ -23,7 +23,8 @@  -export  (     [ -      get_id/1 +      get_id/1, +      random_id/0     ]  ). @@ -32,7 +33,8 @@     [        from_id/1,        get_ranges/1, -      get_damages/1 +      get_damages/1, +      apply_to_attributes/2     ]  ). @@ -285,3 +287,24 @@ from_id (24) ->        damage_type = pierce,        damage_mod = heavy     }. + +random_id () -> +   roll:between(0, 24). + +apply_to_attributes (Attributes, Weapon) -> +   Dexterity = attributes:get_dexterity(Attributes), +   Speed = attributes:get_dexterity(Attributes), +   RangeModifier = Weapon#weapon.range_mod, +   DamageModifier = Weapon#weapon.damage_mod, +   WithRangeModifier = +      case RangeModifier of +         long -> +            attributes:set_dexterity(max(0, (Dexterity - 20)), Attributes); +         _ -> Attributes +      end, +   case DamageModifier of +      heavy -> +         attributes:set_speed(max(0, (Speed - 20)), WithRangeModifier); +      _ -> WithRangeModifier +   end. + | 


