目录结构调整
This commit is contained in:
349
codes/games/sales_service/youle/server_room/class.import.js
Normal file
349
codes/games/sales_service/youle/server_room/class.import.js
Normal file
@@ -0,0 +1,349 @@
|
||||
///////////////////////////////////////////////////
|
||||
/////// cls_youle_room_import: 输入接口 ///////
|
||||
///////////////////////////////////////////////////
|
||||
var cls_youle_room_import = cls_youle_room_import || {
|
||||
|
||||
new: function() {
|
||||
|
||||
var imp = {};
|
||||
|
||||
//创建房间时根据roomtype获取需要的房卡数量
|
||||
imp.createroom_needroomcard = function(o_game, roomtype){
|
||||
var o_game_config = youle_room.app.youle_platform.config.method.get_paravalue("game_config", o_game.o_agent.agentid, o_game.gameid);
|
||||
var mod_game = youle_room.app[o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.get_needroomcard){
|
||||
return mod_game.export.get_needroomcard(roomtype, o_game_config);
|
||||
}
|
||||
}
|
||||
if (mod_game.needroomcard){
|
||||
return mod_game.needroomcard(roomtype, o_game_config);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//创建房间时根据roomtype获取总局数
|
||||
imp.createroom_asetcount = function(o_game, roomtype){
|
||||
var o_game_config = youle_room.app.youle_platform.config.method.get_paravalue("game_config", o_game.o_agent.agentid, o_game.gameid);
|
||||
var mod_game = youle_room.app[o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.get_asetcount){
|
||||
return mod_game.export.get_asetcount(roomtype, o_game_config);
|
||||
}
|
||||
}
|
||||
if (mod_game.asetcount){
|
||||
return mod_game.asetcount(roomtype, o_game_config);
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
|
||||
//创建房间时根据roomtype获取元宝下限
|
||||
imp.createroom_beanfloor = function(o_game, roomtype){
|
||||
var o_game_config = youle_room.app.youle_platform.config.method.get_paravalue("game_config", o_game.o_agent.agentid, o_game.gameid);
|
||||
|
||||
var mod_game = youle_room.app[o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.createroom_beanfloor){
|
||||
return mod_game.export.createroom_beanfloor(roomtype, o_game_config);
|
||||
}
|
||||
}
|
||||
if (mod_game.createroom_beanfloor){
|
||||
return mod_game.createroom_beanfloor(roomtype, o_game_config);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//加入房间时根据roomtype获取需要的房卡数量,如果不需要房卡则需要返回0
|
||||
imp.joinroom_needroomcard = function(o_game, roomtype){
|
||||
var o_game_config = youle_room.app.youle_platform.config.method.get_paravalue("game_config", o_game.o_agent.agentid, o_game.gameid);
|
||||
var mod_game = youle_room.app[o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.get_needroomcard_joinroom){
|
||||
return mod_game.export.get_needroomcard_joinroom(roomtype, o_game_config);
|
||||
}
|
||||
}
|
||||
if (mod_game.needroomcard_joinroom){
|
||||
return mod_game.needroomcard_joinroom(roomtype, o_game_config);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//根据roomtype获取房间的扣卡模式,0:房主扣卡 1:每人扣卡 2:大赢家扣卡
|
||||
imp.deduct_roomcard_mode = function(o_game, roomtype){
|
||||
var o_game_config = youle_room.app.youle_platform.config.method.get_paravalue("game_config", o_game.o_agent.agentid, o_game.gameid);
|
||||
var mod_game = youle_room.app[o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.deduct_roomcard_mode){
|
||||
return mod_game.export.deduct_roomcard_mode(roomtype, o_game_config);
|
||||
}
|
||||
}
|
||||
if (mod_game.deduct_roomcard_mode){
|
||||
return mod_game.deduct_roomcard_mode(roomtype, o_game_config);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//除了满桌自动开战外,子游戏可以设置开战人数
|
||||
imp.makewar_playercount = function(o_game, roomtype){
|
||||
var o_game_config = youle_room.app.youle_platform.config.method.get_paravalue("game_config", o_game.o_agent.agentid, o_game.gameid);
|
||||
var mod_game = youle_room.app[o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.makewar_playercount){
|
||||
return mod_game.export.makewar_playercount(roomtype, o_game_config);
|
||||
}
|
||||
}
|
||||
if (mod_game.makewar_playercount){
|
||||
return mod_game.makewar_playercount(roomtype, o_game_config);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//星星场房主抽成星星数量
|
||||
imp.owner_beanpush = function(o_game, roomtype){
|
||||
var o_game_config = youle_room.app.youle_platform.config.method.get_paravalue("game_config", o_game.o_agent.agentid, o_game.gameid);
|
||||
var mod_game = youle_room.app[o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.owner_beanpush){
|
||||
return mod_game.export.owner_beanpush(roomtype, o_game_config);
|
||||
}
|
||||
}
|
||||
if (mod_game.owner_beanpush){
|
||||
return mod_game.owner_beanpush(roomtype, o_game_config);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//开局时通知游戏,并返回游戏的开局数据包
|
||||
imp.makewar_deskwar = function(o_room){
|
||||
var matchroom_deductbean = function(){
|
||||
if (!o_room.match_id){
|
||||
return;
|
||||
}
|
||||
var o_agentsvr_agent = youle_agent.agents.method.find_agent(o_room.o_game.o_agent.agentid);
|
||||
var o_agentsvr_game = o_agentsvr_agent.method.find_game(o_room.o_game.gameid);
|
||||
var match_idx = min_ary_indexof(o_agentsvr_game.matchlist.list, o_room.match_id, "id");
|
||||
if (match_idx == -1){
|
||||
return;
|
||||
}
|
||||
var match_object = o_agentsvr_game.matchlist.list[match_idx];
|
||||
if (!match_object.bean){
|
||||
return;
|
||||
}
|
||||
|
||||
var do_deduct_bean = function(){
|
||||
var msg = {};
|
||||
msg.app = youle_room.app.appname;
|
||||
msg.route = youle_room.app.youle_agent.routename;
|
||||
msg.rpc = "update_bean";
|
||||
msg.data = {};
|
||||
msg.data.agentid = o_room.o_game.o_agent.agentid;
|
||||
msg.data.change = 0;
|
||||
msg.data.pushbean = -1 * match_object.bean;
|
||||
msg.data.gameid = o_room.o_game.gameid;
|
||||
msg.data.showrebate = 1;
|
||||
msg.data.type = 5;
|
||||
|
||||
//房间id = 时间戳 + 4位随机码 + 房号
|
||||
var roomid = new Date().getTime() + min_randomChar(4) + o_room.roomcode;
|
||||
var datatime = min_now();
|
||||
var beanmult = 0;
|
||||
if (o_room.beanmult){
|
||||
beanmult = o_room.beanmult;
|
||||
}
|
||||
var shortcode = 0;
|
||||
if (o_room.shortcode){
|
||||
shortcode = o_room.shortcode;
|
||||
}
|
||||
var deductmode = youle_room.import.deduct_roomcard_mode(o_room.o_game, o_room.roomtype);
|
||||
for (var i = 0; i < o_room.seatlist.length; i++) {
|
||||
if (o_room.seatlist[i]){
|
||||
var playerid = o_room.seatlist[i].playerid;
|
||||
var roomcard = 0;
|
||||
if (playerid == o_room.owner.playerid){
|
||||
roomcard = youle_room.import.createroom_needroomcard(o_room.o_game, o_room.roomtype);
|
||||
} else {
|
||||
roomcard = youle_room.import.joinroom_needroomcard(o_room.o_game, o_room.roomtype);
|
||||
}
|
||||
var isrobot = 0;
|
||||
if (o_room.seatlist[i].isrobot){
|
||||
isrobot = 1;
|
||||
}
|
||||
if (!isrobot){
|
||||
msg.data.playerid = playerid;
|
||||
youle_room.app.youle_agent[msg.rpc](msg);
|
||||
}
|
||||
|
||||
var sql = "insert into gold_account(goac_id,goac_agentid,goac_gameid,goac_roomcode,goac_roommode,goac_createtime,goac_beanmult,goac_ownerid,goac_shortcode,goac_deduct,goac_roomcard,goac_datatype,goac_asetcount,goac_asetnum,goac_playerid,goac_isrobot,goac_grade,goac_rebatefrom,goac_rebateto,goac_toplayerid,goac_rebatemode,goac_setvalue,goac_rebatevalue,goac_time) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
||||
youle_room.mysql_grade.execsql("execsql", sql, [roomid, o_room.o_game.o_agent.agentid, o_room.o_game.gameid, o_room.roomcode, 4, o_room.createtime, beanmult, o_room.owner.ownerid, shortcode, deductmode, roomcard, 0, o_room.asetcount, 0, playerid, isrobot, 0, 3, 0, 0, 3, match_object.bean, match_object.bean, datatime]);
|
||||
}
|
||||
}
|
||||
}
|
||||
min_ontimeout(do_deduct_bean, 1000);
|
||||
}
|
||||
var o_game_config = youle_room.app.youle_platform.config.method.get_paravalue("game_config", o_room.o_game.o_agent.agentid, o_room.o_game.gameid);
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.makewar){
|
||||
var data = mod_game.export.makewar(o_room, o_game_config);
|
||||
matchroom_deductbean(); //比赛场扣除报名的星星费用
|
||||
return data;
|
||||
}
|
||||
}
|
||||
if (mod_game.makewar){
|
||||
var data = mod_game.makewar(o_room, o_game_config);
|
||||
matchroom_deductbean(); //比赛场扣除报名的星星费用
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//进入房间或断线重连时获取牌局信息
|
||||
imp.get_deskinfo = function(o_room, seat){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.get_deskinfo){
|
||||
return mod_game.export.get_deskinfo(o_room, seat);
|
||||
}
|
||||
}
|
||||
if (mod_game.getDeskInfo){
|
||||
return mod_game.getDeskInfo(o_room, seat);
|
||||
}
|
||||
}
|
||||
|
||||
//解散时通知游戏
|
||||
imp.get_disbandRoom = function(o_room){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.get_disbandRoom){
|
||||
return mod_game.export.get_disbandRoom(o_room);
|
||||
}
|
||||
}
|
||||
if (mod_game.disbandRoom){
|
||||
return mod_game.disbandRoom(o_room);
|
||||
}
|
||||
}
|
||||
|
||||
//玩家中途进入房间
|
||||
imp.player_enter = function(o_room, seat){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.player_enter){
|
||||
return mod_game.export.player_enter(o_room, seat);
|
||||
}
|
||||
}
|
||||
if (mod_game.player_enter){
|
||||
return mod_game.player_enter(o_room, seat);
|
||||
}
|
||||
}
|
||||
|
||||
//玩家中途退出房间
|
||||
imp.player_leave = function(o_room, seat){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.player_leave){
|
||||
return mod_game.export.player_leave(o_room, seat);
|
||||
}
|
||||
}
|
||||
if (mod_game.player_leave){
|
||||
return mod_game.player_leave(o_room, seat);
|
||||
}
|
||||
}
|
||||
|
||||
//恢复房间数据
|
||||
imp.restore_room = function(o_room, o_deskinfo){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.restore_room){
|
||||
return mod_game.export.restore_room(o_room, o_deskinfo);
|
||||
}
|
||||
}
|
||||
if (mod_game.restore_room){
|
||||
return mod_game.restore_room(o_room, o_deskinfo);
|
||||
}
|
||||
}
|
||||
|
||||
//玩家准备
|
||||
imp.player_CanPrepare = function(o_room, seat){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.player_CanPrepare){
|
||||
return mod_game.export.player_CanPrepare(o_room, seat);
|
||||
}
|
||||
}
|
||||
if (mod_game.player_CanPrepare){
|
||||
return mod_game.player_CanPrepare(o_room, seat);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
imp.player_prepare = function(o_room, seat){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.player_prepare){
|
||||
return mod_game.export.player_prepare(o_room, seat);
|
||||
}
|
||||
}
|
||||
if (mod_game.player_prepare){
|
||||
return mod_game.player_prepare(o_room, seat);
|
||||
}
|
||||
}
|
||||
|
||||
//无限局玩家是否可以离开房间
|
||||
imp.isPlayerCanLeave = function(o_room, seat){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.isPlayerCanLeave){
|
||||
return mod_game.export.isPlayerCanLeave(o_room, seat);
|
||||
}
|
||||
}
|
||||
if (mod_game.isPlayerCanLeave){
|
||||
return mod_game.isPlayerCanLeave(o_room, seat);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//通过战绩gameinfo1获取大赢家标志如[0,0,1]空座位不需要写入数组顺序从0号座位依次写入
|
||||
imp.getWinnerByGameInfo1 = function(o_room, gameinfo1){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.getWinnerByGameInfo1){
|
||||
return mod_game.export.getWinnerByGameInfo1(o_room, gameinfo1);
|
||||
}
|
||||
}
|
||||
if (mod_game.getWinnerByGameInfo1){
|
||||
return mod_game.getWinnerByGameInfo1(o_room, gameinfo1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//通过战绩gameinfo1获取积分列表如[10,10,-20]空座位不需要写入数组顺序从0号座位依次写入
|
||||
imp.getScoreByGameInfo1 = function(o_room, gameinfo1){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.getScoreByGameInfo1){
|
||||
return mod_game.export.getScoreByGameInfo1(o_room, gameinfo1);
|
||||
}
|
||||
}
|
||||
if (mod_game.getScoreByGameInfo1){
|
||||
return mod_game.getScoreByGameInfo1(o_room, gameinfo1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//通知子游戏解散房间
|
||||
imp.gameBreak = function(o_room){
|
||||
var mod_game = youle_room.app[o_room.o_game.modename];
|
||||
if (mod_game.export){
|
||||
if (mod_game.export.gameBreak){
|
||||
return mod_game.export.gameBreak(o_room);
|
||||
}
|
||||
}
|
||||
if (mod_game.gameBreak){
|
||||
return mod_game.gameBreak(o_room);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return imp;
|
||||
}
|
||||
}
|
||||
|
||||
//内部输入接口
|
||||
youle_room.import = cls_youle_room_import.new();
|
||||
Reference in New Issue
Block a user