英雄出战
This commit is contained in:
parent
1eabba61ff
commit
e47ef98c3f
@ -71,7 +71,7 @@ class User(object):
|
|||||||
['sex', 0, '更新性别(可选参数,不传就不更新)'],
|
['sex', 0, '更新性别(可选参数,不传就不更新)'],
|
||||||
['head_id', 0, '更新头像(可选参数,不传就不更新)'],
|
['head_id', 0, '更新头像(可选参数,不传就不更新)'],
|
||||||
['head_frame', 0, '更新头像框(可选参数,不传就不更新)'],
|
['head_frame', 0, '更新头像框(可选参数,不传就不更新)'],
|
||||||
['hero_id', 0, '更新上阵英雄id(可选参数,不传就不更新)'],
|
['hero_id', 0, '更新上阵英雄唯一id(可选参数,不传就不更新)'],
|
||||||
['first_fight', 0, '更新首次战斗(可选参数,不传就不更新)'],
|
['first_fight', 0, '更新首次战斗(可选参数,不传就不更新)'],
|
||||||
['already_guide', 0, '已引导(可选参数,不传就不更新)'],
|
['already_guide', 0, '已引导(可选参数,不传就不更新)'],
|
||||||
['guild_id', 0, '跟新工会id(可选参数,不传就不更新)'],
|
['guild_id', 0, '跟新工会id(可选参数,不传就不更新)'],
|
||||||
|
@ -333,7 +333,6 @@ class BaseAuthedController extends BaseController {
|
|||||||
case mt\Item::HERO_TYPE:
|
case mt\Item::HERO_TYPE:
|
||||||
{
|
{
|
||||||
Hero::addHero($itemMeta);
|
Hero::addHero($itemMeta);
|
||||||
User::upsertHeadList($itemMeta);
|
|
||||||
$propertyService->addHeroChg();
|
$propertyService->addHeroChg();
|
||||||
$propertyService->addUserChg();
|
$propertyService->addUserChg();
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,6 @@ class ShopController extends BaseAuthedController {
|
|||||||
case mt\Item::HERO_TYPE:
|
case mt\Item::HERO_TYPE:
|
||||||
{
|
{
|
||||||
Hero::addHero($itemMeta);
|
Hero::addHero($itemMeta);
|
||||||
User::upsertHeadList($itemMeta);
|
|
||||||
$propertyChgService->addHeroChg();
|
$propertyChgService->addHeroChg();
|
||||||
$propertyChgService->addUserChg();
|
$propertyChgService->addUserChg();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ require_once('models/Season.php');
|
|||||||
require_once('models/Nft.php');
|
require_once('models/Nft.php');
|
||||||
require_once('models/Gun.php');
|
require_once('models/Gun.php');
|
||||||
require_once('models/UserSeasonRing.php');
|
require_once('models/UserSeasonRing.php');
|
||||||
|
require_once('models/Chip.php');
|
||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Drop.php');
|
require_once('mt/Drop.php');
|
||||||
@ -28,6 +29,7 @@ use models\Hero;
|
|||||||
use models\Gun;
|
use models\Gun;
|
||||||
use models\Season;
|
use models\Season;
|
||||||
use models\Nft;
|
use models\Nft;
|
||||||
|
use models\Chip;
|
||||||
use models\UserSeasonRing;
|
use models\UserSeasonRing;
|
||||||
|
|
||||||
class UserController extends BaseAuthedController {
|
class UserController extends BaseAuthedController {
|
||||||
@ -62,74 +64,17 @@ class UserController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
$this->_incDailyV(TN_DAILY_LOGINS, 0, 1);
|
$this->_incDailyV(TN_DAILY_LOGINS, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addFragmentBox(){
|
|
||||||
$items = array(
|
|
||||||
array(
|
|
||||||
'item_id' => V_ITEM_GOLD,
|
|
||||||
'item_num' => 10000
|
|
||||||
),array(
|
|
||||||
'item_id' => V_ITEM_DIAMOND,
|
|
||||||
'item_num' => 10000
|
|
||||||
),
|
|
||||||
);
|
|
||||||
$boxMeta=\mt\Item::getMetaListByType(\mt\Item::FRAGMENT_BOX_TYPE);
|
|
||||||
foreach ($boxMeta as $box){
|
|
||||||
array_push($items,array(
|
|
||||||
'item_id' => $box['id'],
|
|
||||||
'item_num' => 10
|
|
||||||
));
|
|
||||||
}
|
|
||||||
$awardService = new services\AwardService();
|
|
||||||
$propertyChgService = new services\PropertyChgService();
|
|
||||||
$this->_addItems($items,$awardService,$propertyChgService);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addChip(){
|
|
||||||
$itemMeta = \mt\Item::getMetaListByType(\mt\Item::CHIP_TYPE);
|
|
||||||
$list1 = [];
|
|
||||||
$list2 = [];
|
|
||||||
foreach ($itemMeta as $value){
|
|
||||||
switch ($value['sub_type']){
|
|
||||||
case 1:{
|
|
||||||
array_push($list1,$value['id']);
|
|
||||||
};break;
|
|
||||||
case 2:{
|
|
||||||
array_push($list2,$value['id']);
|
|
||||||
};break;
|
|
||||||
default:{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for ($i=1;$i<=15;$i++){
|
|
||||||
$itemId1 = $list1[rand(0,count($list1)-1)];
|
|
||||||
$itemId2 = $list2[rand(0,count($list2)-1)];
|
|
||||||
$itemMeta = mt\Item::get($itemId1);
|
|
||||||
if ($itemMeta) {
|
|
||||||
$tokenType = Nft::getTokenType($itemMeta);
|
|
||||||
if ($tokenType == Nft::NONE_TYPE) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
Nft::addNft($itemMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$itemMeta2= mt\Item::get($itemId2);
|
|
||||||
if ($itemMeta2) {
|
|
||||||
$tokenType = Nft::getTokenType($itemMeta2);
|
|
||||||
if ($tokenType == Nft::NONE_TYPE) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
Nft::addNft($itemMeta2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function _addFreeItem(){
|
private function _addFreeItem(){
|
||||||
|
$chipMeta = \mt\Item::getMetaListByType(\mt\Item::CHIP_TYPE);
|
||||||
|
foreach ($chipMeta as $row){
|
||||||
|
Chip::addChip($row);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) {
|
foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) {
|
||||||
$heroMeta = mt\Item::get($heroId);
|
$heroMeta = mt\Item::get($heroId);
|
||||||
if ($heroMeta) {
|
if ($heroMeta) {
|
||||||
Hero::addHero($heroMeta);
|
Hero::addHero($heroMeta);
|
||||||
User::upsertHeadList($heroMeta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$addItems =array();
|
$addItems =array();
|
||||||
@ -143,15 +88,15 @@ class UserController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$items = array(
|
array_push($addItems,
|
||||||
array(
|
array(
|
||||||
'item_id' => V_ITEM_GOLD,
|
'item_id' => V_ITEM_GOLD,
|
||||||
'item_num' => 50
|
'item_num' => 50
|
||||||
)
|
));
|
||||||
);
|
|
||||||
$awardService = new services\AwardService();
|
$awardService = new services\AwardService();
|
||||||
$propertyChgService = new services\PropertyChgService();
|
$propertyChgService = new services\PropertyChgService();
|
||||||
$this->_addItems($items, $awardService, $propertyChgService);
|
$this->_addItems($addItems, $awardService, $propertyChgService);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loginCheck($userInfo)
|
private function loginCheck($userInfo)
|
||||||
@ -723,17 +668,17 @@ class UserController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, 'gun_id is error');
|
$this->_rspErr(1, 'gun_id is error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$temp = explode('|',$heroMeta['normal_gift']);
|
|
||||||
$userInfo = $this->_getOrmUserInfo();
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
||||||
if ($heroMeta['normal_gift'] && !in_array($heroMeta['normal_gift'],$headList)){
|
if ($heroMeta['hero_head'] && !in_array($heroMeta['hero_head'],$headList)){
|
||||||
array_push($headList,$heroMeta['normal_gift']);
|
array_push($headList,$heroMeta['hero_head']);
|
||||||
}
|
}
|
||||||
Hero::addFreeHero($heroMeta);
|
Hero::addFreeHero($heroMeta);
|
||||||
|
$heroUid = SqlHelper::getLastInsertId($this->_getSelfMysql());
|
||||||
Gun::addFreeGun($gunMeta);
|
Gun::addFreeGun($gunMeta);
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'hero_id' => $temp ? $temp[1] : 0,
|
'hero_id' => $heroUid,
|
||||||
'head_id' => $temp ? $temp[0] : 0,
|
'head_id' => $heroMeta['hero_head'],
|
||||||
'head_frame' => 60000,
|
'head_frame' => 60000,
|
||||||
'head_list' => json_encode($headList),
|
'head_list' => json_encode($headList),
|
||||||
'head_frame_list' => json_encode(array(60000)),
|
'head_frame_list' => json_encode(array(60000)),
|
||||||
|
@ -6,12 +6,14 @@ require_once('mt/Item.php');
|
|||||||
require_once('mt/LevelUp.php');
|
require_once('mt/LevelUp.php');
|
||||||
require_once('models/UserSeasonRing.php');
|
require_once('models/UserSeasonRing.php');
|
||||||
require_once('models/Parachute.php');
|
require_once('models/Parachute.php');
|
||||||
|
require_once('models/Hero.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
use phpcommon;
|
use phpcommon;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\UserSeasonRing;
|
use models\UserSeasonRing;
|
||||||
use models\Parachute;
|
use models\Parachute;
|
||||||
|
use models\Hero;
|
||||||
|
|
||||||
class User extends BaseModel {
|
class User extends BaseModel {
|
||||||
|
|
||||||
@ -42,6 +44,11 @@ class User extends BaseModel {
|
|||||||
public static function show($row)
|
public static function show($row)
|
||||||
{
|
{
|
||||||
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
|
$heroDb = Hero::find($row['hero_id']);
|
||||||
|
$heroId = 0;
|
||||||
|
if ($heroDb){
|
||||||
|
$heroId = $heroDb['hero_id'];
|
||||||
|
}
|
||||||
return array(
|
return array(
|
||||||
'activated' => $row['activated'],
|
'activated' => $row['activated'],
|
||||||
'rename_count' => $row['rename_count'],
|
'rename_count' => $row['rename_count'],
|
||||||
@ -59,14 +66,14 @@ class User extends BaseModel {
|
|||||||
'bceg' => cegFormat($row['bceg']),
|
'bceg' => cegFormat($row['bceg']),
|
||||||
'gold' => cegFormat($row['gold']),
|
'gold' => cegFormat($row['gold']),
|
||||||
'diamond' => cecFormat($row['diamond']),
|
'diamond' => cecFormat($row['diamond']),
|
||||||
'hero_id' => $row['hero_id'],
|
'hero_id' => $heroId,
|
||||||
'first_fight' => $row['first_fight'],
|
'first_fight' => $row['first_fight'],
|
||||||
'already_guide' => $row['already_guide'],
|
'already_guide' => $row['already_guide'],
|
||||||
'pve_instance_id' => $row['pve_instance_id'],
|
'pve_instance_id' => $row['pve_instance_id'],
|
||||||
'like_count' => $row['like_count'],
|
'like_count' => $row['like_count'],
|
||||||
// 'head_list' => self::getHeadList($row),
|
'head_list' => self::getHeadList($row),
|
||||||
'head_list' => self::exportHeadList($row)['head_list'],
|
// 'head_list' => self::exportHeadList($row)['head_list'],
|
||||||
'hero_list' => self::exportHeadList($row)['hero_list'],
|
// 'hero_list' => self::exportHeadList($row)['hero_list'],
|
||||||
'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()),
|
'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()),
|
||||||
'is_gain_item' => $row['is_gain_item'],
|
'is_gain_item' => $row['is_gain_item'],
|
||||||
'guild_id' => $row['guild_id'],
|
'guild_id' => $row['guild_id'],
|
||||||
@ -82,6 +89,11 @@ class User extends BaseModel {
|
|||||||
public static function info($row)
|
public static function info($row)
|
||||||
{
|
{
|
||||||
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
|
$heroDb = Hero::find($row['hero_id']);
|
||||||
|
$heroId = 0;
|
||||||
|
if ($heroDb){
|
||||||
|
$heroId = $heroDb['hero_id'];
|
||||||
|
}
|
||||||
return array(
|
return array(
|
||||||
'activated' => $row['activated'],
|
'activated' => $row['activated'],
|
||||||
'rename_count' => $row['rename_count'],
|
'rename_count' => $row['rename_count'],
|
||||||
@ -99,12 +111,12 @@ class User extends BaseModel {
|
|||||||
'bceg' => cegFormat($row['bceg']),
|
'bceg' => cegFormat($row['bceg']),
|
||||||
'gold' => cegFormat($row['gold']),
|
'gold' => cegFormat($row['gold']),
|
||||||
'diamond' => cecFormat($row['diamond']),
|
'diamond' => cecFormat($row['diamond']),
|
||||||
'hero_id' => $row['hero_id'],
|
'hero_id' => $heroId,
|
||||||
'first_fight' => $row['first_fight'],
|
'first_fight' => $row['first_fight'],
|
||||||
'already_guide' => $row['already_guide'],
|
'already_guide' => $row['already_guide'],
|
||||||
// 'head_list' => self::getHeadList($row),
|
'head_list' => self::getHeadList($row),
|
||||||
'head_list' => self::exportHeadList($row)['head_list'],
|
// 'head_list' => self::exportHeadList($row)['head_list'],
|
||||||
'hero_list' => self::exportHeadList($row)['hero_list'],
|
// 'hero_list' => self::exportHeadList($row)['hero_list'],
|
||||||
'pve_instance_id' => $row['pve_instance_id'],
|
'pve_instance_id' => $row['pve_instance_id'],
|
||||||
'like_count' => $row['like_count'],
|
'like_count' => $row['like_count'],
|
||||||
'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()),
|
'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()),
|
||||||
@ -122,6 +134,12 @@ class User extends BaseModel {
|
|||||||
|
|
||||||
public static function toSimple($row)
|
public static function toSimple($row)
|
||||||
{
|
{
|
||||||
|
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
|
$heroDb = Hero::find($row['hero_id']);
|
||||||
|
$heroId = 0;
|
||||||
|
if ($heroDb){
|
||||||
|
$heroId = $heroDb['hero_id'];
|
||||||
|
}
|
||||||
return array(
|
return array(
|
||||||
'account_id' => $row['account_id'],
|
'account_id' => $row['account_id'],
|
||||||
'address' => phpcommon\extractOpenId($row['account_id']),
|
'address' => phpcommon\extractOpenId($row['account_id']),
|
||||||
@ -135,7 +153,7 @@ class User extends BaseModel {
|
|||||||
'score' => $row['score'],
|
'score' => $row['score'],
|
||||||
'gold' => cegFormat($row['gold']),
|
'gold' => cegFormat($row['gold']),
|
||||||
'diamond' => cecFormat($row['diamond']),
|
'diamond' => cecFormat($row['diamond']),
|
||||||
'hero_id' => $row['hero_id'],
|
'hero_id' => $heroId,
|
||||||
'pve_instance_id' => $row['pve_instance_id'],
|
'pve_instance_id' => $row['pve_instance_id'],
|
||||||
'like_count' => $row['like_count'],
|
'like_count' => $row['like_count'],
|
||||||
'first_fight' => $row['first_fight'],
|
'first_fight' => $row['first_fight'],
|
||||||
@ -144,14 +162,18 @@ class User extends BaseModel {
|
|||||||
|
|
||||||
public static function isValidHeadId($userInfo, $headId)
|
public static function isValidHeadId($userInfo, $headId)
|
||||||
{
|
{
|
||||||
$headList = self::exportHeadList($userInfo);
|
// $headList = self::exportHeadList($userInfo);
|
||||||
return in_array($headId, $headList['head_list']);
|
// return in_array($headId, $headList['head_list']);
|
||||||
|
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
||||||
|
return in_array($headId, $headList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isValidHeroId($userInfo, $heroId)
|
public static function isValidHeroId($userInfo, $heroId)
|
||||||
{
|
{
|
||||||
$heroList = self::exportHeadList($userInfo);
|
// $heroList = self::exportHeadList($userInfo);
|
||||||
return in_array($heroId, $heroList['hero_list']);
|
// return in_array($heroId, $heroList['hero_list']);
|
||||||
|
$heroDb = Hero::find($heroId);
|
||||||
|
return empty($heroDb) ? false : true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isValidHeadFrame($userInfo, $headFrame)
|
public static function isValidHeadFrame($userInfo, $headFrame)
|
||||||
@ -173,16 +195,13 @@ class User extends BaseModel {
|
|||||||
private static function getHeadList($userInfo)
|
private static function getHeadList($userInfo)
|
||||||
{
|
{
|
||||||
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
||||||
$rows = SqlHelper::ormSelect(
|
$rows = array();
|
||||||
myself()->_getSelfMysql(),
|
Hero::getHeroList(function ($row) use (&$rows){
|
||||||
't_hero',
|
array_push($rows,$row);
|
||||||
array(
|
});
|
||||||
'account_id' => $userInfo['account_id'],
|
|
||||||
)
|
|
||||||
);
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$itemMeta = mt\Item::get($row['hero_id']);
|
$itemMeta = mt\Item::get($row['hero_id']);
|
||||||
if ($itemMeta && $itemMeta['hero_head']) {
|
if ($itemMeta && $itemMeta['hero_head'] && !in_array($itemMeta['hero_head'],$headList)) {
|
||||||
array_push($headList, $itemMeta['hero_head']);
|
array_push($headList, $itemMeta['hero_head']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,17 +249,6 @@ class User extends BaseModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUserByRank($rank){
|
|
||||||
|
|
||||||
$list = SqlHelper::ormSelect(
|
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_user',
|
|
||||||
array(
|
|
||||||
'rank'=> $rank
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return $list ? $list: array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getUserByRankMess($row){
|
public static function getUserByRankMess($row){
|
||||||
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||||
@ -318,22 +326,4 @@ class User extends BaseModel {
|
|||||||
);
|
);
|
||||||
return $list ? $list: array();
|
return $list ? $list: array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function upsertHeadList($itemMeta){
|
|
||||||
$head = $itemMeta?$itemMeta['normal_gift']:'';
|
|
||||||
if (!$head){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$userInfo = myself()->_getOrmUserInfo();
|
|
||||||
$head_list = emptyReplace(json_decode($userInfo['head_list'], true), array());
|
|
||||||
if (in_array($head,$head_list)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
array_push($head_list,$head);
|
|
||||||
$fields = array(
|
|
||||||
'head_list' => json_encode($head_list),
|
|
||||||
);
|
|
||||||
self::update($fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user