1
This commit is contained in:
parent
db35890c46
commit
0caf19e408
@ -70,19 +70,14 @@ class Chip extends BaseModel
|
|||||||
'token_id' => $nftDb['token_id'],
|
'token_id' => $nftDb['token_id'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$cb($row);
|
|
||||||
}else{
|
|
||||||
$cb($row);
|
|
||||||
}
|
}
|
||||||
|
$cb($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function activateChip($row){
|
private static function activateChip($row){
|
||||||
if (myself()->_isVirtualItem($row['item_id'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($row['item_num'] <= 0) {
|
if ($row['item_num'] <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -322,7 +317,8 @@ class Chip extends BaseModel
|
|||||||
$chipAttr = [];
|
$chipAttr = [];
|
||||||
$chipIdsArr = explode('|',$chip_ids);
|
$chipIdsArr = explode('|',$chip_ids);
|
||||||
foreach ($chipIdsArr as $val){
|
foreach ($chipIdsArr as $val){
|
||||||
$chip = self::toDto(self::getChipByIdx($val));
|
// $chip = self::toDto(self::getChipByIdx($val));
|
||||||
|
$chip = self::toDto(self::getChipByTokenId($val));
|
||||||
foreach ($chip['rand_attr'] as $v){
|
foreach ($chip['rand_attr'] as $v){
|
||||||
array_push($chipAttr,$v);
|
array_push($chipAttr,$v);
|
||||||
}
|
}
|
||||||
@ -340,7 +336,8 @@ class Chip extends BaseModel
|
|||||||
if (count($chipIdsArr) == 4){
|
if (count($chipIdsArr) == 4){
|
||||||
$min = 15;
|
$min = 15;
|
||||||
foreach ($chipIdsArr as $val){
|
foreach ($chipIdsArr as $val){
|
||||||
$chip = self::getChipByIdx($val);
|
// $chip = self::getChipByIdx($val);
|
||||||
|
$chip = self::getChipByTokenId($val);
|
||||||
if ($chip['chip_grade']<$min){
|
if ($chip['chip_grade']<$min){
|
||||||
$min = $chip['chip_grade'];
|
$min = $chip['chip_grade'];
|
||||||
}
|
}
|
||||||
|
30
webapp/models/ChipPlugin.php
Normal file
30
webapp/models/ChipPlugin.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class ChipPlugin extends BaseModel
|
||||||
|
{
|
||||||
|
public static function getInlayChip($tokenId){
|
||||||
|
$chips = array();
|
||||||
|
if (! $tokenId){
|
||||||
|
return $chips;
|
||||||
|
}
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_chip_plugin',
|
||||||
|
array(
|
||||||
|
'token_id' => $tokenId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($row){
|
||||||
|
$temp = array(
|
||||||
|
$row['chip1'],$row['chip2'],$row['chip3'],$row['chip4']
|
||||||
|
);
|
||||||
|
$chips = array_filter($temp);
|
||||||
|
}
|
||||||
|
return implode('|',$chips);
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ require_once('mt/GunLevel.php');
|
|||||||
require_once('mt/GunQuality.php');
|
require_once('mt/GunQuality.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
require_once('models/GunSkin.php');
|
require_once('models/GunSkin.php');
|
||||||
|
require_once('models/ChipPlugin.php');
|
||||||
require_once('services/NftService.php');
|
require_once('services/NftService.php');
|
||||||
require_once('services/FormulaService.php');
|
require_once('services/FormulaService.php');
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ use mt;
|
|||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use services\NftService;
|
use services\NftService;
|
||||||
use services\FormulaService;
|
use services\FormulaService;
|
||||||
|
use models\ChipPlugin;
|
||||||
|
|
||||||
class Gun extends BaseModel {
|
class Gun extends BaseModel {
|
||||||
|
|
||||||
@ -133,27 +135,51 @@ class Gun extends BaseModel {
|
|||||||
'token_id' => $nftDb['token_id'],
|
'token_id' => $nftDb['token_id'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// if (!$row) {
|
if ($row){
|
||||||
// $itemMeta = mt\Item::get($nftDb['item_id']);
|
if ( ! $row['activate']){
|
||||||
// if ($itemMeta) {
|
self::activateGun($row);
|
||||||
// self::addNftGun($itemMeta, $nftDb['token_id']);
|
$row = SqlHelper::ormSelectOne(
|
||||||
// $row = SqlHelper::ormSelectOne(
|
myself()->_getSelfMysql(),
|
||||||
// myself()->_getSelfMysql(),
|
't_gun',
|
||||||
// 't_gun',
|
array(
|
||||||
// array(
|
'token_id' => $nftDb['token_id'],
|
||||||
// 'token_id' => $nftDb['token_id'],
|
)
|
||||||
// )
|
);
|
||||||
// );
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
if ($row) {
|
|
||||||
$cb($row);
|
$cb($row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function activateGun($row){
|
||||||
|
$itemMeta = mt\Item::get($row['gun_id']);
|
||||||
|
if (!$itemMeta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$randAttr = array();
|
||||||
|
{
|
||||||
|
$initQualityMeta = mt\GunQuality::getByQuality(1);
|
||||||
|
if ($initQualityMeta) {
|
||||||
|
$randAttr = mt\GunQuality::getRandAttr($initQualityMeta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$fieldsKv = array(
|
||||||
|
'gun_lv' => 1,
|
||||||
|
'quality' => 1,
|
||||||
|
'state' => self::GETED_STATE,
|
||||||
|
'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,
|
||||||
|
'unlock_trade_time' => 0,
|
||||||
|
'labour' => 0,
|
||||||
|
'activate' => 1,
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
self::updateByTokenId($row['token_id'],$fieldsKv);
|
||||||
|
}
|
||||||
|
|
||||||
public static function toDto($row)
|
public static function toDto($row)
|
||||||
{
|
{
|
||||||
$attr = emptyReplace(json_decode($row['rand_attr'], true), array());
|
$attr = emptyReplace(json_decode($row['rand_attr'], true), array());
|
||||||
@ -196,6 +222,7 @@ class Gun extends BaseModel {
|
|||||||
$todayMissionGetCeg = 0;
|
$todayMissionGetCeg = 0;
|
||||||
}
|
}
|
||||||
$gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']);
|
$gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']);
|
||||||
|
$chipIds = ChipPlugin::getInlayChip($row['token_id']);
|
||||||
$dto = array(
|
$dto = array(
|
||||||
'idx' => $row['idx'],
|
'idx' => $row['idx'],
|
||||||
'token_id' => $row['token_id'],
|
'token_id' => $row['token_id'],
|
||||||
@ -211,8 +238,8 @@ class Gun extends BaseModel {
|
|||||||
'raw_pve_ceg_uplimit' => 0,
|
'raw_pve_ceg_uplimit' => 0,
|
||||||
'attr_base' => $baseAttr,
|
'attr_base' => $baseAttr,
|
||||||
'attr_pro' => $attrPro,
|
'attr_pro' => $attrPro,
|
||||||
'attr_chip' => Chip::getChipAttr($row['chip_ids'])['attr_chip'],
|
'attr_chip' => Chip::getChipAttr($chipIds)['attr_chip'],
|
||||||
'chip_core' => Chip::getChipAttr($row['chip_ids'])['chip_core'],
|
'chip_core' => Chip::getChipAttr($chipIds)['chip_core'],
|
||||||
'try_count' => $row['try_count'],
|
'try_count' => $row['try_count'],
|
||||||
'current_pvp_get_ceg' => $todayGetGold / 100,
|
'current_pvp_get_ceg' => $todayGetGold / 100,
|
||||||
'last_pvp_get_ceg_time' => $lastGetGoldTime,
|
'last_pvp_get_ceg_time' => $lastGetGoldTime,
|
||||||
@ -225,7 +252,7 @@ class Gun extends BaseModel {
|
|||||||
'unlock_lefttime' => max(0,
|
'unlock_lefttime' => max(0,
|
||||||
$unlockTime - myself()->_getNowTime()),
|
$unlockTime - myself()->_getNowTime()),
|
||||||
'unlock_trade_time' => $row['unlock_trade_time'],
|
'unlock_trade_time' => $row['unlock_trade_time'],
|
||||||
'chip_ids' => $row['chip_ids'],
|
'chip_ids' => $chipIds,
|
||||||
'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],2)), //计算ceg上限所需参数
|
'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],2)), //计算ceg上限所需参数
|
||||||
'offer_reward_state' => 0,
|
'offer_reward_state' => 0,
|
||||||
'labour' => $row['labour'],
|
'labour' => $row['labour'],
|
||||||
@ -275,6 +302,7 @@ class Gun extends BaseModel {
|
|||||||
'unlock_time' => 0,
|
'unlock_time' => 0,
|
||||||
'unlock_trade_time' => 0,
|
'unlock_trade_time' => 0,
|
||||||
'labour' => 0,
|
'labour' => 0,
|
||||||
|
'activate' => 1,
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
);
|
);
|
||||||
|
@ -11,6 +11,7 @@ require_once('mt/SkillCommon.php');
|
|||||||
require_once('models/HeroSkin.php');
|
require_once('models/HeroSkin.php');
|
||||||
require_once('models/Chip.php');
|
require_once('models/Chip.php');
|
||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
|
require_once('models/ChipPlugin.php');
|
||||||
require_once('services/NftService.php');
|
require_once('services/NftService.php');
|
||||||
require_once('services/FormulaService.php');
|
require_once('services/FormulaService.php');
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ use phpcommon;
|
|||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use services\NftService;
|
use services\NftService;
|
||||||
use services\FormulaService;
|
use services\FormulaService;
|
||||||
|
use models\ChipPlugin;
|
||||||
|
|
||||||
|
|
||||||
class Hero extends BaseModel {
|
class Hero extends BaseModel {
|
||||||
@ -125,28 +126,48 @@ class Hero extends BaseModel {
|
|||||||
'token_id' => $nftDb['token_id'],
|
'token_id' => $nftDb['token_id'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// if (!$row) {
|
|
||||||
// $itemMeta = mt\Item::get($nftDb['item_id']);
|
|
||||||
// if ($itemMeta) {
|
|
||||||
// self::addNftHero($itemMeta, $nftDb['token_id']);
|
|
||||||
// $row = SqlHelper::ormSelectOne(
|
|
||||||
// myself()->_getSelfMysql(),
|
|
||||||
// 't_hero',
|
|
||||||
// array(
|
|
||||||
// 'token_id' => $nftDb['token_id'],
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
// User::upsertHeadList($itemMeta);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
|
if (!$row['activate']) {
|
||||||
|
self::activateHero($row);
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hero',
|
||||||
|
array(
|
||||||
|
'token_id' => $nftDb['token_id'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
$cb($row);
|
$cb($row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function activateHero($row){
|
||||||
|
$itemMeta = mt\Item::get($row['hero_id']);
|
||||||
|
if (!$itemMeta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$randAttr = array();
|
||||||
|
$fieldsKv = array(
|
||||||
|
'hero_lv' => 1,
|
||||||
|
'quality' => 1,
|
||||||
|
'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)),
|
||||||
|
'state' => self::GETED_STATE,
|
||||||
|
'skill_lv1' => 1,
|
||||||
|
'skill_lv2' => 1,
|
||||||
|
'rand_attr' => json_encode($randAttr),
|
||||||
|
'lock_type' => self::NO_LOCK,
|
||||||
|
'unlock_time' => 0,
|
||||||
|
'unlock_trade_time' => 0,
|
||||||
|
'skill_points' => 0,
|
||||||
|
'labour' => 0,
|
||||||
|
'activate' => 1,
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
self::updateByTokenId($row['token_id'],$fieldsKv);
|
||||||
|
}
|
||||||
|
|
||||||
public static function toDto($row)
|
public static function toDto($row)
|
||||||
{
|
{
|
||||||
$attr = emptyReplace(json_decode($row['rand_attr'], true), array());
|
$attr = emptyReplace(json_decode($row['rand_attr'], true), array());
|
||||||
@ -204,6 +225,7 @@ class Hero extends BaseModel {
|
|||||||
array_push($attr_skill,$item);
|
array_push($attr_skill,$item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$chipIds = ChipPlugin::getInlayChip($row['token_id']);
|
||||||
$heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']);
|
$heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']);
|
||||||
$dto = array(
|
$dto = array(
|
||||||
'idx' => $row['idx'],
|
'idx' => $row['idx'],
|
||||||
@ -220,8 +242,8 @@ class Hero extends BaseModel {
|
|||||||
'attr_base' => $baseAttr,
|
'attr_base' => $baseAttr,
|
||||||
'attr_pro' => $attrPro,
|
'attr_pro' => $attrPro,
|
||||||
'attr_skill' => $attr_skill,
|
'attr_skill' => $attr_skill,
|
||||||
'attr_chip' => Chip::getChipAttr($row['chip_ids'])['attr_chip'],
|
'attr_chip' => Chip::getChipAttr($chipIds)['attr_chip'],
|
||||||
'chip_core' => Chip::getChipAttr($row['chip_ids'])['chip_core'],
|
'chip_core' => Chip::getChipAttr($chipIds)['chip_core'],
|
||||||
'try_count' => $row['try_count'],
|
'try_count' => $row['try_count'],
|
||||||
'lock_type' => $lockType,
|
'lock_type' => $lockType,
|
||||||
'unlock_time' => $unlockTime,
|
'unlock_time' => $unlockTime,
|
||||||
@ -236,7 +258,7 @@ class Hero extends BaseModel {
|
|||||||
'unlock_trade_time' => $row['unlock_trade_time'],
|
'unlock_trade_time' => $row['unlock_trade_time'],
|
||||||
'advanced_count' => $row['advanced_count'],
|
'advanced_count' => $row['advanced_count'],
|
||||||
'lucky' => $heroLucky,
|
'lucky' => $heroLucky,
|
||||||
'chip_ids' => $row['chip_ids'],
|
'chip_ids' => $chipIds,
|
||||||
'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],1)), //计算ceg上限所需参数
|
'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],1)), //计算ceg上限所需参数
|
||||||
'skill_common' => $skill_common,
|
'skill_common' => $skill_common,
|
||||||
'skill_points' => $row['skill_points'],
|
'skill_points' => $row['skill_points'],
|
||||||
@ -287,6 +309,7 @@ class Hero extends BaseModel {
|
|||||||
'unlock_trade_time' => 0,
|
'unlock_trade_time' => 0,
|
||||||
'skill_points' => 0,
|
'skill_points' => 0,
|
||||||
'labour' => 0,
|
'labour' => 0,
|
||||||
|
'activate' => 1,
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
);
|
);
|
||||||
@ -619,4 +642,5 @@ class Hero extends BaseModel {
|
|||||||
return $hero;
|
return $hero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user