1
This commit is contained in:
parent
c8b2fdb57a
commit
a4ce44cd28
@ -53,34 +53,35 @@ class Quest{
|
|||||||
':quest_type' => $quest_type,
|
':quest_type' => $quest_type,
|
||||||
));
|
));
|
||||||
if ($row) {
|
if ($row) {
|
||||||
if ($q['condition'] == 7 && $quest_type == 1) {
|
if ($row['quest_state'] == 0) {
|
||||||
if($quest_num <= $q['value']) {
|
if ($q['condition'] == 7 && $quest_type == 1) {
|
||||||
$quest_state = 1;
|
if($quest_num <= $q['value']) {
|
||||||
$this->triggerQuest(71013, 1, 1, $account_id);
|
$quest_state = 1;
|
||||||
}
|
$this->triggerQuest(71013, 1, 1, $account_id);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if ($row['quest_num'] + $quest_num >= $q['value']) {
|
|
||||||
$quest_num = $q['value'];
|
|
||||||
$quest_state = 1;
|
|
||||||
$this->triggerQuest(71013, 1, 1, $account_id);
|
|
||||||
} else {
|
} else {
|
||||||
$quest_num = $row['quest_num'] + $quest_num;
|
if ($row['quest_num'] + $quest_num >= $q['value']) {
|
||||||
$quest_state = 0;
|
$quest_num = $q['value'];
|
||||||
|
$quest_state = 1;
|
||||||
|
$this->triggerQuest(71013, 1, 1, $account_id);
|
||||||
|
} else {
|
||||||
|
$quest_num = $row['quest_num'] + $quest_num;
|
||||||
|
$quest_state = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ret = $conn->execScript('UPDATE quest SET quest_num=:quest_num, quest_state=:quest_state ' .
|
||||||
|
' WHERE accountid=:accountid AND quest_id =:quest_id AND quest_type=:quest_type;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':quest_id' => $quest_id,
|
||||||
|
':quest_type' => $quest_type,
|
||||||
|
':quest_num' => $quest_num,
|
||||||
|
':quest_state' => $quest_state
|
||||||
|
));
|
||||||
|
if (!$ret) {
|
||||||
|
die();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$ret = $conn->execScript('UPDATE quest SET quest_num=:quest_num, quest_state=:quest_state ' .
|
|
||||||
' WHERE accountid=:accountid AND quest_id =:quest_id AND quest_type=:quest_type;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':quest_id' => $quest_id,
|
|
||||||
':quest_type' => $quest_type,
|
|
||||||
':quest_num' => $quest_num,
|
|
||||||
':quest_state' => $quest_state
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -105,6 +105,10 @@ class EquipController{
|
|||||||
$equip_id = $_REQUEST['equip_id'];
|
$equip_id = $_REQUEST['equip_id'];
|
||||||
$coin_num = $_REQUEST['coin_num'];
|
$coin_num = $_REQUEST['coin_num'];
|
||||||
$equip_level = $_REQUEST['equip_level'];
|
$equip_level = $_REQUEST['equip_level'];
|
||||||
|
if ($equip_level >= 10) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 4, '装备已到满级');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$e = $this->getEquip($equip_id * 10 + $equip_level);
|
$e = $this->getEquip($equip_id * 10 + $equip_level);
|
||||||
if (!$e) {
|
if (!$e) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
|
||||||
@ -114,10 +118,6 @@ class EquipController{
|
|||||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($e['equip_level'] >= 10) {
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 4, '装备已到满级');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND equip_id=:equip_id;',
|
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND equip_id=:equip_id;',
|
||||||
array(
|
array(
|
||||||
':account_id' => $account_id,
|
':account_id' => $account_id,
|
||||||
|
@ -45,6 +45,33 @@ class QuestController{
|
|||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getExplode($string)
|
||||||
|
{
|
||||||
|
$delim = "|";
|
||||||
|
$drop_multiply = explode($delim, $string);
|
||||||
|
$delim1 = ":";
|
||||||
|
$arr = array();
|
||||||
|
for ($i = 0; $i < count($drop_multiply); $i++) {
|
||||||
|
$mul = explode($delim1, $drop_multiply[$i]);
|
||||||
|
array_push($arr, $mul);
|
||||||
|
}
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getDrop($drop_id)
|
||||||
|
{
|
||||||
|
$g_conf_drop_cluster = require('../config/game2001api.drop.cluster.php');
|
||||||
|
$drop_conf = getDropConfig($g_conf_drop_cluster, $drop_id);
|
||||||
|
$d = array(
|
||||||
|
'drop_id' => $drop_conf['drop_id'],
|
||||||
|
'item_id' => $drop_conf['item_id'],
|
||||||
|
'num' => $drop_conf['num'],
|
||||||
|
'weight' => $drop_conf['weight'],
|
||||||
|
'type' => $drop_conf['type']
|
||||||
|
);
|
||||||
|
return $d;
|
||||||
|
}
|
||||||
|
|
||||||
protected function insertActive($account_id)
|
protected function insertActive($account_id)
|
||||||
{
|
{
|
||||||
$conn = $this->getMysql($account_id);
|
$conn = $this->getMysql($account_id);
|
||||||
@ -260,11 +287,6 @@ class QuestController{
|
|||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$q = $this->getQuest($quest_id);
|
|
||||||
if (!$q) {
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个任务');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$row = $conn->execQueryOne('SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id AND quest_type=:quest_type;',
|
$row = $conn->execQueryOne('SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id AND quest_type=:quest_type;',
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
@ -288,11 +310,51 @@ class QuestController{
|
|||||||
die();
|
die();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($q['condition'] == 13) {
|
|
||||||
$this->triggerQuest($quest_id, $quest_type, 1, $account_id);
|
|
||||||
}
|
|
||||||
//发奖励
|
|
||||||
|
|
||||||
|
//发奖励
|
||||||
|
$reward = $q['gold'];
|
||||||
|
if ($quest_type == 0) {
|
||||||
|
$t = $this->getTaskReward($quest_id);
|
||||||
|
if (!$t) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个任务');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$d = $this->getDrop($t['reward']);
|
||||||
|
if (!$d) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$weight_sum = 0;
|
||||||
|
$weight_array = $this->getExplode($d['weight']);
|
||||||
|
for ($i = 0; $i < count($weight_array); $i++) {
|
||||||
|
$weight_sum += $weight_array[$i][0];
|
||||||
|
}
|
||||||
|
$random = Rand(0, $weight_sum);
|
||||||
|
$weight = 0;
|
||||||
|
for ($i = 0; $i < count($weight_array); $i++) {
|
||||||
|
$weight += $weight_array[$i][0];
|
||||||
|
if ($weight > $random) {
|
||||||
|
$key = $i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$item_id_array = $this->getExplode($d['item_id']);
|
||||||
|
$num_array = $this->getExplode($d['num']);
|
||||||
|
$item_id = $item_id_array[$key][0];
|
||||||
|
$item_num = $num_array[$key][0] * $mul;
|
||||||
|
array_push($item_list, array(
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'item_num' => $item_num,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$q = $this->getQuest($quest_id);
|
||||||
|
if (!$q) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个任务');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$reward = $q['gold'];
|
||||||
|
error_log($reward);
|
||||||
|
}
|
||||||
if ($row['quest_type'] == 1) {
|
if ($row['quest_type'] == 1) {
|
||||||
$active = $conn->execQueryOne('SELECT active_num, active_sum FROM active WHERE accountid=:accountid;',
|
$active = $conn->execQueryOne('SELECT active_num, active_sum FROM active WHERE accountid=:accountid;',
|
||||||
array(
|
array(
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require 'classes/Quest.php';
|
||||||
|
|
||||||
class RoleController{
|
class RoleController{
|
||||||
|
|
||||||
protected function getMysql($account_id)
|
protected function getMysql($account_id)
|
||||||
@ -76,6 +78,12 @@ class RoleController{
|
|||||||
$harm = $_REQUEST['harm'];
|
$harm = $_REQUEST['harm'];
|
||||||
$add_HP = $_REQUEST['add_HP'];
|
$add_HP = $_REQUEST['add_HP'];
|
||||||
$alive_time = $_REQUEST['alive_time'];
|
$alive_time = $_REQUEST['alive_time'];
|
||||||
|
$team_status = $_REQUEST['team_status'];
|
||||||
|
$snipe_kill = $_REQUEST['snipe_kill'];
|
||||||
|
$rifle_kill = $_REQUEST['rifle_kill'];
|
||||||
|
$pistol_kill = $_REQUEST['pistol_kill'];
|
||||||
|
$submachine_kill = $_REQUEST['submachine_kill'];
|
||||||
|
$rescue_member = $_REQUEST['rescue_member'];
|
||||||
$conn = $this->getMysql($account_id);
|
$conn = $this->getMysql($account_id);
|
||||||
$kill_his = $kills;
|
$kill_his = $kills;
|
||||||
$harm_his = $harm;
|
$harm_his = $harm;
|
||||||
@ -142,6 +150,37 @@ class RoleController{
|
|||||||
die();
|
die();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//刷新任务
|
||||||
|
$quest = new classes\Quest();
|
||||||
|
$quest->triggerQuest(71003, 1, 1, $account_id);
|
||||||
|
$quest->triggerQuest(71008, 1, $alive_time, $account_id);
|
||||||
|
$quest->triggerQuest(71009, 1, $harm, $account_id);
|
||||||
|
$quest->triggerQuest(71010, 1, $kills, $account_id);
|
||||||
|
$quest->triggerQuest(71011, 1, 1, $account_id);
|
||||||
|
$quest->triggerQuest(71012, 1, $rescue_member, $account_id);
|
||||||
|
$quest->triggerQuest(72003, 1, 1, $account_id);
|
||||||
|
$quest->triggerQuest(72009, 1, $alive_time, $account_id);
|
||||||
|
$quest->triggerQuest(72010, 1, $harm, $account_id);
|
||||||
|
$quest->triggerQuest(72011, 1, $kills, $account_id);
|
||||||
|
$quest->triggerQuest(72016, 1, 1, $account_id);
|
||||||
|
$quest->triggerQuest(72017, 1, $rescue_member, $account_id);
|
||||||
|
$quest->triggerQuest(72012, 1, $snipe_kill, $account_id);
|
||||||
|
$quest->triggerQuest(72013, 1, $rifle_kill, $account_id);
|
||||||
|
$quest->triggerQuest(72014, 1, $pistol_kill, $account_id);
|
||||||
|
$quest->triggerQuest(72015, 1, $submachine_kill, $account_id);
|
||||||
|
if ($team_status != 0 && $rank <= 5) {
|
||||||
|
$quest->triggerQuest(71007, 1, 1, $account_id);
|
||||||
|
}
|
||||||
|
if ($team_status == 1 && $rank == 1) {
|
||||||
|
$quest->triggerQuest(72007, 1, 1, $account_id);
|
||||||
|
}
|
||||||
|
if ($team_status == 2) {
|
||||||
|
$quest->triggerQuest(71006, 1, 1, $account_id);
|
||||||
|
$quest->triggerQuest(72006, 1, 1, $account_id);
|
||||||
|
if ($rank == 1) {
|
||||||
|
$quest->triggerQuest(72008, 1, 1, $account_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HistoryRecord()
|
public function HistoryRecord()
|
||||||
@ -181,6 +220,19 @@ class RoleController{
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shareGame()
|
||||||
|
{
|
||||||
|
$account_id = $_REQUEST['account_id'];
|
||||||
|
$conn = $this->getMysql($account_id);
|
||||||
|
if (!$conn) {
|
||||||
|
phpcommon\sendError(ERR_BASE_USER + 1, '没有这个玩家');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$quest = new classes\Quest();
|
||||||
|
$quest->triggerQuest(71002, 1, 1, $account_id);
|
||||||
|
$quest->triggerQuest(72002, 1, 1, $account_id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user