From d46e3e7f9a9b8b9bf83b2cbba8ffe10eccbbf2c5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 14 Aug 2020 19:05:01 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 1 + sql/gamedb2004_n_migrate_200814_01.sql | 8 + webapp/bootstrap/init.php | 6 + webapp/classes/AddReward.php | 92 +++ webapp/controller/AdditemController.class.php | 115 ++++ webapp/controller/EquipController.class.php | 536 +++++++++++++++++- .../controller/GameOverController.class.php | 31 +- webapp/controller/RoleController.class.php | 4 +- webapp/controller/ShareController.class.php | 31 +- webapp/controller/ShopController.class.php | 99 +++- 10 files changed, 894 insertions(+), 29 deletions(-) create mode 100644 sql/gamedb2004_n_migrate_200814_01.sql diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 9f2f720..fbb84dc 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -263,6 +263,7 @@ CREATE TABLE `equip` ( `modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', `using_id` int(11) NOT NULL DEFAULT '0' COMMENT '上阵id', + `exp` int(11) NOT NULL DEFAULT '0' COMMENT '当前经验', PRIMARY KEY (`idx`), UNIQUE KEY `accountid_id` (`accountid`, id) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; diff --git a/sql/gamedb2004_n_migrate_200814_01.sql b/sql/gamedb2004_n_migrate_200814_01.sql new file mode 100644 index 0000000..b14854d --- /dev/null +++ b/sql/gamedb2004_n_migrate_200814_01.sql @@ -0,0 +1,8 @@ +begin; + +delete from sign where accountid like '6001_%'; +update user set sign_sum=0 where accountid like '6001_%'; + +insert into version (version) values(20200814); + +commit; diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index e67b44c..dd88b9d 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -90,6 +90,12 @@ define('DAILYCOIN_DECAY', 130); //每日金币衰减比例 define('DAILYCOIN_TIMES', 131); //每日金币领取次数 define('DAILYCOIN_NUM', 132); //每日金币基准数 define('SHARE_VIDEO_REWARD', 147); //分享视频奖励 +define('EQUIPREWARD_PARAMETER', 152); //结算比例 +define('DIAMONDTOCOIN_NUM', 153); //钻石换金币 require 'config_loader.php'; +function needSpecConfig($channel) +{ + return $channel == 6001; +} diff --git a/webapp/classes/AddReward.php b/webapp/classes/AddReward.php index 7b5033f..c8e83bf 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -56,6 +56,21 @@ class AddReward { return $arr; } + protected function getEquip($equip_id) + { + $g_conf_equip_cluster = require('../res/equip@equip.php'); + $equip_conf = getEquipConfig($g_conf_equip_cluster, $equip_id); + if (!$equip_conf) { + return null; + } + $e = array( + 'id' => $equip_conf['id'], + 'equip_material' => $equip_conf['equip_material'], + 'real_index_id' => $equip_conf['real_index_id'], + ); + return $e; + } + public function addReward($item_id, $item_num, $account_id, $time, $t) { $conn = $this->getMysql($account_id); @@ -87,6 +102,8 @@ class AddReward { $this->addtenticket($item['item_id'], $item['item_num'], $account_id); } else if ($i['type'] == 10 || $i['type'] == 11){ $this->addweizhuang($item['item_id'], $item['item_num'], $account_id); + } else if ($i['type'] == 12) { + $item_list = $this->addEquip($item['item_id'], $account_id); } else { $price = $i['diamond']; if ($time != 0) { @@ -492,5 +509,80 @@ class AddReward { } } } + + protected function addEquip($item_id, $accountid) + { + $conn = $this->getMysql($accountid); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + die(); + return; + } + $row = $conn->execQueryOne('SELECT id FROM equip WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $accountid, + ':id' => $item_id, + )); + //没有装备解锁装备 + $item_list = array(); + if (!$row) { + $rows = $conn->execQuery('SELECT using_id FROM equip WHERE accountid=:accountid;', + array( + ':accountid' => $accountid, + )); + $using_id = $item_id; + if ($rows) { + foreach ($rows as $r) { + $using_id = $r['using_id']; + } + } + $ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time, using_id, exp) ' . + ' VALUES(:account_id, :id, 0, :active_time, :sub_time, :create_time, :modify_time, :using_id, :exp) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time, using_id=:using_id, exp=:exp;', + array( + ':account_id' => $accountid, + ':id' => $item_id, + ':active_time' => 0, + ':create_time' => time(), + ':modify_time' => time(), + ':sub_time' => 0, + ':using_id' => $using_id, + ':exp' => 0, + )); + if(!$ret){ + die(); + return; + } + array_push($item_list,array( + 'item_id' => $item_id, + 'item_num' => 1, + 'time' => 0, + )); + } else { + //转化碎片 + $e = $this->getEquip($item_id); + if (!$e) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备'); + die(); + return; + } + $this->addweizhuang(18006, $e['equip_material'], $accountid); + array_push($item_list, array( + 'item_id' => 18006, + 'item_num' => $e['equip_material'], + 'time' => 0, + )); + } + return $item_list; + } + + + public function getRealIndexid($id, $accountid) { + $e = $this->getEquip($id); + if (!$e || $e['real_index_id'] == '' || !$e['real_index_id']) { + return intval($id); + } + return intval($e['real_index_id']); + } } ?> diff --git a/webapp/controller/AdditemController.class.php b/webapp/controller/AdditemController.class.php index 1166f55..cfa8631 100644 --- a/webapp/controller/AdditemController.class.php +++ b/webapp/controller/AdditemController.class.php @@ -52,6 +52,18 @@ class AdditemController{ return $arr; } + protected function getParameter($para_id) + { + $parameter_meta_cluster = require('../res/parameter@parameter.php'); + $parameter_meta = getParameterConfig($parameter_meta_cluster, $para_id); + $p = array( + 'id' => $parameter_meta['id'], + 'name' => $parameter_meta['param_name'], + 'param_value' => $parameter_meta['param_value'], + ); + return $p; + } + public function additem() { $item_id = $_REQUEST['item_id']; @@ -170,5 +182,108 @@ class AdditemController{ } } + //兑换金币 + public function getCoin() + { + $accountid = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($accountid, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $num = $_REQUEST['num']; + $conn = $this->getMysql($accountid); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $row = $conn->execQueryOne('SELECT diamond_num, coin_num FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $accountid + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + + if ($row['diamond_num'] < $num) { + phpcommon\sendError(ERR_USER_BASE + 2, '钻石不足'); + return; + } + + $p = $this->getParameter(DIAMONDTOCOIN_NUM); + $estr = explode('|', $p['param_value']); + $addnum = floor($estr[1] / $estr[0] * $num); + $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, diamond_num=:diamond_num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $accountid, + ':coin_num' => $addnum + $row['coin_num'], + ':diamond_num' => $row['diamond_num'] - $num, + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'coin_nums' => $addnum + $row['coin_num'], + 'diamond_nums' => $row['diamond_num'] - $num + )); + + } + + + public function addEquip() + { + $accountid=$_REQUEST['account_id']; + $item_id = $_REQUEST['id']; + $conn = $this->getMysql($accountid); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + die(); + return; + } + $row = $conn->execQueryOne('SELECT id FROM equip WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $accountid, + ':id' => $item_id, + )); + //没有装备解锁装备 + $item_list = array(); + if (!$row) { + $rows = $conn->execQuery('SELECT using_id FROM equip WHERE accountid=:accountid;', + array( + ':accountid' => $accountid, + )); + $using_id = $item_id; + if ($rows) { + foreach ($rows as $r) { + $using_id = $r['using_id']; + } + } + $ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time, using_id, exp) ' . + ' VALUES(:account_id, :id, 0, :active_time, :sub_time, :create_time, :modify_time, :using_id, :exp) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time, using_id=:using_id, exp=:exp;', + array( + ':account_id' => $accountid, + ':id' => $item_id, + ':active_time' => 0, + ':create_time' => time(), + ':modify_time' => time(), + ':sub_time' => 0, + ':using_id' => $using_id, + ':exp' => 0, + )); + if(!$ret){ + die(); + return; + } + } + } } ?> diff --git a/webapp/controller/EquipController.class.php b/webapp/controller/EquipController.class.php index 5e186e1..9097010 100644 --- a/webapp/controller/EquipController.class.php +++ b/webapp/controller/EquipController.class.php @@ -25,7 +25,7 @@ class EquipController{ $it = array( 'id' => $item_conf['id'], 'diamond' => $item_conf['diamond'], - 'dprice' => $item_conf['dprice'], + //'dprice' => $item_conf['dprice'], 'type' => $item_conf['fuction'], 'diamond_hour' => $item_conf['diamond_hour'] ); @@ -48,6 +48,9 @@ class EquipController{ { $g_conf_equip_cluster = require('../res/equip@equip.php'); $equip_conf = getEquipConfig($g_conf_equip_cluster, $equip_id); + if (!$equip_conf) { + return null; + } $e = array( 'id' => $equip_conf['id'], 'upgrade_priority' => $equip_conf['upgrade_priority'], @@ -59,7 +62,11 @@ class EquipController{ 'diamond_cost' => $equip_conf['diamond_cost'], 'reduce_time' => $equip_conf['reduce_time'], 'diamond_time' => $equip_conf['diamond_time'], - ); + 'upgrade_gold' => $equip_conf['upgrade_gold'], + 'promote_gold' => $equip_conf['promote_gold'], + 'promote_material' => $equip_conf['promote_material'], + 'real_index_id' => $equip_conf['real_index_id'], + ); return $e; } @@ -76,6 +83,151 @@ class EquipController{ return $arr; } + public function equipInfo() + { + $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; + } + $equip_list = array(); + $rows = $conn->execQuery('SELECT * FROM equip WHERE accountid=:account_id;', + array( + 'account_id' => $account_id, + )); + $addreward = new classes\AddReward(); + if (!$rows) { + //新玩家装备数据 + $id = $addreward->getRealIndexid(12151, $account_id); + $ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time, using_id, exp) ' . + ' VALUES(:account_id, :id, 0, :active_time, :sub_time, :create_time, :modify_time, :using_id, 0) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time, using_id=:using_id, exp=0;', + array( + ':account_id' => $account_id, + ':id' => $id, + ':active_time' => 0, + ':create_time' => time(), + ':modify_time' => time(), + ':sub_time' => 0, + ':using_id' => $id, + )); + if(!$ret){ + die(); + return; + } + $ret1 = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, num, active_time, create_time, modify_time) ' . + ' VALUES(:account_id, :id, 0, :status, 130, :active_time, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, num=1, active_time=:active_time, modify_time=:modify_time;', + array( + ':account_id' => $account_id, + ':id' => 18006, + ':active_time' => 0, + ':status' => 0, + ':create_time' => time(), + ':modify_time' => time() + )); + array_push($equip_list, array( + 'id' => $id, + 'lv' => 0, + 'active_time' => 0, + 'using_id' => $id, + 'exp' => 0, + )); + } else { + if (count($rows) == 1) { + $id = 0; + $flag = 0; + $using_id = 0; + foreach ($rows as $row) { + $id = $addreward->getRealIndexid($row['id'], $account_id); + $using_id = $id; + array_push($equip_list, array( + 'id' => $id, + 'lv' => $row['lv'], + 'active_time' => 0, + 'using_id' => $using_id, + 'exp' => $row['exp'], + )); + $ret = $conn->execScript('UPDATE equip SET id=:id, using_id=:using_id ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':id' => $id, + ':using_id' => $using_id + )); + if (!$ret) { + die(); + return; + } + $e = $this->getEquip($row['id']); + if ($e['upgrade_priority'] == '') { + $flag = 1; + } + } + if ($flag == 0) { + //更新老玩家数据 + $g_conf_lot_cluster = require('../res/equip@equip.php'); + for ($i = 0; $i < count($g_conf_lot_cluster); $i++) { + $e = $this->getEquip(12100 + $i); + if (!$e || $e['id'] >= $row['id'] || $e['upgrade_priority'] == '') { + continue; + } + $id = $addreward->getRealIndexid($e['id'], $account_id); + $ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time, using_id, exp) ' . + ' VALUES(:account_id, :id, :lv, :active_time, :sub_time, :create_time, :modify_time, :using_id, 0) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=:lv, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time, using_id=:using_id, exp=0;', + array( + ':account_id' => $account_id, + ':id' => $id, + ':active_time' => 0, + ':create_time' => time(), + ':modify_time' => time(), + ':sub_time' => 0, + ':using_id' => $using_id, + ':lv' => $e['max_level'] + )); + if(!$ret){ + die(); + return; + } + array_push($equip_list, array( + 'id' => $id, + 'lv' => $e['max_level'], + 'active_time' => 0, + 'using_id' => $using_id, + 'exp' => 0, + )); + } + } + } else { + //装备信息 + foreach ($rows as $row) { + $id = $addreward->getRealIndexid($row['id'], $account_id); + array_push($equip_list, array( + 'id' => $id, + 'lv' => $row['lv'], + 'active_time' => 0, + 'using_id' => $row['using_id'], + 'exp' => $row['exp'], + )); + } + } + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'equip_list' => $equip_list, + 'time_flag' => 0, + )); + } + public function getEquipInfo() { $account_id = $_REQUEST['account_id']; @@ -109,9 +261,9 @@ class EquipController{ break; } } - $ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time, using_id) ' . - ' VALUES(:account_id, :id, 0, :active_time, :sub_time, :create_time, :modify_time, :using_id) ' . - ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time, using_id=:using_id;', + $ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time, using_id, exp) ' . + ' VALUES(:account_id, :id, 0, :active_time, :sub_time, :create_time, :modify_time, :using_id, 0) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time, using_id=:using_id, exp=0;', array( ':account_id' => $account_id, ':id' => $id, @@ -478,5 +630,379 @@ class EquipController{ 'using_id' => $equip_id, )); } + + public function exchangeNewEquip() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $equip_id = $_REQUEST['id']; + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $row = $conn->execQueryOne('SELECT id, using_id, lv FROM equip WHERE accountid=:account_id AND id=:id;', + array( + ':account_id' => $account_id, + ':id' => $equip_id + )); + $lv = 0; + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 3, '武器未获得'); + return; + } else { + $lv = $row['lv']; + } + + $ret = $conn->execScript('UPDATE equip SET using_id=:using_id, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':using_id' => $equip_id, + ':modify_time' => time(), + )); + if (!$ret) { + die(); + return; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'using_id' => $equip_id, + 'lv' => $lv + )); + } + + public function shengjiEquip() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $equip_id = $_REQUEST['id']; + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $e = $this->getEquip($equip_id); + if (!$e) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备'); + return; + } + $upgrade_gold = $e['upgrade_gold']; + $drop_multiply = explode('&', $upgrade_gold); + $arr = array(); + for ($i = 0; $i < count($drop_multiply); $i++) { + $mul = explode('|', $drop_multiply[$i]); + array_push($arr, $mul); + } + $row = $conn->execQueryOne('SELECT id, lv, exp FROM equip WHERE accountid=:account_id AND id=:id;', + array( + ':account_id' => $account_id, + ':id' => $equip_id + )); + $item_id_arr = array(); + $item_num_arr = array(); + $exp = 0; + $lv = 0; + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 3, '武器未获得'); + return; + } else { + $lv = $row['lv']; + $exp = $row['exp']; + } + + if ($lv >= $e['max_level']) { + phpcommon\sendError(ERR_USER_BASE + 5, '达到最大等级'); + return; + } + $arr2 = array(); + $str = $arr[$lv][0]; + $estr = explode(';', $str); + $val = $estr[1]; + if ($lv > 0) { + $str1 = $arr[$lv - 1][0]; + $estr1 = explode(';', $str1); + $val = $estr[1] - $estr1[1]; + } + if ($val <= $exp) { + phpcommon\sendError(ERR_USER_BASE + 4, '当前等级经验已满'); + return; + } + for ($a1 = 0; $a1 < count($arr[$lv]); $a1++) { + $mul2 = explode(';', $arr[$lv][$a1]); + array_push($arr2, $mul2); + } + + $arr3 = array(); + for ($ii = 0; $ii < count($arr2); $ii++) { + for ($a2 = 0; $a2 < count($arr2[$ii]); $a2++) { + $mul3 = explode(':', $arr2[$ii][$a2]); + if (count($mul3) > 1) { + array_push($arr3, $mul3); + } + } + } + foreach ($arr3 as $ar) { + $it = $this->getItem($ar[0]); + if (!$it) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); + return; + } + $rowuser = $conn->execQueryOne('SELECT coin_num, diamond_num FROM user WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + )); + if (!$rowuser) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + + if ($it['type'] == 1) { + if ($ar[1] > $rowuser['coin_num']) { + phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); + return; + } + } else if ($it['type'] == 3) { + if ($ar[1] > $row['diamond_num']) { + phpcommon\sendError(ERR_USER_BASE + 4, '钻石不足'); + return; + } + } else if ($it['type'] == 11) { + $rowbag = $conn->execQueryOne('SELECT num FROM bag WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $account_id, + 'id' => $ar[0] + )); + if ($ar[1] > $rowbag['num']) { + phpcommon\sendError(ERR_USER_BASE + 5, '道具不足'); + return; + } + } + } + foreach ($arr3 as $ar1) { + $this->subCoin($ar1[0], $ar1[1], $account_id); + } + + $ret = $conn->execScript('UPDATE equip SET exp=:exp, modify_time=:modify_time ' . + ' WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $account_id, + ':id' => $equip_id, + ':modify_time' => time(), + ':exp' => $exp + 1, + )); + if (!$ret) { + die(); + return; + + } + $addreward = new classes\AddReward(); + $coin_num = $addreward->getCoinNum($account_id); + $num = $addreward->getDiamondNum($account_id); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'exp' => $exp + 1, + 'coin_nums' => $coin_num, + 'diamond_nums' => $num, + 'lv' => $lv, + )); + } + + protected function subCoin($item_id, $item_num, $account_id) + { + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + die(); + return; + } + + $row = $conn->execQueryOne('SELECT coin_num, diamond_num FROM user WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + die(); + return; + } + + $it = $this->getItem($item_id); + if (!$it) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); + die(); + return; + } + + if ($item_id != 0){ + if ($it['type'] == 1) { + $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':modify_time' => time(), + ':coin_num' => $row['coin_num'] - $item_num, + )); + if (!$ret) { + die(); + return; + } + } else if ($it['type'] == 3) { + $ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':modify_time' => time(), + ':diamond_num' => $row['diamond_num'] - $item_num, + )); + if (!$ret) { + die(); + return; + } + } else if ($it['type'] == 11) { + $rowbag = $conn->execQueryOne('SELECT num FROM bag WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $account_id, + 'id' => $item_id + )); + $ret = $conn->execScript('UPDATE bag SET num=:num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $account_id, + ':modify_time' => time(), + ':num' => $rowbag['num'] - $item_num, + ':id' => $item_id + )); + if (!$ret) { + die(); + return; + } + } + } + } + + public function jinjieEquip() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $equip_id = $_REQUEST['id']; + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $row = $conn->execQueryOne('SELECT id, using_id, lv, exp FROM equip WHERE accountid=:account_id AND id=:id;', + array( + ':account_id' => $account_id, + ':id' => $equip_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 3, '武器未获得'); + return; + } + + $lv = $row['lv']; + $e = $this->getEquip($equip_id); + if (!$e) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备'); + return; + } + $upgrade_gold = $e['upgrade_gold']; + $drop_multiply = explode('&', $upgrade_gold); + $arr = array(); + for ($i = 0; $i < count($drop_multiply); $i++) { + $mul = explode('|', $drop_multiply[$i]); + array_push($arr, $mul); + } + $arr2 = array(); + $flag = 0; + for ($a = 0; $a < count($arr); $a++) { + $str = $arr[$a][0]; + $estr = explode(';', $str); + if ($estr[1][0] > $row['exp']) { + phpcommon\sendError(ERR_USER_BASE + 4, '未达到进阶需求'); + return; + } + } + if ($lv >= $e['max_level']) { + phpcommon\sendError(ERR_USER_BASE + 5, '达到最大等级'); + return; + } + $coinarr = explode('|', $e['promote_gold']); + $key = $lv; + $coin_num = $coinarr[$key]; + $row = $conn->execQueryOne('SELECT coin_num, diamond_num FROM user WHERE accountid=:account_id;', + array( + ':account_id' => $account_id, + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + + if ($coin_num > $row['coin_num']) { + phpcommon\sendError(ERR_USER_BASE + 3, '金币不足'); + return; + } + + $mar_array = $this->getExplode($e['promote_material']); + $mid = $mar_array[$key][0]; + $mnum = $mar_array[$key][1]; + $rbag = $conn->execQueryOne('SELECT num FROM bag WHERE accountid=:account_id AND id=:id;', + array( + ':account_id' => $account_id, + ':id' => $mid, + )); + + if (!$rbag || $rbag['num'] < $mnum) { + phpcommon\sendError(ERR_USER_BASE + 6, '材料不足'); + return; + } + + $this->subCoin(10001, $coin_num, $account_id); + $this->subCoin($mid, $mnum, $account_id); + $ret = $conn->execScript('UPDATE equip SET exp=:exp, lv=:lv, modify_time=:modify_time ' . + ' WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $account_id, + ':id' => $equip_id, + ':modify_time' => time(), + ':exp' => 0, + ':lv' => $lv + 1 + )); + if (!$ret) { + die(); + return; + } + $addreward = new classes\AddReward(); + $coin_num = $addreward->getCoinNum($account_id); + $num = $addreward->getDiamondNum($account_id); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'exp' => 0, + 'lv' => $lv + 1, + 'coin_nums' => $coin_num, + 'diamond_nums' => $num + + )); + } } ?> diff --git a/webapp/controller/GameOverController.class.php b/webapp/controller/GameOverController.class.php index 2fa3cac..7100239 100644 --- a/webapp/controller/GameOverController.class.php +++ b/webapp/controller/GameOverController.class.php @@ -92,6 +92,17 @@ class GameOverController{ return $d; } + protected function getParameter($para_id) + { + $parameter_meta_cluster = require('../res/parameter@parameter.php'); + $parameter_meta = getParameterConfig($parameter_meta_cluster, $para_id); + $p = array( + 'id' => $parameter_meta['id'], + 'name' => $parameter_meta['param_name'], + 'param_value' => $parameter_meta['param_value'], + ); + return $p; + } protected function getRankReward($rank) { @@ -131,19 +142,37 @@ class GameOverController{ $coin = 0; $score = 0; $kills = 0; + $normal_coin = 0; + $num = 1; if (isset($_REQUEST['type'])) { $type = $_REQUEST['type']; } + $p = $this->getParameter(EQUIPREWARD_PARAMETER); + $par = $p['param_value']; + if ($type == 1) { $ar = $this->getRankReward($rank); $coin = $ar['zbmode_param']; + $num = ceil($ar['zbmode_param'] / $par); if (isset($_REQUEST['kills'])) { $score = $_REQUEST['kills'] * 10; } + } else if ($type == 0) { + if (isset($_REQUEST['coin'])) { + $num = ceil($_REQUEST['coin'] / $par); + } } //道具物品 $first_list = array(); - $first_list = $this->randomReward($rank, $type); + if (phpcommon\extractChannel($account_id) == 6000 || phpcommon\extractChannel($account_id) == 6001) { + array_push($first_list, array( + 'item_id' => 18006, + 'item_num' => $num, + 'time' => 0, + )); + } else { + $first_list = $this->randomReward($rank, $type); + } $first_db = array( 'first_uuid' => $first_uuid, 'first_list' => $first_list, diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 1880344..b0a601a 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -185,7 +185,7 @@ class RoleController{ } } $ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times) ' . - ' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0) ' . + ' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 3000, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0) ' . ' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0;', array( ':accountid' => $account_id, @@ -213,7 +213,7 @@ class RoleController{ 'harm' => 0, 'add_HP' => 0, 'alive_time' => 0, - 'coin_num' => 200, + 'coin_num' => 3000, 'first_fight' => 0, 'collect_status' => 0, 'keys_num' => 0, diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index a08a929..187ac91 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -452,14 +452,20 @@ class ShareController{ ':accountid' => $account_id )); foreach ($rows as $row) { + $item_list = array(); $sh = $this->getShare($row['ach_id']); $array = $this->getExplode($sh['rewards']); + for ($i = 0; $i < count($array); $i++) { + array_push($item_list, array( + 'item_id' => $array[$i][0], + 'num' => $array[$i][1], + 'time' => $array[$i][2], + )); + } array_push($info_list, array( 'achivement_id' => $row['ach_id'], 'status' => $row['status'], - 'item_id' => $array[0][0], - 'num' => $array[0][1], - 'time' => $array[0][2], + 'item_list' => $item_list, 'people_num' => $sh['people'], )); } @@ -527,22 +533,15 @@ class ShareController{ } $item_list = array(); $addreward = new classes\AddReward(); - //if ($ach_id != 6) { - $array = $this->getExplode($sh['rewards']); + $array = $this->getExplode($sh['rewards']); + for ($i = 0; $i < count($array); $i++) { array_push($item_list, array( - 'item_id' => $array[0][0], - 'item_num' => $array[0][1], - 'time' => $array[0][2], + 'item_id' => $array[$i][0], + 'item_num' => $array[$i][1], + 'time' => $array[$i][2], )); $all_item_list = $addreward->addReward($array[0][0], $array[0][1], $account_id, $array[0][2], 0); - //} else if ($ach_id == 6) { - //array_push($item_list, array( - // 'item_id' => 10003, - // 'item_num' => 100, - // 'time' => 0, - //)); - //$addreward->addReward(10003, 100, $account_id, 0, 0); - //} + } //更新状态 $ret = $conn->execScript('UPDATE share_achievement SET status=1, modify_time=:modify_time ' . ' WHERE accountid=:accountid AND ach_id=:ach_id;', diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 06aa385..86c3b33 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -42,6 +42,7 @@ class ShopController{ 'bug_groupnum' => $item_conf['bug_groupnum'], 'shop_list' => $item_conf['shop_list'], 'bug_groupnum' => $item_conf['bug_groupnum'], + 'Isbug_again' => $item_conf['Isbug_again'], ); return $it; } @@ -59,6 +60,7 @@ class ShopController{ 'bug_groupnum' => $item_conf['bug_groupnum'], 'shop_list' => $item_conf['shop_list'], 'bug_groupnum' => $item_conf['bug_groupnum'], + 'Isbug_again' => $item_conf['Isbug_again'], ); return $it; } @@ -186,7 +188,7 @@ class ShopController{ if ($r['status'] == 2 || $r['active_time'] != 0) { continue; } - if ($it['type'] == 10 || $it['type'] == 11) { + if ($it['Isbug_again'] == 1) { continue; } $status = 1; @@ -198,7 +200,7 @@ class ShopController{ 'id' => $it['id'], )); } - if ($it['type'] == 10 || $it['type'] == 11) { + if ($it['Isbug_again'] == 1) { $num = $it['bug_groupnum']; } array_push($coin_shop,array( @@ -216,7 +218,7 @@ class ShopController{ 'id' => $it['id'], )); } - if ($it['type'] == 10 || $it['type'] == 11) { + if ($it['Isbug_again'] == 1) { $num = $it['bug_groupnum']; } array_push($diamond_shop,array( @@ -234,7 +236,7 @@ class ShopController{ 'id' => $it['id'], )); } - if ($it['type'] == 10 || $it['type'] == 11) { + if ($it['Isbug_again'] == 1) { $num = $it['bug_groupnum']; } array_push($coin_shop,array( @@ -373,6 +375,93 @@ class ShopController{ return $weight_array[$keys][0]; } + public function shopBuyMore() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $id = $_REQUEST['id']; + $type = $_REQUEST['type']; + $num = $_REQUEST['num']; + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $i = $this->getItem($id); + $price = 0; + if ($i['shop_type'] == 1) { + $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', + array( + ':accountid' => $account_id, + ':id' => $id + )); + $price = $i['price'] * $num; + if ($row_c) { + $price = round($i['price'] * $row_c['coin_discount'] / 10); + } + $this->SubCoin($price, $account_id, 1); + } else if ($i['shop_type'] == 2) { + $price = $i['dprice'] * $num; + $row_d = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND diamond_id=:id;', + array( + ':accountid' => $account_id, + ':id' => $id + )); + if ($row_d) { + $price = round($i['dprice'] * $row_d['diamond_discount'] / 10); + } + $this->SubCoin($price, $account_id, 2); + } else if ($i['shop_type'] == 3) { + if ($type == 0) { + $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', + array( + ':accountid' => $account_id, + ':id' => $id + )); + $price = $i['price'] * $num; + if ($row_c) { + $price = round($i['price'] * $row_c['coin_discount'] / 10); + } + $this->SubCoin($price, $account_id, 1); + } else if ($type == 1) { + $price = $i['dprice'] * $num; + $row_d = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND diamond_id=:id;', + array( + ':accountid' => $account_id, + ':id' => $id + )); + if ($row_d) { + $price = round($i['dprice'] * $row_d['diamond_discount'] / 10); + } + $this->SubCoin($price, $account_id, 2); + } + } + //增加奖励 + $addreward = new classes\AddReward(); + $all_item_list = $addreward->addReward($id, $num, $account_id, 0, 0); + $coin_num = $addreward->getCoinNum($account_id); + $diamond_num = $addreward->getDiamondNum($account_id); + $item_list = array(); + array_push($item_list,array( + 'item_id' => $id, + 'item_num' => $num, + 'time' => 0, + )); + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + 'coin_nums' => $coin_num, + 'diamond_nums' => $diamond_num, + 'item_list' => $item_list, + 'all_item_list' => $all_item_list + )); + } + public function buyItem() { $account_id = $_REQUEST['account_id']; @@ -396,7 +485,7 @@ class ShopController{ )); if ($row) { $it = $this->getItem($id); - if ($row['status'] != 2 && $row['active_time'] == 0 && $it['type'] != 10 && $it['type'] != 11) { + if ($row['status'] != 2 && $row['active_time'] == 0 && $it['Isbug_again'] != 1) { phpcommon\sendError(ERR_USER_BASE + 4, '商品已购买'); return; }