1
This commit is contained in:
parent
0715e8b168
commit
45c161a6e9
63
webapp/bootstrap/constant.php
Normal file
63
webapp/bootstrap/constant.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
define('TEAMID_KEY', 'team_uuid:');
|
||||
|
||||
define('V_ITEM_GOLD', 10001); //金币
|
||||
define('V_ITEM_DIAMOND', 10002); //钻石
|
||||
define('V_ITEM_EXP', 10003); //经验
|
||||
define('V_ITEM_ACTIVE', 10004); //活跃度
|
||||
|
||||
define('TN_BEGIN', 8001);
|
||||
define('TN_ACTIVE', 8002);
|
||||
define('TN_SHOP', 8003);
|
||||
define('TN_RECHARGE_UPGRADE_TIMES', 8004);
|
||||
define('TN_SHARE_GAMES', 8005);
|
||||
define('TN_END', 8005);
|
||||
|
||||
define('TN_DAILY_BEGIN', 9001);
|
||||
define('TN_DAILY_LOGINS', 9001);
|
||||
define('TN_DAILY_ACTIVE', 9002);
|
||||
define('TN_DAILY_SHOP', 9003);
|
||||
define('TN_DAILY_RECHARGE_UPGRADE_TIMES', 9004);
|
||||
define('TN_DAILY_SHARE_GAMES', 9005);
|
||||
define('TN_DAILY_END', 9005);
|
||||
|
||||
define('TN_WEEKLY_BEGIN', 10001);
|
||||
define('TN_WEEKLY_ACTIVE', 10002);
|
||||
define('TN_WEEKLY_SHOP', 10003);
|
||||
define('TN_WEEKLY_RECHARGE_UPGRADE_TIMES', 10004);
|
||||
define('TN_WEEKLY_SHARE_GAMES', 10005);
|
||||
define('TN_WEEKLY_END', 10005);
|
||||
|
||||
const kHAT_Begin = 0;
|
||||
const kHAT_Hp = 1;
|
||||
const kHAT_HPRecover = 2;
|
||||
const kHAT_Atk = 3;
|
||||
const kHAT_Def = 4;
|
||||
const kHAT_Speed = 5;
|
||||
const kHAT_ShotRange = 6;
|
||||
const kHAT_ShotSpeed = 7;
|
||||
const kHAT_ReloadSpeed = 8;
|
||||
const kHAT_FireRate = 9;
|
||||
const kHAT_Volume = 10;
|
||||
const kHAT_MaxHp = 11;
|
||||
const kHAT_ShotView = 12;
|
||||
const kHAT_ReloadTime = 14;
|
||||
|
||||
const kHAT_WeaponDmg = 20;
|
||||
const kHAT_WeaponShotSpeed = 21;
|
||||
const kHAT_WeaponReloadTime = 22;
|
||||
const kHAT_WeaponExplosionRange = 23;
|
||||
const kHAT_WeaponExplosionContinueTime = 24;
|
||||
const kHAT_PoisoningReduction = 25;
|
||||
const kHAT_RescueTime = 26;
|
||||
const kHAT_DrugTime = 27;
|
||||
const kHAT_DrugEfficacy = 28;
|
||||
const kHAT_CarOil = 29;
|
||||
const kHAT_WeaponExplosionDealyTime = 30;
|
||||
const kHAT_RecoverHpAdd = 31;
|
||||
const kHAT_SkillTime = 32;
|
||||
const kHAT_WeaponThrowRange = 33;
|
||||
|
||||
const kHAT_ABS_VAL = 1;
|
||||
const kHAT_RATE_VAL = 2;
|
@ -5,35 +5,7 @@ require 'phpcommon/common.php';
|
||||
require_once('phpcommon/sqlhelper.php');
|
||||
require_once('models/BaseModel.php');
|
||||
require_once('services/BaseService.php');
|
||||
|
||||
define('TEAMID_KEY', 'team_uuid:');
|
||||
|
||||
define('V_ITEM_GOLD', 10001); //金币
|
||||
define('V_ITEM_DIAMOND', 10002); //钻石
|
||||
define('V_ITEM_EXP', 10003); //经验
|
||||
define('V_ITEM_ACTIVE', 10004); //活跃度
|
||||
|
||||
define('TN_BEGIN', 8001);
|
||||
define('TN_ACTIVE', 8002);
|
||||
define('TN_SHOP', 8003);
|
||||
define('TN_RECHARGE_UPGRADE_TIMES', 8004);
|
||||
define('TN_SHARE_GAMES', 8005);
|
||||
define('TN_END', 8005);
|
||||
|
||||
define('TN_DAILY_BEGIN', 9001);
|
||||
define('TN_DAILY_LOGINS', 9001);
|
||||
define('TN_DAILY_ACTIVE', 9002);
|
||||
define('TN_DAILY_SHOP', 9003);
|
||||
define('TN_DAILY_RECHARGE_UPGRADE_TIMES', 9004);
|
||||
define('TN_DAILY_SHARE_GAMES', 9005);
|
||||
define('TN_DAILY_END', 9005);
|
||||
|
||||
define('TN_WEEKLY_BEGIN', 10001);
|
||||
define('TN_WEEKLY_ACTIVE', 10002);
|
||||
define('TN_WEEKLY_SHOP', 10003);
|
||||
define('TN_WEEKLY_RECHARGE_UPGRADE_TIMES', 10004);
|
||||
define('TN_WEEKLY_SHARE_GAMES', 10005);
|
||||
define('TN_WEEKLY_END', 10005);
|
||||
require_once('constant.php');
|
||||
|
||||
function getConfigBaseDir()
|
||||
{
|
||||
@ -87,7 +59,7 @@ function array_find($arr, $cb)
|
||||
return null;
|
||||
}
|
||||
|
||||
require 'config_loader.php';
|
||||
require_once('config_loader.php');
|
||||
|
||||
function new_sendError($errcode, $errmsg_tid, $errmsg)
|
||||
{
|
||||
|
@ -112,6 +112,11 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(2, '锁定期间不能操作');
|
||||
return;
|
||||
}
|
||||
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
||||
if (!$heroMeta) {
|
||||
$this->_rspErr(100, '服务器内部错误');
|
||||
return;
|
||||
}
|
||||
$currLevelMeta = mt\HeroLevel::getByQualityLevel($heroDb['quality'], $heroDb['hero_lv']);
|
||||
if (!$currLevelMeta) {
|
||||
$this->_rspErr(100, '服务器内部错误');
|
||||
@ -156,8 +161,9 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$baseAttrs = mt\Hero::getHeroAttr($heroMeta);
|
||||
$attrs = emptyReplace(json_decode($heroDb['rand_attr'], true), array());
|
||||
$ret = mt\HeroLevel::addRandAttr($nextLevelMeta, $attrs);
|
||||
$ret = mt\HeroLevel::addRandAttr($nextLevelMeta, $baseAttrs, $attrs);
|
||||
if (!$ret) {
|
||||
$this->_rspErr(2, '服务器内部错误');
|
||||
return;
|
||||
@ -200,6 +206,11 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(2, '锁定期间不能操作');
|
||||
return;
|
||||
}
|
||||
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
||||
if (!$heroMeta) {
|
||||
$this->_rspErr(100, '服务器内部错误');
|
||||
return;
|
||||
}
|
||||
$currQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality']);
|
||||
if (!$currQualityMeta) {
|
||||
$this->_rspErr(100, '服务器内部错误');
|
||||
@ -249,13 +260,14 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$baseAttrs = mt\Hero::getHeroAttr($heroMeta);
|
||||
$attrs = emptyReplace(json_decode($heroDb['rand_attr'], true), array());
|
||||
{
|
||||
$obtainAttrs = mt\HeroQuality::getRandAttr($nextQualityMeta);
|
||||
mt\AttrHelper::mergeAttr($attrs, $obtainAttrs);
|
||||
}
|
||||
{
|
||||
$ret = mt\HeroLevel::addRandAttr($nextLevelMeta, $attrs);
|
||||
$ret = mt\HeroLevel::addRandAttr($nextLevelMeta, $baseAttrs, $attrs);
|
||||
if (!$ret) {
|
||||
$this->_rspErr(2, '服务器内部错误');
|
||||
return;
|
||||
|
@ -5,6 +5,7 @@ namespace models;
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/HeroLevel.php');
|
||||
require_once('mt/HeroQuality.php');
|
||||
require_once('mt/AttrHelper.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
|
||||
use mt;
|
||||
@ -61,6 +62,11 @@ class Hero extends BaseModel {
|
||||
$lockType = $row['lock_type'];
|
||||
$unlockTime = $row['unlock_time'];
|
||||
}
|
||||
$heroMeta = mt\Hero::get($row['hero_id']);
|
||||
if ($heroMeta) {
|
||||
$baseAttr = mt\Hero::getHeroAttr($heroMeta);
|
||||
mt\AttrHelper::mergeAttr($attr, $baseAttr);
|
||||
}
|
||||
$dto = array(
|
||||
'hero_uniid' => $row['idx'],
|
||||
'hero_id' => $row['hero_id'],
|
||||
|
@ -24,4 +24,46 @@ class AttrHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static function addRandAttrs($cfgAttrs, $num, $baseAttrs, &$dbAttrs)
|
||||
{
|
||||
$matchedAttrs = array();
|
||||
foreach ($cfgAttrs as $cfgAttr) {
|
||||
$attrId = $cfgAttr[0];
|
||||
$type = $cfgAttr[1];
|
||||
if (array_find($dbAttrs, function($val) use ( $attrId, $type) {
|
||||
return $val['attr_id'] == $attrId && $val['type'] == $type;
|
||||
})) {
|
||||
array_push($matchedAttrs, $cfgAttr);
|
||||
} else if (array_find($baseAttrs, function($val) use ($attrId, $type) {
|
||||
return $val['attr_id'] == $attrId && $val['type'] == $type;
|
||||
})) {
|
||||
array_push($matchedAttrs, $cfgAttr);
|
||||
}
|
||||
}
|
||||
shuffle($matchedAttrs);
|
||||
for ($i = 0; $i < $num; ++$i) {
|
||||
if ($i < $matchedAttrs) {
|
||||
$cfgAttr = $matchedAttrs[$i];
|
||||
|
||||
$attrId = $cfgAttr[0];
|
||||
$type = $cfgAttr[1];
|
||||
$val = rand($cfgAttr[2], $cfgAttr[3]);
|
||||
$found = false;
|
||||
foreach ($dbAttrs as &$attr) {
|
||||
if ($attr['attr_id'] == $attrId &&
|
||||
$attr['type'] == $type) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
if ($found) {
|
||||
array_push($dbAttrs, array(
|
||||
'attr_id' => $attrId,
|
||||
'type' => $type,
|
||||
'val' => $val
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,37 @@ class Hero {
|
||||
return count($values) > 0 ? $values[0] : 0;
|
||||
}
|
||||
|
||||
public static function getHeroAttr($meta)
|
||||
{
|
||||
$fields = array(
|
||||
array(
|
||||
'attr_id' => kHAT_Hp,
|
||||
'field_name' => 'hp'
|
||||
),
|
||||
array(
|
||||
'attr_id' => kHAT_Atk,
|
||||
'field_name' => 'damage'
|
||||
),
|
||||
array(
|
||||
'attr_id' => kHAT_Def,
|
||||
'field_name' => 'defence'
|
||||
),
|
||||
array(
|
||||
'attr_id' => kHAT_Speed,
|
||||
'field_name' => 'move_speed'
|
||||
),
|
||||
);
|
||||
$attr = array();
|
||||
foreach ($fields as $field) {
|
||||
array_push($attr, array(
|
||||
'attr_id' => $field['attr_id'],
|
||||
'type' => kHAT_ABS_VAL,
|
||||
'val' => (int)$meta[$field['field_name']]
|
||||
));
|
||||
}
|
||||
return $attr;
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
|
@ -19,21 +19,12 @@ class HeroLevel {
|
||||
return getXVal(self::$qualityLevelHash, $quality . '_' . $level, null);
|
||||
}
|
||||
|
||||
public static function addRandAttr($levelMeta, &$attrs)
|
||||
public static function addRandAttr($levelMeta, $baseAttrs, &$dbAttrs)
|
||||
{
|
||||
$attrArr = StrHelper::parseList($levelMeta['rand_attrs'], array('|', ':'));
|
||||
foreach ($attrArr as $tuple) {
|
||||
$attrId = $tuple[0];
|
||||
$type = $tuple[1];
|
||||
$val = rand($tuple[2], $tuple[3]);
|
||||
foreach ($attrs as &$attr) {
|
||||
if ($attr['attr_id'] == $attrId &&
|
||||
$attr['type'] == $type) {
|
||||
$attr['val'] += $val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$nums = explode(':', $levelMeta['rand_attrs_num']);
|
||||
$num = rand($nums[0], $nums[1]);
|
||||
$cfgAttrs = StrHelper::parseList($levelMeta['rand_attrs'], array('|', ':'));
|
||||
AttrHelper::addRandAttrs($cfgAttrs, $num, $baseAttrs, $dbAttrs);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user