summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-01-09 19:00:32 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-01-09 19:00:32 +0100 |
commit | e8ab45f453bf095a09672c1685315d8d52472f11 (patch) | |
tree | 5093a65dd0f27c5721cdcfac8279977914430c26 | |
parent | 8c2d1d61060cf60a205d3e1aea1855dcab33ae82 (diff) |
[BROKEN] Continuing to work on that bounty...
-rw-r--r-- | src/bounty/bnt_join_battle.erl | 46 | ||||
-rw-r--r-- | src/shared/struct/shr_battle_summary.erl | 11 |
2 files changed, 48 insertions, 9 deletions
diff --git a/src/bounty/bnt_join_battle.erl b/src/bounty/bnt_join_battle.erl index a5abdf4..498aa6a 100644 --- a/src/bounty/bnt_join_battle.erl +++ b/src/bounty/bnt_join_battle.erl @@ -8,6 +8,9 @@ bounty_params, { player_id :: shr_player:id(), + summary_ix :: non_neg_integer(), + summary_category :: shr_battle_summary:category(), + summary_mode :: shr_battle_summary:mode(), pending_battle_id :: btl_pending_battle:id(), roster_ixs :: list(non_neg_integer()), map_id :: map_map:id() % null if the bounty is to join. @@ -25,12 +28,12 @@ -type bounty_params() :: #bounty_params{}. -type bounty_data() :: (#bounty_data{} | none). --type stage() :: -1..0. +-type stage() :: -1..1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export([generate/3, attempt/4]). +-export([generate/4, attempt/5]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -558,13 +561,44 @@ stage (-1, BountyParams, none) -> { pending_battle = NewPendingBattle } + }; + +stage (1, BountyParams, none) -> + PlayerID = BountyParams#bounty_params.player_id, + SummaryIX = SelectedRosterCharacterIXs = BountyParams#bounty_params.roster_ixs, + + NewPendingBattle = + generate_pending_battle(PlayerID, MapID, SelectedRosterCharacterIXs), + + ok = + ataxia_client:update + ( + pending_battle_db, + ataxia_security:user_from_id(PlayerID), + ataxic:update_value(ataxic:constant(NewPendingBattle)), + PendingBattleID + ), + + { + ok, + #bounty_data + { + pending_battle = NewPendingBattle + } }. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec generate (shr_player:id(), map_map:id(), list(non_neg_integer())) -> 'ok'. -generate (PlayerID, MapID, SelectedRosterCharacterIXs) -> +-spec generate + ( + shr_player:id(), + non_neg_integer(), + map_map:id(), + list(non_neg_integer()) + ) + -> 'ok'. +generate (PlayerID, SummaryIX, MapID, SelectedRosterCharacterIXs) -> PlayerUser = ataxia_security:user_from_id(PlayerID), AnyoneAndMeAllowed = ataxia_security:add_access(PlayerUser, ataxia_security:allow_any()), @@ -581,6 +615,7 @@ generate (PlayerID, MapID, SelectedRosterCharacterIXs) -> #bounty_params { player_id = PlayerID, + summary_ix = SummaryIX, map_id = MapID, roster_ixs = SelectedRosterCharacterIXs, pending_battle_id = NewPendingBattleID @@ -595,6 +630,7 @@ generate (PlayerID, MapID, SelectedRosterCharacterIXs) -> -spec attempt ( shr_player:id(), + non_neg_integer(), list(non_neg_integer()), btl_pending_battle:id(), btl_pending_battle:type() @@ -603,6 +639,7 @@ generate (PlayerID, MapID, SelectedRosterCharacterIXs) -> attempt ( PlayerID, + SummaryIX, SelectedRosterCharacterIXs, PendingBattleID, PendingBattle @@ -611,6 +648,7 @@ attempt % #bounty_params % { % player_id = PlayerID, +% summary_ix = SummaryIX, % map_id = ataxia_id:null(), % roster_ixs = SelectedRosterCharacterIXs, % pending_battle_id = PendingBattleID diff --git a/src/shared/struct/shr_battle_summary.erl b/src/shared/struct/shr_battle_summary.erl index 5169b2c..245ee87 100644 --- a/src/shared/struct/shr_battle_summary.erl +++ b/src/shared/struct/shr_battle_summary.erl @@ -3,14 +3,15 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type category() :: (attack | defend | none). +-type mode() :: (attack | defend | none). +-type category() :: (event | invasion | campaign). -record ( battle_summary, { id :: ataxia_id:type(), - category :: category(), + mode :: mode(), name :: binary(), last_edit :: binary(), is_players_turn :: boolean() @@ -19,7 +20,7 @@ -opaque type() :: #battle_summary{}. --export_type([type/0, category/0]). +-export_type([type/0, mode/0, category/0]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -83,7 +84,7 @@ new (ID, Name, Time, IsPlayersTurn) -> { id = ID, name = Name, - category = none, + mode = none, last_edit = Time, is_players_turn = IsPlayersTurn }. @@ -94,7 +95,7 @@ none () -> { id = <<"">>, name = <<"">>, - category = none, + mode = none, last_edit = <<"">>, is_players_turn = false }. |