diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 5d77f7b5..a3281809 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1877,6 +1877,7 @@ CREATE TABLE `t_server_task_battle_count` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id', `period` int(11) NOT NULL DEFAULT '0' COMMENT '周期', + `loot_index` int(11) NOT NULL DEFAULT '0' COMMENT '掉落包索引', `state` int(11) NOT NULL DEFAULT '0' COMMENT '1:总计数 2:循环计数', `val` bigint(20) NOT NULL DEFAULT '0' COMMENT 'val', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', diff --git a/sql/gamedb2006_migrate_240711_01.sql b/sql/gamedb2006_migrate_240711_01.sql index 47ea0300..5fab5884 100644 --- a/sql/gamedb2006_migrate_240711_01.sql +++ b/sql/gamedb2006_migrate_240711_01.sql @@ -6,6 +6,7 @@ CREATE TABLE `t_server_task_battle_count` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id', `period` int(11) NOT NULL DEFAULT '0' COMMENT '周期', + `loot_index` int(11) NOT NULL DEFAULT '0' COMMENT '掉落包索引', `state` int(11) NOT NULL DEFAULT '0' COMMENT '1:总计数 2:循环计数', `val` bigint(20) NOT NULL DEFAULT '0' COMMENT 'val', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', diff --git a/webapp/models/ServerTaskBattleCount.php b/webapp/models/ServerTaskBattleCount.php index 32a9fc9a..4b9528a4 100644 --- a/webapp/models/ServerTaskBattleCount.php +++ b/webapp/models/ServerTaskBattleCount.php @@ -10,30 +10,31 @@ class ServerTaskBattleCount extends BaseModel const TOTAL_COUNT = 1; //总计数 const LOOP_COUNT = 2; //循环计数 - public static function getV($period, $state, $defVal = 0) + public static function getV($period,$lootIndex, $state, $defVal = 0) { - $valData = self::internalGetV($period, $state, $defVal); + $valData = self::internalGetV($period, $lootIndex,$state, $defVal); return $valData['val']; } - public static function setV($period, $state, $defVal) + public static function setV($period,$lootIndex, $state, $defVal) { - self::internalSetV($period, $state, $defVal); + self::internalSetV($period,$lootIndex, $state, $defVal); } - public static function incV($period, $state, $val) + public static function incV($period,$lootIndex, $state, $val) { - $oldVal = self::getV($period, $state); - self::internalSetV($period, $state, $oldVal + $val); + $oldVal = self::getV($period,$lootIndex, $state); + self::internalSetV($period,$lootIndex, $state, $oldVal + $val); } - private static function internalGetV($period, $state, $defVal = 0){ + private static function internalGetV($period,$lootIndex, $state, $defVal = 0){ $row = SqlHelper::ormSelectOne( myself()->_getSelfMysql(), 't_server_task_battle_count', array( 'account_id' => myself()->_getAccountId(), 'period' => $period, + 'loot_index' => $lootIndex, 'state' => $state, ) ); @@ -43,7 +44,7 @@ class ServerTaskBattleCount extends BaseModel ); } - private static function internalSetV($period,$state, $val) + private static function internalSetV($period,$lootIndex,$state, $val) { SqlHelper::upsert (myself()->_getSelfMysql(), @@ -51,6 +52,7 @@ class ServerTaskBattleCount extends BaseModel array( 'account_id' => myself()->_getAccountId(), 'period' => $period, + 'loot_index' => $lootIndex, 'state' => $state ), array( @@ -60,6 +62,7 @@ class ServerTaskBattleCount extends BaseModel array( 'account_id' => myself()->_getAccountId(), 'period' => $period, + 'loot_index' => $lootIndex, 'state' => $state, 'val' => $val, 'createtime' => myself()->_getNowTime(), diff --git a/webapp/services/LootService.php b/webapp/services/LootService.php index fd3962c5..cbcc1bf9 100644 --- a/webapp/services/LootService.php +++ b/webapp/services/LootService.php @@ -82,9 +82,9 @@ class LootService $period = $serverTaskMeta?$serverTaskMeta['id']:0; // $totalTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,0); - $totalTimes = ServerTaskBattleCount::getV($period,ServerTaskBattleCount::TOTAL_COUNT); + $totalTimes = ServerTaskBattleCount::getV($period,$lootMeta['id'],ServerTaskBattleCount::TOTAL_COUNT); // $recycleTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,1); - $recycleTimes = ServerTaskBattleCount::getV(0,ServerTaskBattleCount::LOOP_COUNT); + $recycleTimes = ServerTaskBattleCount::getV(0,$lootMeta['id'],ServerTaskBattleCount::LOOP_COUNT); $contentArr = explode("|",$lootMeta['content']); $initTimes = $contentArr[0]; $po = $contentArr[1]; @@ -97,15 +97,22 @@ class LootService } $p = min($po + ($recycleTimes-1) * $pd,$pm) * 100 ; $rnd = rand(1,100); + error_log("LOOT".json_encode(array( + 'totalTimes' => $lootMeta['id'].'|'.$totalTimes, + 'recycleTimes' => $lootMeta['id'].'|'.$recycleTimes, + 'rnd' => $rnd, + 'rate' => $p, + 'lootMeta' => $lootMeta, + ))); // myself()->_incV(TN_TOTAL_LOOT_TIMES,0,1); - ServerTaskBattleCount::incV($period,ServerTaskBattleCount::TOTAL_COUNT,1); + ServerTaskBattleCount::incV($period,$lootMeta['id'],ServerTaskBattleCount::TOTAL_COUNT,1); if ($rnd <= $p){ // myself()->_setV(TN_TOTAL_LOOT_TIMES,1,1); - ServerTaskBattleCount::setV(0,ServerTaskBattleCount::LOOP_COUNT,1); + ServerTaskBattleCount::setV(0,$lootMeta['id'],ServerTaskBattleCount::LOOP_COUNT,1); self::disposeLootIndex($index1,$depth,$items); }else{ // myself()->_incV(TN_TOTAL_LOOT_TIMES,1,1); - ServerTaskBattleCount::incV(0,ServerTaskBattleCount::LOOP_COUNT,1); + ServerTaskBattleCount::incV(0,$lootMeta['id'],ServerTaskBattleCount::LOOP_COUNT,1); self::disposeLootIndex($index2,$depth,$items); } } diff --git a/webapp/services/RoomBattleDataService.php b/webapp/services/RoomBattleDataService.php index c63be2f3..e4c66598 100644 --- a/webapp/services/RoomBattleDataService.php +++ b/webapp/services/RoomBattleDataService.php @@ -167,6 +167,7 @@ class RoomBattleDataService extends BaseService { $gold = 0; // $accountLucky = Hero::getAccountLucky($userDb['address']); $accountLucky = Hero::getAccountLuckyTemp(); + error_log("LootLucky:".$accountLucky); $rewardMeta = mt\BattleReward::find($mapModeMeta['rewardMode'],$accountLucky); if (!$rewardMeta){ return ;