diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index bed933e9..604380b3 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -140,7 +140,7 @@ class HeroController extends BaseAuthedController { $this->_rspErr(1, "Not enough hero skill points"); return; } - Hero::upgradeSkill($heroUniId,$skillIdx); + Hero::upgradeSkill($heroUniId,$skillIdx,$skill['skill_point']); $propertyChgService = new services\PropertyChgService(); $propertyChgService->addHeroChg(); $this->_rspData(array( diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 3c0743d6..e33b7e05 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -396,7 +396,7 @@ class Hero extends BaseModel { )); } - public static function upgradeSkill($heroUniId, $skillIdx) + public static function upgradeSkill($heroUniId, $skillIdx,$skill_points) { if (!in_array($skillIdx, array(0, 1))) { return; @@ -406,6 +406,9 @@ class Hero extends BaseModel { $fieldName => function () use($fieldName) { return "${fieldName} + 1"; }, + 'skill_points' => function() use ($skill_points){ + return "GREATEST(0, skill_points - ${$skill_points})"; + }, 'modifytime' => myself()->_getNowTime() )); }