1
This commit is contained in:
parent
9432aa8235
commit
a37bcd8ac6
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
|
require_once('mt/Drop.php');
|
||||||
|
|
||||||
require_once('models/Bag.php');
|
require_once('models/Bag.php');
|
||||||
|
|
||||||
@ -54,10 +55,7 @@ class BagController extends BaseAuthedController {
|
|||||||
$this->_rspErr(2, '配置表错误');
|
$this->_rspErr(2, '配置表错误');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($itemMeta['type'] != mt\Item::FUNC_TYPE) {
|
if ($itemMeta['type'] == mt\Item::FUNC_TYPE) {
|
||||||
$this->_rspErr(3, '该道具为不可使用道具');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch ($itemMeta['sub_type']) {
|
switch ($itemMeta['sub_type']) {
|
||||||
case mt\Item::FUNC_RENAME_CARD_SUBTYPE:
|
case mt\Item::FUNC_RENAME_CARD_SUBTYPE:
|
||||||
{
|
{
|
||||||
@ -71,6 +69,11 @@ class BagController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if ($itemMeta['type'] == mt\Item::GIFT_PACKAGE_TYPE) {
|
||||||
|
$this->openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3);
|
||||||
|
} else {
|
||||||
|
$this->_rspErr(4, '该道具功能暂未实现');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rename()
|
public function rename()
|
||||||
@ -174,4 +177,36 @@ class BagController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3)
|
||||||
|
{
|
||||||
|
$dropMeta = mt\Drop::get($itemMeta['drop']);
|
||||||
|
if (!$dropMeta) {
|
||||||
|
$this->_rspErr(1, '配置表错误');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$costItems = mt\Item::getUseCostItems($itemMeta);
|
||||||
|
error_log(json_encode($costItems));
|
||||||
|
$lackItem = null;
|
||||||
|
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||||
|
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->_decItems($costItems);
|
||||||
|
$this->_decItems(array(
|
||||||
|
array(
|
||||||
|
'item_id' => $itemMeta['id'],
|
||||||
|
'item_num' => 1
|
||||||
|
)
|
||||||
|
));
|
||||||
|
$this->_scatterDrop('gift_package:' . $itemMeta['id'],
|
||||||
|
$dropMeta,
|
||||||
|
$this->awardService,
|
||||||
|
$this->propertyChgService);
|
||||||
|
$this->propertyChgService->addBagChg();
|
||||||
|
$this->_rspData(array(
|
||||||
|
'award' => $this->awardService->toDto(),
|
||||||
|
'property_chg' => $this->propertyChgService->toDto(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,13 @@ use phpcommon\SqlHelper;
|
|||||||
|
|
||||||
class BattleController extends BaseAuthedController {
|
class BattleController extends BaseAuthedController {
|
||||||
|
|
||||||
|
public function preBattleCheck()
|
||||||
|
{
|
||||||
|
$this->_rspData(array(
|
||||||
|
'pre_battle_payload' => ''
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public function battleReport()
|
public function battleReport()
|
||||||
{
|
{
|
||||||
$userInfo = $this->_getOrmUserInfo();
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
|
@ -32,6 +32,9 @@ class GMController extends BaseAuthedController {
|
|||||||
'.additem' => function () use($params) {
|
'.additem' => function () use($params) {
|
||||||
$this->addItem($params);
|
$this->addItem($params);
|
||||||
},
|
},
|
||||||
|
'.addtili' => function () use($params) {
|
||||||
|
$this->addTili($params);
|
||||||
|
},
|
||||||
'.getsystime' => function () use($params) {
|
'.getsystime' => function () use($params) {
|
||||||
$this->getSysTime($params);
|
$this->getSysTime($params);
|
||||||
},
|
},
|
||||||
@ -53,6 +56,7 @@ class GMController extends BaseAuthedController {
|
|||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'text' => <<<END
|
'text' => <<<END
|
||||||
.additem 道具id 道具数量 //添加道具
|
.additem 道具id 道具数量 //添加道具
|
||||||
|
.addtili 英雄id 体力值 //添加英雄体力
|
||||||
.getsystime //获取服务器时间
|
.getsystime //获取服务器时间
|
||||||
.setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00
|
.setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00
|
||||||
END
|
END
|
||||||
@ -78,6 +82,21 @@ END
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function addTili($params)
|
||||||
|
{
|
||||||
|
$heroId = getXVal($params, 0, 0);
|
||||||
|
$tili = getXVal($params, 1, 0);
|
||||||
|
Hero::update($heroId, array(
|
||||||
|
'hero_tili' => "hero_tili + ${tili}"
|
||||||
|
));
|
||||||
|
$propertyChgService->addHeroChg();
|
||||||
|
$this->_rspData(array(
|
||||||
|
'text' => '添加道具成功',
|
||||||
|
'award' => $awardService->toDto(),
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
private function getSysTime($params)
|
private function getSysTime($params)
|
||||||
{
|
{
|
||||||
$sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime());
|
$sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime());
|
||||||
|
@ -43,7 +43,7 @@ class Battle extends BaseModel {
|
|||||||
|
|
||||||
public static function update($fieldsKv)
|
public static function update($fieldsKv)
|
||||||
{
|
{
|
||||||
SqlHelper::upsert
|
SqlHelper::update
|
||||||
(myself()->_getSelfMysql(),
|
(myself()->_getSelfMysql(),
|
||||||
't_battle',
|
't_battle',
|
||||||
array(
|
array(
|
||||||
|
@ -28,6 +28,7 @@ class Hero extends BaseModel {
|
|||||||
return array(
|
return array(
|
||||||
'hero_id' => $row['hero_id'],
|
'hero_id' => $row['hero_id'],
|
||||||
'hero_lv' => $row['hero_lv'],
|
'hero_lv' => $row['hero_lv'],
|
||||||
|
'hero_tili' => $row['hero_tili'],
|
||||||
'skin_id' => $row['skin_id'],
|
'skin_id' => $row['skin_id'],
|
||||||
'skill_lv1' => $row['skill_lv1'],
|
'skill_lv1' => $row['skill_lv1'],
|
||||||
'skill_lv2' => $row['skill_lv2'],
|
'skill_lv2' => $row['skill_lv2'],
|
||||||
@ -102,4 +103,17 @@ class Hero extends BaseModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function update($heroId, $fieldsKv)
|
||||||
|
{
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hero',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'hero_id' => $heroId,
|
||||||
|
),
|
||||||
|
$fieldsKv
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,20 @@ class Item {
|
|||||||
return $costItems;
|
return $costItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getUseCostItems($itemMeta)
|
||||||
|
{
|
||||||
|
$costItems = array();
|
||||||
|
foreach (splitStr2($itemMeta['use_cost']) as $arr) {
|
||||||
|
if (count($arr) >= 2) {
|
||||||
|
array_push($costItems, array(
|
||||||
|
'item_id' => $arr[0],
|
||||||
|
'item_num' => $arr[1]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $costItems;
|
||||||
|
}
|
||||||
|
|
||||||
public static function isBagItem($type, $subType)
|
public static function isBagItem($type, $subType)
|
||||||
{
|
{
|
||||||
return in_array($type, array(
|
return in_array($type, array(
|
||||||
|
@ -6,14 +6,19 @@ require_once('mt/Item.php');
|
|||||||
require_once('mt/Equip.php');
|
require_once('mt/Equip.php');
|
||||||
require_once('mt/Season.php');
|
require_once('mt/Season.php');
|
||||||
require_once('mt/Rank.php');
|
require_once('mt/Rank.php');
|
||||||
|
require_once('mt/Parameter.php');
|
||||||
|
|
||||||
require_once('models/Season.php');
|
require_once('models/Season.php');
|
||||||
require_once('models/Battle.php');
|
require_once('models/Battle.php');
|
||||||
|
require_once('models/Bag.php');
|
||||||
|
require_once('models/Hero.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\Season;
|
use models\Season;
|
||||||
use models\Battle;
|
use models\Battle;
|
||||||
|
use models\Bag;
|
||||||
|
use models\Hero;
|
||||||
|
|
||||||
class BattleDataService extends BaseService {
|
class BattleDataService extends BaseService {
|
||||||
|
|
||||||
@ -21,10 +26,17 @@ class BattleDataService extends BaseService {
|
|||||||
|
|
||||||
public function updateBattleData()
|
public function updateBattleData()
|
||||||
{
|
{
|
||||||
|
error_log(json_encode($_REQUEST));
|
||||||
|
error_log('updateBattleData1');
|
||||||
|
if (!$this->decCost()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error_log('updateBattleData2');
|
||||||
$this->currSeasonMeta = mt\Season::getCurrentSeason();
|
$this->currSeasonMeta = mt\Season::getCurrentSeason();
|
||||||
if (!$this->currSeasonMeta) {
|
if (!$this->currSeasonMeta) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
error_log('updateBattleData3');
|
||||||
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
||||||
if (!$this->seasonDb) {
|
if (!$this->seasonDb) {
|
||||||
Season::add($this->currSeasonMeta['id']);
|
Season::add($this->currSeasonMeta['id']);
|
||||||
@ -33,6 +45,7 @@ class BattleDataService extends BaseService {
|
|||||||
if (!$this->seasonDb) {
|
if (!$this->seasonDb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
error_log('updateBattleData4');
|
||||||
$this->updateScore();
|
$this->updateScore();
|
||||||
$hisBattleData = Battle::getMyBattleData();
|
$hisBattleData = Battle::getMyBattleData();
|
||||||
if (!isset($hisBattleData)) {
|
if (!isset($hisBattleData)) {
|
||||||
@ -99,6 +112,7 @@ class BattleDataService extends BaseService {
|
|||||||
'battle_data' => json_encode($seasonBattleData),
|
'battle_data' => json_encode($seasonBattleData),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$this->addItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function apply(&$battleData)
|
private function apply(&$battleData)
|
||||||
@ -255,6 +269,7 @@ class BattleDataService extends BaseService {
|
|||||||
|
|
||||||
private function updateScore()
|
private function updateScore()
|
||||||
{
|
{
|
||||||
|
if (getReqVal('room_mode', 0) == 0) {
|
||||||
$userInfo = myself()->_getOrmUserInfo();
|
$userInfo = myself()->_getOrmUserInfo();
|
||||||
$rankScore = getReqVal('rank_score', 0);
|
$rankScore = getReqVal('rank_score', 0);
|
||||||
if ($rankScore > 0) {
|
if ($rankScore > 0) {
|
||||||
@ -282,5 +297,41 @@ class BattleDataService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function decCost()
|
||||||
|
{
|
||||||
|
$heroDb = Hero::find(getReqVal('hero_id', 0));
|
||||||
|
if (!$heroDb) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$costTili = mt\Parameter::getVal('cost_fatigue', 0);
|
||||||
|
if ($heroDb['hero_tili'] < $costTili) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Hero::update($heroDb['hero_id'], array(
|
||||||
|
'hero_tili' => function () use($costTili) {
|
||||||
|
return "GREATEST(0, hero_tili - ${costTili})";
|
||||||
|
}
|
||||||
|
));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addItems()
|
||||||
|
{
|
||||||
|
$tmpStrs1 = explode('|', getReqVal('items', ''));
|
||||||
|
error_log('addItems ' . getReqVal('items', ''));
|
||||||
|
foreach ($tmpStrs1 as $tmpStr) {
|
||||||
|
$tmpStrs2 = explode(':', $tmpStr);
|
||||||
|
if (count($tmpStrs2) >= 2) {
|
||||||
|
$itemId = $tmpStrs2[0];
|
||||||
|
$itemNum = $tmpStrs2[1];
|
||||||
|
$itemMeta = mt\Item::get($itemId);
|
||||||
|
if ($itemMeta) {
|
||||||
|
Bag::addItem($itemId, $itemNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user