From 85b1e04a22e7564b702aa27c5f6467ad4d5f4416 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 15 Feb 2019 18:18:54 +0100 Subject: Re-organizing shr_ structs. --- src/map/query/map_update.erl | 1 + src/shared/struct/inventory/shr_armor.erl.m4 | 68 ++++++++ src/shared/struct/inventory/shr_glyph.erl.m4 | 62 ++++++++ src/shared/struct/inventory/shr_glyph_board.erl.m4 | 109 +++++++++++++ src/shared/struct/inventory/shr_portrait.erl.m4 | 73 +++++++++ src/shared/struct/inventory/shr_weapon.erl.m4 | 79 +++++++++ src/shared/struct/map/shr_direction.erl | 38 +++++ src/shared/struct/map/shr_inventory.erl | 153 ++++++++++++++++++ src/shared/struct/map/shr_location.erl | 90 +++++++++++ src/shared/struct/map/shr_map.erl | 176 +++++++++++++++++++++ src/shared/struct/map/shr_map_marker.erl | 52 ++++++ src/shared/struct/map/shr_tile.erl.m4 | 133 ++++++++++++++++ src/shared/struct/shr_armor.erl.m4 | 68 -------- src/shared/struct/shr_direction.erl | 38 ----- src/shared/struct/shr_glyph.erl.m4 | 62 -------- src/shared/struct/shr_glyph_board.erl.m4 | 109 ------------- src/shared/struct/shr_inventory.erl | 153 ------------------ src/shared/struct/shr_location.erl | 90 ----------- src/shared/struct/shr_map.erl | 154 ------------------ src/shared/struct/shr_portrait.erl.m4 | 73 --------- src/shared/struct/shr_tile.erl.m4 | 133 ---------------- src/shared/struct/shr_weapon.erl.m4 | 79 --------- 22 files changed, 1034 insertions(+), 959 deletions(-) create mode 100644 src/shared/struct/inventory/shr_armor.erl.m4 create mode 100644 src/shared/struct/inventory/shr_glyph.erl.m4 create mode 100644 src/shared/struct/inventory/shr_glyph_board.erl.m4 create mode 100644 src/shared/struct/inventory/shr_portrait.erl.m4 create mode 100644 src/shared/struct/inventory/shr_weapon.erl.m4 create mode 100644 src/shared/struct/map/shr_direction.erl create mode 100644 src/shared/struct/map/shr_inventory.erl create mode 100644 src/shared/struct/map/shr_location.erl create mode 100644 src/shared/struct/map/shr_map.erl create mode 100644 src/shared/struct/map/shr_map_marker.erl create mode 100644 src/shared/struct/map/shr_tile.erl.m4 delete mode 100644 src/shared/struct/shr_armor.erl.m4 delete mode 100644 src/shared/struct/shr_direction.erl delete mode 100644 src/shared/struct/shr_glyph.erl.m4 delete mode 100644 src/shared/struct/shr_glyph_board.erl.m4 delete mode 100644 src/shared/struct/shr_inventory.erl delete mode 100644 src/shared/struct/shr_location.erl delete mode 100644 src/shared/struct/shr_map.erl delete mode 100644 src/shared/struct/shr_portrait.erl.m4 delete mode 100644 src/shared/struct/shr_tile.erl.m4 delete mode 100644 src/shared/struct/shr_weapon.erl.m4 diff --git a/src/map/query/map_update.erl b/src/map/query/map_update.erl index 5cb9e42..00f9a29 100644 --- a/src/map/query/map_update.erl +++ b/src/map/query/map_update.erl @@ -109,6 +109,7 @@ update_data (QueryState, Input) -> QueryState#query_state.map, Input#input.w, Input#input.h, + shr_map_marker:empty_collection(), Input#input.t ) }. diff --git a/src/shared/struct/inventory/shr_armor.erl.m4 b/src/shared/struct/inventory/shr_armor.erl.m4 new file mode 100644 index 0000000..18d203a --- /dev/null +++ b/src/shared/struct/inventory/shr_armor.erl.m4 @@ -0,0 +1,68 @@ +-module(shr_armor). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: binary(). + +-record +( + armor, + { + id :: id(), + name :: binary(), + omnimods :: shr_omnimods:type() + } +). + +-opaque type() :: #armor{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-export +( + [ + get_id/1, + get_name/1, + get_omnimods/1 + ] +). + +-export +( + [ + none/0, + from_id/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-spec get_id (type()) -> id(). +get_id (Ar) -> Ar#armor.id. + +-spec get_name (type()) -> binary(). +get_name (Ar) -> Ar#armor.name. + +-spec get_omnimods (type()) -> shr_omnimods:type(). +get_omnimods (Ar) -> Ar#armor.omnimods. + +-spec from_id (id()) -> type(). +m4_include(__MAKEFILE_DATA_DIR/armor/global.m4.conf)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/armor/basic.m4d)m4_dnl +from_id(_) -> + none(). + +-spec none () -> type(). +none () -> from_id(<<"0">>). diff --git a/src/shared/struct/inventory/shr_glyph.erl.m4 b/src/shared/struct/inventory/shr_glyph.erl.m4 new file mode 100644 index 0000000..cd59a27 --- /dev/null +++ b/src/shared/struct/inventory/shr_glyph.erl.m4 @@ -0,0 +1,62 @@ +-module(shr_glyph). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: binary(). + +-record +( + glyph, + { + id :: id(), + name :: binary(), + omnimods :: shr_omnimods:type() + } +). + +-type type() :: #glyph{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +-export +( + [ + from_id/1 + ] +). + +-export +( + [ + get_id/1, + get_name/1, + get_omnimods/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec get_id (type()) -> id(). +get_id (Glyph) -> Glyph#glyph.id. + +-spec get_name (type()) -> binary(). +get_name (Glyph) -> Glyph#glyph.name. + +-spec get_omnimods (type()) -> shr_omnimods:type(). +get_omnimods (Glyph) -> Glyph#glyph.omnimods. + +-spec from_id (id()) -> type(). +m4_include(__MAKEFILE_DATA_DIR/glyph/global.m4.conf)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/glyph/basic.m4d)m4_dnl +from_id(_) -> + from_id(<<"0">>). diff --git a/src/shared/struct/inventory/shr_glyph_board.erl.m4 b/src/shared/struct/inventory/shr_glyph_board.erl.m4 new file mode 100644 index 0000000..7fe77b1 --- /dev/null +++ b/src/shared/struct/inventory/shr_glyph_board.erl.m4 @@ -0,0 +1,109 @@ +-module(shr_glyph_board). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: binary(). + +-record +( + glyph_board, + { + id :: id(), + name :: binary(), + omnimods :: shr_omnimods:type(), + slots :: list(integer()) + } +). + +-type type() :: #glyph_board{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + from_id/1 + ] +). + +-export +( + [ + get_id/1, + get_name/1, + get_omnimods/1, + get_slots/1 + ] +). + +-export +( + [ + none/0, + get_omnimods_with_glyphs/2 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec get_omnimods_with_glyphs_internals + ( + shr_omnimods:type(), + list(shr_glyph:type()), + list(integer()) + ) + -> ({'ok', shr_omnimods:type()} | 'error'). +get_omnimods_with_glyphs_internals (Omnimods, [], []) -> + {ok, Omnimods}; +get_omnimods_with_glyphs_internals (_Omnimods, [], _) -> + error; +get_omnimods_with_glyphs_internals (_Omnimods, _, []) -> + error; +get_omnimods_with_glyphs_internals (Omnimods, [Glyph|NextGlyphs], [M|NextMs]) -> + Multiplier = (M / 100), + GlyphOmnimods = shr_glyph:get_omnimods(Glyph), + ModGlyphOmnimods = shr_omnimods:apply_coefficient(Multiplier, GlyphOmnimods), + NextOmnimods = shr_omnimods:merge(Omnimods, ModGlyphOmnimods), + + get_omnimods_with_glyphs_internals(NextOmnimods, NextGlyphs, NextMs). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec get_id (type()) -> id(). +get_id (GlyphBoard) -> GlyphBoard#glyph_board.id. + +-spec get_name (type()) -> binary(). +get_name (GlyphBoard) -> GlyphBoard#glyph_board.name. + +-spec get_omnimods (type()) -> shr_omnimods:type(). +get_omnimods (GlyphBoard) -> GlyphBoard#glyph_board.omnimods. + +-spec get_slots (type()) -> list(non_neg_integer()). +get_slots (GlyphBoard) -> GlyphBoard#glyph_board.slots. + +-spec from_id (id()) -> type(). +m4_include(__MAKEFILE_DATA_DIR/glyph_board/global.m4.conf)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/glyph_board/basic.m4d)m4_dnl +from_id(_) -> + none(). + +-spec none () -> type(). +none () -> from_id(<<"0">>). + +-spec get_omnimods_with_glyphs + ( + list(shr_glyph:type()), + type() + ) + -> ({'ok', shr_omnimods:type()} | 'error'). +get_omnimods_with_glyphs (Glyphs, GlyphBoard) -> + BoardOmnimods = GlyphBoard#glyph_board.omnimods, + BoardSlots = GlyphBoard#glyph_board.slots, + + get_omnimods_with_glyphs_internals(BoardOmnimods, Glyphs, BoardSlots). diff --git a/src/shared/struct/inventory/shr_portrait.erl.m4 b/src/shared/struct/inventory/shr_portrait.erl.m4 new file mode 100644 index 0000000..fefc434 --- /dev/null +++ b/src/shared/struct/inventory/shr_portrait.erl.m4 @@ -0,0 +1,73 @@ +-module(shr_portrait). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: binary(). + +-record +( + portrait, + { + id :: id(), + name :: binary(), + body_id :: binary(), + icon_id :: binary() + } +). + +-opaque type() :: #portrait{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-export +( + [ + get_id/1, + get_name/1, + get_body_id/1, + get_icon_id/1 + ] +). + +-export +( + [ + from_id/1, + default/0 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-spec get_id (type()) -> id(). +get_id (Pt) -> Pt#portrait.id. + +-spec get_name (type()) -> binary(). +get_name (Pt) -> Pt#portrait.name. + +-spec get_body_id (type()) -> binary(). +get_body_id (Pt) -> Pt#portrait.body_id. + +-spec get_icon_id (type()) -> binary(). +get_icon_id (Pt) -> Pt#portrait.icon_id. + +-spec from_id (id()) -> type(). +m4_include(__MAKEFILE_DATA_DIR/portrait/global.m4.conf)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/portrait/basic.m4d)m4_dnl +from_id(_) -> + default(). + +-spec default () -> type(). +default () -> from_id(<<"cat">>). diff --git a/src/shared/struct/inventory/shr_weapon.erl.m4 b/src/shared/struct/inventory/shr_weapon.erl.m4 new file mode 100644 index 0000000..1a2dcf5 --- /dev/null +++ b/src/shared/struct/inventory/shr_weapon.erl.m4 @@ -0,0 +1,79 @@ +-module(shr_weapon). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: binary(). + +-record +( + weapon, + { + id :: id(), + name :: binary(), + is_primary :: boolean(), + range_min:: non_neg_integer(), + range_max :: non_neg_integer(), + omnimods :: shr_omnimods:type() + } +). + +-opaque type() :: #weapon{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-export +( + [ + get_id/1, + get_name/1, + get_minimum_range/1, + get_maximum_range/1, + get_omnimods/1 + ] +). + +-export +( + [ + none/0, + from_id/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-spec get_id (type()) -> id(). +get_id (Wp) -> Wp#weapon.id. + +-spec get_name (type()) -> binary(). +get_name (Wp) -> Wp#weapon.name. + +-spec get_minimum_range (type()) -> non_neg_integer(). +get_minimum_range (Wp) -> Wp#weapon.range_min. + +-spec get_maximum_range (type()) -> non_neg_integer(). +get_maximum_range (Wp) -> Wp#weapon.range_max. + +-spec get_omnimods (type()) -> shr_omnimods:type(). +get_omnimods (Wp) -> Wp#weapon.omnimods. + +-spec from_id (id()) -> type(). +m4_include(__MAKEFILE_DATA_DIR/weapon/global.m4.conf)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/weapon/basic.m4d)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/weapon/secondary.m4d)m4_dnl +from_id (_) -> + none(). + +-spec none () -> type(). +none () -> from_id(<<"0">>). diff --git a/src/shared/struct/map/shr_direction.erl b/src/shared/struct/map/shr_direction.erl new file mode 100644 index 0000000..f0793b3 --- /dev/null +++ b/src/shared/struct/map/shr_direction.erl @@ -0,0 +1,38 @@ +-module(shr_direction). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type enum() :: ('up' | 'down' | 'left' | 'right'). +-type type() :: enum(). + +-export_type([enum/0, type/0]). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + decode/1, + encode/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec decode (binary()) -> enum(). +decode (<<"U">>) -> up; +decode (<<"D">>) -> down; +decode (<<"L">>) -> left; +decode (<<"R">>) -> right. + +-spec encode (enum()) -> binary(). +encode (up) -> <<"U">>; +encode (down) -> <<"D">>; +encode (left) -> <<"L">>; +encode (right) -> <<"R">>. diff --git a/src/shared/struct/map/shr_inventory.erl b/src/shared/struct/map/shr_inventory.erl new file mode 100644 index 0000000..1f04533 --- /dev/null +++ b/src/shared/struct/map/shr_inventory.erl @@ -0,0 +1,153 @@ +-module(shr_inventory). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: ataxia_id:type(). +-record +( + inventory, + { + owner_id :: shr_player:id(), + portrait_ids :: ordsets:ordset(binary()), + glyph_ids :: ordsets:ordset(binary()), + glyph_board_ids :: ordsets:ordset(binary()), + weapon_ids :: ordsets:ordset(binary()), + armor_ids :: ordsets:ordset(binary()) + } +). + +-opaque type() :: #inventory{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-export +( + [ + get_owner_id/1, + + get_portrait_ids/1, + get_glyph_ids/1, + get_glyph_board_ids/1, + get_weapon_ids/1, + get_armor_ids/1, + + set_portrait_ids/2, + set_glyph_ids/2, + set_glyph_board_ids/2, + set_weapon_ids/2, + set_armor_ids/2 + ] +). + +-export +( + [ + get_portrait_ids_field/0, + get_glyph_ids_field/0, + get_glyph_board_ids_field/0, + get_weapon_ids_field/0, + get_armor_ids_field/0 + ] +). + +-export +( + [ + new/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-spec get_owner_id (type()) -> shr_player:id(). +get_owner_id (Inv) -> Inv#inventory.owner_id. + +-spec get_portrait_ids (type()) -> ordsets:ordset(binary()). +get_portrait_ids (Inv) -> Inv#inventory.portrait_ids. + +-spec get_glyph_ids (type()) -> ordsets:ordset(binary()). +get_glyph_ids (Inv) -> Inv#inventory.glyph_ids. + +-spec get_glyph_board_ids (type()) -> ordsets:ordset(binary()). +get_glyph_board_ids (Inv) -> Inv#inventory.glyph_board_ids. + +-spec get_weapon_ids (type()) -> ordsets:ordset(binary()). +get_weapon_ids (Inv) -> Inv#inventory.weapon_ids. + +-spec get_armor_ids (type()) -> ordsets:ordset(binary()). +get_armor_ids (Inv) -> Inv#inventory.armor_ids. + +-spec set_portrait_ids (ordsets:ordset(binary()), type()) -> type(). +set_portrait_ids (Value, Inv) -> + Inv#inventory + { + portrait_ids = Value + }. + +-spec set_glyph_ids (ordsets:ordset(binary()), type()) -> type(). +set_glyph_ids (Value, Inv) -> + Inv#inventory + { + glyph_ids = Value + }. + +-spec set_glyph_board_ids (ordsets:ordset(binary()), type()) -> type(). +set_glyph_board_ids (Value, Inv) -> + Inv#inventory + { + glyph_board_ids = Value + }. + +-spec set_weapon_ids (ordsets:ordset(binary()), type()) -> type(). +set_weapon_ids (Value, Inv) -> + Inv#inventory + { + weapon_ids = Value + }. + +-spec set_armor_ids (ordsets:ordset(binary()), type()) -> type(). +set_armor_ids (Value, Inv) -> + Inv#inventory + { + armor_ids = Value + }. + +-spec get_portrait_ids_field () -> non_neg_integer(). +get_portrait_ids_field () -> #inventory.portrait_ids. + +-spec get_glyph_ids_field () -> non_neg_integer(). +get_glyph_ids_field () -> #inventory.glyph_ids. + +-spec get_glyph_board_ids_field () -> non_neg_integer(). +get_glyph_board_ids_field () -> #inventory.glyph_board_ids. + +-spec get_weapon_ids_field () -> non_neg_integer(). +get_weapon_ids_field () -> #inventory.weapon_ids. + +-spec get_armor_ids_field () -> non_neg_integer(). +get_armor_ids_field () -> #inventory.armor_ids. + +-spec new (shr_player:id()) -> type(). +new (OwnerID) -> + EmptySet = ordsets:new(), + + #inventory + { + owner_id = OwnerID, + portrait_ids = EmptySet, + glyph_ids = EmptySet, + glyph_board_ids = EmptySet, + weapon_ids = EmptySet, + armor_ids = EmptySet + }. diff --git a/src/shared/struct/map/shr_location.erl b/src/shared/struct/map/shr_location.erl new file mode 100644 index 0000000..ec62ff7 --- /dev/null +++ b/src/shared/struct/map/shr_location.erl @@ -0,0 +1,90 @@ +-module(shr_location). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type type() :: ({non_neg_integer(), non_neg_integer()} | 'nowhere'). + +-export_type([type/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + decode/1, + encode/1, + get_nowhere/0 + ] +). + +-export +( + [ + apply_direction/2, + dist/2 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec validate ({integer(), integer()}) -> type(). +validate ({X, Y}) -> + if + (X < 0) -> nowhere; + (Y < 0) -> nowhere; + true -> {X, Y} + end. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec get_nowhere () -> type(). +get_nowhere () -> nowhere. + +-spec apply_direction (shr_direction:enum(), type()) -> type(). +apply_direction (left, {X, Y}) -> + validate({(X - 1), Y}); +apply_direction (right, {X, Y}) -> + validate({(X + 1), Y}); +apply_direction (up, {X, Y}) -> + validate({X, (Y - 1)}); +apply_direction (down, {X, Y}) -> + validate({X, (Y + 1)}); +apply_direction (_, nowhere) -> + error("Trying to move from 'nowhere'."), + nowhere. + +-spec dist(type(), type()) -> non_neg_integer(). +dist ({OX, OY}, {DX, DY}) -> + (abs(DY - OY) + abs(DX - OX)); +dist (_, _) -> + error("Trying to measure distance to 'nowhere'"), + 999. + +-spec encode (type()) -> {list(any())}. +encode ({X, Y}) -> + { + [ + {<<"x">>, X}, + {<<"y">>, Y} + ] + }; +encode (nowhere) -> + { + [ + {<<"x">>, -1}, + {<<"y">>, -1} + ] + }. + +-spec decode (map()) -> type(). +decode (Map) -> + X = maps:get(<<"x">>, Map), + Y = maps:get(<<"y">>, Map), + + true = (is_integer(X) and is_integer(Y)), + + validate({X, Y}). diff --git a/src/shared/struct/map/shr_map.erl b/src/shared/struct/map/shr_map.erl new file mode 100644 index 0000000..b72c566 --- /dev/null +++ b/src/shared/struct/map/shr_map.erl @@ -0,0 +1,176 @@ +-module(shr_map). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type id() :: ataxia_id:type(). + +-record +( + map, + { + owner :: shr_player:id(), + width :: non_neg_integer(), + height :: non_neg_integer(), + tile_instances :: shr_tile:instances_tuple(), + markers :: shr_map_marker:collection() + } +). + +-opaque type() :: #map{}. + +-export_type([type/0, id/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-export +( + [ + get_owner/1, + get_width/1, + get_height/1, + get_tile_instances/1, + get_tile_instance/2, + get_markers/1, + get_marker/2, + + get_used_tile_ids/1 + ] +). + +%%%% Fields +-export +( + [ + get_width_field/0, + get_height_field/0, + get_markers_field/0, + get_tile_instances_field/0 + ] +). + +%%%% Utility +-export +( + [ + update_from_list/5, + default/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec location_to_index + ( + non_neg_integer(), + shr_location:type() + ) + -> ('error' | non_neg_integer()). +location_to_index (ArrayWidth, {X, Y}) -> + if + (X < 0) -> error; + (Y < 0) -> error; + (X >= ArrayWidth) -> error; + true -> ((Y * ArrayWidth) + X) + end. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-spec get_owner (type()) -> shr_player:id(). +get_owner (Map) -> Map#map.owner. + +-spec get_width (type()) -> non_neg_integer(). +get_width (Map) -> Map#map.width. + +-spec get_height (type()) -> non_neg_integer(). +get_height (Map) -> Map#map.height. + +-spec get_tile_instances (type()) -> shr_tile:instances_tuple(). +get_tile_instances (Map) -> Map#map.tile_instances. + +-spec get_tile_instance (shr_location:type(), type()) -> shr_tile:instance(). +get_tile_instance (Location, Map) -> + TileIX = location_to_index(Map#map.width, Location), + element((TileIX + 1), Map#map.tile_instances). + +-spec get_markers (type()) -> shr_map_marker:collection(). +get_markers (Map) -> Map#map.markers. + +-spec get_marker + ( + shr_map_marker:name(), + type() + ) + -> ('not_found' | {'ok', shr_map_marker:type()}). +get_marker (Name, Map) -> + shr_map_marker:get(Name, Map#map.markers). + +%%%% Fields +-spec get_width_field () -> non_neg_integer(). +get_width_field () -> #map.width. + +-spec get_height_field () -> non_neg_integer(). +get_height_field () -> #map.height. + +-spec get_markers_field () -> non_neg_integer(). +get_markers_field () -> #map.markers. + +-spec get_tile_instances_field () -> non_neg_integer(). +get_tile_instances_field () -> #map.tile_instances. + +%%%% Utility +-spec get_used_tile_ids (type()) -> ordsets:ordset(shr_tile:class_id()). +get_used_tile_ids (Map) -> + UsedTileIDs = + lists:foldl + ( + fun (TileInstance, CurrentTileIDs) -> + ordsets:add_element + ( + shr_tile:extract_main_class_id(TileInstance), + CurrentTileIDs + ) + end, + ordsets:new(), + tuple_to_list(Map#map.tile_instances) + ), + + UsedTileIDs. + +-spec update_from_list + ( + type(), + non_neg_integer(), + non_neg_integer(), + shr_map_marker:collection(), + list(list(binary())) + ) + -> type(). +update_from_list (Map, Width, Height, Markers, List) -> + TileInstances = lists:map(fun shr_tile:instance_from_binary_list/1, List), + + Map#map + { + width = Width, + height = Height, + markers = Markers, + tile_instances = list_to_tuple(TileInstances) + }. + +-spec default (binary()) -> type(). +default (Owner) -> + DefaultTileInstance = shr_tile:default_tile_instance(), + + #map + { + owner = Owner, + width = 32, + height = 32, + markers = shr_map_marker:empty_collection(), + tile_instances = list_to_tuple(lists:duplicate(1024, DefaultTileInstance)) + }. diff --git a/src/shared/struct/map/shr_map_marker.erl b/src/shared/struct/map/shr_map_marker.erl new file mode 100644 index 0000000..35ba195 --- /dev/null +++ b/src/shared/struct/map/shr_map_marker.erl @@ -0,0 +1,52 @@ +-module(shr_map_marker). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type name() :: binary(). +-type type() :: 'none'. +-type collection() :: orddict:orddict(name(), type()). + +-export_type([name/0, type/0, collection/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + get/2, + empty_collection/0 + ] +). + +-export +( + [ + decode_collection/1, + encode_collection/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec get (name(), collection()) -> ('not_found' | {'ok', type()}). +get (Name, Collection) -> + case orddict:find(Name, Collection) of + error -> not_found; + Other -> Other + end. + +-spec empty_collection () -> collection(). +empty_collection () -> orddict:new(). + +-spec encode_collection (collection()) -> list(any()). +encode_collection (_Collection) -> []. + +-spec decode_collection (map()) -> collection(). +decode_collection (_Map) -> orddict:new(). diff --git a/src/shared/struct/map/shr_tile.erl.m4 b/src/shared/struct/map/shr_tile.erl.m4 new file mode 100644 index 0000000..7876f8f --- /dev/null +++ b/src/shared/struct/map/shr_tile.erl.m4 @@ -0,0 +1,133 @@ +-module(shr_tile). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type class_id() :: binary(). +-type variant_id() :: binary(). +-type instances_tuple() :: tuple(). + +-record +( + tile, + { + id :: class_id(), + name :: binary(), + cost :: non_neg_integer(), + omnimods :: shr_omnimods:type(), + family :: variant_id(), + depth :: non_neg_integer() + } +). + +-opaque instance() :: list(binary()). +-opaque border() :: list(binary()). + +-opaque type() :: #tile{}. + +-export_type([type/0, class_id/0, variant_id/0, instance/0, border/0]). +-export_type([instances_tuple/0]). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + get_class_id/1, + get_name/1, + get_cost/1, + get_omnimods/1, + from_class_id/1, + cost_when_oob/0 + ] +). + +-export +( + [ + instance_to_binary_list/1, + instance_from_binary_list/1, + default_tile_instance/0 + ] +). + +-export +( + [ + extract_main_class_id/1, + extract_variant_id/1, + extract_borders/1 + ] +). + +-export +( + [ + extract_border_main_class_id/1, + extract_border_variant_id/1 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +-spec extract_main_class_id (instance()) -> class_id(). +extract_main_class_id (I) -> lists:nth(1, I). + +-spec extract_borders (instance()) -> list(border()). +extract_borders (I) -> + [_|[_|Result]] = I, + Result. + +-spec extract_variant_id (instance()) -> variant_id(). +extract_variant_id (I) -> lists:nth(2, I). + +-spec extract_border_main_class_id (border()) -> class_id(). +extract_border_main_class_id (B) -> lists:nth(1, B). + +-spec extract_border_variant_id (border()) -> variant_id(). +extract_border_variant_id (B) -> lists:nth(2, B). + +-spec from_class_id (class_id()) -> type(). +m4_include(__MAKEFILE_DATA_DIR/tile/global.m4.conf)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/tile/special.m4d)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/tile/grassland.m4d)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/tile/mud.m4d)m4_dnl +m4_include(__MAKEFILE_DATA_DIR/tile/water.m4d)m4_dnl +from_class_id(_) -> + from_class_id(<<"0">>). + +-spec cost_when_oob () -> non_neg_integer(). +cost_when_oob () -> __TILE_COST_WHEN_OOB. + +-spec get_class_id (type()) -> class_id(). +get_class_id (Tile) -> Tile#tile.id. + +-spec get_cost (type()) -> non_neg_integer(). +get_cost (Tile) -> Tile#tile.cost. + +-spec get_name (type()) -> binary(). +get_name (Tile) -> Tile#tile.name. + +-spec get_omnimods (type()) -> shr_omnimods:type(). +get_omnimods (Tile) -> Tile#tile.omnimods. + +-spec instance_from_binary_list (list(binary())) -> instance(). +instance_from_binary_list (L) -> + LLength = length(L), + + case (((LLength rem 2) == 0) and (LLength /= 0)) of + true -> L; + _ -> [<<"0">>, <<"0">>] + end. + +-spec instance_to_binary_list (instance()) -> list(binary()). +instance_to_binary_list (I) -> I. + +-spec default_tile_instance () -> instance(). +default_tile_instance () -> [<<"1">>, <<"0">>]. diff --git a/src/shared/struct/shr_armor.erl.m4 b/src/shared/struct/shr_armor.erl.m4 deleted file mode 100644 index 18d203a..0000000 --- a/src/shared/struct/shr_armor.erl.m4 +++ /dev/null @@ -1,68 +0,0 @@ --module(shr_armor). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: binary(). - --record -( - armor, - { - id :: id(), - name :: binary(), - omnimods :: shr_omnimods:type() - } -). - --opaque type() :: #armor{}. - --export_type([type/0, id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1, - get_name/1, - get_omnimods/1 - ] -). - --export -( - [ - none/0, - from_id/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --spec get_id (type()) -> id(). -get_id (Ar) -> Ar#armor.id. - --spec get_name (type()) -> binary(). -get_name (Ar) -> Ar#armor.name. - --spec get_omnimods (type()) -> shr_omnimods:type(). -get_omnimods (Ar) -> Ar#armor.omnimods. - --spec from_id (id()) -> type(). -m4_include(__MAKEFILE_DATA_DIR/armor/global.m4.conf)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/armor/basic.m4d)m4_dnl -from_id(_) -> - none(). - --spec none () -> type(). -none () -> from_id(<<"0">>). diff --git a/src/shared/struct/shr_direction.erl b/src/shared/struct/shr_direction.erl deleted file mode 100644 index f0793b3..0000000 --- a/src/shared/struct/shr_direction.erl +++ /dev/null @@ -1,38 +0,0 @@ --module(shr_direction). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type enum() :: ('up' | 'down' | 'left' | 'right'). --type type() :: enum(). - --export_type([enum/0, type/0]). -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - decode/1, - encode/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec decode (binary()) -> enum(). -decode (<<"U">>) -> up; -decode (<<"D">>) -> down; -decode (<<"L">>) -> left; -decode (<<"R">>) -> right. - --spec encode (enum()) -> binary(). -encode (up) -> <<"U">>; -encode (down) -> <<"D">>; -encode (left) -> <<"L">>; -encode (right) -> <<"R">>. diff --git a/src/shared/struct/shr_glyph.erl.m4 b/src/shared/struct/shr_glyph.erl.m4 deleted file mode 100644 index cd59a27..0000000 --- a/src/shared/struct/shr_glyph.erl.m4 +++ /dev/null @@ -1,62 +0,0 @@ --module(shr_glyph). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: binary(). - --record -( - glyph, - { - id :: id(), - name :: binary(), - omnimods :: shr_omnimods:type() - } -). - --type type() :: #glyph{}. - --export_type([type/0, id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - --export -( - [ - from_id/1 - ] -). - --export -( - [ - get_id/1, - get_name/1, - get_omnimods/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec get_id (type()) -> id(). -get_id (Glyph) -> Glyph#glyph.id. - --spec get_name (type()) -> binary(). -get_name (Glyph) -> Glyph#glyph.name. - --spec get_omnimods (type()) -> shr_omnimods:type(). -get_omnimods (Glyph) -> Glyph#glyph.omnimods. - --spec from_id (id()) -> type(). -m4_include(__MAKEFILE_DATA_DIR/glyph/global.m4.conf)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/glyph/basic.m4d)m4_dnl -from_id(_) -> - from_id(<<"0">>). diff --git a/src/shared/struct/shr_glyph_board.erl.m4 b/src/shared/struct/shr_glyph_board.erl.m4 deleted file mode 100644 index 7fe77b1..0000000 --- a/src/shared/struct/shr_glyph_board.erl.m4 +++ /dev/null @@ -1,109 +0,0 @@ --module(shr_glyph_board). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: binary(). - --record -( - glyph_board, - { - id :: id(), - name :: binary(), - omnimods :: shr_omnimods:type(), - slots :: list(integer()) - } -). - --type type() :: #glyph_board{}. - --export_type([type/0, id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - from_id/1 - ] -). - --export -( - [ - get_id/1, - get_name/1, - get_omnimods/1, - get_slots/1 - ] -). - --export -( - [ - none/0, - get_omnimods_with_glyphs/2 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec get_omnimods_with_glyphs_internals - ( - shr_omnimods:type(), - list(shr_glyph:type()), - list(integer()) - ) - -> ({'ok', shr_omnimods:type()} | 'error'). -get_omnimods_with_glyphs_internals (Omnimods, [], []) -> - {ok, Omnimods}; -get_omnimods_with_glyphs_internals (_Omnimods, [], _) -> - error; -get_omnimods_with_glyphs_internals (_Omnimods, _, []) -> - error; -get_omnimods_with_glyphs_internals (Omnimods, [Glyph|NextGlyphs], [M|NextMs]) -> - Multiplier = (M / 100), - GlyphOmnimods = shr_glyph:get_omnimods(Glyph), - ModGlyphOmnimods = shr_omnimods:apply_coefficient(Multiplier, GlyphOmnimods), - NextOmnimods = shr_omnimods:merge(Omnimods, ModGlyphOmnimods), - - get_omnimods_with_glyphs_internals(NextOmnimods, NextGlyphs, NextMs). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec get_id (type()) -> id(). -get_id (GlyphBoard) -> GlyphBoard#glyph_board.id. - --spec get_name (type()) -> binary(). -get_name (GlyphBoard) -> GlyphBoard#glyph_board.name. - --spec get_omnimods (type()) -> shr_omnimods:type(). -get_omnimods (GlyphBoard) -> GlyphBoard#glyph_board.omnimods. - --spec get_slots (type()) -> list(non_neg_integer()). -get_slots (GlyphBoard) -> GlyphBoard#glyph_board.slots. - --spec from_id (id()) -> type(). -m4_include(__MAKEFILE_DATA_DIR/glyph_board/global.m4.conf)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/glyph_board/basic.m4d)m4_dnl -from_id(_) -> - none(). - --spec none () -> type(). -none () -> from_id(<<"0">>). - --spec get_omnimods_with_glyphs - ( - list(shr_glyph:type()), - type() - ) - -> ({'ok', shr_omnimods:type()} | 'error'). -get_omnimods_with_glyphs (Glyphs, GlyphBoard) -> - BoardOmnimods = GlyphBoard#glyph_board.omnimods, - BoardSlots = GlyphBoard#glyph_board.slots, - - get_omnimods_with_glyphs_internals(BoardOmnimods, Glyphs, BoardSlots). diff --git a/src/shared/struct/shr_inventory.erl b/src/shared/struct/shr_inventory.erl deleted file mode 100644 index 1f04533..0000000 --- a/src/shared/struct/shr_inventory.erl +++ /dev/null @@ -1,153 +0,0 @@ --module(shr_inventory). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: ataxia_id:type(). --record -( - inventory, - { - owner_id :: shr_player:id(), - portrait_ids :: ordsets:ordset(binary()), - glyph_ids :: ordsets:ordset(binary()), - glyph_board_ids :: ordsets:ordset(binary()), - weapon_ids :: ordsets:ordset(binary()), - armor_ids :: ordsets:ordset(binary()) - } -). - --opaque type() :: #inventory{}. - --export_type([type/0, id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_owner_id/1, - - get_portrait_ids/1, - get_glyph_ids/1, - get_glyph_board_ids/1, - get_weapon_ids/1, - get_armor_ids/1, - - set_portrait_ids/2, - set_glyph_ids/2, - set_glyph_board_ids/2, - set_weapon_ids/2, - set_armor_ids/2 - ] -). - --export -( - [ - get_portrait_ids_field/0, - get_glyph_ids_field/0, - get_glyph_board_ids_field/0, - get_weapon_ids_field/0, - get_armor_ids_field/0 - ] -). - --export -( - [ - new/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --spec get_owner_id (type()) -> shr_player:id(). -get_owner_id (Inv) -> Inv#inventory.owner_id. - --spec get_portrait_ids (type()) -> ordsets:ordset(binary()). -get_portrait_ids (Inv) -> Inv#inventory.portrait_ids. - --spec get_glyph_ids (type()) -> ordsets:ordset(binary()). -get_glyph_ids (Inv) -> Inv#inventory.glyph_ids. - --spec get_glyph_board_ids (type()) -> ordsets:ordset(binary()). -get_glyph_board_ids (Inv) -> Inv#inventory.glyph_board_ids. - --spec get_weapon_ids (type()) -> ordsets:ordset(binary()). -get_weapon_ids (Inv) -> Inv#inventory.weapon_ids. - --spec get_armor_ids (type()) -> ordsets:ordset(binary()). -get_armor_ids (Inv) -> Inv#inventory.armor_ids. - --spec set_portrait_ids (ordsets:ordset(binary()), type()) -> type(). -set_portrait_ids (Value, Inv) -> - Inv#inventory - { - portrait_ids = Value - }. - --spec set_glyph_ids (ordsets:ordset(binary()), type()) -> type(). -set_glyph_ids (Value, Inv) -> - Inv#inventory - { - glyph_ids = Value - }. - --spec set_glyph_board_ids (ordsets:ordset(binary()), type()) -> type(). -set_glyph_board_ids (Value, Inv) -> - Inv#inventory - { - glyph_board_ids = Value - }. - --spec set_weapon_ids (ordsets:ordset(binary()), type()) -> type(). -set_weapon_ids (Value, Inv) -> - Inv#inventory - { - weapon_ids = Value - }. - --spec set_armor_ids (ordsets:ordset(binary()), type()) -> type(). -set_armor_ids (Value, Inv) -> - Inv#inventory - { - armor_ids = Value - }. - --spec get_portrait_ids_field () -> non_neg_integer(). -get_portrait_ids_field () -> #inventory.portrait_ids. - --spec get_glyph_ids_field () -> non_neg_integer(). -get_glyph_ids_field () -> #inventory.glyph_ids. - --spec get_glyph_board_ids_field () -> non_neg_integer(). -get_glyph_board_ids_field () -> #inventory.glyph_board_ids. - --spec get_weapon_ids_field () -> non_neg_integer(). -get_weapon_ids_field () -> #inventory.weapon_ids. - --spec get_armor_ids_field () -> non_neg_integer(). -get_armor_ids_field () -> #inventory.armor_ids. - --spec new (shr_player:id()) -> type(). -new (OwnerID) -> - EmptySet = ordsets:new(), - - #inventory - { - owner_id = OwnerID, - portrait_ids = EmptySet, - glyph_ids = EmptySet, - glyph_board_ids = EmptySet, - weapon_ids = EmptySet, - armor_ids = EmptySet - }. diff --git a/src/shared/struct/shr_location.erl b/src/shared/struct/shr_location.erl deleted file mode 100644 index ec62ff7..0000000 --- a/src/shared/struct/shr_location.erl +++ /dev/null @@ -1,90 +0,0 @@ --module(shr_location). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type type() :: ({non_neg_integer(), non_neg_integer()} | 'nowhere'). - --export_type([type/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - decode/1, - encode/1, - get_nowhere/0 - ] -). - --export -( - [ - apply_direction/2, - dist/2 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec validate ({integer(), integer()}) -> type(). -validate ({X, Y}) -> - if - (X < 0) -> nowhere; - (Y < 0) -> nowhere; - true -> {X, Y} - end. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec get_nowhere () -> type(). -get_nowhere () -> nowhere. - --spec apply_direction (shr_direction:enum(), type()) -> type(). -apply_direction (left, {X, Y}) -> - validate({(X - 1), Y}); -apply_direction (right, {X, Y}) -> - validate({(X + 1), Y}); -apply_direction (up, {X, Y}) -> - validate({X, (Y - 1)}); -apply_direction (down, {X, Y}) -> - validate({X, (Y + 1)}); -apply_direction (_, nowhere) -> - error("Trying to move from 'nowhere'."), - nowhere. - --spec dist(type(), type()) -> non_neg_integer(). -dist ({OX, OY}, {DX, DY}) -> - (abs(DY - OY) + abs(DX - OX)); -dist (_, _) -> - error("Trying to measure distance to 'nowhere'"), - 999. - --spec encode (type()) -> {list(any())}. -encode ({X, Y}) -> - { - [ - {<<"x">>, X}, - {<<"y">>, Y} - ] - }; -encode (nowhere) -> - { - [ - {<<"x">>, -1}, - {<<"y">>, -1} - ] - }. - --spec decode (map()) -> type(). -decode (Map) -> - X = maps:get(<<"x">>, Map), - Y = maps:get(<<"y">>, Map), - - true = (is_integer(X) and is_integer(Y)), - - validate({X, Y}). diff --git a/src/shared/struct/shr_map.erl b/src/shared/struct/shr_map.erl deleted file mode 100644 index a57ed32..0000000 --- a/src/shared/struct/shr_map.erl +++ /dev/null @@ -1,154 +0,0 @@ --module(shr_map). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: ataxia_id:type(). - --record -( - map, - { - owner :: shr_player:id(), - width :: non_neg_integer(), - height :: non_neg_integer(), - tile_instances :: shr_tile:instances_tuple() - } -). - --opaque type() :: #map{}. - --export_type([type/0, id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_owner/1, - get_width/1, - get_height/1, - get_tile_instances/1, - get_tile_instance/2, - - get_used_tile_ids/1 - ] -). - -%%%% Fields --export -( - [ - get_width_field/0, - get_height_field/0, - get_tile_instances_field/0 - ] -). - -%%%% Utility --export -( - [ - update_from_list/4, - default/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec location_to_index - ( - non_neg_integer(), - shr_location:type() - ) - -> ('error' | non_neg_integer()). -location_to_index (ArrayWidth, {X, Y}) -> - if - (X < 0) -> error; - (Y < 0) -> error; - (X >= ArrayWidth) -> error; - true -> ((Y * ArrayWidth) + X) - end. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --spec get_owner (type()) -> shr_player:id(). -get_owner (Map) -> Map#map.owner. - --spec get_width (type()) -> non_neg_integer(). -get_width (Map) -> Map#map.width. - --spec get_height (type()) -> non_neg_integer(). -get_height (Map) -> Map#map.height. - --spec get_tile_instances (type()) -> shr_tile:instances_tuple(). -get_tile_instances (Map) -> Map#map.tile_instances. - --spec get_tile_instance (shr_location:type(), type()) -> shr_tile:instance(). -get_tile_instance (Location, Map) -> - TileIX = location_to_index(Map#map.width, Location), - element((TileIX + 1), Map#map.tile_instances). - -%%%% Fields --spec get_width_field () -> non_neg_integer(). -get_width_field () -> #map.width. - --spec get_height_field () -> non_neg_integer(). -get_height_field () -> #map.height. - --spec get_tile_instances_field () -> non_neg_integer(). -get_tile_instances_field () -> #map.tile_instances. - -%%%% Utility --spec get_used_tile_ids (type()) -> ordsets:ordset(shr_tile:class_id()). -get_used_tile_ids (Map) -> - UsedTileIDs = - lists:foldl - ( - fun (TileInstance, CurrentTileIDs) -> - ordsets:add_element - ( - shr_tile:extract_main_class_id(TileInstance), - CurrentTileIDs - ) - end, - ordsets:new(), - tuple_to_list(Map#map.tile_instances) - ), - - UsedTileIDs. - --spec update_from_list - ( - type(), - non_neg_integer(), - non_neg_integer(), - list(list(binary())) - ) - -> type(). -update_from_list (Map, Width, Height, List) -> - TileInstances = lists:map(fun shr_tile:instance_from_binary_list/1, List), - - Map#map - { - width = Width, - height = Height, - tile_instances = list_to_tuple(TileInstances) - }. - --spec default (binary()) -> type(). -default (Owner) -> - DefaultTileInstance = shr_tile:default_tile_instance(), - - #map - { - owner = Owner, - width = 32, - height = 32, - tile_instances = list_to_tuple(lists:duplicate(1024, DefaultTileInstance)) - }. diff --git a/src/shared/struct/shr_portrait.erl.m4 b/src/shared/struct/shr_portrait.erl.m4 deleted file mode 100644 index fefc434..0000000 --- a/src/shared/struct/shr_portrait.erl.m4 +++ /dev/null @@ -1,73 +0,0 @@ --module(shr_portrait). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: binary(). - --record -( - portrait, - { - id :: id(), - name :: binary(), - body_id :: binary(), - icon_id :: binary() - } -). - --opaque type() :: #portrait{}. - --export_type([type/0, id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1, - get_name/1, - get_body_id/1, - get_icon_id/1 - ] -). - --export -( - [ - from_id/1, - default/0 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --spec get_id (type()) -> id(). -get_id (Pt) -> Pt#portrait.id. - --spec get_name (type()) -> binary(). -get_name (Pt) -> Pt#portrait.name. - --spec get_body_id (type()) -> binary(). -get_body_id (Pt) -> Pt#portrait.body_id. - --spec get_icon_id (type()) -> binary(). -get_icon_id (Pt) -> Pt#portrait.icon_id. - --spec from_id (id()) -> type(). -m4_include(__MAKEFILE_DATA_DIR/portrait/global.m4.conf)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/portrait/basic.m4d)m4_dnl -from_id(_) -> - default(). - --spec default () -> type(). -default () -> from_id(<<"cat">>). diff --git a/src/shared/struct/shr_tile.erl.m4 b/src/shared/struct/shr_tile.erl.m4 deleted file mode 100644 index 7876f8f..0000000 --- a/src/shared/struct/shr_tile.erl.m4 +++ /dev/null @@ -1,133 +0,0 @@ --module(shr_tile). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type class_id() :: binary(). --type variant_id() :: binary(). --type instances_tuple() :: tuple(). - --record -( - tile, - { - id :: class_id(), - name :: binary(), - cost :: non_neg_integer(), - omnimods :: shr_omnimods:type(), - family :: variant_id(), - depth :: non_neg_integer() - } -). - --opaque instance() :: list(binary()). --opaque border() :: list(binary()). - --opaque type() :: #tile{}. - --export_type([type/0, class_id/0, variant_id/0, instance/0, border/0]). --export_type([instances_tuple/0]). -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - get_class_id/1, - get_name/1, - get_cost/1, - get_omnimods/1, - from_class_id/1, - cost_when_oob/0 - ] -). - --export -( - [ - instance_to_binary_list/1, - instance_from_binary_list/1, - default_tile_instance/0 - ] -). - --export -( - [ - extract_main_class_id/1, - extract_variant_id/1, - extract_borders/1 - ] -). - --export -( - [ - extract_border_main_class_id/1, - extract_border_variant_id/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - --spec extract_main_class_id (instance()) -> class_id(). -extract_main_class_id (I) -> lists:nth(1, I). - --spec extract_borders (instance()) -> list(border()). -extract_borders (I) -> - [_|[_|Result]] = I, - Result. - --spec extract_variant_id (instance()) -> variant_id(). -extract_variant_id (I) -> lists:nth(2, I). - --spec extract_border_main_class_id (border()) -> class_id(). -extract_border_main_class_id (B) -> lists:nth(1, B). - --spec extract_border_variant_id (border()) -> variant_id(). -extract_border_variant_id (B) -> lists:nth(2, B). - --spec from_class_id (class_id()) -> type(). -m4_include(__MAKEFILE_DATA_DIR/tile/global.m4.conf)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/tile/special.m4d)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/tile/grassland.m4d)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/tile/mud.m4d)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/tile/water.m4d)m4_dnl -from_class_id(_) -> - from_class_id(<<"0">>). - --spec cost_when_oob () -> non_neg_integer(). -cost_when_oob () -> __TILE_COST_WHEN_OOB. - --spec get_class_id (type()) -> class_id(). -get_class_id (Tile) -> Tile#tile.id. - --spec get_cost (type()) -> non_neg_integer(). -get_cost (Tile) -> Tile#tile.cost. - --spec get_name (type()) -> binary(). -get_name (Tile) -> Tile#tile.name. - --spec get_omnimods (type()) -> shr_omnimods:type(). -get_omnimods (Tile) -> Tile#tile.omnimods. - --spec instance_from_binary_list (list(binary())) -> instance(). -instance_from_binary_list (L) -> - LLength = length(L), - - case (((LLength rem 2) == 0) and (LLength /= 0)) of - true -> L; - _ -> [<<"0">>, <<"0">>] - end. - --spec instance_to_binary_list (instance()) -> list(binary()). -instance_to_binary_list (I) -> I. - --spec default_tile_instance () -> instance(). -default_tile_instance () -> [<<"1">>, <<"0">>]. diff --git a/src/shared/struct/shr_weapon.erl.m4 b/src/shared/struct/shr_weapon.erl.m4 deleted file mode 100644 index 1a2dcf5..0000000 --- a/src/shared/struct/shr_weapon.erl.m4 +++ /dev/null @@ -1,79 +0,0 @@ --module(shr_weapon). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: binary(). - --record -( - weapon, - { - id :: id(), - name :: binary(), - is_primary :: boolean(), - range_min:: non_neg_integer(), - range_max :: non_neg_integer(), - omnimods :: shr_omnimods:type() - } -). - --opaque type() :: #weapon{}. - --export_type([type/0, id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1, - get_name/1, - get_minimum_range/1, - get_maximum_range/1, - get_omnimods/1 - ] -). - --export -( - [ - none/0, - from_id/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --spec get_id (type()) -> id(). -get_id (Wp) -> Wp#weapon.id. - --spec get_name (type()) -> binary(). -get_name (Wp) -> Wp#weapon.name. - --spec get_minimum_range (type()) -> non_neg_integer(). -get_minimum_range (Wp) -> Wp#weapon.range_min. - --spec get_maximum_range (type()) -> non_neg_integer(). -get_maximum_range (Wp) -> Wp#weapon.range_max. - --spec get_omnimods (type()) -> shr_omnimods:type(). -get_omnimods (Wp) -> Wp#weapon.omnimods. - --spec from_id (id()) -> type(). -m4_include(__MAKEFILE_DATA_DIR/weapon/global.m4.conf)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/weapon/basic.m4d)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/weapon/secondary.m4d)m4_dnl -from_id (_) -> - none(). - --spec none () -> type(). -none () -> from_id(<<"0">>). -- cgit v1.2.3-70-g09d2