This commit is contained in:
hujiabin 2024-08-12 19:21:37 +08:00
parent 71b80cafd5
commit 5a52e8e8b8
11 changed files with 397 additions and 142 deletions

View File

@ -377,7 +377,8 @@ class Award(object):
def __init__(self):
self.fields = [
['!items', [AwardItem()], '奖励物品列表'],
['!heros', [Hero()], '英雄信息']
['!heros', [Hero()], '英雄信息'],
['!chips', [Chip()], '芯片信息'],
]
class PropertyChg(object):

View File

@ -1,5 +1,6 @@
<?php
require_once('services/AddItemsService.php');
require_once('services/LogService.php');
require_once('services/TimingPropService.php');
require_once('mt/Item.php');
@ -492,141 +493,151 @@ class BaseAuthedController extends BaseController {
}
}
public function _addItems($items, $awardService, $propertyService)
{
myself()->_checkS();
$heads = array();
$headFrames = array();
foreach ($items as $item) {
//道具产出埋点
LogService::productItem($item);
if ($awardService){
$awardService->addItem($item['item_id'], $item['item_num']);
}
if ($this->_isVirtualItem($item['item_id'])) {
$this->_addVirtualItem($item['item_id'], $item['item_num'],$awardService,$propertyService);
$propertyService->addUserChg();
} else {
$itemMeta = mt\Item::get($item['item_id']);
if ($itemMeta) {
if (mt\Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) {
Bag::addItem($item['item_id'], $item['item_num']);
$propertyService->addBagChg();
} else {
for ($i=0; $i<$item['item_num']; $i++){
switch ($itemMeta['type']) {
case mt\Item::HERO_TYPE:
{
$heroMeta = \mt\Hero::get($itemMeta['id']);
$res = Hero::addHero($heroMeta);
if ($res){
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
$awardService->addHero($item['item_id'],$lastIdx);
}
$propertyService->addHeroChg();
$propertyService->addUserChg();
}
break;
case mt\Item::HERO_SKIN_TYPE:
{
HeroSkin::addSkin($itemMeta);
$propertyService->addHeroSkinChg();
}
break;
case mt\Item::HEAD_TYPE:
{
array_push($heads, $itemMeta['id']);
$propertyService->addUserChg();
}
break;
case mt\Item::HEAD_FRAME_TYPE:
{
array_push($headFrames, $itemMeta['id']);
$propertyService->addUserChg();
}
break;
case mt\Item::GUN_TYPE:
{
Gun::addGun($itemMeta);
$propertyService->addGunChg();
}
break;
case mt\Item::GUN_SKIN_TYPE:
{
GunSkin::addSkin($itemMeta['id']);
$propertyService->addGunSkinChg();
}
break;
case mt\Item::FRAGMENT_BOX_TYPE:
{
Bag::addItem($item['item_id'], $item['item_num']);
$propertyService->addBagChg();
}
break;
case mt\Item::RING_TYPE:
{
UserSeasonRing::addRing($itemMeta);
$propertyService->addUserChg();
}
break;
case mt\Item::PARACHUTE_TYPE:
{
Parachute::addParachute($itemMeta);
$propertyService->addUserChg();
}
break;
case mt\Item::CHIP_TYPE:
{
Chip::addChip($itemMeta);
$propertyService->addChip();
}
break;
case mt\Item::RANDOM_BOX_TYPE:
{
$this->_openRandomBox($itemMeta,$awardService,$propertyService);
}
break;
case mt\Item::AVATAR_TYPE:
{
Avatar::addAvatar($itemMeta);
}
break;
case mt\Item::TIMING_PROP_TYPE:
{
$timingObj = new \services\TimingPropService();
$timingObj->handleProp($itemMeta);
}
break;
default:
{
$this->_addLogEx($this->_getAccountId(),
'additems', 'invalid_item',
array(
'param1' => $item['item_id'],
'param2' => $item['item_num'],
));
}
break;
}
}
}
}
}
}//end foreach
if (!empty($heads) || !empty($headFrames)) {
$userInfo = $this->_getOrmUserInfo();
$headsDb = emptyReplace(json_decode($userInfo['head_list'], true), array());
$headFramesDb = emptyReplace(json_decode($userInfo['head_frame_list'], true), array());
$heads = array_unique(array_merge($heads, $headsDb));
$headFrames = array_values(array_unique(array_merge($headFrames, $headFramesDb)));
$this->_updateUserInfo(array(
'head_list' => json_encode($heads),
'head_frame_list' => json_encode($headFrames),
));
}
public function _addItems($items, $awardService, $propertyService){
$obj = new services\AddItemsService();
$obj->addItems($items, $awardService, $propertyService);
}
// public function _addItems($items, $awardService, $propertyService)
// {
// myself()->_checkS();
// $heads = array();
// $headFrames = array();
// foreach ($items as $item) {
// //道具产出埋点
// LogService::productItem($item);
// if ($awardService){
// $awardService->addItem($item['item_id'], $item['item_num']);
// }
// if ($this->_isVirtualItem($item['item_id'])) {
// $this->_addVirtualItem($item['item_id'], $item['item_num'],$awardService,$propertyService);
// $propertyService->addUserChg();
// } else {
// $itemMeta = mt\Item::get($item['item_id']);
// if ($itemMeta) {
// if (mt\Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) {
// Bag::addItem($item['item_id'], $item['item_num']);
// $propertyService->addBagChg();
// } else {
// for ($i=0; $i<$item['item_num']; $i++){
// switch ($itemMeta['type']) {
// case mt\Item::HERO_TYPE:
// {
// $heroMeta = \mt\Hero::get($itemMeta['id']);
// $res = Hero::addHero($heroMeta);
// if ($res){
// $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
// $awardService->addHero($item['item_id'],$lastIdx);
// }
// $propertyService->addHeroChg();
// $propertyService->addUserChg();
// }
// break;
// case mt\Item::HERO_SKIN_TYPE:
// {
// HeroSkin::addSkin($itemMeta);
// $propertyService->addHeroSkinChg();
// }
// break;
// case mt\Item::HEAD_TYPE:
// {
// array_push($heads, $itemMeta['id']);
// $propertyService->addUserChg();
// }
// break;
// case mt\Item::HEAD_FRAME_TYPE:
// {
// array_push($headFrames, $itemMeta['id']);
// $propertyService->addUserChg();
// }
// break;
// case mt\Item::GUN_TYPE:
// {
// Gun::addGun($itemMeta);
// $propertyService->addGunChg();
// }
// break;
// case mt\Item::GUN_SKIN_TYPE:
// {
// GunSkin::addSkin($itemMeta['id']);
// $propertyService->addGunSkinChg();
// }
// break;
// case mt\Item::FRAGMENT_BOX_TYPE:
// {
// Bag::addItem($item['item_id'], $item['item_num']);
// $propertyService->addBagChg();
// }
// break;
// case mt\Item::RING_TYPE:
// {
// UserSeasonRing::addRing($itemMeta);
// $propertyService->addUserChg();
// }
// break;
// case mt\Item::PARACHUTE_TYPE:
// {
// Parachute::addParachute($itemMeta);
// $propertyService->addUserChg();
// }
// break;
// case mt\Item::CHIP_TYPE:
// {
// Chip::addChip($itemMeta);
// $propertyService->addChip();
// }
// break;
// case mt\Item::RANDOM_BOX_TYPE:
// {
// $this->_openRandomBox($itemMeta,$awardService,$propertyService);
// }
// break;
// case mt\Item::AVATAR_TYPE:
// {
// Avatar::addAvatar($itemMeta);
// }
// break;
// case mt\Item::TIMING_PROP_TYPE:
// {
// $timingObj = new \services\TimingPropService();
// $timingObj->handleProp($itemMeta);
// }
// break;
// case mt\Item::APPOINT_PROP_TYPE:
// {
//
// }
// break;
// default:
// {
// $this->_addLogEx($this->_getAccountId(),
// 'additems', 'invalid_item',
// array(
// 'param1' => $item['item_id'],
// 'param2' => $item['item_num'],
// ));
// }
// break;
// }
// }
//
// }
// }
// }
// }//end foreach
// if (!empty($heads) || !empty($headFrames)) {
// $userInfo = $this->_getOrmUserInfo();
// $headsDb = emptyReplace(json_decode($userInfo['head_list'], true), array());
// $headFramesDb = emptyReplace(json_decode($userInfo['head_frame_list'], true), array());
// $heads = array_unique(array_merge($heads, $headsDb));
// $headFrames = array_values(array_unique(array_merge($headFrames, $headFramesDb)));
// $this->_updateUserInfo(array(
// 'head_list' => json_encode($heads),
// 'head_frame_list' => json_encode($headFrames),
// ));
// }
// }
public function _openRandomBox($itemMeta,$awardService,$propertyService){
if ($itemMeta['include_item_id']) {
$includeItemIds = explode('|', $itemMeta['include_item_id']);

View File

@ -138,6 +138,7 @@ class HashRateController extends BaseAuthedController
// if ($taskMeta['is_refresh'] == \mt\AchievementsPower::REFRESH_STATE && $refreshTimes < $refreshTimesMax){
// $this->hashRateService->refreshHashRateTask($taskMeta,$currentPeriod['id']);
// }
$this->hashRateService->resetCurrentGoal($taskMeta);
$this->_rspData(array(
'award' => $reward,
));

View File

@ -105,9 +105,14 @@ class HeroController extends BaseAuthedController {
//消耗材料
$this->_decItems($costItems);
$propertyChgService = new services\PropertyChgService();
$awardService = new services\AwardService();
$propertyChgService->addBagChg();
for ($i=0; $i<$number; $i++){
Hero::addSyntheticHero($heroMeta,2);
$res= Hero::addSyntheticHero($heroMeta,2);
if ($res){
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
$awardService->addChip($itemId,$lastIdx);
}
}
$propertyChgService->addHeroChg();
// $this->_incPeriodV(TN_HASH_RATE_SYN_HERO_TIMES, 0, $number);
@ -124,7 +129,7 @@ class HeroController extends BaseAuthedController {
);
LogService::burialPointEvent($event);
$this->_rspData(array(
'item_id' => $heroMeta['id'],
'award' => $awardService->toDto(),
'property_chg' => $propertyChgService->toDto(),
));

View File

@ -292,6 +292,7 @@ class Chip extends BaseModel
'item_id'=>$itemMeta['id'],
'item_num'=>1,
));
return true;
}
public static function getChipByTokenId($token_ids){

View File

@ -746,10 +746,18 @@ class Hero extends BaseModel {
$attr = array();
$basicMeta = mt\BattleBasicAttribute::get($heroId);
if ($basicMeta) {
$randMeta = mt\BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$quality);
if ($randMeta) {
$attr = mt\BattleRandAttribute::getRandAttr($randMeta);
for ($i=1;$i<=$quality;$i++){
$randMeta = mt\BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$i);
if ($randMeta) {
$result = mt\BattleRandAttribute::getRandAttr($randMeta);
if ($result){
foreach ($result as $value){
array_push($attr,$value);
}
}
}
}
}
return $attr;
}

View File

@ -112,6 +112,7 @@ class Item {
const GOLD_SYN = 31;
const BATTLE_REWARD_BOX = 32;
const TIMING_PROP_TYPE = 33;
const APPOINT_PROP_TYPE = 40;
const FUNC_RENAME_CARD_SUBTYPE = 1;
const FUNC_GUILD_CARD_SUBTYPE = 3;
@ -127,6 +128,11 @@ class Item {
const SKIN_FRAGMENT_SUBTYPE = 4;
const APPOINT_HERO_SUBTYPE = 1;
const APPOINT_CHIP_SUBTYPE = 2;
const APPOINT_SKIN_SUBTYPE = 3;
public static function get($id)
{
return getXVal(self::getMetaList(), $id, null);

View File

@ -0,0 +1,187 @@
<?php
namespace services;
use mt\Item;
use models\Bag;
use models\Hero;
use models\HeroSkin;
use models\Gun;
use models\GunSkin;
use models\UserSeasonRing;
use models\Parachute;
use models\Chip;
use models\Avatar;
use phpcommon\SqlHelper;
class AddItemsService extends BaseService
{
public function addItems($items, $awardService, $propertyService){
myself()->_checkS();
$heads = array();
$headFrames = array();
foreach ($items as $item) {
//道具产出埋点
LogService::productItem($item);
if ($awardService){
$awardService->addItem($item['item_id'], $item['item_num']);
}
if (myself()->_isVirtualItem($item['item_id'])) {
myself()->_addVirtualItem($item['item_id'], $item['item_num'],$awardService,$propertyService);
$propertyService->addUserChg();
} else {
$itemMeta = Item::get($item['item_id']);
if ($itemMeta) {
if (Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) {
Bag::addItem($item['item_id'], $item['item_num']);
$propertyService->addBagChg();
} else {
for ($i=0; $i<$item['item_num']; $i++){
switch ($itemMeta['type']) {
case Item::HERO_TYPE:
{
$heroMeta = \mt\Hero::get($itemMeta['id']);
$res = Hero::addHero($heroMeta);
if ($res){
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
$awardService->addHero($item['item_id'],$lastIdx);
}
$propertyService->addHeroChg();
$propertyService->addUserChg();
}
break;
case Item::HERO_SKIN_TYPE:
{
HeroSkin::addSkin($itemMeta);
$propertyService->addHeroSkinChg();
}
break;
case Item::HEAD_TYPE:
{
array_push($heads, $itemMeta['id']);
$propertyService->addUserChg();
}
break;
case Item::HEAD_FRAME_TYPE:
{
array_push($headFrames, $itemMeta['id']);
$propertyService->addUserChg();
}
break;
case Item::GUN_TYPE:
{
Gun::addGun($itemMeta);
$propertyService->addGunChg();
}
break;
case Item::GUN_SKIN_TYPE:
{
GunSkin::addSkin($itemMeta['id']);
$propertyService->addGunSkinChg();
}
break;
case Item::FRAGMENT_BOX_TYPE:
{
Bag::addItem($item['item_id'], $item['item_num']);
$propertyService->addBagChg();
}
break;
case Item::RING_TYPE:
{
UserSeasonRing::addRing($itemMeta);
$propertyService->addUserChg();
}
break;
case Item::PARACHUTE_TYPE:
{
Parachute::addParachute($itemMeta);
$propertyService->addUserChg();
}
break;
case Item::CHIP_TYPE:
{
$res = Chip::addChip($itemMeta);
if ($res){
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
$awardService->addChip($item['item_id'],$lastIdx);
}
$propertyService->addChip();
}
break;
case Item::RANDOM_BOX_TYPE:
{
myself()->_openRandomBox($itemMeta,$awardService,$propertyService);
}
break;
case Item::AVATAR_TYPE:
{
Avatar::addAvatar($itemMeta);
}
break;
case Item::TIMING_PROP_TYPE:
{
$timingObj = new \services\TimingPropService();
$timingObj->handleProp($itemMeta);
}
break;
case Item::APPOINT_PROP_TYPE:
{
switch ($itemMeta['sub_type']){
case Item::APPOINT_HERO_SUBTYPE :{
$heroMeta = \mt\Hero::get($itemMeta['relationship']);
$res = Hero::addSyntheticHero($heroMeta,$itemMeta['quality']);
if ($res){
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
$awardService->addHero($heroMeta['id'],$lastIdx);
}
$propertyService->addHeroChg();
}
break;
case Item::APPOINT_CHIP_SUBTYPE :{
$chipMeta = Item::get($itemMeta['relationship']);
$res = Chip::addSyntheticChip($chipMeta,$itemMeta['quality']);
if ($res){
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
$awardService->addChip($chipMeta['id'],$lastIdx);
}
$propertyService->addChip();
}
break;
case Item::APPOINT_SKIN_SUBTYPE :{
}
break;
}
}
break;
default:
{
myself()->_addLogEx(myself()->_getAccountId(),
'additems', 'invalid_item',
array(
'param1' => $item['item_id'],
'param2' => $item['item_num'],
));
}
break;
}
}
}
}
}
}//end foreach
if (!empty($heads) || !empty($headFrames)) {
$userInfo = myself()->_getOrmUserInfo();
$headsDb = emptyReplace(json_decode($userInfo['head_list'], true), array());
$headFramesDb = emptyReplace(json_decode($userInfo['head_frame_list'], true), array());
$heads = array_unique(array_merge($heads, $headsDb));
$headFrames = array_values(array_unique(array_merge($headFrames, $headFramesDb)));
myself()->_updateUserInfo(array(
'head_list' => json_encode($heads),
'head_frame_list' => json_encode($headFrames),
));
}
}
}

View File

@ -2,6 +2,7 @@
namespace services;
use models\Chip;
use models\Hero;
use mt\Item;
@ -9,6 +10,7 @@ class AwardService extends BaseService {
private $items = array();
private $heros = array();
private $chips = array();
public function addItem($itemId, $itemNum)
{
@ -44,11 +46,23 @@ class AwardService extends BaseService {
}
}
public function addChip($itemId,$unnid)
{
$itemMeta = Item::get($itemId);
if (!$itemMeta){
return;
}
if ($itemMeta['type'] == Item::CHIP_TYPE){
array_push($this->chips,Chip::toDto(Chip::find($unnid)));
}
}
public function toDto()
{
return array(
'items' => $this->items,
'heros' => $this->heros,
'chips' => $this->chips,
);
}

View File

@ -400,6 +400,20 @@ class HashRateService extends BaseService
myself()->_incDailyV(TN_HASH_DAILY_REFRESH_TIMES,0,1);
}
public function resetCurrentGoal($taskMate){
if ($taskMate['task_type'] == AchievementsPower::TYPE5){
return;
}
$taskList = $this->getHashRateTasks($taskMate['task_type']);
foreach ($taskList as &$task){
if ($task['task_id'] == $taskMate['id']){
$task['current'] = 0;
}
}
$this->hashRateTask['task'.$taskMate['task_type']] = $taskList;
$this->saveHashRateTask();
}
public function _isHaveRedTag($period){
foreach ($this->hashRateTask as $item){
if (is_array($item)){

View File

@ -154,9 +154,16 @@ class MintNftHero
$attr = array();
$basicMeta = BattleBasicAttribute::get($heroId);
if ($basicMeta) {
$randMeta = BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$quality);
if ($randMeta) {
$attr = BattleRandAttribute::getRandAttr($randMeta);
for ($i=1;$i<=$quality;$i++){
$randMeta = BattleRandAttribute::getByWeight($basicMeta['randomAttribute_Default'],$i);
if ($randMeta) {
$result = BattleRandAttribute::getRandAttr($randMeta);
if ($result){
foreach ($result as $value){
array_push($attr,$value);
}
}
}
}
}
return $attr;