diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 8abb63c..f157a94 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -220,7 +220,9 @@ DROP TABLE IF EXISTS `history_record`; CREATE TABLE `history_record`( `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', `accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', - `room_uuid` VARCHAR(60) NOT NULL DEFAULT '' COMMENT '战斗id', + `room_uuid` varchar(60) NOT NULL DEFAULT '' COMMENT '战斗id', + `map_id` int(11) NOT NULL COMMENT '地图id', + `map_tpl_name` varchar(50) NOT NULL DEFAULT '' COMMENT '地图模板名字', `map_name` varchar(50) DEFAULT '' COMMENT '地图名字', `game_time` int(11) NOT NULL COMMENT '游戏完成时间', `rank` int(11) NOT NULL COMMENT '游戏排名', diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index d3a6d50..68107e2 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -66,6 +66,7 @@ define('SKIN_SKILL_TIME', 21); //皮肤满级体验时间 define('DOUBLE_GOLD', 22); //免费金币翻倍率 define('DOUBLE_SIGN_IN', 23); //每日签到翻倍率 define('DOUBLE_END_WAR', 24); //战斗结束翻倍率 +define('DOUBLE_BOX', 25); //抽箱子奖励翻倍率 require 'config_loader.php'; diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 0a27e50..d35daf3 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -139,6 +139,8 @@ class RoleController{ phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } + $map_id = $_REQUEST['map_id']; + $map_tpl_name = $_REQUEST['map_tpl_name']; $room_uuid = $_REQUEST['room_uuid']; //战斗id $map_name = $_REQUEST['map_name']; //地图名 $game_time = $_REQUEST['game_time']; //游戏结束时间 @@ -161,6 +163,13 @@ class RoleController{ $coin_num = $_REQUEST['coin_num']; //金币 $integral = $_REQUEST['score']; //积分 + if (!$map_id) { + $map_id = 0; + } + if (!$map_tpl_name) { + $map_tpl_name = ''; + } + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id @@ -208,12 +217,14 @@ class RoleController{ } //插入历史记录 - $ret = $conn->execScript('INSERT INTO history_record(accountid, room_uuid, map_name, game_time, rank, kills, harms, hurts, alive_time, coin, status, create_time, modify_time) ' . - ' VALUES(:accountid, :room_uuid, :map_name, :game_time, :rank, :kills, :harms, :hurts, :alive_time, :coin, 0, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:accountid, room_uuid=:room_uuid, map_name=:map_name, game_time=:game_time, rank=:rank, kills=:kills, harms=:harms, hurts=:hurts, alive_time=:alive_time, coin=:coin, status=0, modify_time=:modify_time;', + $ret = $conn->execScript('INSERT INTO history_record(accountid, room_uuid, map_id, map_tpl_name, map_name, game_time, rank, kills, harms, hurts, alive_time, coin, status, create_time, modify_time) ' . + ' VALUES(:accountid, :room_uuid, :map_id, :map_tpl_name, :map_name, :game_time, :rank, :kills, :harms, :hurts, :alive_time, :coin, 0, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:accountid, room_uuid=:room_uuid, map_id=:map_id, map_tpl_name=:map_tpl_name, map_name=:map_name, game_time=:game_time, rank=:rank, kills=:kills, harms=:harms, hurts=:hurts, alive_time=:alive_time, coin=:coin, status=0, modify_time=:modify_time;', array( ':accountid' => $account_id, ':room_uuid' => $room_uuid, + ':map_id' => $map_id, + ':map_tpl_name' => $map_tpl_name, ':map_name' => $map_name, ':game_time' => $game_time, ':rank' => $rank, diff --git a/webapp/controller/SkinController.class.php b/webapp/controller/SkinController.class.php index 6142676..b2ae788 100644 --- a/webapp/controller/SkinController.class.php +++ b/webapp/controller/SkinController.class.php @@ -256,28 +256,12 @@ class SkinController{ } $fragment_num = 0; $array = $this->getExplode($s['skin_compose']); - if ($row['fragment_num'] >= $array[0][1]) { - $fragment_num = $row['fragment_num'] - $array[0][1]; - } else { - $coin = $s['skin_price'] * 1.0 / $array[0][1] * ($array[0][1] - $row['fragment_num']); - $rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - if ($rowUser['coin_num'] < $coin) { - phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); - return; - } - $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':coin_num' => $rowUser['coin_num'] - $coin, - ':modify_time' => time() - )); - - $fragment_num = 0; + if ($row['fragment_num'] < $array[0][1]) { + phpcommon\sendError(ERR_USER_BASE + 2,'皮肤碎片数量不足'); + return; } + $fragment_num = $row['fragment_num'] - $array[0][1]; + $skin_status = 1; if ($row['skin_status'] == 0) { $skin_status = 0; diff --git a/webapp/controller/SupplyBoxController.class.php b/webapp/controller/SupplyBoxController.class.php index 4c153bc..196ffb2 100644 --- a/webapp/controller/SupplyBoxController.class.php +++ b/webapp/controller/SupplyBoxController.class.php @@ -60,6 +60,18 @@ class SupplyBoxController{ return $arr; } + protected function getParameter($para_id) + { + $g_conf_para_cluster = require('../config/game2001api.parameter.cluster.php'); + $para_conf = getParameterConfig($g_conf_para_cluster, $para_id); + $p = array( + 'id' => $para_conf['id'], + 'param_name' => $para_conf['param_name'], + 'param_value' => $para_conf['param_value'], + ); + return $p; + } + public function supplyBoxInfo() { $account_id = $_REQUEST['account_id']; @@ -377,5 +389,47 @@ class SupplyBoxController{ ':modify_time' => time() )); } + + public function supplyReward() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $item_id = $_REQUEST['item_id']; + $p_num = $this->getParameter(DOUBLE_BOX); + $item_num = $_REQUEST['item_num'] * ($p_num['param_value'] - 1); + if ($item_id == 10001) { + $row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':coin_num' => $item_num + $row['coin_num'], + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + } else if($item_id > 13000 && $item_id < 14000){ + $this->addReward($item_id, $item_num, $account_id); + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + )); + } } ?>