2012-07-31 02:35:11 +00:00
|
|
|
-define(SIMPLES, [#tile{suit=S, value=V} || S <- [pin, man, sou], V <- lists:seq(2,8)]).
|
|
|
|
-define(TERMINALS, [#tile{suit=S, value=V} || S <- [pin, man, sou], V <- [1,9]]).
|
|
|
|
-define(DRAGONS, [#tile{suit=dragon, value=V} || V <- [green, red, white]]).
|
|
|
|
-define(WINDS, [#tile{suit=wind, value=V} || V <- [east, south, west, north]]).
|
|
|
|
-define(HONOURS, ?DRAGONS ++ ?WINDS).
|
|
|
|
-define(TILES, ?SIMPLES ++ ?TERMINALS ++ ?HONOURS).
|
|
|
|
|
2012-08-01 04:11:36 +00:00
|
|
|
%% @type wind() = east | south | west | north
|
2012-07-21 04:09:27 +00:00
|
|
|
-type wind() :: east | south | west | north.
|
2012-08-01 03:44:52 +00:00
|
|
|
|
2012-08-01 04:11:36 +00:00
|
|
|
%% @type dragon() = green | red | white
|
2012-07-21 04:09:27 +00:00
|
|
|
-type dragon() :: green | red | white.
|
2012-05-08 04:46:15 +00:00
|
|
|
|
2012-08-01 04:11:36 +00:00
|
|
|
%% @type tile() = {tile, Suit, Value, From}
|
|
|
|
%% Suit = pin | man | sou | wind | dragon
|
|
|
|
%% Value = integer() | wind() | dragon()
|
|
|
|
%% From = draw | wind()
|
2012-07-21 04:09:27 +00:00
|
|
|
-record(tile, {
|
|
|
|
suit :: pin | man | sou | wind | dragon,
|
|
|
|
value :: integer() | wind() | dragon(),
|
|
|
|
from=draw :: draw | wind()
|
2012-05-08 04:46:15 +00:00
|
|
|
}).
|
2012-07-21 04:09:27 +00:00
|
|
|
-type tile() :: #tile{}.
|
2012-05-08 04:46:15 +00:00
|
|
|
|
2012-08-01 04:11:36 +00:00
|
|
|
%% @type meld() = {meld, Type, Tiles}
|
|
|
|
%% Type = pair | chii | pon | kan
|
|
|
|
%% Tiels = [tile()]
|
2012-07-21 04:09:27 +00:00
|
|
|
-record(meld, {
|
|
|
|
type :: pair | chii | pon | kan,
|
|
|
|
tiles :: [tile()]
|
2012-05-08 04:46:15 +00:00
|
|
|
}).
|
2012-07-21 04:09:27 +00:00
|
|
|
-type meld() :: #meld{}.
|
2012-07-03 02:05:05 +00:00
|
|
|
|
2012-08-01 04:11:36 +00:00
|
|
|
%% @type hand() = {hand, Tiles, Melds}
|
|
|
|
%% Tiles = [tile()]
|
|
|
|
%% Melds = [meld()]
|
2012-07-21 04:09:27 +00:00
|
|
|
-record(hand, {
|
|
|
|
tiles=[] :: [tile()],
|
|
|
|
melds=[] :: [meld()]
|
2012-07-03 02:05:05 +00:00
|
|
|
}).
|
2012-07-21 04:09:27 +00:00
|
|
|
-type hand() :: #hand{}.
|
2012-07-31 02:35:11 +00:00
|
|
|
|
2012-08-01 04:11:36 +00:00
|
|
|
%% @type player() = {player, Name, Seat, Hand, Discards, Drawn}
|
|
|
|
%% Name = string()
|
|
|
|
%% Seat = wind()
|
|
|
|
%% Hand = hand()
|
|
|
|
%% Discards = [tile()]
|
|
|
|
%% Drawn = none | {tsumo | ron, tile()}
|
2012-07-31 02:35:11 +00:00
|
|
|
-record(player, {
|
2012-12-04 04:47:36 +00:00
|
|
|
name :: string(),
|
|
|
|
seat :: wind(),
|
|
|
|
hand=#hand{} :: hand(),
|
|
|
|
discards=[] :: [tile()],
|
|
|
|
drawn=none :: none | {tsumo | ron, tile()}
|
2012-07-31 02:35:11 +00:00
|
|
|
}).
|
|
|
|
-type player() :: #player{}.
|
|
|
|
|
2012-08-01 04:11:36 +00:00
|
|
|
%% @type phase() = Phase
|
|
|
|
%% Phase = draw | discard
|
2012-07-31 02:35:11 +00:00
|
|
|
-type phase() :: draw | discard.
|
|
|
|
|
2012-08-01 04:11:36 +00:00
|
|
|
%% @type game() = {game, Rounds, Timeout, Round, Turn, Phase, Wall, Rinshan, Dora, Uradora, Players}
|
|
|
|
%% Rounds = integer()
|
|
|
|
%% Timeout = integer() | infinity
|
|
|
|
%% Round = wind()
|
|
|
|
%% Turn = wind()
|
|
|
|
%% Phase = phase()
|
|
|
|
%% Wall = [tile()]
|
|
|
|
%% Rinshan = [tile()]
|
|
|
|
%% Dora = [tile()]
|
|
|
|
%% Uradora = [tile()]
|
|
|
|
%% Players = [player()]
|
2012-07-31 02:35:11 +00:00
|
|
|
-record(game, {
|
|
|
|
rounds=2 :: integer(),
|
|
|
|
timeout=infinity :: integer() | infinity,
|
|
|
|
round=east :: wind(),
|
|
|
|
turn=east :: wind(),
|
|
|
|
phase=draw :: phase(),
|
|
|
|
wall :: [tile()],
|
|
|
|
rinshan :: [tile()],
|
|
|
|
dora :: [tile()],
|
|
|
|
uradora :: [tile()],
|
|
|
|
players :: [player()]
|
|
|
|
}).
|
2012-08-01 03:44:52 +00:00
|
|
|
-type game() :: #game{}.
|