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/shared/struct/inventory/shr_weapon.erl.m4 | 79 +++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/shared/struct/inventory/shr_weapon.erl.m4 (limited to 'src/shared/struct/inventory/shr_weapon.erl.m4') 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">>). -- cgit v1.2.3-70-g09d2