This commit is contained in:
hujiabin 2024-04-25 11:44:48 +08:00
parent 2ffff4f3c4
commit d0a862f2f5
8 changed files with 13 additions and 204 deletions

View File

@ -288,7 +288,7 @@ class Hero(object):
['unseal_time', 0, '解封时间'],
['valid_time', 0, '最大有效时间'],
['valid_lefttime', 0, '剩余有效时间'],
['is_new', 0, '0:展示红点 1:不用展示'],
['is_old', 0, '0:展示红点 1:不用展示'],
]
class LevelingHero(object):
@ -335,7 +335,7 @@ class Item(object):
['item_uniid', 0, '道具唯一id'],
['item_id', 0, '道具id'],
['item_num', 0, '道具数量'],
['is_new', 0, '0:展示红点 1:不用展示'],
['is_old', 0, '0:展示红点 1:不用展示'],
['!attr', [Attr()], '属性'],
]
@ -892,7 +892,7 @@ class Chip(object):
['!rand_attr', [ChipAttr()], '属性'],
['tags', '', '1Gen状态'],
['quality', '', '品阶'],
['is_new', '', '0:展示红点 1:不用展示'],
['is_old', '', '0:展示红点 1:不用展示'],
]
class ChipPro(object):

View File

@ -174,7 +174,7 @@ CREATE TABLE `t_hero` (
`wealth_attr` mediumblob COMMENT '财富值属性',
`seal_type` int(11) NOT NULL DEFAULT '0' COMMENT '0:未封存 1已封存',
`unseal_time` int(11) NOT NULL DEFAULT '0' COMMENT '解开封时间',
`is_new` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ',
`is_old` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ',
PRIMARY KEY (`idx`),
UNIQUE KEY `token_id` (`token_id`),
@ -221,7 +221,7 @@ CREATE TABLE `t_bag` (
`rand_attr` mediumblob COMMENT '随机属性',
`today_get_gold` bigint NOT NULL DEFAULT '0' COMMENT '金币',
`last_get_gold_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后获取金币的时间',
`is_new` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ',
`is_old` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
@ -258,7 +258,7 @@ CREATE TABLE `t_chip` (
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1已初始激活',
`quality` int(11) NOT NULL DEFAULT '0' COMMENT '品阶',
`wealth_attr` mediumblob COMMENT '财富值属性',
`is_new` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ',
`is_old` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',

View File

@ -1,8 +1,8 @@
begin;
alter table t_hero add column `is_new` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ';
alter table t_chip add column `is_new` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ';
alter table t_bag add column `is_new` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ';
alter table t_hero add column `is_old` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ';
alter table t_chip add column `is_old` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ';
alter table t_bag add column `is_old` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ';

View File

@ -100,7 +100,7 @@ class Bag extends BaseModel {
'attr' => emptyReplace(json_decode($row['rand_attr'], true), array()),
'today_get_gold' => $todayGetGold,
'last_get_gold_time' => $lastGetGoldTime,
'is_new' => $row['is_new'],
'is_old' => $row['is_old'],
);
}
@ -216,12 +216,6 @@ class Bag extends BaseModel {
}
if ($itemMeta['cannot_stack']) {
$randAttr = array();
if (mt\Item::isRandAttrItem($itemMeta)) {
$qualityMeta = mt\ChipQuality::getByQuality($itemMeta['quality']);
if ($qualityMeta) {
$randAttr = mt\ChipQuality::getRandAttr($qualityMeta);
}
}
$fieldsKv = array(
'item_id' => $itemId,
'item_num' => 1,

View File

@ -196,7 +196,7 @@ class Chip extends BaseModel
'rand_attr'=> $rand_attr,
'quality'=> $row['quality'],
'attribute' => $attribute,
'is_new' => $row['is_new'],
'is_old' => $row['is_old'],
);
$dto['chip_name'] = mt\Item::get($row['item_id'])?mt\Item::get($row['item_id'])['name']:'XXX';
// $nft_address = '';

View File

@ -242,7 +242,7 @@ class Hero extends BaseModel {
$validTime - myself()->_getNowTime()),
'valid_time' => max(0,
86400 * $heroAtteMeta['validTime']),
'is_new' => $row['is_new'],
'is_old' => $row['is_old'],
);
}
@ -323,7 +323,7 @@ class Hero extends BaseModel {
$validTime - myself()->_getNowTime()),
'valid_time' => max(0,
86400 * $heroAtteMeta['validTime']),
'is_new' => $row['is_new'],
'is_old' => $row['is_old'],
);
// $nft_address = '';

View File

@ -1,119 +0,0 @@
<?php
namespace mt;
require_once('mt/AttrHelper.php');
require_once('mt/StrHelper.php');
require_once('mt/Item.php');
use phpcommon;
class ChipAttr {
const ROLE_CHIP_SUBTYPE = 1;
const GUN_CHIP_SUBTYPE = 2;
protected static $metaList;
protected static $attrPoolList;
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('chip@chip.php');
}
return self::$metaList;
}
protected static function getAttrPoolList()
{
if (!self::$attrPoolList) {
self::$attrPoolList = getMetaTable('chipAttrPool@chipAttrPool.php');
}
return self::$attrPoolList;
}
public static function getAttrPool($chip){
$temp = array();
$attrWeight = 0;
foreach (self::getAttrPoolList() as $item){
if ($item['chip_type'] == $chip['chip_type']){
$attrWeight += $item['attr_weight'];
for ($i = 0; $i < $item['attr_weight']; $i++) {
$temp[] = $item;
}
}
}
$attr_pool = $temp[rand(0, $attrWeight -1)];
if ($attr_pool){
$attr_pool['num_weight'] = explode('|',$attr_pool['num_weight']);
foreach ($attr_pool['num_weight'] as $key =>$item){
$attr_pool['num_weight'][$key] = explode(':',$item);
}
$weight = 0;
$tempData = array ();
foreach ($attr_pool['num_weight'] as $one) {
$weight += $one[1];
for ($i = 0; $i < $one[1]; $i++) {
$tempData[] = $one;
}
}
$k = rand(0, $weight -1);
$attr_pool['val'] = $tempData[$k][0];
unset($attr_pool['num_weight']);
}
return $attr_pool;
}
// public static function generateOneAttr($type){
//// $itemMeta = Item::get($item_id);
//// return self::getAttrPool(self::getAttrByItemId($itemMeta['id']));
//
//// $attr_pool = self::getAttrPool(self::getAttrByItemId($itemMeta['id']));
//// $attr = emptyReplace(json_decode($chip['rand_attr'], true), array());
//// array_push($attr,$attr_pool);
//// return $attr;
// if ($type == self::ROLE_CHIP_SUBTYPE){
// $chip = self::getNodeChip();
// $attr = $chip[ array_rand($chip)];
// return self::getAttrPool($attr);
// }
// if ($type == self::GUN_CHIP_SUBTYPE){
// $chip = self::getGunChip();
// $attr = $chip[ array_rand($chip)];
// return self::getAttrPool($attr);
// }
// return array();
// }
//
//
//
// private static function getNodeChip(){
// $node_chip = array();
// foreach (self::getMetaList() as $item){
// if ($item['chip_type'] == self::ROLE_CHIP_SUBTYPE){
// array_push($node_chip,$item);
// }
// }
// return $node_chip;
// }
//
// private static function getGunChip(){
// $gun_chip = array();
// foreach (self::getMetaList() as $item){
// if ($item['chip_type'] == self::GUN_CHIP_SUBTYPE){
// array_push($gun_chip,$item);
// }
// }
// return $gun_chip;
// }
public static function getAttrByItemId($item_id){
foreach (self::getMetaList() as $item){
if ($item['item_id'] == $item_id){
return $item;
}
}
}
}

View File

@ -1,66 +0,0 @@
<?php
namespace mt;
require_once('mt/AttrHelper.php');
require_once('mt/StrHelper.php');
use phpcommon;
class ChipQuality {
public static function get($id)
{
return getXVal(self::getMetaList(), $id);
}
public static function getByQuality($quality)
{
self::mustBeQualityHash();
return getXVal(self::$qualityHash, $quality, null);
}
public static function getRandAttr($qualityMeta)
{
$nums = explode(':', $qualityMeta['rand_attrs_num']);
$attrs = StrHelper::parseList($qualityMeta['rand_attrs'], array('|', ':'));
$num = rand($nums[0], $nums[1]);
shuffle($attrs);
$result = array();
$i = 0;
foreach ($attrs as $item) {
if ($i < $num) {
array_push($result,
array(
'attr_id' => $item[0],
'type' => $item[1],
'val' => rand($item[2], $item[3])
));
}
++$i;
}
return $result;
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('chipQuality@chipQuality.php');
}
return self::$metaList;
}
protected static function mustBeQualityHash()
{
if (!self::$qualityHash) {
self::$qualityHash = array();
foreach (self::getMetaList() as $meta) {
self::$qualityHash[$meta['quality']] = $meta;
}
}
}
protected static $metaList;
protected static $qualityHash;
}