Commits

Yuriy Netesov  committed 0893146 Draft

fixed kiss room ext a bit

  • Participants
  • Parent commits febc2c0

Comments (0)

Files changed (10)

File apps/kissbang/src/kiss_room_ext_srv.erl

                 room_pid,
                 current_state}).
 
+-record(swinger_select_mode, {last_swinger}).
 -record(swing_bottle_mode_state, {current_swinger}).
--record(kiss_mode_state, {kissers = []}).
+-record(kiss_mode_state, {kissers = [], last_swinger}).
 
 %%--------------------------------------------------------------------
 %% @doc
     {next_state, pending, State}.
 pending({on_room_became_active}, _From, State) ->
     Reply = ok,
-    {reply, Reply, swinger_select_mode, State};
+    NewCurrentState = #swinger_select_mode{last_swinger = inner_select_random_user(male, State#state.users)},
+    {reply, Reply, swinger_select_mode, State#state{current_state = NewCurrentState}};
 pending({on_room_death}, _From, State) ->
     Reply = ok,
     {stop, normal, Reply, State};
 handle_sync_event({on_user_leave, UserGuid}, _From, StateName, State) ->
     {Reply, NewState} = inner_user_leave(State, UserGuid),
     {reply, Reply, StateName, NewState};
-handle_sync_event({on_room_death}, _From, StateName, State) ->
+handle_sync_event({on_room_death}, _From, _StateName, State) ->
     Reply = ok,
     {stop, normal ,Reply, State}.
 
 
 
 inner_select_swinger(State) ->
-    lists:last(State#state.users). %% TODO : implement me
+    OppositeSex = get_sex_opposite(element(1, State#swinger_select_mode.last_swinger)),
+    inner_select_random_user(OppositeSex, State#swinger_select_mode.last_swinger).
 
 inner_swing_bottle(State) ->
     CurrentState = State#state.current_state,
     CurrentSwinger = CurrentState#swing_bottle_mode_state.current_swinger,
     NewCurrentState = #kiss_mode_state{kissers = [CurrentSwinger, 
                                                   inner_select_random_user(get_sex_opposite(element(1, CurrentSwinger)), State#state.users)
-                                                  ]},
+                                                  ], last_swinger = CurrentSwinger},
     State#state{current_state = NewCurrentState}.
 
 

File apps/kissbang/src/room_srv.erl

 inner_broadcast_message(_Message, []) ->
     ok.
 
-inner_broadcast_message(Sender, Message, [User | RestUsers]) when User =:= Sender -> %% don't broadcast to self
-    inner_broadcast_message(Sender, Message, RestUsers);
-inner_broadcast_message(Sender, Message, [User | RestUsers]) -> 
-    proxy_srv:async_route_messages(User, [Message]),
-    inner_broadcast_message(Sender, Message, RestUsers);
-inner_broadcast_message(_Sender, _Message, []) ->
-    ok.
+inner_broadcast_message(_Sender, Message, Users) ->
+    inner_broadcast_message(Message, Users).
 
 inner_join(Guid, State, StateName) ->
     Users = State#state.users,

File extern/meck/.eunit/meck.COVER.html

 <html>
 <head><title>.eunit/meck.COVER.html</title></head><body bgcolor=white text=black>
 <pre>
-File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck.erl by COVER 2012-07-25 at 15:46:27
+File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck.erl by COVER 2012-07-26 at 18:11:24
 
 ****************************************************************************
 

File extern/meck/.eunit/meck_cover.COVER.html

 <html>
 <head><title>.eunit/meck_cover.COVER.html</title></head><body bgcolor=white text=black>
 <pre>
-File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_cover.erl by COVER 2012-07-25 at 15:46:27
+File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_cover.erl by COVER 2012-07-26 at 18:11:24
 
 ****************************************************************************
 

File extern/meck/.eunit/meck_mod.COVER.html

 <html>
 <head><title>.eunit/meck_mod.COVER.html</title></head><body bgcolor=white text=black>
 <pre>
-File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_mod.erl by COVER 2012-07-25 at 15:46:27
+File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_mod.erl by COVER 2012-07-26 at 18:11:24
 
 ****************************************************************************
 

File extern/meck/.eunit/meck_performance_test.COVER.html

 <html>
 <head><title>.eunit/meck_performance_test.COVER.html</title></head><body bgcolor=white text=black>
 <pre>
-File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_performance_test.erl by COVER 2012-07-25 at 15:46:27
+File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_performance_test.erl by COVER 2012-07-26 at 18:11:24
 
 ****************************************************************************
 

File extern/meck/.eunit/meck_test_module.COVER.html

 <html>
 <head><title>.eunit/meck_test_module.COVER.html</title></head><body bgcolor=white text=black>
 <pre>
-File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_test_module.erl by COVER 2012-07-25 at 15:46:27
+File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_test_module.erl by COVER 2012-07-26 at 18:11:24
 
 ****************************************************************************
 

File extern/meck/.eunit/meck_test_parametrized_module.COVER.html

 <html>
 <head><title>.eunit/meck_test_parametrized_module.COVER.html</title></head><body bgcolor=white text=black>
 <pre>
-File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_test_parametrized_module.erl by COVER 2012-07-25 at 15:46:27
+File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_test_parametrized_module.erl by COVER 2012-07-26 at 18:11:24
 
 ****************************************************************************