aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-05-11 21:59:56 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-05-11 21:59:56 +0200
commita8e7e53a19ccc80e41b48e737ffed36e13110380 (patch)
treeb27748a25e29b3a02c1c1757afd5c49683d5108b
parent92756a57bcad59c8b7a617b608bb6b7a18f128c8 (diff)
downloadtacticians-server-code-improvements.zip
tacticians-server-code-improvements.tar.bz2
Fixes arg order, JSON encodes timeline elements.code-improvements
-rw-r--r--src/battlemap/src/game-logic/turn_actions.erl22
-rw-r--r--src/battlemap/src/struct/battle_action.erl6
-rw-r--r--src/battlemap/src/struct/character_turn_update.erl4
3 files changed, 18 insertions, 14 deletions
diff --git a/src/battlemap/src/game-logic/turn_actions.erl b/src/battlemap/src/game-logic/turn_actions.erl
index 51c4fb3..b9108f7 100644
--- a/src/battlemap/src/game-logic/turn_actions.erl
+++ b/src/battlemap/src/game-logic/turn_actions.erl
@@ -136,11 +136,11 @@ commit_move (Update, Path, NewLocation) ->
-spec handle_move
(
- character_turn_update:type(),
- battle_action:type()
+ battle_action:type(),
+ character_turn_update:type()
)
-> character_turn_update:type().
-handle_move (Update, BattleAction) ->
+handle_move (BattleAction, Update) ->
Data = character_turn_update:get_data(Update),
Path = battle_action:get_path(BattleAction),
@@ -237,11 +237,11 @@ get_attack_sequence (Character, TargetCharacter) ->
-spec handle_attack
(
- character_turn_update:type(),
- battle_action:type()
+ battle_action:type(),
+ character_turn_update:type()
)
-> character_turn_update:type().
-handle_attack (Update, BattleAction) ->
+handle_attack (BattleAction, Update) ->
Data = character_turn_update:get_data(Update),
Battle = character_turn_data:get_battle(Data),
Character = character_turn_data:get_character(Data),
@@ -304,13 +304,13 @@ handle_attack (Update, BattleAction) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec handle
(
- character_turn_update:type(),
- battle_action:type()
+ battle_action:type(),
+ character_turn_update:type()
)
-> character_turn_update:type().
-handle (Update, BattleAction) ->
+handle (BattleAction, Update) ->
case battle_action:get_category(BattleAction) of
- move -> handle_move(Update, BattleAction);
+ move -> handle_move(BattleAction, Update);
switch_weapon -> handle_switch_weapon(Update);
- attack -> handle_attack(Update, BattleAction)
+ attack -> handle_attack(BattleAction, Update)
end.
diff --git a/src/battlemap/src/struct/battle_action.erl b/src/battlemap/src/struct/battle_action.erl
index b7d80ee..3cedfa7 100644
--- a/src/battlemap/src/struct/battle_action.erl
+++ b/src/battlemap/src/struct/battle_action.erl
@@ -107,4 +107,8 @@ get_target_ix (_) ->
-spec get_category (type()) -> category().
get_category (Action) when is_record(Action, attack) -> attack;
get_category (Action) when is_record(Action, move) -> move;
-get_category (Action) when is_record(Action, switch_weapon) -> switch_weapon.
+get_category (Action) when is_record(Action, switch_weapon) -> switch_weapon;
+get_category (Action) ->
+ io:format("How'd you get there?~p~n", [Action]),
+ true = Action.
+
diff --git a/src/battlemap/src/struct/character_turn_update.erl b/src/battlemap/src/struct/character_turn_update.erl
index dda09d9..9e0041f 100644
--- a/src/battlemap/src/struct/character_turn_update.erl
+++ b/src/battlemap/src/struct/character_turn_update.erl
@@ -64,9 +64,9 @@ get_db (Update) -> Update#type.db.
set_data (Data, Update) ->
Update#type{ data = Data}.
--spec add_to_timeline (any(), type()) -> type().
+-spec add_to_timeline (turn_result:type(), type()) -> type().
add_to_timeline (Item, Update) ->
- Update#type{ timeline = [Item|Update#type.timeline] }.
+ Update#type{ timeline = [turn_result:encode(Item)|Update#type.timeline] }.
-spec add_to_db (any(), type()) -> type().
add_to_db (Item, Update) ->