diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 4af5f184..24b3f855 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -336,34 +336,21 @@ class Gun extends BaseModel { return $finalyAddGold; } - public static function pveGainGold($gunDto, $count) + public static function gainGoldPve($gunDto, $count) { - if ($count <= 0) { - return 0; - } - $finalyAddGold = self::calcPveGainGold($gunDto, $count); + $newGold = min($gunDto['pve_ceg_uplimit'], + $gunDto['current_pve_get_ceg'] + $addGold); + $finalyAddGold = max(0, $newGold - $gunDto['current_pve_get_ceg']); if ($finalyAddGold > 0) { self::update($gunDto['gun_uniid'], array( - 'today_pve_get_ceg' => $gunDto['today_pve_get_ceg'] + $finalyAddGold, + 'current_pve_get_ceg' => $newGold, 'last_pve_get_ceg_time' => myself()->_getNowTime() )); } return $finalyAddGold; } - public static function calcPveGainGold($gunDto, $count) - { - if ($count <= 0) { - return 0; - } - $newGold = min($gunDto['pve_ceg_uplimit'], - $gunDto['today_pve_get_ceg'] + - round($gunDto['pve_ceg_uplimit'] / $count)); - $finalyAddGold = max(0, $newGold - $gunDto['today_pve_get_ceg']); - return $finalyAddGold; - } - private static function getAttrProByLevel($row,$baseAttr,$attr){ $attrPro1 = []; $itemMeta = mt\Item::get($row['gun_id']); diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index ca4fe236..2ab7de20 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -391,16 +391,15 @@ class Hero extends BaseModel { return $finalyAddGold; } - public static function pveGainGold($heroDto, $count) + public static function gainGoldPve($heroDto, $count) { - if ($count <= 0) { - return 0; - } - $finalyAddGold = self::calcPveGainGold($heroDto, $count); + $newGold = min($heroDto['pve_ceg_uplimit'], + $heroDto['current_pve_get_ceg'] + $addGold); + $finalyAddGold = max(0, $newGold - $heroDto['current_pve_get_ceg']); if ($finalyAddGold > 0) { self::update($heroDto['hero_uniid'], array( - 'today_pve_get_ceg' => $heroDto['today_pve_get_ceg'] + $finalyAddGold, + 'current_pve_get_ceg' => $newGold, 'last_pve_get_ceg_time' => myself()->_getNowTime() )); } diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index ac84911f..3bb75387 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -608,13 +608,13 @@ class BattleDataService extends BaseService { 'weaponPveCeg2' => $weaponPveCeg2, ))); if ($heroPveCeg > 0) { - $heroPveCeg = Hero::gainGoldPvp($this->heroDto, $heroPveCeg); + $heroPveCeg = Hero::gainGoldPve($this->heroDto, $heroPveCeg); } if ($weaponPveCeg1 > 0) { - $weaponPveCeg1 = Gun::gainGoldPvp($this->weapon1Dto, $weaponPveCeg1); + $weaponPveCeg1 = Gun::gainGoldPve($this->weapon1Dto, $weaponPveCeg1); } if ($weaponPveCeg2 > 0) { - $weaponPveCeg2 = Gun::gainGoldPvp($this->weapon1Dto, $weaponPveCeg2); + $weaponPveCeg2 = Gun::gainGoldPve($this->weapon1Dto, $weaponPveCeg2); } error_log(json_encode(array( 'new_heroPveCeg' => $heroPveCeg,