Skip to content

Commit

Permalink
Merge pull request #5 from ClarenceAu/master
Browse files Browse the repository at this point in the history
修改了test的启动node的参数.
  • Loading branch information
witeman committed Mar 12, 2012
2 parents 654ba71 + de9f320 commit e7d0cf0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
6 changes: 6 additions & 0 deletions include/pp.hrl
Expand Up @@ -473,3 +473,9 @@
-record(notify_unwatch, {
game
}).

-define(NOTIFY_ACTOR, 58).
-record(notify_actor, {
gid,
seat
}).
16 changes: 0 additions & 16 deletions src/exch.erl
Expand Up @@ -136,27 +136,11 @@ process_cast(Event, Exch) ->
Data = Exch#exch.data,
Ctx = Exch#exch.ctx,

if
is_record(Event, watch) ->
io:format("EVENT: ~p~n", [Event]);
true ->
ok
end,
% Result = Mod:State(Data, Ctx, Event),
% advance(Exch, Event, Result).
%io:format("STATE: ~p~nMOD: ~p~nEVENT: ~p~n", [State, Mod, Event]),
case Cbk:cast(Event, Ctx, Data) of
skip ->
Result = Mod:State(Data, Ctx, Event),
case Result of
{stop, _, _} ->
io:format("STATE: ~p~nMOD: ~p~nEVENT: ~p~n", [State, Mod, Event]);
_ -> ok
end,
%io:format("RESULT: ~p~n", [Result]),
advance(Exch, Event, Result);
{NewGame, NewCtx} ->
%io:format("NEWGAME: ~p~nNEWCTX: ~p~n", [NewGame, NewCtx]),
{noreply, Exch#exch{data = NewGame, ctx = NewCtx}}
end.

Expand Down
13 changes: 11 additions & 2 deletions src/pp.erl
Expand Up @@ -667,6 +667,11 @@ notify_unwatch() ->
record(notify_unwatch, {
game()
}).
notify_actor() ->
record(notify_actor, {
game(),
seat()
}).
%%% Pickle

write(R) when is_record(R, bad) ->
Expand Down Expand Up @@ -839,7 +844,9 @@ write(R) when is_record(R, notify_seat_detail) ->
write(R) when is_record(R, notify_game_detail) ->
[?NOTIFY_GAME_DETAIL | pickle(notify_game_detail(), R)];
write(R) when is_record(R, notify_unwatch) ->
[?NOTIFY_UNWATCH | pickle(notify_unwatch(), R)].
[?NOTIFY_UNWATCH | pickle(notify_unwatch(), R)];
write(R) when is_record(R, notify_actor) ->
[?NOTIFY_ACTOR | pickle(notify_actor(), R)].

%%% Unpickle

Expand Down Expand Up @@ -1013,7 +1020,9 @@ read(<<?NOTIFY_UNWATCH, Bin/binary>>) ->
read(<<?NOTIFY_GAME_DETAIL, Bin/binary>>) ->
unpickle(notify_game_detail(), Bin);
read(<<?NOTIFY_SEAT_DETAIL, Bin/binary>>) ->
unpickle(notify_seat_detail(), Bin).
unpickle(notify_seat_detail(), Bin);
read(<<?NOTIFY_ACTOR, Bin/binary>>) ->
unpickle(notify_actor(), Bin).

send(Socket, Data, Ping) ->
Bin = list_to_binary(write(Data)),
Expand Down
2 changes: 1 addition & 1 deletion src/test/dmb.erl
Expand Up @@ -253,7 +253,7 @@ start_game_slaves(N) ->
%%% Enable kernel poll and disable SMP. The latter is not obligatory.

common_args() ->
"+K true -smp disable".
"+K true -smp disable -pa ebin deps/*/ebin".

start_slave_node(Name, Args) ->
case slave:start_link(net_adm:localhost(), Name, Args) of
Expand Down
12 changes: 7 additions & 5 deletions src/texas/g.erl
Expand Up @@ -533,25 +533,27 @@ get_seat(Game, Player)

request_bet(Game, SeatNum, Call, Min, Max) ->
Seat = element(SeatNum, Game#game.seats),
Game1 = broadcast(Game, #notify_actor{ gid = Game#game.gid, seat = SeatNum}),

if
%% auto-play enabled
Seat#seat.cmd_que /= [] ->
Seat1 = process_autoplay(Game, Seat),
Game#game {
Seat1 = process_autoplay(Game1, Seat),
Game1#game {
seats = setelement(SeatNum,
Game#game.seats,
Game1#game.seats,
Seat1)
};
%% regular bet request
true ->
BetReq = #bet_req{
game = Game#game.gid,
game = Game1#game.gid,
call = Call,
min = Min,
max = Max
},
gen_server:cast(Seat#seat.player, BetReq),
Game
Game1
end.

%%% Use stored commands instead of asking player
Expand Down

0 comments on commit e7d0cf0

Please sign in to comment.