diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 53eac75..be9f43b 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -95,7 +95,6 @@ CREATE TABLE `user` ( `act_ad_status` int(11) NOT NULL DEFAULT '0' COMMENT '观看广告奖励领取状态', `share_video_sums` int(11) NOT NULL DEFAULT '0' COMMENT '分享录频次数', `biogame_times` int(11) NOT NULL DEFAULT '0' COMMENT '生化模式场次', - `shop_view_times` int(11) NOT NULL DEFAULT '0' COMMENT '商店看广告次数', `new_first_equip` int(11) NOT NULL DEFAULT '0' COMMENT '新玩家结算武器', `newhand2` int(11) NOT NULL DEFAULT '0' COMMENT '精英礼包领取状态', diff --git a/webapp/controller/GameOverController.class.php b/webapp/controller/GameOverController.class.php index 3949e49..0a6088d 100644 --- a/webapp/controller/GameOverController.class.php +++ b/webapp/controller/GameOverController.class.php @@ -375,4 +375,92 @@ class GameOverController{ } return $flag; } + + public function getFuckBoxReward() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $id = 10; + if (isset($_REQUEST['id'])) { + $id = $_REQUEST['id']; + } + $item_list = array(); + $all_item_list = array(); + $item_list = $this->randomBoxNew($id); + $addreward = new classes\AddReward(); + foreach($item_list as $it) { + $items = $addreward->addReward($it['item_id'], $it['item_num'], $account_id, $it['time'], 0); + foreach($items as $j) { + array_push($all_item_list, array( + 'item_id' => $j['item_id'], + 'item_num' => $j['item_num'], + 'time' => $j['time'], + )); + } + } + $coin_num = $addreward->getCoinNum($account_id); + $diamond_num = $addreward->getDiamondNum($account_id); + 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 + )); + } + + protected function randomBoxNew($type) + { + //随机奖励 + $b = $this->getBox($type); + $count = $b['count']; + $item_list = array(); + $item_id_array = $this->getExplode($b['item_id']); + $item_num_array = $this->getExplode($b['num']); + $item_time_array = $this->getExplode($b['time']); + $weight_array = $this->getExplode($b['weight']); + $reward_array = array(); + for ($c = 0; $c < $count; $c++) { + $weight_sum = 0; + $keys = 0; + for ($ii = 0; $ii < count($weight_array); $ii++) { + $flag = $this->removal($reward_array, $item_id_array[$ii][0]); + if ($flag == 1) { + continue; + } + $weight_sum += $weight_array[$ii][0]; + } + $random = Rand(0, $weight_sum); + $weight = 0; + for ($ii = 0; $ii < count($weight_array); $ii++) { + $flag = $this->removal($reward_array, $item_id_array[$ii][0]); + if ($flag == 1) { + continue; + } + $weight += $weight_array[$ii][0]; + if ($weight >= $random) { + $keys = $ii; + break; + } + } + $item_id = $item_id_array[$keys][0]; + $item_num = $item_num_array[$keys][0]; + $time = $item_time_array[$keys][0]; + array_push($reward_array, array( + 'id' => $item_id + )); + array_push($item_list, array( + 'item_id' => $item_id, + 'item_num' => $item_num, + 'time' => $time + )); + } + return $item_list; + } }