| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-01-18 13:06:47 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-01-18 13:06:47 +0100 | 
| commit | 71c2f5c128785058c4f11b7d36aeb43c85cccc5f (patch) | |
| tree | cb2543b74719763e4fd8e9b5fb44dc1a61e6492c | |
| parent | bc725f4fbd975142d205852e7a04ff82d39c14ae (diff) | |
...
| -rw-r--r-- | src/type/attributes.erl | 68 | ||||
| -rw-r--r-- | src/type/weapon.erl | 35 | 
2 files changed, 100 insertions, 3 deletions
| diff --git a/src/type/attributes.erl b/src/type/attributes.erl new file mode 100644 index 0000000..b4395cb --- /dev/null +++ b/src/type/attributes.erl @@ -0,0 +1,68 @@ +-module(attributes). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-record +( +   attributes, +   { +      constitution, +      dexterity, +      intelligence, +      mind, +      speed, +      strength +   } +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-export +( +   [ +      get_constitution/1, +      get_dexterity/1, +      get_intelligence/1, +      get_mind/1, +      get_speed/1, +      get_strength/1, + +      set_constitution/2, +      set_dexterity/2, +      set_intelligence/2, +      set_mind/2, +      set_speed/2, +      set_strength/2 +   ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +get_constitution (Att) -> Att#attributes.constitution. +get_dexterity (Att) -> Att#attributes.dexterity. +get_intelligence (Att) -> Att#attributes.intelligence. +get_mind (Att) -> Att#attributes.mind. +get_speed (Att) -> Att#attributes.speed. +get_strength (Att) -> Att#attributes.strength. + +set_constitution (Att, Val) -> +   Att#attributes{ constitution = Val }. +set_dexterity (Att, Val) -> +   Att#attributes{ dexterity = Val }. +set_intelligence (Att, Val) -> +   Att#attributes{ intelligence = Val }. +set_mind (Att, Val) -> +   Att#attributes{ mind = Val }. +set_speed (Att, Val) -> +   Att#attributes{ speed = Val }. +set_strength (Att, Val) -> +   Att#attributes{ strength = Val }. diff --git a/src/type/weapon.erl b/src/type/weapon.erl index 7e811cc..254184c 100644 --- a/src/type/weapon.erl +++ b/src/type/weapon.erl @@ -10,7 +10,6 @@        id,        name,        icon, -      range,        type,        pwr_min,        pwr_max, @@ -30,7 +29,6 @@        get_name/1,        get_icon/1,        get_type/1, -      get_range/1,        get_max_power/1,        get_min_power/1,        get_max_prof/1, @@ -38,9 +36,38 @@     ]  ). +-export +( +   [ +      get_category/1, +      get_ranges/1 +   ] +). +  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +ranges_of_type (short_bow) ->    {2, 4}; +ranges_of_type (long_bow) ->     {2, 6}; +ranges_of_type (crossbow) ->     {2, 4}; +ranges_of_type (arbalest) ->     {2, 4}; +ranges_of_type (sword) ->        {1, 1}; +ranges_of_type (claymore) ->     {1, 2}; +ranges_of_type (mace) ->         {1, 1}; +ranges_of_type (war_hammer) ->   {1, 2}; +ranges_of_type (dagger) ->       {1, 1}; +ranges_of_type (spear) ->        {1, 2}. + +category_of_type (short_bow) ->  physical; +category_of_type (long_bow) ->   physical; +category_of_type (crossbow) ->   physical; +category_of_type (arbalest) ->   physical; +category_of_type (sword) ->      physical; +category_of_type (claymore) ->   physical; +category_of_type (mace) ->       physical; +category_of_type (war_hammer) -> physical; +category_of_type (dagger) ->     physical; +category_of_type (spear) ->      physical.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -50,8 +77,10 @@ get_id (Wp) -> Wp#weapon.id.  get_name (Wp) -> Wp#weapon.name.  get_icon (Wp) -> Wp#weapon.icon.  get_type (Wp) -> Wp#weapon.type. -get_range (Wp) -> Wp#weapon.range.  get_max_power (Wp) -> Wp#weapon.pwr_max.  get_min_power (Wp) -> Wp#weapon.pwr_min.  get_max_prof (Wp) -> Wp#weapon.prof_max.  get_rel_attribs (Wp) -> Wp#weapon.rel_attribs. + +get_ranges (Wp) -> ranges_of_type(Wp#weapon.type). +get_category (Wp) -> category_of_type(Wp#weapon.type). | 


