//client call public void vote_disband_room(Int64 room_id, Int64 disband) { log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "begin vote_disband_room"); mj_huanghuang_table _table = server.tables.get_mj_huanghuang_table(room_id); if (_table != null) { log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "vote_disband_room"); string client_uuid = hub.hub.gates.current_client_uuid; var _proxy = _table.get_player_proxy(client_uuid); _proxy.disband = (GameCommon.roomDisbandVoteState)disband; _table.broadcast("room", "vote_disband_room_state", _proxy.player_info["unionid"], (Int64)_proxy.disband); bool b_disband = true; int vote_count = 0; foreach (var item in _table.players) { if (item.Value.disband != GameCommon.roomDisbandVoteState.agree) { b_disband = false; log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "not_disband_room"); } if (item.Value.disband != GameCommon.roomDisbandVoteState.unvote) { vote_count++; } } if (vote_count >= _table.peopleNum) { _table.voting = false; } if (b_disband) { //解散房间表明一轮结束,计算输赢,桌上玩家游戏任务加一 if (_table.play_count > 1) { foreach (var item in _table.players) { if ((Int64)item.Value.player_info["score"] > 0 && item.Value.is_robot != true) { hub.hub.hubs.call_hub("lobby", "lobby", "get_victory_count", item.Value.player_info["unionid"]); } if (item.Value.is_robot != true) { hub.hub.hubs.call_hub("lobby", "lobby", "get_game_count", item.Value.player_info["unionid"]); } } } _table.voting = false; log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "disband_room"); _table.disband(); } } log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "end vote_disband_room"); }
//lobby hub gm module call public void server_disband_room(Int64 room_id, string client_uuid) { log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "begin server_disband_room"); mj_huanghuang_table _table = server.tables.get_mj_huanghuang_table(room_id); if (_table != null) { log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "gm_disband_room"); if (_table.play_count > 1) { foreach (var item in _table.players) { if ((Int64)item.Value.player_info["score"] > 0 && item.Value.is_robot != true) { hub.hub.hubs.call_hub("lobby", "lobby", "get_victory_count", item.Value.player_info["unionid"]); } if (item.Value.is_robot != true) { hub.hub.hubs.call_hub("lobby", "lobby", "get_game_count", item.Value.player_info["unionid"]); } } } _table.disband(); hub.hub.gates.call_client(client_uuid, "gm", "server_disband_room", true); } else { hub.hub.gates.call_client(client_uuid, "gm", "server_disband_room", false); log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "room_id error"); } log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "end server_disband_room"); }
//client call public void req_disband_room(Int64 room_id) { log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "begin req_disband_room"); mj_huanghuang_table _table = server.tables.get_mj_huanghuang_table(room_id); if (_table != null && _table.in_game) { string client_uuid = hub.hub.gates.current_client_uuid; var _proxy = _table.get_player_proxy(client_uuid); if (!_table.voting) { log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "req_disband_room"); _table.voting = true; _proxy.disband = GameCommon.roomDisbandVoteState.agree; ArrayList uuids = new ArrayList(); foreach (var p in _table.players) { if (p.Key != _proxy.unionid) { p.Value.disband = GameCommon.roomDisbandVoteState.unvote;//赋初值 uuids.Add(p.Value.uuid); } } log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "broadcast req_disband_vote"); hub.hub.gates.call_group_client(uuids, "room", "req_disband_vote"); _proxy.disband = GameCommon.roomDisbandVoteState.agree; _table.broadcast("room", "vote_disband_room_state", _proxy.player_info["unionid"], (Int64)_proxy.disband); hub.hub.timer.addticktime(60 * 1000, (Int64 tick) => { if (_table.is_free) { return; } if (!_table.voting) { return; } _table.voting = false; foreach (var item in _table.players) { if (item.Value.disband == GameCommon.roomDisbandVoteState.unvote) { item.Value.disband = GameCommon.roomDisbandVoteState.agree; _table.broadcast("room", "vote_disband_room_state", item.Value.player_info["unionid"], (Int64)item.Value.disband); } log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "{0}", item.Key); } bool b_disband = true; foreach (var item in _table.players) { if (item.Value.disband != GameCommon.roomDisbandVoteState.agree) { b_disband = false; log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "not_disband_room"); } } if (b_disband) { //解散房间表明一轮结束,计算输赢,桌上玩家游戏任务加一 if (_table.play_count > 1) { foreach (var item in _table.players) { if ((Int64)item.Value.player_info["score"] > 0 && item.Value.is_robot != true) { hub.hub.hubs.call_hub("lobby", "lobby", "get_victory_count", item.Value.player_info["unionid"]); } if (item.Value.is_robot != true) { hub.hub.hubs.call_hub("lobby", "lobby", "get_game_count", item.Value.player_info["unionid"]); } } } log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "disband_room"); _table.disband(); } }); } } log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "end req_disband_room"); }