From 99fcad8cbe31ba23d9c079b62e8a174c5b3ddf1b Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sat, 3 Mar 2018 20:28:46 +0100 Subject: Fixing stuff that made Dialyzer output warnings. --- src/battle/attack.erl | 3 ++- src/battle/movement.erl | 2 +- src/query/character_turn.erl | 20 ++++++++++---------- src/struct/battle.erl | 2 +- src/struct/battle_action.erl | 22 ++++++++++++++-------- src/struct/battlemap.erl | 2 +- src/struct/character.erl | 2 +- src/struct/statistics.erl | 2 +- 8 files changed, 31 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/battle/attack.erl b/src/battle/attack.erl index 7384f78..9baf798 100644 --- a/src/battle/attack.erl +++ b/src/battle/attack.erl @@ -28,7 +28,8 @@ critical/0, attack_category/0, attack_effect/0, - attack_desc/0 + attack_desc/0, + attack_order_with_parry/0 ] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/battle/movement.erl b/src/battle/movement.erl index 720b60c..588fad9 100644 --- a/src/battle/movement.erl +++ b/src/battle/movement.erl @@ -49,7 +49,7 @@ cross (Battlemap, ForbiddenLocations, [Step|NextSteps], Cost, Location) -> -spec cross ( battlemap:struct(), - array:array(location:type()), + list(location:type()), list(direction:enum()), location:type() ) diff --git a/src/query/character_turn.erl b/src/query/character_turn.erl index 818ac8a..f2c7263 100644 --- a/src/query/character_turn.erl +++ b/src/query/character_turn.erl @@ -55,7 +55,7 @@ parse_input (Req) -> actions = Actions }. --spec fetch_relevant_data (input()) -> battle:struct(). +-spec fetch_relevant_data (input()) -> relevant_data(). fetch_relevant_data (Input) -> PlayerID = Input#input.player_id, BattleID = Input#input.battle_id, @@ -171,8 +171,8 @@ handle_actions (RData, Input) -> { ActionsDiffUpdates, ClientUpdates, - PostActionCharacterInstance, - PostActionBattle + PostActionBattle, + PostActionCharacterInstance } = lists:foldl ( @@ -182,15 +182,15 @@ handle_actions (RData, Input) -> { CurrActionsDiffUpdates, CurrClientUpdates, - CurrCharacterInstance, - CurrBattle + CurrBattle, + CurrCharacterInstance } ) -> { NewActionsDiffUpdates, NewClientUpdates, - NewCharacterInstance, - NewBattle + NewBattle, + NewCharacterInstance } = battle_action:handle ( @@ -202,11 +202,11 @@ handle_actions (RData, Input) -> { (CurrActionsDiffUpdates ++ NewActionsDiffUpdates), (CurrClientUpdates ++ NewClientUpdates), - NewCharacterInstance, - NewBattle + NewBattle, + NewCharacterInstance } end, - {[], [], CharacterInstance, Battle}, + {[], [], Battle, CharacterInstance}, Actions ), { diff --git a/src/struct/battle.erl b/src/struct/battle.erl index bfa0e8d..4ee3b51 100644 --- a/src/struct/battle.erl +++ b/src/struct/battle.erl @@ -3,7 +3,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --opaque id() :: binary(). +-type id() :: binary(). -record ( diff --git a/src/struct/battle_action.erl b/src/struct/battle_action.erl index c1bccc7..755b771 100644 --- a/src/struct/battle_action.erl +++ b/src/struct/battle_action.erl @@ -63,7 +63,13 @@ decode_atk_action (JSONMap) -> decode_swp_action (_JSONMap) -> #switch_weapon{}. - +-spec handle_attack_sequence + ( + character_instance:struct(), + character_instance:struct(), + list(attack:attack_order_with_pary()) + ) + -> {list(attack:attack_desc()), non_neg_integer(), non_neg_integer()}. handle_attack_sequence ( CharacterInstance, @@ -124,7 +130,7 @@ handle_attack_sequence %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec decode (binary()) -> struct(). +-spec decode (map()) -> struct(). decode (EncodedAction) -> JSONActionMap = EncodedAction, %jiffy:decode(EncodedAction, [return_maps]), ActionType = maps:get(<<"t">>, JSONActionMap), @@ -185,8 +191,8 @@ when is_record(BattleAction, switch_weapon) -> [ {switched_weapons, CharacterInstanceIX} ], - UpdatedCharacterInstance, - Battle + Battle, + UpdatedCharacterInstance }; handle (Battle, CharacterInstance, CharacterInstanceIX, BattleAction) when is_record(BattleAction, move) -> @@ -231,8 +237,8 @@ when is_record(BattleAction, move) -> [ {moved, Path, NewLocation} ], - UpdatedCharacterInstance, - Battle + Battle, + UpdatedCharacterInstance }; handle (Battle, CharacterInstance, _CharacterInstanceIX, BattleAction) when is_record(BattleAction, attack) -> @@ -288,6 +294,6 @@ when is_record(BattleAction, attack) -> [], % TODO % TODO: hide that into turn_result structs. AttackEffects, - UpdatedCharacterInstance, - UpdatedBattle + UpdatedBattle, + UpdatedCharacterInstance }. diff --git a/src/struct/battlemap.erl b/src/struct/battlemap.erl index 9204084..59e0639 100644 --- a/src/struct/battlemap.erl +++ b/src/struct/battlemap.erl @@ -3,7 +3,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --opaque id() :: binary(). +-type id() :: binary(). -record ( diff --git a/src/struct/character.erl b/src/struct/character.erl index 96660ee..8e1099e 100644 --- a/src/struct/character.erl +++ b/src/struct/character.erl @@ -3,7 +3,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --opaque id() :: non_neg_integer(). +-type id() :: non_neg_integer(). -record ( diff --git a/src/struct/statistics.erl b/src/struct/statistics.erl index f3d78a8..6e29ea4 100644 --- a/src/struct/statistics.erl +++ b/src/struct/statistics.erl @@ -69,7 +69,7 @@ float_to_int (F) -> ceil(F). min_max (Min, Max, V) -> min(Max, max(Min, V)). -spec average (list(number())) -> number(). -average ([]) -> 0; +%average ([]) -> 0; average (L) -> lists:sum(L) / length(L). % V | 010 | 030 | 050 | 070 | 100 | -- cgit v1.2.3-70-g09d2