1
This commit is contained in:
parent
8aa3b635c4
commit
aa03ecf64f
@ -1,9 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class GMController extends BaseController {
|
require_once('services/AwardService.php');
|
||||||
|
require_once('services/PropertyChgService.php');
|
||||||
|
|
||||||
function __construct()
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
class GMController extends BaseAuthedController {
|
||||||
|
|
||||||
|
public function _handlePre()
|
||||||
{
|
{
|
||||||
|
parent::_handlePre();
|
||||||
if (SERVER_ENV == _ONLINE) {
|
if (SERVER_ENV == _ONLINE) {
|
||||||
die("can't create GMController");
|
die("can't create GMController");
|
||||||
return;
|
return;
|
||||||
@ -12,6 +18,56 @@ class GMController extends BaseController {
|
|||||||
|
|
||||||
public function execCmd()
|
public function execCmd()
|
||||||
{
|
{
|
||||||
|
$cmds = explode(' ', getReqVal('cmd', ''));
|
||||||
|
if (count($cmds) < 0) {
|
||||||
|
$this->_rspErr(1, '请输入指令');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$cmd = $cmds[0];
|
||||||
|
$params = count($cmds) > 1 ? array_slice($cmds, 1) : array();
|
||||||
|
$cmdHash = array(
|
||||||
|
'.help' => function () use($params) {
|
||||||
|
$this->help($params);
|
||||||
|
},
|
||||||
|
'.additem' => function () use($params) {
|
||||||
|
$this->addItem($params);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$func = getXVal($cmdHash, $cmd);
|
||||||
|
if ($func) {
|
||||||
|
$func($params);
|
||||||
|
} else {
|
||||||
|
$this->_rspErr(2, '无法识别的指令');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function help($params)
|
||||||
|
{
|
||||||
|
$this->_rspData(array(
|
||||||
|
'text' => <<<END
|
||||||
|
.additem 道具id 道具数量
|
||||||
|
END
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addItem($params)
|
||||||
|
{
|
||||||
|
$itemId = getXVal($params, 0, 0);
|
||||||
|
$itemNum = getXVal($params, 1, 0);
|
||||||
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$awardService = new services\AwardService();
|
||||||
|
$this->_addItems(array(
|
||||||
|
array(
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'item_num' => $itemNum
|
||||||
|
)
|
||||||
|
), $awardService, $propertyChgService);
|
||||||
|
$this->_rspData(array(
|
||||||
|
'text' => '添加道具成功',
|
||||||
|
'award' => $awardService->toDto(),
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user