From eb78c5f52310b1eaa64a7bc376f119536270a887 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Mon, 7 Jan 2019 18:43:09 +0100 Subject: Player maps & battles: lists -> orddicts. --- src/shared/struct/shr_battle_summary.erl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/shared/struct/shr_battle_summary.erl') diff --git a/src/shared/struct/shr_battle_summary.erl b/src/shared/struct/shr_battle_summary.erl index 9af72b4..5169b2c 100644 --- a/src/shared/struct/shr_battle_summary.erl +++ b/src/shared/struct/shr_battle_summary.erl @@ -3,11 +3,14 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type category() :: (attack | defend | none). + -record ( battle_summary, { - id :: binary(), + id :: ataxia_id:type(), + category :: category(), name :: binary(), last_edit :: binary(), is_players_turn :: boolean() @@ -16,7 +19,7 @@ -opaque type() :: #battle_summary{}. --export_type([type/0]). +-export_type([type/0, category/0]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -80,6 +83,7 @@ new (ID, Name, Time, IsPlayersTurn) -> { id = ID, name = Name, + category = none, last_edit = Time, is_players_turn = IsPlayersTurn }. @@ -90,6 +94,7 @@ none () -> { id = <<"">>, name = <<"">>, + category = none, last_edit = <<"">>, is_players_turn = false }. @@ -133,10 +138,11 @@ get_last_edit_field () -> #battle_summary.last_edit. -spec get_is_players_turn_field () -> non_neg_integer(). get_is_players_turn_field () -> #battle_summary.is_players_turn. --spec encode (type()) -> {list(any())}. -encode (BattleSummary) -> +-spec encode ({non_neg_integer(), type()}) -> {list(any())}. +encode ({IX, BattleSummary}) -> { [ + {<<"ix">>, IX}, {<<"id">>, BattleSummary#battle_summary.id}, {<<"nme">>, BattleSummary#battle_summary.name}, {<<"ldt">>, BattleSummary#battle_summary.last_edit}, -- cgit v1.2.3-70-g09d2