From cd885b85d683d06cf863e351aaae021091cb75b2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 7 Dec 2021 16:01:32 +0800 Subject: [PATCH] 1 --- webapp/controller/UserController.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index c094649..1ba9e0f 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -52,6 +52,7 @@ class UserController extends BaseAuthedController { $gold = 0; $diamond = 0; $heroList = array(); + $haveHeadHeroList = array(); $headList = array(); $headFrameList = array(); $addItems = array(); @@ -60,7 +61,10 @@ class UserController extends BaseAuthedController { $heroMeta = mt\Hero::get($heroId); if ($heroMeta) { Hero::addHero($heroMeta); - array_push($heroList, $heroId); + array_push($heroList, $heroMeta); + if ($heroMeta['hero_head']) { + array_push($haveHeadHeroList, $heroMeta); + } } } } @@ -111,7 +115,11 @@ class UserController extends BaseAuthedController { } $headId = !empty($headList) ? $headList[rand() % count($headList)] : 0; $headFrame = !empty($headFrameList) ? $headFrameList[rand() % count($headFrameList)] : 0; - $heroId = !empty($heroList) ? $heroList[rand() % count($heroList)] : 0; + $heroId = !empty($heroList) ? $heroList[rand() % count($heroList)]['id'] : 0; + if ($headId == 0) { + $headId = !empty($haveHeadHeroList) ? + $haveHeadHeroList[rand() % count($haveHeadHeroList)]['hero_head'] : 0; + } SqlHelper::upsert ($this->_getSelfMysql(), 't_user',