经济系统(1)
This commit is contained in:
parent
b3142aedd0
commit
1b38768d80
14
sql/gamedb2006_migrate_240305_01.sql
Normal file
14
sql/gamedb2006_migrate_240305_01.sql
Normal file
@ -0,0 +1,14 @@
|
||||
begin;
|
||||
|
||||
alter table t_hero add column `current_wealth` int(11) NOT NULL DEFAULT '0' COMMENT '当前财富值';
|
||||
alter table t_hero add column `current_wealth_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '当前财富值修改时间';
|
||||
alter table t_hero add column `wealth_attr` mediumblob COMMENT '财富值属性';
|
||||
alter table t_hero drop column base_attr;
|
||||
|
||||
alter table t_chip add column `wealth_attr` mediumblob COMMENT '财富值属性';
|
||||
|
||||
|
||||
|
||||
insert into version (version) values(2024030501);
|
||||
|
||||
commit;
|
@ -1,29 +1,15 @@
|
||||
<?php
|
||||
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Bag.php');
|
||||
|
||||
require_once('mt/ChipAttr.php');
|
||||
require_once('mt/HeroQuality.php');
|
||||
require_once('mt/ChipAttribute.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
|
||||
require_once('services/FormulaService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
use models\Chip;
|
||||
use models\Bag;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\User;
|
||||
use services\FormulaService;
|
||||
use services\LogService;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class ChipController extends BaseAuthedController
|
||||
@ -94,8 +80,12 @@ class ChipController extends BaseAuthedController
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
$chipMeta = \mt\Item::get($chipDb['item_id']);
|
||||
$chipAttrMeta = \mt\ChipAttribute::get($chipMeta['id']);
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($chipAttrMeta['economyAttribute'],$chipDb['quality'] + 1);
|
||||
Chip::update2($chipUniId, array(
|
||||
'quality' => $chipDb['quality'] + 1,
|
||||
'wealth_attr' => json_encode($attribute),
|
||||
));
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addChip();
|
||||
|
@ -27,7 +27,7 @@ class ChipPageController extends BaseAuthedController
|
||||
$chipPageDb = ChipPage::find($heroUid);
|
||||
}
|
||||
$chipPageService = new services\ChipPageService();
|
||||
$chipPageService->refreshSlotState($chipPageDb);
|
||||
$chipPageService->refreshSlotState($chipPageDb,$heroDb);
|
||||
$chipPageDb = ChipPage::find($heroUid);
|
||||
$chipPageDto = ChipPage::toDtoInfo($chipPageDb);
|
||||
$this->_rspData(array(
|
||||
@ -43,6 +43,11 @@ class ChipPageController extends BaseAuthedController
|
||||
$this->_rspErr(1, 'Missing parameter');
|
||||
return ;
|
||||
}
|
||||
$heroDb = Hero::find($hero_unnid);
|
||||
if (!$heroDb){
|
||||
$this->_rspErr(1,'param error');
|
||||
return ;
|
||||
}
|
||||
$chipPageDb = ChipPage::find($hero_unnid);
|
||||
if (!$chipPageDb){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
@ -102,6 +107,11 @@ class ChipPageController extends BaseAuthedController
|
||||
$this->_rspErr(1, 'Missing parameter');
|
||||
return ;
|
||||
}
|
||||
$heroDb = Hero::find($hero_unnid);
|
||||
if (!$heroDb){
|
||||
$this->_rspErr(1,'param error');
|
||||
return ;
|
||||
}
|
||||
$chipPageDb = ChipPage::find($hero_unnid);
|
||||
if (!$chipPageDb){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
@ -126,6 +136,11 @@ class ChipPageController extends BaseAuthedController
|
||||
|
||||
public function removeChipAll(){
|
||||
$hero_unnid = getReqVal('hero_unnid',0);
|
||||
$heroDb = Hero::find($hero_unnid);
|
||||
if (!$heroDb){
|
||||
$this->_rspErr(1,'param error');
|
||||
return ;
|
||||
}
|
||||
$chipPageDb = ChipPage::find($hero_unnid);
|
||||
if (!$chipPageDb){
|
||||
$this->_rspErr(1,'page parameter error');
|
||||
|
@ -2,37 +2,33 @@
|
||||
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/HeroLevel.php');
|
||||
require_once('mt/Skill.php');
|
||||
require_once('mt/HeroQuality.php');
|
||||
require_once('mt/ChipAttribute.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/ChipPage.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/HeroPreset.php');
|
||||
require_once('models/Bag.php');
|
||||
require_once('models/Transaction.php');
|
||||
require_once('models/BcOrder.php');
|
||||
|
||||
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/LogService.php');
|
||||
require_once('services/BlockChainService.php');
|
||||
|
||||
|
||||
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
use models\HeroSkin;
|
||||
use models\ChipPage;
|
||||
use models\Gun;
|
||||
use models\Nft;
|
||||
use models\HeroPreset;
|
||||
use models\Bag;
|
||||
use models\Transaction;
|
||||
use models\BcOrder;
|
||||
|
||||
use services\LogService;
|
||||
|
||||
class HeroController extends BaseAuthedController {
|
||||
@ -42,9 +38,7 @@ class HeroController extends BaseAuthedController {
|
||||
{
|
||||
$heroList = array();
|
||||
Hero::getHeroList(function ($row) use(&$heroList) {
|
||||
// if(!in_array($row['hero_id'],array(30200,30700,31000))){
|
||||
array_push($heroList, Hero::toDto($row));
|
||||
// }
|
||||
array_push($heroList, $row);
|
||||
});
|
||||
$this->_rspData(array(
|
||||
'hero_list' => $heroList
|
||||
@ -189,8 +183,11 @@ class HeroController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
$heroMeta = \mt\Item::get($heroDb['hero_id']);
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($heroMeta['relationship'], $heroDb['quality'] + 1);
|
||||
Hero::update($heroUniId, array(
|
||||
'quality' => $heroDb['quality'] + 1,
|
||||
'wealth_attr' => json_encode($attribute),
|
||||
));
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addHeroChg();
|
||||
|
@ -9,6 +9,8 @@ require_once('services/ContractConfig.php');
|
||||
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/ChipAttr.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
require_once('mt/ChipAttribute.php');
|
||||
|
||||
|
||||
use mt;
|
||||
@ -45,6 +47,7 @@ class Chip extends BaseModel
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
public static function update2($chipUniId, $fieldsKv){
|
||||
if (self::find($chipUniId)) {
|
||||
SqlHelper::update
|
||||
@ -167,13 +170,8 @@ class Chip extends BaseModel
|
||||
// $todayGetGold = 0;
|
||||
// }
|
||||
$rand_attr = emptyReplace(json_decode($row['rand_attr'], true), array());
|
||||
$chipMeta = mt\ChipAttr::getAttrByItemId($row['item_id']);
|
||||
if ($chipMeta){
|
||||
array_unshift($rand_attr,array(
|
||||
'attr_id'=>$chipMeta['attr_id'],
|
||||
'val' => $chipMeta['lv'.$row['chip_grade']]
|
||||
));
|
||||
}
|
||||
$attribute = emptyReplace(json_decode($row['wealth_attr'], true), array());
|
||||
|
||||
$dto = array(
|
||||
'idx'=> $row['idx'],
|
||||
'chip_uniid'=> $row['idx'],
|
||||
@ -185,6 +183,7 @@ class Chip extends BaseModel
|
||||
'inlay_state'=> $row['inlay_state'],
|
||||
'rand_attr'=> $rand_attr,
|
||||
'quality'=> $row['quality'],
|
||||
'attribute' => $attribute,
|
||||
);
|
||||
$dto['chip_name'] = mt\Item::get($row['item_id'])?mt\Item::get($row['item_id'])['name']:'XXX';
|
||||
// $nft_address = '';
|
||||
@ -244,17 +243,26 @@ class Chip extends BaseModel
|
||||
|
||||
public static function internalAddItem($conn, $itemMeta, $accountId, $tokenId,$state,$quality=1)
|
||||
{
|
||||
|
||||
$randAttr = array();
|
||||
$chipAttrMeta = \mt\ChipAttribute::get($itemMeta['id']);
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($chipAttrMeta['economyAttribute'],$quality);
|
||||
{
|
||||
$randAttr = array();
|
||||
$randMeta = mt\BattleRandAttribute::getByWeight($chipAttrMeta['battleAttribute']);
|
||||
if ($randMeta){
|
||||
$randAttr = mt\BattleRandAttribute::getRandAttr($randMeta);
|
||||
}
|
||||
}
|
||||
$fieldsKv = array(
|
||||
'item_id' => $itemMeta['id'],
|
||||
'item_num' => 1,
|
||||
'state' => $state,
|
||||
'rand_attr' => json_encode($randAttr),
|
||||
'chip_grade' => 1,
|
||||
'inlay_state' => 0,
|
||||
'chip_type' => $itemMeta['sub_type'],
|
||||
'activate' => 1,
|
||||
'quality' => $quality,
|
||||
'wealth_attr' => json_encode($attribute),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
@ -306,13 +314,9 @@ class Chip extends BaseModel
|
||||
}
|
||||
|
||||
public static function updateInlayState($chip_unnid,$status){
|
||||
$row = self::find($chip_unnid);
|
||||
if ($row){
|
||||
self::update2($chip_unnid,array(
|
||||
'inlay_state' => $status
|
||||
));
|
||||
}
|
||||
|
||||
self::update2($chip_unnid,array(
|
||||
'inlay_state' => $status
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,11 +21,6 @@ class ChipPage extends BaseModel
|
||||
'hero_uniid' => $hero_unnid
|
||||
)
|
||||
);
|
||||
if ($row){
|
||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||
$row = null;
|
||||
}
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
@ -36,6 +31,7 @@ class ChipPage extends BaseModel
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
if ( !$chipDb ) {
|
||||
$value['chip_id'] = 0;
|
||||
Chip::updateInlayState($value['chip_id'],0);
|
||||
}
|
||||
}
|
||||
self::update($row['hero_uniid'],array(
|
||||
@ -49,12 +45,7 @@ class ChipPage extends BaseModel
|
||||
if ($value['chip_id']){
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
$newData[$key]['item_id'] = $chipDb['item_id'];
|
||||
$chipAttrMeta = ChipAttr::getAttrByItemId($chipDb['item_id']);
|
||||
$rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array());
|
||||
array_push($attrs,array(
|
||||
'attr_id'=>$chipAttrMeta['attr_id'],
|
||||
'val'=>$chipAttrMeta['lv'.$chipDb['chip_grade']],
|
||||
));
|
||||
foreach ($rand_attr as $val){
|
||||
array_push($attrs,$val);
|
||||
}
|
||||
@ -83,6 +74,7 @@ class ChipPage extends BaseModel
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
if ( !$chipDb ) {
|
||||
$value['chip_id'] = 0;
|
||||
Chip::updateInlayState($value['chip_id'],0);
|
||||
}
|
||||
}
|
||||
self::update($row['hero_uniid'],array(
|
||||
@ -92,16 +84,9 @@ class ChipPage extends BaseModel
|
||||
$newData = emptyReplace(json_decode($newRow['data'], true), array());
|
||||
$attrs = array();
|
||||
foreach ($newData as $key=>$value){
|
||||
$newData[$key]['item_id'] = 0;
|
||||
if ($value['chip_id']){
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
$newData[$key]['item_id'] = $chipDb['item_id'];
|
||||
$chipAttrMeta = ChipAttr::getAttrByItemId($chipDb['item_id']);
|
||||
$rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array());
|
||||
array_push($attrs,array(
|
||||
'attr_id'=>$chipAttrMeta['attr_id'],
|
||||
'val'=>$chipAttrMeta['lv'.$chipDb['chip_grade']],
|
||||
));
|
||||
foreach ($rand_attr as $val){
|
||||
array_push($attrs,$val);
|
||||
}
|
||||
|
@ -10,11 +10,13 @@ require_once('mt/AttrHelper.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/BattleBasicAttribute.php');
|
||||
require_once('mt/BattleRandAttribute.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Avatar.php');
|
||||
require_once('models/ChipPlugin.php');
|
||||
require_once('models/ChipPage.php');
|
||||
require_once('services/NftService.php');
|
||||
require_once('services/FormulaService.php');
|
||||
require_once('services/ContractConfig.php');
|
||||
@ -26,8 +28,7 @@ use phpcommon\SqlHelper;
|
||||
use services\NftService;
|
||||
use services\FormulaService;
|
||||
use services\ContractConfig;
|
||||
use models\ChipPlugin;
|
||||
use models\User;
|
||||
|
||||
|
||||
class Hero extends BaseModel {
|
||||
|
||||
@ -257,6 +258,7 @@ class Hero extends BaseModel {
|
||||
$isSelect = 1;
|
||||
}
|
||||
$skinDb = HeroSkin::findBx($row['hero_id']);
|
||||
$attribute = self::celHeroWealthUpLimit($row);
|
||||
$dto = array(
|
||||
'idx' => $row['idx'],
|
||||
'token_id' => $row['token_id'],
|
||||
@ -283,9 +285,10 @@ class Hero extends BaseModel {
|
||||
'offer_reward_state' => 0,
|
||||
'tags' => isset($row['tags'])?$row['tags']:'',
|
||||
'is_select' => $isSelect,
|
||||
'lucky' => $attribute['lucky'],
|
||||
'current_wealth' => $row['current_wealth'],
|
||||
'wealth_uplimit' => $attribute['wealth'],
|
||||
'ability' => self::abilityInfo($row, $attr)
|
||||
|
||||
|
||||
);
|
||||
|
||||
// $nft_address = '';
|
||||
@ -297,6 +300,38 @@ class Hero extends BaseModel {
|
||||
return $dto;
|
||||
}
|
||||
|
||||
private static function celHeroWealthUpLimit($row){
|
||||
|
||||
//最大财富值和幸运值计算
|
||||
$wealth = 0;
|
||||
$wealth_rate = 0;
|
||||
$lucky = 0;
|
||||
$lucky_rate = 0;
|
||||
$heroAttrs = emptyReplace(json_decode($row['wealth_attr'], true), array());
|
||||
$heroResult = \mt\EconomyAttribute::getAttrValue($heroAttrs);
|
||||
$wealth += $heroResult['wealth'];
|
||||
$wealth_rate += $heroResult['wealth_rate'];
|
||||
$lucky += $heroResult['lucky'];
|
||||
$lucky_rate += $heroResult['lucky_rate'];
|
||||
$chipPageDb = ChipPage::find($row['idx']);
|
||||
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
|
||||
foreach ($data as $value){
|
||||
$chipDb = Chip::find($value['chip_id']);
|
||||
if ( $chipDb ) {
|
||||
$chipAttrs = emptyReplace(json_decode($chipDb['wealth_attr'], true), array());
|
||||
$chipResult = \mt\EconomyAttribute::getAttrValue($chipAttrs);
|
||||
$wealth += $chipResult['wealth'];
|
||||
$wealth_rate += $chipResult['wealth_rate'];
|
||||
$lucky += $chipResult['lucky'];
|
||||
$lucky_rate += $chipResult['lucky_rate'];
|
||||
}
|
||||
}
|
||||
return array(
|
||||
"wealth" => floor($wealth * (1+$wealth_rate)),
|
||||
"lucky" => floor($lucky * (1+$lucky_rate)),
|
||||
);
|
||||
}
|
||||
|
||||
public static function avatarInfo($row){
|
||||
$avatarDbs = Avatar::getAvatarByHeroIdx($row['idx']);
|
||||
$avatarInfos = array();
|
||||
@ -495,6 +530,11 @@ class Hero extends BaseModel {
|
||||
}
|
||||
}
|
||||
$randAttr = self::getRandAttr($heroMeta['id']) ;
|
||||
{
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($heroMeta['relationship'], $quality);
|
||||
$result = \mt\EconomyAttribute::getAttrValue($attribute);
|
||||
$wealth = floor($result['wealth'] * (1+$result['wealth_rate']));
|
||||
}
|
||||
$fieldsKv = array(
|
||||
'hero_id' => $heroMeta['id'],
|
||||
'hero_lv' => 1,
|
||||
@ -508,9 +548,11 @@ class Hero extends BaseModel {
|
||||
'unlock_time' => 0,
|
||||
'unlock_trade_time' => 0,
|
||||
'activate' => 1,
|
||||
'base_attr' => json_encode($randAttr),
|
||||
'current_wealth' => $wealth,
|
||||
'wealth_attr' => json_encode($attribute),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
'wealth_modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
if ($accountId) {
|
||||
$fieldsKv['account_id'] = $accountId;
|
||||
|
30
webapp/mt/AttributeList.php
Normal file
30
webapp/mt/AttributeList.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace mt;
|
||||
|
||||
|
||||
class AttributeList
|
||||
{
|
||||
|
||||
const WEALTH_ABS = 51; //财富值-数量加成容器
|
||||
const WEALTH_RATE = 52; //财富值-比例加成容器-集合型
|
||||
const LUCKY_ABS = 54; //幸运值-数量加成容器
|
||||
const LUCKY_RATE = 55; //幸运值-比例加成容器-集合型
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return getXVal(self::getMetaList(), $id);
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('attributeList@attributeList.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
|
||||
}
|
30
webapp/mt/ChipAttribute.php
Normal file
30
webapp/mt/ChipAttribute.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace mt;
|
||||
|
||||
require_once('mt/AttrHelper.php');
|
||||
require_once('mt/StrHelper.php');
|
||||
require_once('mt/Item.php');
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class ChipAttribute {
|
||||
public static function get($id)
|
||||
{
|
||||
return getXVal(self::getMetaList(), $id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('chipAttribute@chipAttribute.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
|
||||
}
|
116
webapp/mt/EconomyAttribute.php
Normal file
116
webapp/mt/EconomyAttribute.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace mt;
|
||||
|
||||
require_once('mt/AttributeList.php');
|
||||
|
||||
class EconomyAttribute
|
||||
{
|
||||
|
||||
public static function getAttribute($index,$quality){
|
||||
$meta = self::findByGrade($index,$quality);
|
||||
$attribute = array();
|
||||
if ($meta){
|
||||
$attrs = explode("|",$meta['attribute']);
|
||||
foreach ($attrs as $attr){
|
||||
$temp = explode(":",$attr);
|
||||
switch ($temp[0]){
|
||||
case AttributeList::WEALTH_ABS : {
|
||||
array_push($attribute,array(
|
||||
"attr_id" => AttributeList::WEALTH_ABS,
|
||||
"val" => rand($temp[1],$temp[2])
|
||||
));
|
||||
}
|
||||
break;
|
||||
case AttributeList::WEALTH_RATE : {
|
||||
array_push($attribute,array(
|
||||
"attr_id" => AttributeList::WEALTH_RATE,
|
||||
"val" => rand($temp[1]*10000,$temp[2]*10000)/10000
|
||||
));
|
||||
}
|
||||
break;
|
||||
case AttributeList::LUCKY_ABS : {
|
||||
array_push($attribute,array(
|
||||
"attr_id" => AttributeList::LUCKY_ABS,
|
||||
"val" => rand($temp[1],$temp[2])
|
||||
));
|
||||
}
|
||||
break;
|
||||
case AttributeList::LUCKY_RATE : {
|
||||
array_push($attribute,array(
|
||||
"attr_id" => AttributeList::LUCKY_RATE,
|
||||
"val" => rand($temp[1]*10000,$temp[2]*10000)/10000
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
public static function getAttrValue($attribute){
|
||||
$wealth = 0;
|
||||
$wealth_rate = 0;
|
||||
$lucky = 0;
|
||||
$lucky_rate = 0;
|
||||
foreach ($attribute as $value){
|
||||
switch ($value['attr_id']){
|
||||
case AttributeList::WEALTH_ABS :{
|
||||
$wealth += $value['val'];
|
||||
}
|
||||
break;
|
||||
case AttributeList::WEALTH_RATE:{
|
||||
$wealth_rate += $value['val'];
|
||||
}
|
||||
break;
|
||||
case AttributeList::LUCKY_ABS :{
|
||||
$lucky += $value['val'];
|
||||
}
|
||||
break;
|
||||
case AttributeList::LUCKY_RATE:{
|
||||
$lucky_rate += $value['val'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// $wealthVal = floor($wealth * (1+$wealth_rate));
|
||||
// $luckyVal = floor($lucky * (1+$lucky_rate));
|
||||
return array(
|
||||
"wealth" => $wealth,
|
||||
"wealth_rate" => $wealth_rate,
|
||||
"lucky" => $lucky,
|
||||
"lucky_rate" => $lucky_rate,
|
||||
);
|
||||
}
|
||||
|
||||
public static function findByGrade($index,$quality){
|
||||
foreach (self::getMetaList() as $meta){
|
||||
if ($meta['invoke'] == $index && $meta['grade'] == $quality){
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getByIndex($index){
|
||||
$metaList = array();
|
||||
foreach (self::getMetaList() as $meta){
|
||||
if ($meta['invoke'] == $index){
|
||||
array_push($metaList,$meta);
|
||||
}
|
||||
}
|
||||
return $metaList;
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('economyAttribute@economyAttribute.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
}
|
@ -5,28 +5,56 @@ namespace services;
|
||||
require_once('models/ChipPage.php');
|
||||
|
||||
require_once('mt/StarLevel.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
|
||||
use models\ChipPage;
|
||||
use mt\EconomyAttribute;
|
||||
use mt\Item;
|
||||
use phpcommon\SqlHelper;
|
||||
class ChipPageService extends BaseService
|
||||
{
|
||||
const MAX_CHIP_SLOT_NUM = 30;
|
||||
const INIT_CHIP_PAGE_NUM = 3;
|
||||
|
||||
public function refreshSlotState($row){
|
||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||
$userInfo = myself()->_getOrmUserInfo();
|
||||
$maxSlot = \mt\StarLevel::getMaxSlot($userInfo['star_num']);
|
||||
foreach ($data as &$val){
|
||||
if ($maxSlot < $val['slot_id'] && $val['state'] == 0){
|
||||
$val['state'] = 0;
|
||||
}else{
|
||||
$val['state'] = 1;
|
||||
}
|
||||
public function refreshSlotState($row,$heroDb){
|
||||
|
||||
$itemMeta = Item::get($heroDb['hero_id']);
|
||||
if (!$itemMeta){
|
||||
return ;
|
||||
}
|
||||
$heroAtteMeta = EconomyAttribute::findByGrade($itemMeta['relationship'],$heroDb['quality']);
|
||||
if (!$heroAtteMeta){
|
||||
return ;
|
||||
}
|
||||
$chipSlot = explode("|",$heroAtteMeta['chipSlot']);
|
||||
$slotArr = array();
|
||||
if ($chipSlot[0] > 0){
|
||||
for ($i=0;$i<$chipSlot[0];$i++){
|
||||
array_push($slotArr,$i*3 +1 );
|
||||
}
|
||||
ChipPage::update($row['hero_uniid'],array(
|
||||
'data' => json_encode($data),
|
||||
));
|
||||
}
|
||||
if ($chipSlot[1] > 0){
|
||||
for ($i=0;$i<$chipSlot[1];$i++){
|
||||
array_push($slotArr,$i*3 +2 );
|
||||
}
|
||||
}
|
||||
if ($chipSlot[2] > 0){
|
||||
for ($i=0;$i<$chipSlot[2];$i++){
|
||||
array_push($slotArr,$i*3 +3 );
|
||||
}
|
||||
}
|
||||
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||
|
||||
foreach ($data as &$val){
|
||||
if ( in_array($val['slot_id'],$slotArr) ){
|
||||
$val['state'] = 1;
|
||||
}else{
|
||||
$val['state'] = 0;
|
||||
}
|
||||
}
|
||||
ChipPage::update($row['hero_uniid'],array(
|
||||
'data' => json_encode($data),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user