1
This commit is contained in:
parent
6ec0749780
commit
04b68353e1
15
doc/Hero.py
15
doc/Hero.py
@ -5,6 +5,21 @@ import _common
|
||||
class Hero(object):
|
||||
|
||||
def __init__(self):
|
||||
self.apis_ = [
|
||||
{
|
||||
'name': 'heroList',
|
||||
'desc': '获取英雄列表',
|
||||
'group': 'Hero',
|
||||
'url': 'webapp/index.php?c=Hero&a=heroList',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!hero_list', _common.Hero, '英雄列表']
|
||||
]
|
||||
}
|
||||
]
|
||||
self.apis_ = [
|
||||
{
|
||||
'desc': 'addItemToDB',
|
||||
|
@ -123,6 +123,19 @@ class UserInfo(object):
|
||||
['first_fight', 0, '是否是第一次战斗'],
|
||||
]
|
||||
|
||||
class Hero(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['hero_id', 0, '英雄id'],
|
||||
['hero_lv', 0, '英雄等级'],
|
||||
['skin_id', 0, '英雄皮肤id'],
|
||||
['skill1_lv1', 0, '必杀技等级'],
|
||||
['skill1_lv2', 0, '躲避技能等级'],
|
||||
['yoke_exp', 0, '当前羁绊等级的经验'],
|
||||
['yoke_total_exp', 0, '羁绊获得的总经验'],
|
||||
]
|
||||
|
||||
class RobotInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
require 'phpcommon/common.php';
|
||||
require_once('models/BaseModel.php');
|
||||
|
||||
define('TEAMID_KEY', 'team_uuid:');
|
||||
//每日任务
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
require_once('mt/Player.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class BaseAuthedController extends BaseController {
|
||||
|
||||
private $accountId = '';
|
||||
@ -87,9 +89,9 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function getUserInfo($fields)
|
||||
{
|
||||
$row = phpcommon\SqlHelper::selectOne
|
||||
$row = SqlHelper::selectOne
|
||||
($this->getSelfMysql(),
|
||||
'user',
|
||||
't_user',
|
||||
$fields,
|
||||
array(
|
||||
'accountid' => $this->getAccountId()
|
||||
@ -105,9 +107,9 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function getOrmUserInfo()
|
||||
{
|
||||
$row = phpcommon\SqlHelper::ormSelectOne
|
||||
$row = SqlHelper::ormSelectOne
|
||||
($this->getSelfMysql(),
|
||||
'user',
|
||||
't_user',
|
||||
array(
|
||||
'accountid' => $this->getAccountId()
|
||||
)
|
||||
@ -122,7 +124,7 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function safeGetOrmUserInfo()
|
||||
{
|
||||
$row = phpcommon\SqlHelper::ormSelectOne
|
||||
$row = SqlHelper::ormSelectOne
|
||||
($this->getSelfMysql(),
|
||||
't_user',
|
||||
array(
|
||||
@ -134,7 +136,7 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function updateUserInfo($fieldsKv)
|
||||
{
|
||||
phpcommon\SqlHelper::update
|
||||
SqlHelper::update
|
||||
($this->getSelfMysql(),
|
||||
'user',
|
||||
array(
|
||||
@ -155,7 +157,7 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function getItem($itemId)
|
||||
{
|
||||
$row = phpcommon\SqlHelper::selectOne
|
||||
$row = SqlHelper::selectOne
|
||||
($this->getSelfMysql(),
|
||||
'bag',
|
||||
array(
|
||||
@ -195,7 +197,7 @@ class BaseAuthedController extends BaseController {
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$row = phpcommon\SqlHelper::selectOne
|
||||
$row = SqlHelper::selectOne
|
||||
($this->getSelfMysql(),
|
||||
'bag',
|
||||
array(
|
||||
@ -237,9 +239,9 @@ class BaseAuthedController extends BaseController {
|
||||
$this->addLottery($item['item_num']);
|
||||
}
|
||||
} else {
|
||||
phpcommon\SqlHelper::upsert
|
||||
SqlHelper::upsert
|
||||
($this->getSelfMysql(),
|
||||
'bag',
|
||||
't_bag',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'item_id' => $item['item_id']
|
||||
@ -271,7 +273,7 @@ class BaseAuthedController extends BaseController {
|
||||
// $this->decGold($item['item_num']);
|
||||
// }
|
||||
} else {
|
||||
phpcommon\SqlHelper::update
|
||||
SqlHelper::update
|
||||
($this->getSelfMysql(),
|
||||
'bag',
|
||||
array(
|
||||
@ -314,7 +316,7 @@ class BaseAuthedController extends BaseController {
|
||||
}
|
||||
protected function decGold($decGold)
|
||||
{
|
||||
phpcommon\SqlHelper::update
|
||||
SqlHelper::update
|
||||
(
|
||||
$this->getSelfMysql(),
|
||||
'user',
|
||||
@ -331,7 +333,7 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function addGold($addGold)
|
||||
{
|
||||
phpcommon\SqlHelper::update
|
||||
SqlHelper::update
|
||||
(
|
||||
$this->getSelfMysql(),
|
||||
'user',
|
||||
@ -345,7 +347,7 @@ class BaseAuthedController extends BaseController {
|
||||
}
|
||||
protected function addLottery($addLottery)
|
||||
{
|
||||
phpcommon\SqlHelper::update
|
||||
SqlHelper::update
|
||||
(
|
||||
$this->getSelfMysql(),
|
||||
'user',
|
||||
@ -415,7 +417,7 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function getTalentLv($skillId, $skillTypeId)
|
||||
{
|
||||
$row = phpcommon\SqlHelper::selectOne
|
||||
$row = SqlHelper::selectOne
|
||||
(
|
||||
$this->getSelfMysql(),
|
||||
'gun_intensify',
|
||||
@ -529,28 +531,12 @@ class BaseAuthedController extends BaseController {
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDtoUser($userInfo)
|
||||
{
|
||||
return array(
|
||||
'name' => $userInfo['name'],
|
||||
'sex' => $userInfo['sex'],
|
||||
'head_id' => $userInfo['hero_id'],
|
||||
'head_frame' => $userInfo['head_frame'],
|
||||
'level' => $userInfo['level'],
|
||||
'exp' => $userInfo['exp'],
|
||||
'gold' => $userInfo['gold'],
|
||||
'diamond' => $userInfo['diamond'],
|
||||
'hero_id' => $userInfo['hero_id'],
|
||||
'first_fight' => $userInfo['first_fight'],
|
||||
);
|
||||
}
|
||||
|
||||
protected function addHero($heroMeta)
|
||||
{
|
||||
if (!$heroMeta) {
|
||||
return;
|
||||
}
|
||||
phpcommon\SqlHelper::upsert
|
||||
SqlHelper::upsert
|
||||
($this->getSelfMysql(),
|
||||
't_hero',
|
||||
array(
|
||||
@ -563,7 +549,7 @@ class BaseAuthedController extends BaseController {
|
||||
'accountid' => $this->getAccountId(),
|
||||
'hero_id' => $heroMeta['id'],
|
||||
'hero_lv' => 1,
|
||||
'skin_id' => $heroMeta['skin_id'],
|
||||
'skin_id' => mt\Player::getDefaultSkin($heroMeta),
|
||||
'skill1_lv1' => 1,
|
||||
'skill1_lv2' => 1,
|
||||
'yoke_exp' => 0,
|
||||
@ -580,13 +566,13 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function addHeroSkinXX($heroId, $skinId)
|
||||
{
|
||||
phpcommon\SqlHelper::upsert
|
||||
SqlHelper::upsert
|
||||
($this->getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'hero_id' => $heroId,
|
||||
'skin_id' => $skinid
|
||||
'skin_id' => $skinId
|
||||
),
|
||||
array(
|
||||
'skin_state' => 3,
|
||||
@ -608,7 +594,7 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
protected function getUsingEquipId()
|
||||
{
|
||||
$row = phpcommon\SqlHelper::selectOne
|
||||
$row = SqlHelper::selectOne
|
||||
($this->getSelfMysql(),
|
||||
'equip',
|
||||
array(
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
require 'phpcommon/sqlhelper.php';
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class BaseController {
|
||||
|
||||
private $nowtime = 0;
|
||||
|
@ -2,43 +2,31 @@
|
||||
|
||||
require_once('mt/NewShop.php');
|
||||
|
||||
require_once('models/Hero.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
|
||||
class HeroController extends BaseAuthedController {
|
||||
|
||||
|
||||
public function addItemToDB()
|
||||
public function heroList()
|
||||
{
|
||||
// $itemArr = [10101,10102,10103,10104,10105,10106,10200,10201,
|
||||
// 10202,10203,10204,10205,10206,10207,10208,12100,12102,12103,12104,
|
||||
// 12105,12106,12107,12119,12120,12121];
|
||||
$playerCfg = require('../res/player@player.php');
|
||||
$itemIDArr = array(30100,30200,30300);
|
||||
$itemArr = array();
|
||||
$len = count($itemIDArr);
|
||||
for($i = 0; $i< $len; $i++)
|
||||
{
|
||||
$heroID = $itemIDArr[$i];
|
||||
if($playerCfg[$heroID])
|
||||
{
|
||||
$heroCfg = $playerCfg[$heroID];
|
||||
$skinListStr = $heroCfg["skinlist"];
|
||||
$skinIDArr = explode("|",$skinListStr);
|
||||
$skinID = $skinIDArr[0];
|
||||
$itemData = array("hero_id"=>$heroID,"skin_id"=>$skinID);
|
||||
array_push($itemArr,$itemData);
|
||||
//error_log("itemTest=01====".$itemIDArr[$i]."==".$skinID);
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
$this->addHeroSkin($skinData);
|
||||
$heroList = array();
|
||||
SqlHelper::ormSelect(
|
||||
$this->getSelfMysql(),
|
||||
't_hero',
|
||||
array(
|
||||
'accountid' => $this->getAccountId()
|
||||
),
|
||||
function ($row) use(&$heroList) {
|
||||
array_push($heroList, Hero::toDto($row));
|
||||
}
|
||||
}
|
||||
$this->addAllHero($itemArr);
|
||||
$this->sendDataToClient(1,"test03",$playerCfg);
|
||||
);
|
||||
$this->rspData(array(
|
||||
'hero_list' => $heroList
|
||||
));
|
||||
}
|
||||
|
||||
private function addHeroToDB($heroID,$_heroCfg)
|
||||
{
|
||||
$code = 100;
|
||||
@ -50,7 +38,7 @@ class HeroController extends BaseAuthedController {
|
||||
$skinID = $skinIDArr[0];
|
||||
$itemData = array("hero_id"=>$heroID,"skin_id"=>$skinID);
|
||||
array_push($itemArr,$itemData);
|
||||
|
||||
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
@ -58,7 +46,7 @@ class HeroController extends BaseAuthedController {
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
|
||||
|
||||
$this->addHeroSkin($skinData);
|
||||
|
||||
$this->addAllHero($itemArr);
|
||||
@ -66,15 +54,13 @@ class HeroController extends BaseAuthedController {
|
||||
array_push($resultArr,$skinData);
|
||||
return $resultArr;
|
||||
}
|
||||
|
||||
private function addHeroAndSkin($heroID,$_heroCfg,$skinID)
|
||||
{
|
||||
$code = 100;
|
||||
$itemArr = array();
|
||||
$resultArr = array();
|
||||
$heroCfg = $_heroCfg;
|
||||
|
||||
|
||||
|
||||
//添加指定皮肤
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
@ -104,6 +90,7 @@ class HeroController extends BaseAuthedController {
|
||||
array_push($resultArr,$skinData02);
|
||||
return $resultArr;
|
||||
}
|
||||
|
||||
public function getAllHero()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
@ -118,6 +105,7 @@ class HeroController extends BaseAuthedController {
|
||||
}
|
||||
$this->sendDataToClient(0,"getHero",$row);
|
||||
}
|
||||
|
||||
public function getHeroInfoByID()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
@ -134,10 +122,12 @@ class HeroController extends BaseAuthedController {
|
||||
}
|
||||
$this->sendDataToClient(0,"getHeroInfoByID",$row);
|
||||
}
|
||||
|
||||
public function getYokeItemInfo()//获得羁绊道具信息
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function changeSkin()//切换英雄皮肤
|
||||
{
|
||||
$skinID = $_REQUEST['skin_id'];
|
||||
@ -611,6 +601,7 @@ class HeroController extends BaseAuthedController {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function addAllHero($items)
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
@ -642,5 +633,3 @@ class HeroController extends BaseAuthedController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
require_once('models/User.php');
|
||||
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Drop.php');
|
||||
require_once('mt/EquipUpgrade.php');
|
||||
@ -13,6 +15,9 @@ require_once('mt/Equip.php');
|
||||
require_once('mt/Player.php');
|
||||
require_once('mt/Robot.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\User;
|
||||
|
||||
class UserController extends BaseAuthedController {
|
||||
|
||||
public function login()
|
||||
@ -30,9 +35,8 @@ class UserController extends BaseAuthedController {
|
||||
if (!$this->loginCheck($userInfo)) {
|
||||
$userInfo = $this->getOrmUserInfo();
|
||||
}
|
||||
$dtoUser = $this->getDtoUser($userInfo);
|
||||
$this->rspData(array(
|
||||
'info' => $dtoUser
|
||||
'info' => User::show($userInfo)
|
||||
));
|
||||
}
|
||||
|
||||
@ -43,7 +47,7 @@ class UserController extends BaseAuthedController {
|
||||
|
||||
private function createNewUser($userName, $avatarUrl)
|
||||
{
|
||||
phpcommon\SqlHelper::upsert
|
||||
SqlHelper::upsert
|
||||
($this->getSelfMysql(),
|
||||
't_user',
|
||||
array(
|
||||
@ -71,21 +75,19 @@ class UserController extends BaseAuthedController {
|
||||
)
|
||||
);
|
||||
{
|
||||
$paramMeta = mt\Parameter::getByName('creator_hero_id');
|
||||
if ($paramMeta) {
|
||||
$heros = mt\Parameter::getListValue($paramMeta);
|
||||
foreach ($heros as $heroId) {
|
||||
$heroMeta = mt\Player::get($heroId);
|
||||
if ($heroMeta) {
|
||||
$this->addHero($heroMeta);
|
||||
}
|
||||
foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) {
|
||||
$heroMeta = mt\Player::get($heroId);
|
||||
if ($heroMeta) {
|
||||
$this->addHero($heroMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
$this->addItem(array(
|
||||
'item_id' => 16001,
|
||||
'item_num' => 0,
|
||||
array(
|
||||
'item_id' => 16001,
|
||||
'item_num' => 0,
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace models;
|
||||
|
||||
class BaseModel {
|
||||
|
||||
}
|
20
webapp/models/Hero.php
Normal file
20
webapp/models/Hero.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace models;
|
||||
|
||||
class Hero extends BaseModel {
|
||||
|
||||
public static function toDto($row)
|
||||
{
|
||||
return array(
|
||||
'hero_id' => $row['hero_id'],
|
||||
'hero_lv' => $row['hero_lv'],
|
||||
'skin_id' => $row['skin_id'],
|
||||
'skill1_lv1' => $row['skill1_lv1'],
|
||||
'skill1_lv2' => $row['skill1_lv2'],
|
||||
'yoke_exp' => $row['yoke_exp'],
|
||||
'yoke_total_exp' => $row['yoke_total_exp'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
namespace models;
|
||||
|
||||
use phpcommon;
|
||||
class User extends BaseModel {
|
||||
|
||||
public static function show($row)
|
||||
{
|
||||
return array(
|
||||
'name' => $row['name'],
|
||||
'sex' => $row['sex'],
|
||||
'head_id' => $row['hero_id'],
|
||||
'head_frame' => $row['head_frame'],
|
||||
'level' => $row['level'],
|
||||
'exp' => $row['exp'],
|
||||
'gold' => $row['gold'],
|
||||
'diamond' => $row['diamond'],
|
||||
'hero_id' => $row['hero_id'],
|
||||
'first_fight' => $row['first_fight'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,20 +26,23 @@ class Parameter {
|
||||
public static function getByName($name)
|
||||
{
|
||||
self::mustBeNameHash();
|
||||
$meta = array_key_exists($id, self::$nameHash) ? self::$nameHash[$name] : null;
|
||||
$meta = array_key_exists($name, self::$nameHash) ? self::$nameHash[$name] : null;
|
||||
return $meta;
|
||||
}
|
||||
|
||||
public static function getVal($name, $defVal)
|
||||
{
|
||||
self::mustBeNameHash();
|
||||
$meta = array_key_exists($id, self::$nameHash) ? self::$nameHash[$name] : null;
|
||||
$meta = self::getByName($name);
|
||||
return $meta ? $meta['param_value'] : $defVal;
|
||||
}
|
||||
|
||||
public static function getListValue($meta)
|
||||
public static function getListValue($name, $defVal = array())
|
||||
{
|
||||
$values = explode("|", $meta['param_value']);
|
||||
$val = self::getVal($name, null);
|
||||
if ($val == null) {
|
||||
return $defVal;
|
||||
}
|
||||
$values = explode('|', $val);
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user