summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-04-29 17:43:18 +0200 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-04-29 17:43:18 +0200 |
commit | c28f8c07374493de31e5581dcd53ad99a2ff917a (patch) | |
tree | 5c8a2d384fa47ee3c16982c8d4d2775df5da2c0c /src/battle | |
parent | c21e6a963fc36005b1afd5e983049a17aff92aca (diff) |
Dialyzer error, compiles, some issues w/ client.
Dialyzer says:
bnt_join_battle.erl:103: The created fun has no local return
bnt_join_battle.erl:122: The call shr_inventory:ataxia_add_equipment(shr_equipment:unresolved(),shr_inventory:type()) does not have an opaque term of type shr_equipment:type() as 1st argument
bnt_join_battle.erl:310: Function repair_join_battle/6 will never be called
shr_inventory:ataxia_add_equipment(shr_equipment:unresolved(),shr_inventory:type())
is defined, though...
Still some hiccups with what is sent to the client.
Diffstat (limited to 'src/battle')
-rw-r--r-- | src/battle/mechanic/turn_action/btl_turn_actions_move.erl | 17 | ||||
-rw-r--r-- | src/battle/reply/btl_add_tile.erl | 2 | ||||
-rw-r--r-- | src/battle/struct/btl_pending_battle.erl | 16 |
3 files changed, 28 insertions, 7 deletions
diff --git a/src/battle/mechanic/turn_action/btl_turn_actions_move.erl b/src/battle/mechanic/turn_action/btl_turn_actions_move.erl index da62e8c..a0cd138 100644 --- a/src/battle/mechanic/turn_action/btl_turn_actions_move.erl +++ b/src/battle/mechanic/turn_action/btl_turn_actions_move.erl @@ -107,7 +107,7 @@ get_path_cost_and_destination (Update, Path) -> btl_character:type(), non_neg_integer() ) - -> 'ok'. + -> ('ok' | 'error'). assert_character_can_move (Char, Cost) -> CharacterMovementPoints = shr_statistics:get_movement_points @@ -118,9 +118,16 @@ assert_character_can_move (Char, Cost) -> ) ), - true = (Cost =< CharacterMovementPoints), - - ok. + case (Cost =< CharacterMovementPoints) of + true -> ok; + false -> + io:format + ( + "~n[E] Character trying to move ~p dist with ~p points.~n", + [Cost, CharacterMovementPoints] + ), + error + end. -spec commit_move ( @@ -184,6 +191,6 @@ handle (BattleAction, Update) -> {PathCost, NewLocation, S1Update} = get_path_cost_and_destination(S0Update, Path), - assert_character_can_move(Character, PathCost), + ok = assert_character_can_move(Character, PathCost), commit_move(Character, S1Update, Path, NewLocation). diff --git a/src/battle/reply/btl_add_tile.erl b/src/battle/reply/btl_add_tile.erl index 980628d..90bcbc9 100644 --- a/src/battle/reply/btl_add_tile.erl +++ b/src/battle/reply/btl_add_tile.erl @@ -24,6 +24,8 @@ generate (Tile) -> {<<"id">>, shr_tile:get_id(Tile)}, {<<"nam">>, shr_tile:get_name(Tile)}, {<<"ct">>, shr_tile:get_cost(Tile)}, + {<<"de">>, 1}, % TODO: provide actual depth. + {<<"fa">>, <<"">>}, % TODO: provide actual family. {<<"omni">>, shr_omnimods:encode(shr_tile:get_omnimods(Tile))} ] }. diff --git a/src/battle/struct/btl_pending_battle.erl b/src/battle/struct/btl_pending_battle.erl index 0e46a24..cb8cbfa 100644 --- a/src/battle/struct/btl_pending_battle.erl +++ b/src/battle/struct/btl_pending_battle.erl @@ -46,6 +46,8 @@ push_player_summary_ix/2, ataxia_set_battle/2, + ataxia_set_battle/3, + ataxia_set_free_slots/2, ataxia_set_battle_id/2, ataxia_set_player_ids/2, @@ -107,12 +109,22 @@ set_battle (Battle, PBattle) -> PBattle#pending_battle{ battle = Battle }. -spec ataxia_set_battle (btl_battle:type(), type()) -> {type(), ataxic:basic()}. ataxia_set_battle (Battle, PBattle) -> + ataxia_set_battle(Battle, ataxic:constant(Battle), PBattle). + +-spec ataxia_set_battle + ( + btl_battle:type(), + ataxic:basic(), + type() + ) + -> {type(), ataxic:basic()}. +ataxia_set_battle (Battle, BattleAtaxiaUpdate, PBattle) -> { - PBattle#pending_battle{ battle = Battle }, + set_battle(Battle, PBattle), ataxic:update_field ( get_battle_field(), - ataxic:constant(Battle) + BattleAtaxiaUpdate ) }. |