This commit is contained in:
wangwei01 2019-07-12 14:54:43 +08:00
parent d6f53dd8db
commit 263f1ce6b3
7 changed files with 90 additions and 119 deletions

View File

@ -45,14 +45,13 @@ CREATE TABLE `user` (
`win_times` int(11) NOT NULL COMMENT '胜场', `win_times` int(11) NOT NULL COMMENT '胜场',
`kills` int(11) NOT NULL COMMENT '所有击杀', `kills` int(11) NOT NULL COMMENT '所有击杀',
`harm` int(11) NOT NULL COMMENT '所有伤害', `harm` int(11) NOT NULL COMMENT '所有伤害',
`add_HP` int(11) NOT NULL COMMENT '所有治疗量', `score` bigint NOT NULL COMMENT '积分',
`alive_time` int(11) NOT NULL COMMENT '所有生存时间', `alive_time` int(11) NOT NULL COMMENT '所有生存时间',
`coin_num` bigint NOT NULL COMMENT '角色金币', `coin_num` bigint NOT NULL COMMENT '角色金币',
`diamond_num` bigint NOT NULL COMMENT '角色钻石', `diamond_num` bigint NOT NULL COMMENT '角色钻石',
`kill_his` int(11) NOT NULL COMMENT '最高击杀', `kill_his` int(11) NOT NULL COMMENT '最高击杀',
`alive_time_his` int(11) NOT NULL COMMENT '最长生存时间', `alive_time_his` int(11) NOT NULL COMMENT '最长生存时间',
`harm_his` int(11) NOT NULL COMMENT '最高伤害', `harm_his` int(11) NOT NULL COMMENT '最高伤害',
`add_HP_his` int(11) NOT NULL COMMENT '最多治疗量',
`create_time` int(11) NOT NULL COMMENT '创建时间', `create_time` int(11) NOT NULL COMMENT '创建时间',
`modify_time` int(11) NOT NULL COMMENT '修改时间', `modify_time` int(11) NOT NULL COMMENT '修改时间',
`first_fight` int(11) NOT NULL COMMENT '是否是第一次战斗', `first_fight` int(11) NOT NULL COMMENT '是否是第一次战斗',
@ -104,6 +103,8 @@ CREATE TABLE `tank` (
`tank_id` int(11) NOT NULL COMMENT '坦克id', `tank_id` int(11) NOT NULL COMMENT '坦克id',
`tank_status` int(11) NOT NULL COMMENT '坦克状态0:上阵中,1:已获得,2:未获得)', `tank_status` int(11) NOT NULL COMMENT '坦克状态0:上阵中,1:已获得,2:未获得)',
`tank_level` int(11) NOT NULL COMMENT '坦克等级', `tank_level` int(11) NOT NULL COMMENT '坦克等级',
`fragment_id` int(11) NOT NULL COMMENT '碎片id',
`fragment_num` int(11) NOT NULL COMMENT '碎片数量',
`experience_level` int(11) NOT NULL COMMENT '坦克体验等级', `experience_level` int(11) NOT NULL COMMENT '坦克体验等级',
`experience_type` int(11) NOT NULL COMMENT '坦克体验类型', `experience_type` int(11) NOT NULL COMMENT '坦克体验类型',
`active_time` varchar(50) NOT NULL DEFAULT '有效时间', `active_time` varchar(50) NOT NULL DEFAULT '有效时间',

View File

@ -9,31 +9,28 @@ define('QUEST_DAY_LOGIN', 71001);
define('QUEST_DAY_SHARE', 71002); define('QUEST_DAY_SHARE', 71002);
define('QUEST_DAY_FIGHT', 71003); define('QUEST_DAY_FIGHT', 71003);
define('QUEST_DAY_SUPPLY', 71004); define('QUEST_DAY_SUPPLY', 71004);
define('QUEST_DAY_UPDATEEQUIP', 71005); define('QUEST_DAY_UPDATETANK', 71005);
define('QUEST_DAY_TEAM', 71006); define('QUEST_DAY_UPDATEDRIVER', 71006);
define('QUEST_DAY_RANK', 71007); define('QUEST_DAY_RANK', 71007);
define('QUEST_DAY_ALIVE', 71008); define('QUEST_DAY_ALIVE', 71008);
define('QUEST_DAY_HARM', 71009); define('QUEST_DAY_HARM', 71009);
define('QUEST_DAY_KILL', 71010); define('QUEST_DAY_KILL', 71010);
define('QUEST_DAY_HELP', 71011); define('QUEST_DAY_COMPLETE', 71011);
define('QUEST_DAY_COMPLETE', 71012);
//成就 //成就
define('QUEST_SUM_LOGIN', 72001); define('QUEST_SUM_LOGIN', 72001);
define('QUEST_SUM_SHARE', 72002); define('QUEST_SUM_SHARE', 72002);
define('QUEST_SUM_FIGHT', 72003); define('QUEST_SUM_FIGHT', 72003);
define('QUEST_SUM_SUPPLY', 72004); define('QUEST_SUM_SUPPLY', 72004);
define('QUEST_SUM_EQUIPMAX', 72005); define('QUEST_SUM_TANKMAX', 72005);
define('QUEST_SUM_TEAM', 72006); define('QUEST_SUM_DRIVER', 72006);
define('QUEST_SUM_WIM', 72007); define('QUEST_SUM_WIM', 72007);
define('QUEST_SUM_TEAMWIN', 72008); define('QUEST_SUM_ALIVE', 72008);
define('QUEST_SUM_ALIVE', 72009); define('QUEST_SUM_HARM', 72009);
define('QUEST_SUM_HARM', 72010); define('QUEST_SUM_KILL', 72010);
define('QUEST_SUM_KILL', 72011); define('QUEST_SUM_SKILL', 72011);
define('QUEST_SUM_SNIPEKILL', 72012); define('QUEST_SUM_TANK1KILL', 72012);
define('QUEST_SUM_RIFLEKILL', 72013); define('QUEST_SUM_TANK2KILL', 72013);
define('QUEST_SUM_PISTOLKILL', 72014); define('QUEST_SUM_TANK3KILL', 72014);
define('QUEST_SUM_SUBMACKILL', 72015);
define('QUEST_SUM_HELP', 72016);
//活动 //活动
define('QUEST_ACTIVITY_LOGIN', 83001); define('QUEST_ACTIVITY_LOGIN', 83001);
define('QUEST_ACTIVITY_GAME', 83002); define('QUEST_ACTIVITY_GAME', 83002);

View File

@ -1,5 +1,7 @@
<?php <?php
require 'classes/Quest.php';
class CommanderController{ class CommanderController{
protected function getMysql($account_id) protected function getMysql($account_id)
@ -135,8 +137,8 @@ class CommanderController{
)); ));
$commander_id = 0; $commander_id = 0;
$commander_level = 0; $commander_level = 0;
$time = 0;
foreach ($rows as $row) { foreach ($rows as $row) {
$time = 0;
$commander_level = $row['commander_level']; $commander_level = $row['commander_level'];
$c = $this->getCommander($row['commander_id']); $c = $this->getCommander($row['commander_id']);
if ($commander_id == $row['commander_id']) { if ($commander_id == $row['commander_id']) {
@ -377,13 +379,18 @@ class CommanderController{
' WHERE accountid=:account_id;', ' WHERE accountid=:account_id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
':coin_num' => $row['coin_num'] - $coin_num, ':coin_num' => $rowCoin['coin_num'] - $coin_num,
':modify_time' => time() ':modify_time' => time()
)); ));
if (!$retCoin) { if (!$retCoin) {
die(); die();
return; return;
} }
$quest = new classes\Quest();
$quest->triggerQuest(QUEST_DAY_UPDATEDRIVER, 1, 1, $account_id);
if ($row['commander_level'] + 1 >= $c['max_lv']) {
$quest->triggerQuest(QUEST_DAY_UPDATEDRIVER, 2, 1, $account_id);
}
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',

View File

@ -83,9 +83,9 @@ class RoleController{
':accountid' => $account_id ':accountid' => $account_id
)); ));
if (!$row) { if (!$row) {
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, diamond_num, kill_his, alive_time_his, harm_his, add_HP_his, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, free_getbox) ' . $ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, score, alive_time, coin_num, diamond_num, kill_his, alive_time_his, harm_his, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, free_getbox) ' .
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0) ' . ' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 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, diamond_num=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=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, free_getbox=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, score=0, alive_time=0, coin_num=0, diamond_num=0, kill_his=0, alive_time_his=0, harm_his=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, free_getbox=0;',
array( array(
':accountid' => $account_id, ':accountid' => $account_id,
':user_name' => $user_name, ':user_name' => $user_name,
@ -106,7 +106,7 @@ class RoleController{
'kills' => 0, 'kills' => 0,
'high_harm' => 0, 'high_harm' => 0,
'harm' => 0, 'harm' => 0,
'add_HP' => 0, 'score' => 0,
'alive_time' => 0, 'alive_time' => 0,
'coin_num' => 0, 'coin_num' => 0,
'first_fight' => 0, 'first_fight' => 0,
@ -126,7 +126,7 @@ class RoleController{
'kills' => $row['kills'], 'kills' => $row['kills'],
'high_harm' => $row['harm_his'], 'high_harm' => $row['harm_his'],
'harm' => $row['harm'], 'harm' => $row['harm'],
'add_HP' => $row['add_HP'], 'score' => $row['score'],
'alive_time' => $row['alive_time'], 'alive_time' => $row['alive_time'],
'coin_num' => $row['coin_num'], 'coin_num' => $row['coin_num'],
'first_fight' => $row['first_fight'], 'first_fight' => $row['first_fight'],
@ -156,20 +156,17 @@ class RoleController{
$rank = $_REQUEST['rank']; //排名 $rank = $_REQUEST['rank']; //排名
$kills = $_REQUEST['kills']; //击杀数 $kills = $_REQUEST['kills']; //击杀数
$harm = $_REQUEST['harm']; //伤害 $harm = $_REQUEST['harm']; //伤害
$add_HP = $_REQUEST['add_HP']; //治疗量
$alive_time = $_REQUEST['alive_time']; //存活时间 $alive_time = $_REQUEST['alive_time']; //存活时间
$team_status = $_REQUEST['team_status']; //是否是组队状态 $skill = $_REQUEST['skill']; //技能释放数
$snipe_kill = $_REQUEST['snipe_kill']; //狙击枪击杀数 $tank1_kill = $_REQUEST['tank1_kill']; //坦克1击杀数
$rifle_kill = $_REQUEST['rifle_kill']; //步枪击杀数 $tank2_kill = $_REQUEST['tank2_kill']; //坦克2击杀数
$pistol_kill = $_REQUEST['pistol_kill']; //手枪击杀数 $tank3_kill = $_REQUEST['tank3_kill'];//坦克3击杀数
$submachine_kill = $_REQUEST['submachine_kill'];//冲锋枪击杀数
$rescue_member = $_REQUEST['rescue_member']; //救起队友次数 $rescue_member = $_REQUEST['rescue_member']; //救起队友次数
$kill_his = $kills; $kill_his = $kills;
$harm_his = $harm; $harm_his = $harm;
$alive_time_his = $alive_time; $alive_time_his = $alive_time;
$add_HP_his = $add_HP;
$coin_num = $_REQUEST['coin_num']; //金币 $coin_num = $_REQUEST['coin_num']; //金币
// $diamond_num = $_REQUEST['score']; //积分 $score = $_REQUEST['score']; //积分
if (!$map_id) { if (!$map_id) {
$map_id = 0; $map_id = 0;
@ -198,10 +195,7 @@ class RoleController{
if ($alive_time_his < $row['alive_time_his']) { if ($alive_time_his < $row['alive_time_his']) {
$alive_time_his = $row['alive_time_his']; $alive_time_his = $row['alive_time_his'];
} }
if ($add_HP_his < $row['add_HP_his']) { $ret = $conn->execScript('UPDATE user SET game_times=:game_times, win_times=:win_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, score=:score, coin_num=:coin_num, modify_time=:modify_time, first_fight=1 ' .
$add_HP_his = $row['add_HP_his'];
}
$ret = $conn->execScript('UPDATE user SET game_times=:game_times, win_times=:win_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, modify_time=:modify_time, first_fight=1 ' .
' WHERE accountid=:accountid;', ' WHERE accountid=:accountid;',
array( array(
':game_times' => $row['game_times'] + 1, ':game_times' => $row['game_times'] + 1,
@ -213,9 +207,9 @@ class RoleController{
':add_HP' => $row['add_HP'] + $add_HP, ':add_HP' => $row['add_HP'] + $add_HP,
':alive_time' => $row['alive_time'] + $alive_time, ':alive_time' => $row['alive_time'] + $alive_time,
':alive_time_his' => $alive_time_his, ':alive_time_his' => $alive_time_his,
':add_HP_his' => $add_HP_his,
':accountid' => $account_id, ':accountid' => $account_id,
':coin_num' => $row['coin_num'] + $coin_num, ':coin_num' => $row['coin_num'] + $coin_num,
':score' => $row['score'] + $score,
':modify_time' => time() ':modify_time' => time()
)); ));
if (!$ret) { if (!$ret) {
@ -253,29 +247,21 @@ class RoleController{
$quest->triggerQuest(QUEST_DAY_ALIVE, 1, (int)($alive_time / 1000 / 60), $account_id); $quest->triggerQuest(QUEST_DAY_ALIVE, 1, (int)($alive_time / 1000 / 60), $account_id);
$quest->triggerQuest(QUEST_DAY_HARM, 1, $harm, $account_id); $quest->triggerQuest(QUEST_DAY_HARM, 1, $harm, $account_id);
$quest->triggerQuest(QUEST_DAY_KILL, 1, $kills, $account_id); $quest->triggerQuest(QUEST_DAY_KILL, 1, $kills, $account_id);
$quest->triggerQuest(QUEST_DAY_HELP, 1, $rescue_member, $account_id);
$quest->triggerQuest(QUEST_SUM_FIGHT, 2, 1, $account_id); $quest->triggerQuest(QUEST_SUM_FIGHT, 2, 1, $account_id);
$quest->triggerQuest(QUEST_SUM_ALIVE, 2, (int)($alive_time / 1000 / 60), $account_id); $quest->triggerQuest(QUEST_SUM_ALIVE, 2, (int)($alive_time / 1000 / 60), $account_id);
$quest->triggerQuest(QUEST_SUM_HARM, 2, $harm, $account_id); $quest->triggerQuest(QUEST_SUM_HARM, 2, $harm, $account_id);
$quest->triggerQuest(QUEST_SUM_KILL, 2, $kills, $account_id); $quest->triggerQuest(QUEST_SUM_KILL, 2, $kills, $account_id);
$quest->triggerQuest(QUEST_SUM_HELP, 2, $rescue_member, $account_id); $quest->triggerQuest(QUEST_SUM_SKILL, 2, $skill, $account_id);
$quest->triggerQuest(QUEST_SUM_SNIPEKILL, 2, $snipe_kill, $account_id); $quest->triggerQuest(QUEST_SUM_TANK1KILL, 2, $tank1_kill, $account_id);
$quest->triggerQuest(QUEST_SUM_RIFLEKILL, 2, $rifle_kill, $account_id); $quest->triggerQuest(QUEST_SUM_TANK2KILL, 2, $tank2_kill, $account_id);
$quest->triggerQuest(QUEST_SUM_PISTOLKILL, 2, $pistol_kill, $account_id); $quest->triggerQuest(QUEST_SUM_TANK3KILL, 2, $tank3_kill, $account_id);
$quest->triggerQuest(QUEST_SUM_SUBMACKILL, 2, $submachine_kill, $account_id); if ($rank <= 5) {
if ($team_status == 1 && $rank <= 5) {
$quest->triggerQuest(QUEST_DAY_RANK, 1, 1, $account_id); $quest->triggerQuest(QUEST_DAY_RANK, 1, 1, $account_id);
} }
if ($team_status == 0 && $rank == 1) { if ($rank == 1) {
$quest->triggerQuest(QUEST_SUM_WIM, 2, 1, $account_id); $quest->triggerQuest(QUEST_SUM_WIM, 2, 1, $account_id);
} }
if ($team_status == 1) {
$quest->triggerQuest(QUEST_DAY_TEAM, 1, 1, $account_id);
$quest->triggerQuest(QUEST_SUM_TEAM, 2, 1, $account_id);
if ($rank == 1) {
$quest->triggerQuest(QUEST_SUM_TEAMWIN, 2, 1, $account_id);
}
}
//额外奖励 //额外奖励
$times = $this->getRewardTimes($coin_num); $times = $this->getRewardTimes($coin_num);
$extra_coin = $coin_num * ($times - 1); $extra_coin = $coin_num * ($times - 1);
@ -317,7 +303,6 @@ class RoleController{
'kill_his' => $kill_his, 'kill_his' => $kill_his,
'alive_time_his' => $alive_time_his, 'alive_time_his' => $alive_time_his,
'harm_his' => $harm_his, 'harm_his' => $harm_his,
'add_HP_his' => $add_HP_his,
'extra_drop' => $extra_drop 'extra_drop' => $extra_drop
)); ));
} }

View File

@ -179,7 +179,7 @@ class SkinController{
' WHERE accountid=:account_id;', ' WHERE accountid=:account_id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
':diamond_num' => $row['diamond_num'] - $num, ':diamond_num' => $rowDiamond['diamond_num'] - $num,
':modify_time' => time() ':modify_time' => time()
)); ));
if (!$retDiamond) { if (!$retDiamond) {

View File

@ -1,5 +1,7 @@
<?php <?php
require 'classes/Quest.php';
class TankController{ class TankController{
protected function getMysql($account_id) protected function getMysql($account_id)
@ -10,7 +12,7 @@ class TankController{
'port' => $mysql_conf['port'], 'port' => $mysql_conf['port'],
'user' => $mysql_conf['user'], 'user' => $mysql_conf['user'],
'passwd' => $mysql_conf['passwd'], 'passwd' => $mysql_conf['passwd'],
'dbname' => 'gamedb2001_' . $mysql_conf['instance_id'] 'dbname' => 'gamedb2002_' . $mysql_conf['instance_id']
)); ));
return $conn; return $conn;
} }
@ -26,6 +28,8 @@ class TankController{
'cost' => $tank_meta['cost'], 'cost' => $tank_meta['cost'],
'cost_int' => $tank_meta['cost_int'], 'cost_int' => $tank_meta['cost_int'],
'max_lv' => $tank_meta['max_lv'], 'max_lv' => $tank_meta['max_lv'],
'compose' => $skin_conf['compose'],
'debris' => $skin_conf['debris'],
); );
return $t; return $t;
} }
@ -79,7 +83,7 @@ class TankController{
die(); die();
} }
$ret = $conn->execScript('UPDATE tank SET skin_status=0, modify_time=:modify_time ' . $ret = $conn->execScript('UPDATE tank SET skin_status=0, modify_time=:modify_time ' .
' WHERE accountid=:account_id AND tank_id=20001;', ' WHERE accountid=:account_id AND tank_id=15001;',
array( array(
':account_id' => $row['accountid'], ':account_id' => $row['accountid'],
':modify_time' => time() ':modify_time' => time()
@ -105,7 +109,7 @@ class TankController{
return; return;
} }
$tank_meta_table = require('../res/tank@tank.php'); $tank_meta_table = require('../res/tank@tank.php');
$t = $this->getTank(20001); $t = $this->getTank(15001);
if(!$t){ if(!$t){
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个坦克'); phpcommon\sendError(ERR_USER_BASE + 1,'没有这个坦克');
return; return;
@ -116,23 +120,24 @@ class TankController{
':account_id' => $account_id ':account_id' => $account_id
)); ));
if ($rowCount == 0) { if ($rowCount == 0) {
for ($i = 20001; $i <= count($tank_meta_table) + 20000; $i++) { for ($i = 15001; $i <= count($tank_meta_table) + 15000; $i++) {
$t = $this->getTank($i); $t = $this->getTank($i);
if (!$t) { if (!$t) {
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个坦克'); phpcommon\sendError(ERR_USER_BASE + 1,'没有这个坦克');
return; return;
} }
if ($i == 20000) { if ($i == 15001) {
$tank_status = 0; $tank_status = 0;
} else { } else {
$tank_status = 2; $tank_status = 2;
} }
$ret = $conn->execScript('INSERT INTO tank(accountid, tank_id, tank_status, active_time, tank_level, experience_level, experience_type, create_time, modify_time) ' . $ret = $conn->execScript('INSERT INTO tank(accountid, tank_id, tank_status, fragment_id, fragment_num, active_time, tank_level, experience_level, experience_type, create_time, modify_time) ' .
' VALUES(:account_id, :tank_id, :tank_status, 0, 1, 0, 0, :create_time, :modify_time) ' . ' VALUES(:account_id, :tank_id, :tank_status, :fragment_id, 0, 0, 1, 0, 0, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:account_id, tank_id=:tank_id, tank_status=:tank_status, active_time=0, tank_level=1, experience_level=0, experience_type=0, modify_time=:modify_time;', ' ON DUPLICATE KEY UPDATE accountid=:account_id, tank_id=:tank_id, tank_status=:tank_status, fragment_id=:fragment_id, fragment_num=0, active_time=0, tank_level=1, experience_level=0, experience_type=0, modify_time=:modify_time;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
':tank_id' => $i, ':tank_id' => $i,
':fragment_id' => $t['debris'],
':tank_status' => $tank_status, ':tank_status' => $tank_status,
':create_time' => time(), ':create_time' => time(),
':modify_time' => time() ':modify_time' => time()
@ -167,15 +172,17 @@ class TankController{
} }
$tank_id = $rowTank['tank_id']; $tank_id = $rowTank['tank_id'];
if ($rowTank['active_time'] != 0) { if ($rowTank['active_time'] != 0) {
$tank_level = $rowSkin['experience_level']; $tank_level = $rowTank['experience_level'];
} else { } else {
$tank_level = $rowSkin['tank_level']; $tank_level = $rowTank['tank_level'];
} }
array_push($tank_list, array( array_push($tank_list, array(
'tank_id' => $rowTank['tank_id'], 'tank_id' => $rowTank['tank_id'],
'tank_level' => $tank_level, 'tank_level' => $tank_level,
'active_time' => $rowTank['active_time'], 'active_time' => $rowTank['active_time'],
'tank_status' => $rowTank['tank_status'], 'tank_status' => $rowTank['tank_status'],
'fragment_id' => $rowTank['fragment_id'],
'fragment_num' => $rowTank['fragment_num'],
)); ));
} }
echo json_encode(array( echo json_encode(array(
@ -206,7 +213,7 @@ class TankController{
phpcommon\sendError(ERR_USER_BASE + 2,'没有这个坦克'); phpcommon\sendError(ERR_USER_BASE + 2,'没有这个坦克');
return; return;
} }
$row = $conn->execQueryOne('SELECT tank_status FROM tank WHERE accountid=:account_id AND tank_id=:tank_id;', $row = $conn->execQueryOne('SELECT tank_status, fragment_num, fragment_id FROM tank WHERE accountid=:account_id AND tank_id=:tank_id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
':tank_id' => $tank_id ':tank_id' => $tank_id
@ -219,36 +226,19 @@ class TankController{
phpcommon\sendError(ERR_USER_BASE + 4,'坦克已解锁'); phpcommon\sendError(ERR_USER_BASE + 4,'坦克已解锁');
return; return;
} }
$num = $t['price']; $num = 0;
$rowDiamond = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:account_id;', $array = $this->getExplode($t['compose']);
array( if ($row['fragment_num'] < $array[0][1]) {
':account_id' => $account_id, phpcommon\sendError(ERR_USER_BASE + 2,'坦克碎片数量不足');
));
if (!$rowDiamond) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return; return;
} }
if ($num > $rowDiamond['diamond_num']) { $fragment_num = $row['fragment_num'] - $array[0][1];
phpcommon\sendError(ERR_USER_BASE + 5, '钻石不足'); $ret = $conn->execScript('UPDATE tank SET tank_status=1, fragment_num=:fragment_num, modify_time=:modify_time ' .
return;
}
$retDiamond = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
' WHERE accountid=:account_id;',
array(
':account_id' => $account_id,
':diamond_num' => $row['diamond_num'] - $num,
':modify_time' => time()
));
if (!$retDiamond) {
die();
return;
}
$ret = $conn->execScript('UPDATE tank SET tank_status=1, modify_time=:modify_time ' .
' WHERE accountid=:account_id AND tank_id=:tank_id;', ' WHERE accountid=:account_id AND tank_id=:tank_id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
':tank_id' => $tank_id, ':tank_id' => $tank_id,
':fragment_num' => $fragment_num,
':modify_time' => time() ':modify_time' => time()
)); ));
if (!$ret) { if (!$ret) {
@ -259,7 +249,9 @@ class TankController{
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
"tank_id" => $tank_id, "tank_id" => $tank_id,
"tank_status" => $tank_status, "tank_status" => 1,
"fragment_id" => $row['fragment_id'],
"fragment_num" => $fragment_num,
)); ));
} }
@ -423,7 +415,7 @@ class TankController{
} }
$tank_id = $_REQUEST['tank_id']; $tank_id = $_REQUEST['tank_id'];
$free = $_REQUEST['free']; $free = $_REQUEST['free'];
$row = $conn->execQueryOne('SELECT tank_level FROM tank WHERE accountid=:account_id AND tank_id=:tank_id;', $row = $conn->execQueryOne('SELECT tank_level, fragment_num fragment_id FROM tank WHERE accountid=:account_id AND tank_id=:tank_id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
':tank_id' => $tank_id ':tank_id' => $tank_id
@ -441,31 +433,12 @@ class TankController{
phpcommon\sendError(ERR_USER_BASE + 3, '坦克已到满级'); phpcommon\sendError(ERR_USER_BASE + 3, '坦克已到满级');
return; return;
} }
$rowCoin = $conn->execQueryOne('SELECT coin_num FROM user WHERE accountid=:account_id;',
array(
':account_id' => $account_id,
));
if (!$rowCoin) {
phpcommon\sendError(ERR_USER_BASE + 1, '指挥官不存在');
return;
}
$coin_num = $t['cost'] * ceil($row['tank_level'] / 5) + $t['cost_int']; $coin_num = $t['cost'] * ceil($row['tank_level'] / 5) + $t['cost_int'];
if ($free == 1) { if ($free == 1) {
$coin_num = 0; $coin_num = 0;
} }
if ($coin_num > $rowCoin['coin_num']) { if ($coin_num > $row['fragment_num'] ){
phpcommon\sendError(ERR_USER_BASE + 6, '金币不足'); phpcommon\sendError(ERR_USER_BASE + 4, '坦克碎片数量不足');
return;
}
$retCoin = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' .
' WHERE accountid=:account_id;',
array(
':account_id' => $account_id,
':coin_num' => $row['coin_num'] - $coin_num,
':modify_time' => time()
));
if (!$retCoin) {
die();
return; return;
} }
$ret = $conn->execScript('UPDATE tank SET tank_level=:tank_level, modify_time=:modify_time ' . $ret = $conn->execScript('UPDATE tank SET tank_level=:tank_level, modify_time=:modify_time ' .
@ -474,17 +447,25 @@ class TankController{
':account_id' => $account_id, ':account_id' => $account_id,
':tank_id' => $tank_id, ':tank_id' => $tank_id,
':tank_level' => $row['tank_level'] + 1, ':tank_level' => $row['tank_level'] + 1,
':fragment_num' => $row['fragment_num'] - $coin_num,
':modify_time' => time() ':modify_time' => time()
)); ));
if (!$ret) { if (!$ret) {
die(); die();
return; return;
} }
$quest = new classes\Quest();
$quest->triggerQuest(QUEST_DAY_UPDATETANK, 1, 1, $account_id);
if ($row['tank_level'] + 1 >= $t['max_lv']) {
$quest->triggerQuest(QUEST_SUM_TANKMAX, 2, 1, $account_id);
}
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'tank_id' => $row['tank_id'], 'tank_id' => $row['tank_id'],
'tank_level' => $row['tank_level'] + 1, 'tank_level' => $row['tank_level'] + 1,
"fragment_id" => $row['fragment_id'],
"fragment_num" => $row['fragment_num'] - $coin_num,
)); ));
} }
} }