1
This commit is contained in:
parent
b4d879504e
commit
d1c7241a05
@ -11,6 +11,7 @@ require_once('models/BattleHistory.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Parachute.php');
|
||||
require_once('models/ChipPage.php');
|
||||
require_once('models/Battle.php');
|
||||
require_once('services/BattleDataService.php');
|
||||
require_once('services/TameBattleDataService.php');
|
||||
require_once('services/FormulaService.php');
|
||||
@ -27,6 +28,7 @@ use models\BattleSettlement;
|
||||
use models\User;
|
||||
use models\Parachute;
|
||||
use models\ChipPage;
|
||||
use models\Battle;
|
||||
|
||||
class BattleController extends BaseAuthedController {
|
||||
|
||||
@ -240,6 +242,7 @@ class BattleController extends BaseAuthedController {
|
||||
'hero_skin' => '',
|
||||
'skill_id' => '',
|
||||
'chip_page' => array(),
|
||||
'battle_times' => '',
|
||||
|
||||
'hero_dto' => '',
|
||||
'weapon_dto1' => '',
|
||||
@ -269,6 +272,10 @@ class BattleController extends BaseAuthedController {
|
||||
$info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2'];
|
||||
$chipPageDb = ChipPage::find($userPresetInfo['presetInfo']['chip_page']);
|
||||
$info['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
||||
$battleDb = Battle::find($account_id);
|
||||
$battleData = json_decode($battleDb['battle_data'], true);
|
||||
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'data', array()) : array();
|
||||
$info['battle_times'] = getXVal($seasonBattleData, 'total_battle_times', 0);
|
||||
|
||||
}else{
|
||||
$info['errcode'] = 51;
|
||||
|
@ -3,7 +3,7 @@
|
||||
class CallbackController extends BaseController {
|
||||
|
||||
private $handlers = array(
|
||||
'gameItemMallBuyOk' => 'gameItemMallBuyOk',
|
||||
'gameItemMallBuyOk' => 'GameItemMallBuyOk',
|
||||
);
|
||||
|
||||
public function dispatch()
|
||||
|
@ -231,23 +231,7 @@ class Chip extends BaseModel
|
||||
|
||||
public static function internalAddItem($conn, $itemMeta, $accountId, $tokenId,$state)
|
||||
{
|
||||
if (!$itemMeta) {
|
||||
return;
|
||||
}
|
||||
if (myself()->_isVirtualItem($itemMeta['id'])) {
|
||||
return;
|
||||
}
|
||||
$chipMeta = ChipAttr::getAttrByItemId($itemMeta['id']);
|
||||
if (!$chipMeta){
|
||||
return;
|
||||
}
|
||||
// $randAttr = array();
|
||||
// if (mt\Item::isRoleChipItem($itemMeta)) {
|
||||
// $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade);
|
||||
// }
|
||||
// if (mt\Item::isGunChipItem($itemMeta)) {
|
||||
// $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade);
|
||||
// }
|
||||
|
||||
$randAttr = array();
|
||||
$fieldsKv = array(
|
||||
'item_id' => $itemMeta['id'],
|
||||
|
@ -329,18 +329,12 @@ class Gun extends BaseModel {
|
||||
private static function internalAddGun($conn, $gunMeta, $accountId, $tokenId,$state)
|
||||
{
|
||||
$randAttr = array();
|
||||
{
|
||||
$initQualityMeta = mt\GunQuality::getByQuality(1);
|
||||
if ($initQualityMeta) {
|
||||
$randAttr = mt\GunQuality::getRandAttr($initQualityMeta);
|
||||
}
|
||||
}
|
||||
$fieldsKv = array(
|
||||
'gun_id' => $gunMeta['id'],
|
||||
'gun_lv' => 1,
|
||||
'quality' => 1,
|
||||
'state' => $state,
|
||||
'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)),
|
||||
// 'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)),
|
||||
'rand_attr' => json_encode($randAttr),
|
||||
'lock_type' => self::NO_LOCK,
|
||||
'unlock_time' => 0,
|
||||
|
@ -337,7 +337,7 @@ class Hero extends BaseModel {
|
||||
'hero_id' => $heroMeta['id'],
|
||||
'hero_lv' => 1,
|
||||
'quality' => 1,
|
||||
'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)),
|
||||
// 'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)),
|
||||
'state' => $state,
|
||||
'skill_lv1' => 1,
|
||||
'skill_lv2' => 1,
|
||||
|
@ -8,7 +8,7 @@ require_once ('services/callback/BuyShopGoodsCbService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class gameItemMallBuyOk {
|
||||
class GameItemMallBuyOk {
|
||||
|
||||
public function process()
|
||||
{
|
204
webapp/services/callback/ShopAddItemService.php
Normal file
204
webapp/services/callback/ShopAddItemService.php
Normal file
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace services;
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/GunQuality.php');
|
||||
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use mt;
|
||||
class ShopAddItemService
|
||||
{
|
||||
|
||||
public function addItem($address,$itemId,$itemNum){
|
||||
if ($itemNum < 1){
|
||||
return;
|
||||
}
|
||||
$itemMeta = \mt\Item::get($itemId);
|
||||
if (!$itemMeta){
|
||||
return;
|
||||
}
|
||||
$accountId = $this->getAccountId($address);
|
||||
$conn = myself()->_getMysql($address);
|
||||
if (\mt\Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) {
|
||||
$this->internalAddBag($conn,$itemId,$itemNum,$accountId);
|
||||
}else{
|
||||
for ($i = 0; $i < $itemNum; $i++) {
|
||||
switch ($itemMeta['type']){
|
||||
case \mt\Item::HERO_TYPE : {
|
||||
$this->internalAddHero($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::GUN_TYPE : {
|
||||
$this->internalAddGun($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::CHIP_TYPE : {
|
||||
$this->internalAddChip($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::HERO_SKIN_TYPE : {
|
||||
$this->internalAddHeroSkin($conn,$itemMeta,$accountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function getAccountId($address){
|
||||
|
||||
$row = SqlHelper::ormSelectOne
|
||||
(myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
)
|
||||
);
|
||||
|
||||
return $row['account_id'];
|
||||
}
|
||||
|
||||
private function internalAddHeroSkin($conn,$skinMeta,$accountId){
|
||||
|
||||
$heroId = 0;
|
||||
if ($skinMeta['isdefaultskin'] == 1){
|
||||
$heroId = $skinMeta['playerid'];
|
||||
}
|
||||
SqlHelper::upsert(
|
||||
$conn,
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
'skin_id' => $skinMeta['id']
|
||||
),
|
||||
array(),
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
'skin_id' => $skinMeta['id'],
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'try_expire_at' => 0,
|
||||
'hero_id' => $heroId,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function internalAddHero($conn, $heroMeta, $accountId)
|
||||
{
|
||||
$skinItemMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE);
|
||||
if ($skinItemMeta){
|
||||
foreach ($skinItemMeta as $value){
|
||||
if ($value['playerid'] == $heroMeta['id'] && $value['isdefaultskin'] == 1){
|
||||
$this->internalAddHeroSkin($conn,$value,$accountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
$randAttr = array();
|
||||
$fieldsKv = array(
|
||||
'account_id' => $accountId,
|
||||
'hero_id' => $heroMeta['id'],
|
||||
'hero_lv' => 1,
|
||||
'quality' => 1,
|
||||
'state' => 0,
|
||||
'skill_lv1' => 1,
|
||||
'skill_lv2' => 1,
|
||||
'rand_attr' => json_encode($randAttr),
|
||||
'lock_type' => 0,
|
||||
'unlock_time' => 0,
|
||||
'unlock_trade_time' => 0,
|
||||
'activate' => 1,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
|
||||
SqlHelper::insert(
|
||||
$conn,
|
||||
't_hero',
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
private function internalAddGun($conn, $gunMeta, $accountId)
|
||||
{
|
||||
$randAttr = array();
|
||||
$fieldsKv = array(
|
||||
'account_id' => $accountId,
|
||||
'gun_id' => $gunMeta['id'],
|
||||
'gun_lv' => 1,
|
||||
'quality' => 1,
|
||||
'state' => 0,
|
||||
'rand_attr' => json_encode($randAttr),
|
||||
'lock_type' => 0,
|
||||
'unlock_time' => 0,
|
||||
'unlock_trade_time' => 0,
|
||||
'activate' => 1,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
SqlHelper::insert(
|
||||
$conn,
|
||||
't_gun',
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
private function internalAddChip($conn, $itemMeta, $accountId)
|
||||
{
|
||||
$randAttr = array();
|
||||
$fieldsKv = array(
|
||||
'account_id' => $accountId,
|
||||
'item_id' => $itemMeta['id'],
|
||||
'item_num' => 1,
|
||||
'state' => 0,
|
||||
'rand_attr' => json_encode($randAttr),
|
||||
'chip_grade' => 1,
|
||||
'chip_type' => $itemMeta['sub_type'],
|
||||
'activate' => 1,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
SqlHelper::insert
|
||||
($conn,
|
||||
't_chip',
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
private function internalAddBag($conn, $itemId, $itemNum, $accountId )
|
||||
{
|
||||
if ($this->_isVirtualItem($itemId)) {
|
||||
return;
|
||||
}
|
||||
SqlHelper::upsert
|
||||
($conn,
|
||||
't_bag',
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
'item_id' => $itemId
|
||||
),
|
||||
array(
|
||||
'item_num' => function () use($itemNum) { return "item_num + {$itemNum}";},
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
),
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _isVirtualItem($itemId)
|
||||
{
|
||||
return in_array($itemId, array(V_ITEM_GOLD, V_ITEM_DIAMOND, V_ITEM_EXP, V_ITEM_ACTIVE,V_ITEM_BCEG,V_ITEM_STAR));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user