This commit is contained in:
aozhiwei 2020-08-18 21:36:15 +08:00
parent df81f15fed
commit 0b7b1219e9
7 changed files with 239 additions and 134 deletions

2
.gitignore vendored
View File

@ -10,4 +10,4 @@
target
config/
__pycache__/
res/

1
res
View File

@ -1 +0,0 @@
config

View File

@ -124,7 +124,7 @@ class EquipController{
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) ' .
' VALUES(:account_id, :id, 0, :status, 200, :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,
@ -140,6 +140,7 @@ class EquipController{
'active_time' => 0,
'using_id' => $id,
'exp' => 0,
'time_flag' => 0,
));
} else {
if (count($rows) == 1) {
@ -155,28 +156,38 @@ class EquipController{
$using_id = $id;
if ($flag == 1) {
$lv = $row['lv'];
$active_time = $row['active_time'] + $row['sub_time'];
} else {
$lv = 0;
$active_time = 0;
}
array_push($equip_list, array(
'id' => $id,
'lv' => $lv,
'active_time' => 0,
'using_id' => $using_id,
'exp' => $row['exp'],
));
$ret = $conn->execScript('UPDATE equip SET id=:id, using_id=:using_id, lv=:lv ' .
' WHERE accountid=:accountid;',
$time_flag = 0;
$time = $row['active_time'] + $row['sub_time'];
if (time() >= $time && $row['sub_time'] != 0) {
$ret1 = $conn->execScript('UPDATE equip SET active_time=0, sub_time=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid AND id=:id;',
array(
':accountid' => $account_id,
':modify_time' => time(),
':id' => $id,
':using_id' => $using_id,
':lv' => $lv
));
if (!$ret) {
if (!$ret1) {
die();
return;
}
$time = 0;
$time_flag = 1;
$active_time = 0;
}
array_push($equip_list, array(
'id' => $id,
'lv' => $lv,
'active_time' => $active_time,
'using_id' => $using_id,
'exp' => $row['exp'],
'time_flag' => $time_flag,
));
}
if ($flag == 0) {
//更新老玩家数据
@ -210,19 +221,38 @@ class EquipController{
'active_time' => 0,
'using_id' => $using_id,
'exp' => 0,
'time_flag' => 0,
));
}
}
} else {
//装备信息
foreach ($rows as $row) {
$time_flag = 0;
$id = $addreward->getRealIndexid($row['id'], $account_id);
$time = $row['active_time'] + $row['sub_time'];
if (time() >= $time && $row['sub_time'] != 0) {
$ret1 = $conn->execScript('UPDATE equip SET active_time=0, sub_time=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid AND id=:id;',
array(
':accountid' => $account_id,
':modify_time' => time(),
':id' => $row['id'],
));
if (!$ret1) {
die();
return;
}
$time = 0;
$time_flag = 1;
}
array_push($equip_list, array(
'id' => $id,
'lv' => $row['lv'],
'active_time' => 0,
'active_time' => $time,
'using_id' => $row['using_id'],
'exp' => $row['exp'],
'time_flag' => $time_flag
));
}
}
@ -231,7 +261,6 @@ class EquipController{
'errcode' => 0,
'errmsg' => '',
'equip_list' => $equip_list,
'time_flag' => 0,
));
}
@ -501,37 +530,32 @@ class EquipController{
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
$id = 0;
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
}
$type = $_REQUEST['type'];
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id;',
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND id=:id;',
array(
':account_id' => $account_id
':account_id' => $account_id,
':id' => $id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$e1 = $this->getEquip($row['id']);
$last_id = $e1['upgrade_priority'];
$id = 0;
$g_conf_lot_cluster = require('../res/equip@equip.php');
for ($i = 0; $i < count($g_conf_lot_cluster); $i++) {
$ec = $this->getEquip(12100 + $i);
if (!$ec || empty($ec['upgrade_priority'])) {
continue;
}
if ($ec['upgrade_priority'] == (int)$last_id - 1) {
$id = $ec['id'];
break;
}
}
$e = $this->getEquip($id);
if (!$e) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
return;
}
$view_list = $this->getExplode($e['reduce_time']);
$reduce_time = $view_list[$row['lv'] - 1][0];
$flag = 0;
//error_log($e['reduce_time']);
$sub_time = $row['sub_time'] - floor($row['sub_time'] * $e['reduce_time'] * 0.01);
$sub_time = $row['sub_time'] - floor($row['sub_time'] * $reduce_time * 0.01);
if ($type == 1) {
$rowUser = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:account_id;',
array(
@ -541,16 +565,20 @@ class EquipController{
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
if ($rowUser['diamond_num'] < $e['diamond_cost']) {
$diamond_arr = $this->getExplode($e['diamond_cost']);
$diamond_cost = $diamond_arr[$row['lv'] - 1][0];
if ($rowUser['diamond_num'] < $diamond_cost) {
phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足');
return;
}
$sub_time = $row['sub_time'] - floor($row['sub_time'] * $e['diamond_time'] * 0.01);
$diamond_list = $this->getExplode($e['diamond_time']);
$diamond_time = $diamond_list[$row['lv'] - 1][0];
$sub_time = $row['sub_time'] - floor($row['sub_time'] * $diamond_time * 0.01);
$retUser = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':diamond_num' => $rowUser['diamond_num'] - $e['diamond_cost'],
':diamond_num' => $rowUser['diamond_num'] - $diamond_cost,
':modify_time' => time()
));
if (!$retUser) {
@ -559,22 +587,21 @@ class EquipController{
}
}
$active_time = $row['active_time'];
$using_id = $row['using_id'];
if ($active_time + $sub_time <= time()) {
$active_time = 0;
$flag = 1;
}
if ($sub_time == 0) {
$flag = 1;
$using_id = $row['id'];
}
$retEquip = $conn->execScript('UPDATE equip SET active_time=:active_time, using_id=:using_id, sub_time=:sub_time, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
$retEquip = $conn->execScript('UPDATE equip SET active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time ' .
' WHERE accountid=:accountid AND id=:id;',
array(
':accountid' => $account_id,
':active_time' => $active_time,
':sub_time' => $sub_time,
':modify_time' => time(),
':using_id' => $using_id,
':id' => $id,
));
if (!$retEquip) {
die();
@ -586,9 +613,9 @@ class EquipController{
'errcode' => 0,
'errmsg' => '',
'diamond_nums' => $num,
'active_time' => $active_time,
'flag' => $flag,
'id' => $row['id'],
'lv' => $row['lv'],
));
}
@ -653,7 +680,7 @@ class EquipController{
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT id, using_id, lv FROM equip WHERE accountid=:account_id AND id=:id;',
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND id=:id;',
array(
':account_id' => $account_id,
':id' => $equip_id
@ -681,7 +708,8 @@ class EquipController{
'errcode' => 0,
'errmsg' => '',
'using_id' => $equip_id,
'lv' => $lv
'lv' => $lv,
'active_time' => $row['active_time'] + $row['sub_time'],
));
}
@ -994,16 +1022,24 @@ class EquipController{
$this->subCoin(10001, $coin_num, $account_id);
$this->subCoin($mid, $mnum, $account_id);
error_log($lv);
error_log($equip_id);
$ret = $conn->execScript('UPDATE equip SET exp=:exp, lv=:lv, modify_time=:modify_time ' .
$active_time = time();
$sub_list = $this->getExplode($e['equip_upgradetime']);
$sub_time = $sub_list[$lv][0];
if ($sub_time == 0) {
$active_time = 0;
$flag = 1;
}
$ret = $conn->execScript('UPDATE equip SET exp=:exp, lv=:lv, modify_time=:modify_time, active_time=:active_time, sub_time=:sub_time ' .
' WHERE accountid=:accountid AND id=:id;',
array(
':accountid' => $account_id,
':id' => $equip_id,
':modify_time' => time(),
':exp' => 0,
':lv' => $lv + 1
':lv' => $lv + 1,
':active_time' => $active_time,
':sub_time' => $sub_time
));
if (!$ret) {
die();
@ -1018,8 +1054,8 @@ class EquipController{
'exp' => 0,
'lv' => $lv + 1,
'coin_nums' => $coin_num,
'diamond_nums' => $num
'diamond_nums' => $num,
'flag' => $flag,
));
}
}

View File

@ -170,6 +170,8 @@ class GameOverController{
'item_num' => $num,
'time' => 0,
));
$first_list = $this->randomBox($first_list, 8);
$first_list = $this->randomBox($first_list, 9);
} else {
$first_list = $this->randomReward($rank, $type);
}
@ -208,7 +210,7 @@ class GameOverController{
$item_list = array();
$all_item_list = array();
if ($type == 0) {
$item_list = $this->fixReward($item_list);
$item_list = $this->fixReward($item_list, 5);
} else {
$r = $this->getRedis($first_uuid);
$user_db_str = $r->get($first_uuid);
@ -245,9 +247,9 @@ class GameOverController{
));
}
protected function fixReward($item_list)
protected function fixReward($item_list, $type)
{
$b1 = $this->getbox(5);
$b1 = $this->getbox($type);
if (!$b1) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
die();
@ -270,6 +272,44 @@ class GameOverController{
return $item_list;
}
protected function randomBox($item_list, $type) {
$b1 = $this->getbox($type);
if (!$b1) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
die();
}
$fixed_id = $this->getExplode($b1['item_id']);
$fixed_time = $this->getExplode($b1['time']);
$fixed_num = $this->getExplode($b1['num']);
$fixed_array = $this->getExplode($b1['weight']);
$sum = 0;
for($i = 0; $i < count($fixed_array); $i++) {
$sum = $fixed_array[$i][0] + $sum;
}
$rm = Rand(0, $sum);
$key = 0;
for($j = 0; $j < count($fixed_array); $j++) {
$key = $fixed_array[$j][0] + $key;
if ($key >= $rm) {
array_push($item_list, array(
'item_id' => $fixed_id[$j][0],
'item_num' => $fixed_num[$j][0],
'time' => $fixed_time[$j][0]
));
if ($type == 8) {
array_push($item_list, array(
'item_id' => $fixed_id[$j][0] + 2000,
'item_num' => $fixed_num[$j][0],
'time' => $fixed_time[$j][0]
));
}
break;
}
}
return $item_list;
}
protected function randomReward($rank,$type)
{
//随机奖励

View File

@ -143,6 +143,21 @@ class RoleController{
return $d;
}
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'],
'promote_gold' => $equip_conf['promote_gold'],
);
return $e;
}
public function roleInfo()
{
$account_id = $_REQUEST['account_id'];
@ -1329,15 +1344,33 @@ class RoleController{
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$rowEquip = $conn->execQueryOne('SELECT id FROM equip WHERE accountid=:accountid;',
$row = $conn->execQueryOne('SELECT using_id FROM equip WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个装备');
return;
}
$id = 0;
if (isset($_REQUEST['id'])) {
$id = $row['using_id'];
} else {
$id = $_REQUEST['id'];
}
$rowEquip = $conn->execQueryOne('SELECT id, lv FROM equip WHERE accountid=:accountid AND id=:id;',
array(
':accountid' => $account_id,
':id' => $id,
));
if (!$rowEquip) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个装备');
return;
}
$coin_times = $rowUser['coin_times'];
$p1 = $this->getParameter(DAILYCOIN_TIMES);
$max_times = $p1['param_value'];
@ -1347,16 +1380,23 @@ class RoleController{
$num = $p3['param_value'];
$e = $this->getEquipUp($rowEquip['id']);
if (!$e) {
$eg = $this->getEquip($rowEquip['id']);
if (!$e || !$eg) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个装备');
return;
}
$coin_num = $e['coin_num'];
if (isset($_REQUEST['num'])) {
$coin_num = $_REQUEST['num'];
} else {
$coin_list = $this->getExplode($e['coin_num']);
$coin_arr = $this->getExplode($eg['promote_gold']);
$coin_num = $coin_list[$rowEquip['lv']][0] * $coin_arr[$rowEquip['lv']][0];
}
if ($coin_times >= $max_times) {
phpcommon\sendError(ERR_USER_BASE + 2, '今日次数达到上限');
return;
}
//$coin_num = $_REQUEST['num'];
//$coin_num = round($num * pow($val, $coin_times));
//error_log($coin_num);
$ret = $conn->execScript('UPDATE user SET coin_times=:coin_times, coin_num=:coin_num, modify_time=:modify_time ' .

View File

@ -67,6 +67,7 @@ class ShareController{
'id' => $share_meta['id'],
'rewards' => $share_meta['rewards'],
'people' => $share_meta['people'],
'type' => $share_meta['type'],
);
return $sh;
}
@ -429,7 +430,12 @@ class ShareController{
$share_meta_table = require('../res/share@share.php');
if (count($rows) == 0) {
$num = count($rows) + 1;
$type = 1;
for ($i = $num; $i <= count($share_meta_table); $i++) {
$s = $this->getShare($i);
if (!$s || $s['type'] != $type) {
continue;
}
$id = $i;
$ret = $conn->execScript('INSERT INTO share_achievement(accountid, ach_id, status, create_time, modify_time) ' .
' VALUES(:account_id, :ach_id, :status, :create_time, :modify_time) ' .
@ -470,6 +476,7 @@ class ShareController{
));
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',

View File

@ -60,6 +60,18 @@ class SignController{
return $it;
}
protected function getShare($share_id)
{
$share_meta_table = require('../res/share@share.php');
$share_meta = getShareConfig($share_meta_table, $share_id);
$sh = array(
'id' => $share_meta['id'],
'rewards' => $share_meta['rewards'],
'people' => $share_meta['people'],
'type' => $share_meta['type'],
);
return $sh;
}
protected function getSeason($season_id)
{
@ -516,85 +528,56 @@ class SignController{
die();
}
//刷新邀请好友奖励
$rowShare = $conn->execQueryOne('SELECT status FROM share_achievement WHERE accountid=:accountid AND ach_id=3;',
$rowShare = $conn->execQuery('SELECT ach_id, status FROM share_achievement WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
$order = 0;
if ($rowShare['status'] == 1) {
$order = 3;
$share1 = $conn->execScript('DELETE from share_achievement ' .
' WHERE accountid=:accountid AND ach_id<=3;',
array(
':accountid' => $account_id,
));
$lastid = 0;
foreach ($rowShare as $rs) {
if ($rs['status'] == 1) {
$order++;
}
$share_ret = $conn->execScript('UPDATE share_achievement SET status=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid AND ach_id>:ach_id;',
$lastid = $rs['ach_id'];
}
if ($order >= count($rowShare)) {
//更新新的邀请列表
$s = $this->getShare($lastid);
if (!$s) {
die();
}
$share_meta_table = require('../res/share@share.php');
$type = $s['type'] + 1;
if ($lastid >= count($share_meta_table)) {
$type = $s['type'];
}
$count = 0;
for ($i = 1; $i <= count($share_meta_table); $i++) {
$s1 = $this->getShare($i);
if (!$s1 || $s1['type'] != $type) {
continue;
}
$id = $i;
$updateid = $rowShare[$count]['ach_id'];
$count++;
$share_ret = $conn->execScript('UPDATE share_achievement SET ach_id=:ach_id, status=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid AND ach_id=:id;',
array(
':accountid' => $account_id,
':modify_time' => time(),
':ach_id' => $id,
':id' => $updateid
));
}
} else {
$share_ret = $conn->execScript('UPDATE share_achievement SET status=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => time(),
':ach_id' => $order
));
if (!$share_ret && !$share1) {
die();
}
}
// protected function updateSeasonStatus($account_id)
// {
// $conn = $this->getMysql($account_id);
// if (!$conn) {
// phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
// die();
// }
// //刷新赛季奖励状态
// $rowUser = $conn->execQueryOne('SELECT season_time, pass_status, integral ' .
// ' FROM user WHERE accountid=:accountid;',
// array(
// ':accountid' => $account_id,
// ));
// if (time() > $rowUser['season_time']) {
// $season_meta_table = require('../res/season@season.php');
// $end_time = 0;
// for ($i = 1; $i <= count($season_meta_table); $i++) {
// $season = $this->getSeason($i);
// if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
// $end_time = strtotime($season['end_time']);
// break;
// }
// }
// $season_point_table = require('../res/seasomPoint@seasomPoint.php');
// $integral = 0;
// for ($j = 1; $j <= count($season_point_table); $j++) {
// $seasonpoint = $this->getSeasonPoint($j);
// if ($rowUser['integral'] <= $seasonpoint['max']) {
// $integral = $seasonpoint['topoint'];
// break;
// }
// }
// $user_ret = $conn->execScript('UPDATE user SET pass_status=0, score=0, season_status=0, integral=:integral, season_end_score=:season_end_score, modify_time=:modify_time, season_games=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, season_win=0, season_time=:season_time ' .
// ' WHERE accountid=:accountid;',
// array(
// ':accountid' => $account_id,
// ':season_end_score' => $rowUser['integral'],
// ':modify_time' => time(),
// ':season_time' => $end_time,
// ':integral' => $integral
// ));
// if (!$user_ret) {
// die();
// }
// $pass_ret = $conn->execScript('UPDATE passinfo SET active_status=0, honor_status=0, modify_time=:modify_time ' .
// ' WHERE accountid=:accountid;',
// array(
// ':accountid' => $account_id,
// ':modify_time' => time()
// ));
// if (!$pass_ret) {
// die();
// }
// }
// }
protected function updateWeekReward($account_id)
{