summaryrefslogtreecommitdiff
path: root/src/type
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-01-17 16:34:10 +0100
committernsensfel <SpamShield0@noot-noot.org>2018-01-17 16:34:10 +0100
commit437d7bea7d2f018ba81741ae691dc543df535eeb (patch)
treec13b7a130ade07e1c66d5b6c89d898983a14c9ae /src/type
parent0cbf2c544d133ba32dc668d30b071cb033496ba3 (diff)
Starting a new branch to add stats.
Diffstat (limited to 'src/type')
-rw-r--r--src/type/character_instance.erl34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/type/character_instance.erl b/src/type/character_instance.erl
index ee50460..3fc7171 100644
--- a/src/type/character_instance.erl
+++ b/src/type/character_instance.erl
@@ -10,7 +10,12 @@
x,
y,
health,
- team
+ team,
+ active_wp,
+ min_dmg,
+ max_dmg,
+ hit_chance,
+ double_hit_chance
}
).
@@ -34,6 +39,7 @@
(
[
new_instance_of/3,
+ switch_weapon/2,
is_dead/1 % is_alive is reserved.
]
).
@@ -41,6 +47,16 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+get_new_weapon(CharInst, Char) ->
+ case CharInst#character_instance.active_wp of
+ 0 ->
+ {_, Weapon} = character:get_weapons(Char),
+ {1, Weapon};
+
+ 1 ->
+ {Weapon, _} = character:get_weapons(Char),
+ {0, Weapon}
+ end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -80,7 +96,21 @@ new_instance_of (Char, Owner, {X, Y}) ->
x = X,
y = Y,
health = character:get_max_health(Char),
- team = Owner
+ team = Owner,
+ active_wp = 0
+ }.
+
+switch_weapon (CharInst, Char) ->
+ {NewWpIndex, Weapon} = get_new_weapon(CharInst, Char),
+ WeaponProf = character:get_proficiency(Char, weapon:get_type(Weapon)),
+ {HitChance, DoubleHitChance} = calc_stats:weapon_hit_chances(WeaponProf),
+ CharInst#character_instance
+ {
+ active_wp = NewWpIndex,
+ min_dmg = calc_stats:weapon_min_damage(Weapon, WeaponProf),
+ max_dmg = weapon:get_max_damage(Weapon),
+ hit_chance = HitChance,
+ double_hit_chance = DoubleHitChance
}.
is_dead (CharInst) -> (CharInst#character_instance.health == 0).