summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-11-18 10:40:03 +0100 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-11-18 10:40:03 +0100 |
commit | 3fb30b108828e3ad6bf811c0f3372a79ec6e9595 (patch) | |
tree | ef12976907cea83f7ef70168173d487b3cdc018e /src/battle/struct/btl_turn_result.erl | |
parent | cc4e39960d3c56fceb2e31c01bf286dccc73615c (diff) |
...
Diffstat (limited to 'src/battle/struct/btl_turn_result.erl')
-rw-r--r-- | src/battle/struct/btl_turn_result.erl | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/battle/struct/btl_turn_result.erl b/src/battle/struct/btl_turn_result.erl index 3e1be50..d8e20c0 100644 --- a/src/battle/struct/btl_turn_result.erl +++ b/src/battle/struct/btl_turn_result.erl @@ -3,7 +3,15 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% +-record +( + condition, + { + module :: atom(), + params :: any() + } +). + -record ( switched_weapon, @@ -80,6 +88,7 @@ | #player_won{} | #player_lost{} | #player_turn_started{} + | #condition{} ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -90,6 +99,7 @@ -export ( [ + new_condition/2, new_player_won/1, new_player_lost/1, new_player_turn_started/1, @@ -114,6 +124,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec new_condition (atom(), any()) -> type(). +new_condition (Module, Params) -> + #condition{ module = Module, params = Params }. + -spec new_player_won (non_neg_integer()) -> type(). new_player_won (PlayerIX) -> #player_won { player_ix = PlayerIX }. @@ -280,5 +294,23 @@ encode (TurnResult) when is_record(TurnResult, player_turn_started) -> {<<"ix">>, PlayerIX} ] }; +encode (TurnResult) when is_record(TurnResult, condition) -> + {ModuleID, EncodedParams} = + erlang:apply + ( + TurnResult#condition.module, + encode_turn_result, + [ + TurnResult#condition.params + ] + ), + + { + [ + {<<"t">>, <<"con">>}, + {<<"m">>, ModuleID}, + {<<"p">>, EncodedParams} + ] + }; encode (Other) -> error(io_lib:format("~n invalid encode param\"~p\"~n", [Other])). |