summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-01-16 00:08:14 +0100 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-01-16 00:08:14 +0100 |
commit | 545be2964873423280fae2cb1c211b746a37b562 (patch) | |
tree | 9096f6c329e4ed5e3470f02ae3256cdbedda6ee3 /src/battle/query/btl_join.erl | |
parent | 1ebb5eaa2edc601bed405f8f7733412b0378a185 (diff) |
...
Diffstat (limited to 'src/battle/query/btl_join.erl')
-rw-r--r-- | src/battle/query/btl_join.erl | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/src/battle/query/btl_join.erl b/src/battle/query/btl_join.erl index 587f555..c38cfde 100644 --- a/src/battle/query/btl_join.erl +++ b/src/battle/query/btl_join.erl @@ -14,6 +14,7 @@ player_id :: shr_player:id(), session_token :: binary(), mode :: mode(), + summary_ix :: non_neg_integer(), size :: non_neg_integer(), roster_ixs :: list(non_neg_integer()), map_id :: ataxia_id:type() @@ -38,6 +39,7 @@ parse_input (Req) -> JSONReqMap = jiffy:decode(Req, [return_maps]), PlayerID = maps:get(<<"pid">>, JSONReqMap), SessionToken = maps:get(<<"stk">>, JSONReqMap), + SummaryIX = maps:get(<<"six">>, JSONReqMap), Mode = case maps:get(<<"m">>, JSONReqMap) of @@ -65,6 +67,7 @@ parse_input (Req) -> session_token = SessionToken, mode = Mode, size = Size, + summary_ix = SummaryIX, roster_ixs = Roster, map_id = MapID }. @@ -85,6 +88,7 @@ authenticate_user (Input) -> handle_attack (Input) -> PlayerID = Input#input.player_id, SelectedCharacterIXs = Input#input.roster_ixs, + SummaryIX = Input#input.summary_ix, PlayerDBUser = ataxia_security:user_from_id(PlayerID), PartySize = length(SelectedCharacterIXs), @@ -106,25 +110,46 @@ handle_attack (Input) -> ] ) ), - ataxic:ge + ataxic:land ( - ataxic:field - ( - ataxia_entry:get_value_field(), - ataxic:field + [ + ataxic:ge + ( + ataxic:field + ( + ataxia_entry:get_value_field(), + ataxic:field + ( + btl_pending_battle:get_free_slots_field(), + ataxic:current_value() + ) + ), + ataxic:constant(PartySize) + ), + ataxic:neg ( - btl_pending_battle:get_free_slots_field(), - ataxic:current_value() + ataxic:field + ( + btl_pending_battle:get_player_ids_field(), + ataxic:apply_function + ( + lists, + member, + [ + ataxic:constant(PlayerID), + ataxic:current_value() + ] + ) + ) ) - ), - ataxic:constant(PartySize) + ] ) - % missing: test that user isn't already a participant. ), bnt_join_battle:attempt ( PlayerID, + SummaryIX, SelectedCharacterIXs, AvailablePendingBattleID, AvailablePendingBattle @@ -135,9 +160,10 @@ handle_attack (Input) -> handle_defend (Input) -> PlayerID = Input#input.player_id, SelectedCharacterIXs = Input#input.roster_ixs, + SummaryIX = Input#input.summary_ix, MapID = Input#input.map_id, - bnt_join_battle:generate(PlayerID, MapID, SelectedCharacterIXs), + bnt_join_battle:generate(PlayerID, SummaryIX, MapID, SelectedCharacterIXs), ok. |