From bbc4326f8aacaaac96998d382fa64c1a55fcd57e Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 8 Jun 2018 14:30:41 +0200 Subject: Fixes armor penalties being applied twice. --- src/battlemap/src/Struct/Character.elm | 10 +++++----- src/battlemap/src/Struct/Statistics.elm | 10 ++++++++-- src/battlemap/src/Update/HandleServerReply.elm | 14 ++++++-------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm index 522bcda..74642b1 100644 --- a/src/battlemap/src/Struct/Character.elm +++ b/src/battlemap/src/Struct/Character.elm @@ -80,6 +80,7 @@ finish_decoding : PartiallyDecoded -> (Type, Int, Int, Int) finish_decoding add_char = let weapon_set = (Struct.WeaponSet.new Struct.Weapon.none Struct.Weapon.none) + armor = Struct.Armor.none almost_char = { id = (toString add_char.ix), @@ -89,11 +90,11 @@ finish_decoding add_char = location = add_char.lc, health = add_char.hea, attributes = add_char.att, - statistics = (Struct.Statistics.new add_char.att weapon_set), + statistics = (Struct.Statistics.new add_char.att weapon_set armor), player_id = add_char.pla, enabled = add_char.ena, weapons = weapon_set, - armor = Struct.Armor.none + armor = armor } in (almost_char, add_char.awp, add_char.swp, add_char.ar) @@ -161,7 +162,7 @@ set_weapons : Struct.WeaponSet.Type -> Type -> Type set_weapons weapons char = {char | weapons = weapons, - statistics = (Struct.Statistics.new char.attributes weapons) + statistics = (Struct.Statistics.new char.attributes weapons char.armor) } decoder : (Json.Decode.Decoder (Type, Int, Int, Int)) @@ -195,10 +196,9 @@ fill_missing_equipment : ( fill_missing_equipment awp swp ar char = let weapon_set = (Struct.WeaponSet.new awp swp) - post_armor_atts = (Struct.Armor.apply_to_attributes ar char.attributes) in {char | - statistics = (Struct.Statistics.new post_armor_atts weapon_set), + statistics = (Struct.Statistics.new char.attributes weapon_set ar), weapons = weapon_set, armor = ar } diff --git a/src/battlemap/src/Struct/Statistics.elm b/src/battlemap/src/Struct/Statistics.elm index aad1411..de18466 100644 --- a/src/battlemap/src/Struct/Statistics.elm +++ b/src/battlemap/src/Struct/Statistics.elm @@ -18,6 +18,7 @@ import List -- Battlemap ------------------------------------------------------------------- import Struct.Attributes +import Struct.Armor import Struct.Weapon import Struct.WeaponSet @@ -111,12 +112,17 @@ get_critical_hits t = t.critical_hits new : ( Struct.Attributes.Type -> Struct.WeaponSet.Type -> + Struct.Armor.Type -> Type ) -new att wp_set = +new att wp_set ar = let active_weapon = (Struct.WeaponSet.get_active_weapon wp_set) - actual_att = (Struct.Weapon.apply_to_attributes active_weapon att) + actual_att = + (Struct.Armor.apply_to_attributes + ar + (Struct.Weapon.apply_to_attributes active_weapon att) + ) constitution = (Struct.Attributes.get_constitution actual_att) dexterity = (Struct.Attributes.get_dexterity actual_att) intelligence = (Struct.Attributes.get_intelligence actual_att) diff --git a/src/battlemap/src/Update/HandleServerReply.elm b/src/battlemap/src/Update/HandleServerReply.elm index 5bafbe4..ec388ee 100644 --- a/src/battlemap/src/Update/HandleServerReply.elm +++ b/src/battlemap/src/Update/HandleServerReply.elm @@ -7,8 +7,6 @@ import Dict import Http -import Debug - -- Battlemap ------------------------------------------------------------------- import Struct.Armor import Struct.Battlemap @@ -157,22 +155,22 @@ apply_command : ( apply_command command current_state = case command of (Struct.ServerReply.AddWeapon wp) -> - (Debug.log "add_weapon" (add_weapon wp current_state)) + (add_weapon wp current_state) (Struct.ServerReply.AddArmor ar) -> - (Debug.log "add_armor" (add_armor ar current_state)) + (add_armor ar current_state) (Struct.ServerReply.AddCharacter char) -> - (Debug.log "add_char" (add_character char current_state)) + (add_character char current_state) (Struct.ServerReply.SetMap map) -> - (Debug.log "set_map" (set_map map current_state)) + (set_map map current_state) (Struct.ServerReply.TurnResults results) -> - (Debug.log "add_to_tl" (add_to_timeline results current_state)) + (add_to_timeline results current_state) (Struct.ServerReply.SetTimeline timeline) -> - (Debug.log "set_tl" (set_timeline timeline current_state)) + (set_timeline timeline current_state) Struct.ServerReply.Okay -> current_state -- cgit v1.2.3-70-g09d2