每日福利 改钻石抽

This commit is contained in:
yangduo 2024-12-19 00:09:56 +08:00
parent 9a72912fa1
commit 47b1222d4d
2 changed files with 68 additions and 0 deletions

View File

@ -100,6 +100,7 @@ define('CLAN_VIDEO_DIAMOND', 165); //观看视频,领取的钻石数量
define('CLAN_DIAMOND', 164); //创建战队需要的钻石数量
define('OPENING_SPEAR', 154); //新玩家奖励第一把武器
define('OPENING_SPEAR2', 178); //新玩家奖励第二把武器
define('LOTTERY_COST', 187); //每日抽奖钻石消耗
require 'config_loader.php';

View File

@ -189,10 +189,12 @@ class ActivityController{
//刷新次数
$p_free = $this->getParameter(FREELOTTERY_TIME);
$p_video = $this->getParameter(VIDEOLOTTERY_TIME);
$costlist = $this->getParameter(LOTTERY_COST);
$free_times = $p_free['value'];
$video_times = $p_video['value'];
$flush_flag = 0;
$now_days = 1;
$cur_cost = -1;
$row = $conn->execQueryOne('SELECT free_times, video_times, now_days, modify_time FROM activity WHERE accountid=:accountid;',
array(
':accountid' => $account_id
@ -234,6 +236,17 @@ class ActivityController{
$video_times = $p_video['value'];
}
}
$coststrs = explode("|", $costlist['value']);
$costlen = sizeof($coststrs);
$left = $free_times + $video_times;
if ($left > 0) {
if ($costlen >= $left) {
$cur_cost = $coststrs[$costlen - $left];
} else {
$cur_cost = $coststrs[$costlen - 1];
}
}
//道具物品
$user_db_str = $r->get($draw_uuid);
if (empty($user_db_str)) {
@ -292,6 +305,7 @@ class ActivityController{
'draw_uuid' => $draw_uuid,
'free_times' => $free_times,
'video_times' => $video_times,
'cur_price' => $cur_cost,
'item_list' => $draw_list,
));
}
@ -318,6 +332,18 @@ class ActivityController{
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
$p_free = $this->getParameter(FREELOTTERY_TIME);
$p_video = $this->getParameter(VIDEOLOTTERY_TIME);
$costlist = $this->getParameter(LOTTERY_COST);
$free_times = $p_free['value'];
$video_times = $p_video['value'];
$left = $free_times + $video_times - $row['free_times'] - $row['video_times'];
if ($left < 1) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
//随机确认奖励
$weight_sum = 0;
$g_conf_lot_cluster = require('../res/lottery@lottery.php');
@ -407,6 +433,47 @@ class ActivityController{
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个物品');
return;
}
//扣钻石
$cur_cost = 0;
$coststrs = explode("|", $costlist['value']);
$costlen = sizeof($coststrs);
if ($costlen >= $left) {
$cur_cost = intval($coststrs[$costlen - $left]);
} else if ($costlen > 0) {
$cur_cost = intval($coststrs[$costlen - 1]);
}
if ($cur_cost > 0) {
$row = $conn->execQueryOne(
'SELECT diamond_num, first_gift, free_coin, free_diamond FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
)
);
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
//扣除钻石
if ($row['diamond_num'] < $cur_cost) {
phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足');
return;
}
$ret = $conn->execScript(
'UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':diamond_num' => $row['diamond_num'] - $cur_cost,
':modify_time' => time()
)
);
if (!$ret) {
die();
return;
}
}
//增加奖励
$addreward = new classes\AddReward();
$all_item_list = $addreward->addReward($item_id, $item_num, $account_id, $time, 0);