diff --git a/src/game.erl b/src/game.erl index 226338c..8c3d30d 100644 --- a/src/game.erl +++ b/src/game.erl @@ -6,7 +6,7 @@ -module(game). --include("riichi.hrl"). +-include("../include/riichi.hrl"). -export([new/0, new/1, @@ -31,10 +31,10 @@ new() -> new(Players) -> lists:foldl(fun add_player/2, new(), Players). -add_player(_Player, Game = #game{players=Players}) +add_player(_Player, #game{players=Players}) when length(Players) >= 4 -> throw("Game full"); -add_player(Name, Game = #game{players = Players}) +add_player(Name, Game = #game{}) when is_list(Name) -> add_player(#player{name=Name}, Game); add_player(Player = #player{}, Game = #game{players=Players}) -> @@ -70,7 +70,7 @@ draw(#game{turn = Turn} = Game) -> Updated = update_player(Game, Turn, Player), Updated#game{wall=Wall}. -get_player(#game{players = Players} = Game, Seat) -> +get_player(#game{players = Players}, Seat) -> Pos = position(Seat) + 1, lists:nth(Pos, Players). diff --git a/src/game_tree.erl b/src/game_tree.erl index 7c08683..150e9db 100644 --- a/src/game_tree.erl +++ b/src/game_tree.erl @@ -1,13 +1,11 @@ -module(game_tree). --include("riichi.hrl"). --include("lazy.hrl"). +-include("../include/riichi.hrl"). +-include("../include/lazy.hrl"). -export([build/1, do/2]). --compile([export_all]). - -record(game_tree, {game, actions}). -record(game_action, {player, action, arguments}). diff --git a/src/riichi.app.src b/src/riichi.app.src index 9197eeb..5bee779 100644 --- a/src/riichi.app.src +++ b/src/riichi.app.src @@ -7,6 +7,7 @@ kernel, stdlib ]}, + {modules, []}, {mod, { riichi_app, []}}, {env, []} ]}. diff --git a/src/server_game.erl b/src/server_game.erl index 9ad483b..9f8e66a 100644 --- a/src/server_game.erl +++ b/src/server_game.erl @@ -5,7 +5,7 @@ -export([waiting/3, playing/2, turn/2]). --export([init/1, handle_event/3, handle_sync_event/4, handle_info/3, terminate/3]). +-export([init/1, handle_event/3, handle_sync_event/4, handle_info/3, terminate/3, code_change/4]). -include("../include/riichi.hrl"). @@ -68,3 +68,6 @@ terminate(Reason, StateName, _State) -> {from_state, StateName}, {reason, Reason}]), ok. + +code_change(_OldVsn, StateName, State, _Extra) -> + {ok, StateName, State}. diff --git a/src/server_lobby.erl b/src/server_lobby.erl index 0df52da..8f935b9 100644 --- a/src/server_lobby.erl +++ b/src/server_lobby.erl @@ -22,7 +22,7 @@ handle_call(get_players, _From, State) -> handle_call(_Msg, _From, State) -> {noreply, State}. -handle_cast({send, {message, From, Body}=Message}, State) -> +handle_cast({send, {message, _From, _Body}=Message}, State) -> Players = State#state.players, [gen_server:cast(Pid, Message) || Pid <- Players], {noreply, State}; @@ -37,4 +37,4 @@ terminate(_Reason, _State) -> ok. code_change(_OldVsn, State, _Extra) -> - {ok, State}. \ No newline at end of file + {ok, State}. diff --git a/src/yaku.erl b/src/yaku.erl index 6eb848b..d727221 100644 --- a/src/yaku.erl +++ b/src/yaku.erl @@ -28,7 +28,15 @@ chinitsu/2, kokushi_musou/2, ryuu_iisou/2, - dai_san_gen/2]). + dai_san_gen/2, + suu_an_kou/2, + tsu_iisou/2, + chinrouto/2, + shou_suushi/2, + dai_suushi/2, + chuuren_pooto/2, + suu_kan_tsu/2 + ]). %% @doc Counts the pons/kans of value tiles in a player's hand. %% Value tiles include all of the dragons, plus the round wind and the player's seat wind. @@ -117,7 +125,7 @@ chanta(#game{}, #player{hand=#hand{tiles=[], melds=Melds}}) -> -spec itsuu(game(), player()) -> boolean(). itsuu(#game{}, #player{hand=#hand{tiles=[], melds=Melds}}) -> Tiles = lists:flatten([TS || #meld{type=chii, tiles=TS} <- Melds]), - Runs = [lists:filter(fun(#tile{suit=S, value=V}) -> S =:= Suit end, Tiles) + Runs = [lists:filter(fun(#tile{suit=S}) -> S =:= Suit end, Tiles) || Suit <- [man,sou,pin]], lists:any(fun(TS) -> sets:from_list([V || #tile{value=V} <- TS]) =:= sets:from_list(lists:seq(1,9))