From 5fd8f5d303e8915cc74a52e5b86d1fd8f073cb4d Mon Sep 17 00:00:00 2001 From: nsensfel Date: Thu, 6 Jun 2019 17:54:05 +0200 Subject: Fixes some of the issues I've found. --- src/battle/mechanic/action/btl_action_attack.erl | 12 +++++++----- src/battle/mechanic/action/btl_action_move.erl | 6 ++++-- src/shared/struct/inventory/shr_equipment.erl | 16 ++++++++-------- src/shared/struct/shr_character.erl | 18 +++++++++++++----- 4 files changed, 32 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/battle/mechanic/action/btl_action_attack.erl b/src/battle/mechanic/action/btl_action_attack.erl index 1953096..4a4ee8a 100644 --- a/src/battle/mechanic/action/btl_action_attack.erl +++ b/src/battle/mechanic/action/btl_action_attack.erl @@ -95,29 +95,31 @@ get_character_abilities (Action, Character, TargetCharacter) -> ), DefenseRange = shr_weapon:get_minimum_range(CharacterWeapon), - AttackRange = shr_weapon:get_maximum_range(CharacterWeapon), + AttackRange = shr_weapon:get_maximum_range(CharacterWeapon), TargetDefenseRange = shr_weapon:get_minimum_range(TargetCharacterWeapon), TargetAttackRange = shr_weapon:get_maximum_range(TargetCharacterWeapon), IsNotOpportunistic = btl_action:get_is_opportunistic(Action), - AttackRange = + RequiredRange = shr_location:dist ( btl_character:get_location(Character), btl_character:get_location(TargetCharacter) ), + true = (AttackRange >= RequiredRange), + { (DefenseRange == 0), ( IsNotOpportunistic and (TargetDefenseRange == 0) - and (TargetAttackRange =< AttackRange) + and (TargetAttackRange =< RequiredRange) ), ( IsNotOpportunistic - and (TargetAttackRange =< AttackRange) + and (TargetAttackRange =< RequiredRange) ) }. @@ -664,7 +666,7 @@ handle (Action, S0Character, S0Update) -> ataxic:update_field ( btl_character:get_current_health_field(), - ataxic:constant(btl_character:get_current_health(S1Character)) + ataxic:constant(btl_character:get_current_health(S1TargetCharacter)) ), {S3Battle, BattleAtaxiaUpdate1} = diff --git a/src/battle/mechanic/action/btl_action_move.erl b/src/battle/mechanic/action/btl_action_move.erl index a32a40f..a24a96e 100644 --- a/src/battle/mechanic/action/btl_action_move.erl +++ b/src/battle/mechanic/action/btl_action_move.erl @@ -53,12 +53,14 @@ cross (PlayerIX, Map, ForbiddenLocations, [Step|NextSteps], Cost, Location) -> false = IsForbidden, Interruptions = - list:foldl + lists:foldl ( fun (MarkerName, CurrentInterruptions) -> case shr_map:get_marker(MarkerName, Map) of {ok, Marker} -> - case shr_map_marker:interrupts_movement(PlayerIX, Marker) of + case + shr_map_marker:interrupts_movement(PlayerIX, Marker) + of true -> [Marker|CurrentInterruptions]; _ -> CurrentInterruptions end; diff --git a/src/shared/struct/inventory/shr_equipment.erl b/src/shared/struct/inventory/shr_equipment.erl index b56a83c..830896c 100644 --- a/src/shared/struct/inventory/shr_equipment.erl +++ b/src/shared/struct/inventory/shr_equipment.erl @@ -502,16 +502,16 @@ decode (Map) -> glyphs = maps:get(?GLYPHS_FIELD, Map) }. --spec encode (unresolved()) -> {list({binary(), any()})}. -encode (EqRef) -> +-spec encode (either()) -> {list({binary(), any()})}. +encode (Eq) -> { [ - {?PRIMARY_WEAPON_FIELD, EqRef#shr_eq_ref.primary}, - {?SECONDARY_WEAPON_FIELD, EqRef#shr_eq_ref.secondary}, - {?ARMOR_FIELD, EqRef#shr_eq_ref.armor}, - {?PORTRAIT_FIELD, EqRef#shr_eq_ref.portrait}, - {?GLYPH_BOARD_FIELD, EqRef#shr_eq_ref.glyph_board}, - {?GLYPHS_FIELD, EqRef#shr_eq_ref.glyphs} + {?PRIMARY_WEAPON_FIELD, get_primary_weapon_id(Eq)}, + {?SECONDARY_WEAPON_FIELD, get_secondary_weapon_id(Eq)}, + {?ARMOR_FIELD, get_armor_id(Eq)}, + {?PORTRAIT_FIELD, get_portrait_id(Eq)}, + {?GLYPH_BOARD_FIELD, get_glyph_board_id(Eq)}, + {?GLYPHS_FIELD, get_glyph_ids(Eq)} ] }. diff --git a/src/shared/struct/shr_character.erl b/src/shared/struct/shr_character.erl index 87a9be8..27cf81d 100644 --- a/src/shared/struct/shr_character.erl +++ b/src/shared/struct/shr_character.erl @@ -416,16 +416,24 @@ decode (Map) -> is_using_secondary = maps:get(?IS_USING_SECONDARY_FIELD, Map) }. --spec encode (unresolved()) -> {list({binary(), any()})}. -encode (CharRef) -> +-spec encode (either()) -> {list({binary(), any()})}. +encode (Character) -> { [ - {?NAME_FIELD, CharRef#shr_char_ref.name}, + {?NAME_FIELD, get_name(Character)}, { ?EQUIPMENT_FIELD, - shr_equipment:encode(CharRef#shr_char_ref.equipment) + shr_equipment:encode(get_equipment(Character)) }, - {?IS_USING_SECONDARY_FIELD, CharRef#shr_char_ref.is_using_secondary} + { + ?IS_USING_SECONDARY_FIELD, + ( + case Character of + #shr_char_ref{is_using_secondary = R} -> R; + #shr_char{is_using_secondary = R} -> R + end + ) + } ] }. -- cgit v1.2.3-70-g09d2