123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565 |
- <?php
- defined( 'IN_WEB') or die( 'Include Error!');
- /**
- * 老虎机概率规则
- */
- class ModelSlotresult{
- //修正需消耗总体力配置表
- public $betSpinsRule=[
- 1=>50,
- 2=>50,
- 3=>50,
- 5=>50,
- 10=>100,
- 20=>200,
- 40=>400,
- 80=>800,
- 100=>1000,
- 200=>2000,
- ];
- //默认转老虎机体力消耗结构[1=>"打",2=>"偷",3=>"体力",4=>"盾牌",5=>"1金币",6=>"2金币",7=>"3金币",8=>"1金币袋",9=>"2金币袋",10=>"3金币袋",11=>"空",12=>"1收集物",13=>"2收集物",14=>"3收集物",15=>"小玩法1",16=>"小玩法2",17=>"小玩法3",18=>"偷1",19=>"偷2",20=>"打1",21=>"打2",22=>"1体力瓶",23=>"2体力瓶"]
- public $defaultLostSpinsArr=[1=>0,2=>0,3=>0,4=>0,5=>0,6=>0,7=>0,8=>0,9=>0,10=>0,11=>0,12=>0,13=>0,14=>0,15=>0,16=>0,17=>0,18=>0,19=>0,20=>0,21=>0,22=>0,23=>0];
- //默认转老虎机体力消耗对权重修正系数配置
- public $defaultSpinsLostCfg = [
- -5 =>[1=>5, 2=>5, 3=>5, 4=>5, 5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>5, 13=>5, 14=>5,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- -4 =>[1=>3, 2=>3, 3=>3, 4=>3, 5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>3, 13=>3, 14=>3,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- -3 =>[1=>2.5,2=>2.5,3=>2.5,4=>2.5,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>2.5,13=>2.5,14=>2.5,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- -2 =>[1=>2, 2=>2, 3=>2, 4=>2, 5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>2, 13=>2, 14=>2,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- -1 =>[1=>1.5,2=>1.5,3=>1.5,4=>1.5,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>1.5,13=>1.5,14=>1.5,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 0 =>[1=>1, 2=>1, 3=>1, 4=>1, 5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>1, 13=>1, 14=>1,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 1 =>[1=>0.9,2=>0.9,3=>0.9,4=>0.9,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.9,13=>0.9,14=>0.9,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 2 =>[1=>0.8,2=>0.8,3=>0.8,4=>0.8,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.8,13=>0.8,14=>0.8,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 3 =>[1=>0.7,2=>0.7,3=>0.7,4=>0.7,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.7,13=>0.7,14=>0.7,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 4 =>[1=>0.6,2=>0.6,3=>0.6,4=>0.6,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.6,13=>0.6,14=>0.6,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 5 =>[1=>0.5,2=>0.5,3=>0.5,4=>0.5,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.5,13=>0.5,14=>0.5,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- ];
- //默认每6小时转老虎机体力消耗对权重修正系数配置
- public $defaultSpinsLostDayCfg = [
- 100 =>[1=>1,2=>1,3=>1.5,4=>1.5,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>1.5,13=>1.5,14=>1.5,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 200 =>[1=>1,2=>1.5,3=>1,4=>1,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>1,13=>1,14=>1,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 500 =>[1=>1,2=>1,3=>0.8,4=>0.8,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.8,13=>0.8,14=>0.8,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 1000 =>[1=>1,2=>1,3=>0.5,4=>0.5,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.5,13=>0.5,14=>0.5,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 2000 =>[1=>1,2=>1,3=>0.3,4=>0.3,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.3,13=>0.3,14=>0.3,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 5000 =>[1=>1,2=>1,3=>0.2,4=>0.2,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.2,13=>0.2,14=>0.2,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- ];
- //默认每6小时转老虎机次数对权重修正系数配置
- public $defaultSlotLimitDayCfg = [
- 10 =>[1=>1,2=>2,3=>1,4=>1,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>2,13=>2,14=>2,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 20 =>[1=>2,2=>1,3=>2,4=>2,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>1.5,13=>1.5,14=>1.5,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 40 =>[1=>1,2=>1,3=>1.5,4=>1.5,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>1,13=>1,14=>1,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 60 =>[1=>1,2=>1,3=>1,4=>1,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>1,13=>1,14=>1,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 80 =>[1=>1,2=>1,3=>0.5,4=>0.5,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.5,13=>0.5,14=>0.5,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- 100=>[1=>1,2=>1,3=>0.2,4=>0.2,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>0.2,13=>0.2,14=>0.2,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1],
- ];
- /**
- * Notes:等级获取旋转权重配置
- * User: wsc
- * Time: 2021/2/25 10:27
- * @param $lv
- * @return mixed
- */
- public function getWeightByLv($lv){
- $ret = oo::commonOprRedis('common')->hGet(okeys::slotWeightCfg(),$lv);
- if(!empty($ret)){
- return json_decode($ret,true);
- }
- //查询数据库概率
- $tb = otable::slotWeightCfg();
- $sql = "select * from {$tb} where levelId={$lv} limit 1";
- $conf = oo::commonOprDb('config')->getOne($sql, MYSQLI_ASSOC);
- oo::commonOprRedis('config')->hSet(okeys::slotWeightCfg(),$lv,$conf['slotpro']);
- $ret = json_decode($conf['slotpro'],true);
- return $ret;
- }
- /**
- * Notes:设置旋转结果体力消耗
- * User: wsc
- * Time: 2021/2/25 9:53
- * @param $uid
- * @param $id
- * @param $num int|float 变化值
- * @return int
- */
- public function changeResSpinsLost($uid,$id,$num){
- $key = okeys::userSlotResSpinsLost($uid);
- if(oo::commonOprRedis('common')->setnx(okeys::clearSlotResSpinsLostLock($uid),1)){
- oo::commonOprRedis('common')->delete($key);
- oo::commonOprRedis('common')->expire(okeys::clearSlotResSpinsLostLock($uid),7*86400);
- }
- $num = floor($num);
- $afterNum = oo::commonOprRedis('common')->hIncrBy($key,$id,$num);
- oo::commonOprRedis('common')->expire($key,7*86400);//临时策略,每次设置缓存7天
- return $afterNum;
- }
- /**
- * Notes:通过活动类型获取所有类型旋转结果体力累计消耗
- * User: wsc
- * Time: 2021/2/25 10:12
- * @param $uid
- * @param int $type 当前活动类型
- * @return int
- */
- public function getSumResSpinsLost($uid,$type=0){
- $sumSpins=0;
- $spinArr = oo::commonOprRedis('common')->hGetAll(okeys::userSlotResSpinsLost($uid));
- foreach ($spinArr as $k=>$v){
- if($k<12){
- $sumSpins +=intval($v);
- }
- }
- if($type==1){//只有收集物品3
- $sumSpins +=intval($spinArr[14]);
- }
- if($type==2){//有收集物品1,2,3
- $sumSpins +=intval($spinArr[12]+$spinArr[13]+$spinArr[14]);
- }
- if($type==3){//小玩法收集物1,2,3
- $sumSpins +=intval($spinArr[15]+$spinArr[16]+$spinArr[17]);
- }
- if($type==4){//1个打 ,2个打
- $sumSpins +=intval($spinArr[18]+$spinArr[19]);
- }
- if($type==5){//1个偷,2个偷
- $sumSpins +=intval($spinArr[20]+$spinArr[21]);
- }
- if($type==10){//1个体力瓶,2个体力瓶
- $sumSpins +=intval($spinArr[22]+$spinArr[23]);
- }
- return $sumSpins;
- }
- public function getSumResWeight($lv,$type=0){
- $sumWeight=0;
- $slotWeightCfg = $this->getWeightByLv($lv);
- $slotWeightCfg = array_column($slotWeightCfg,'v','id');
- foreach ($slotWeightCfg as $k=>$v){
- if($k<12){
- $sumWeight +=intval($v);
- }
- }
- if($type==1){//只有收集物品3
- $sumWeight +=intval($slotWeightCfg[14]);
- }
- if($type==2){//有收集物品1,2,3
- $sumWeight +=intval($slotWeightCfg[12]+$slotWeightCfg[13]+$slotWeightCfg[14]);
- }
- if($type==3){//小玩法收集物1,2,3,
- $sumWeight +=intval($slotWeightCfg[15]+$slotWeightCfg[16]+$slotWeightCfg[17]);
- }
- if($type==4){//1个偷,2个偷
- $sumWeight +=intval($slotWeightCfg[18]+$slotWeightCfg[19]);
- }
- if($type==5){//1个打 ,2个打
- $sumWeight +=intval($slotWeightCfg[20]+$slotWeightCfg[21]);
- }
- if($type==10){//1个体力瓶,2个体力瓶
- $sumWeight +=intval($slotWeightCfg[22]+$slotWeightCfg[23]);
- }
- return $sumWeight;
- }
- /**
- * Notes:减少所有类型旋转结果体力累计消耗
- * User: wsc
- * Time: 2021/2/25 10:46
- * @param $uid
- * @param $lv int 用户等级
- * @param int $type 当前活动类型
- * @param $bet int 当前旋转倍率
- * @return bool
- */
- public function delResSpinsLost($uid,$lv,$bet,$type=0){
- if(!$uid||!$lv||!$bet) return false;
- $betSpinsRule = funs::getArrFromJsonArr(oo::commonOprRedis('config')->hGetAll(okeys::slotCoefficientCfg('betSpinsRule')));
- $betSpinsRule = $betSpinsRule?$betSpinsRule:$this->betSpinsRule;
- $sumSpins = $this->getSumResSpinsLost($uid,$type);
- $ruleSpins = intval($betSpinsRule[$bet])>0?intval($betSpinsRule[$bet]):1000;
- if($sumSpins>$ruleSpins){//每次转动老虎机之后,若玩家所有类型的消耗总体力大于刚刚使用的倍率所对应的“修正需消耗总体力”
- $slotWeightCfg = $this->getWeightByLv($lv);
- $slotWeightCfg = array_column($slotWeightCfg,'v','id');
- $sumWeight = $this->getSumResWeight($lv,$type);
- foreach ($this->defaultLostSpinsArr as $k=>$v){
- if($k<12){
- $this->changeResSpinsLost($uid,$k,-abs($ruleSpins*$slotWeightCfg[$k]/$sumWeight));
- }else{
- if($type==1&&$k==14){//常规收集
- $this->changeResSpinsLost($uid,$k,-abs($ruleSpins*$slotWeightCfg[$k]/$sumWeight));
- }else if($type==2&&in_array($k,[12,13,14])){//特殊收集,特殊收集偷,特殊收集打
- $this->changeResSpinsLost($uid,$k,-abs($ruleSpins*$slotWeightCfg[$k]/$sumWeight));
- }else if($type==3&&in_array($k,[15,16,17])){//小玩法收集
- $this->changeResSpinsLost($uid,$k,-abs($ruleSpins*$slotWeightCfg[$k]/$sumWeight));
- }else if($type==4&&in_array($k,[18,19,2])){//偷收集
- $this->changeResSpinsLost($uid,$k,-abs($ruleSpins*$slotWeightCfg[$k]/$sumWeight));
- }else if($type==5&&in_array($k,[20,21,1])){//打收集
- $this->changeResSpinsLost($uid,$k,-abs($ruleSpins*$slotWeightCfg[$k]/$sumWeight));
- }
- }
- }
- }
- return true;
- }
- /**
- * Notes:活动进度领奖修正对应旋转结果体力累计消耗调整
- * User: wsc
- * Time: 2021/2/25 12:23
- * @param $uid
- * @param $lv
- * @param $spins
- * @param $type int 0偷,打活动 1常规收集 2特殊收集,特殊收集打,特殊收集偷
- * @return bool
- */
- public function activityAddResSpinsLost($uid,$lv,$spins,$gid=0){
- if(!$spins) return false;
- // $id= intval(oo::commonOprRedis('common')->get(okeys::userLastSlotId($uid)));//最后一次转到的结果id
- // if($id){
- $slotWeightCfg = $this->getWeightByLv($lv);
- $slotWeightCfg = array_column($slotWeightCfg,'v','id');
- $sumWeight=0;
- if($gid==1){//普通收集(打,偷,收集物3)
- $changeIds =[1,2,14];
- }else if($gid==2){//特殊收集(收集物1+收集物2+收集物3)
- $changeIds=[12,13,14];
- }else if($gid==3){//特殊收集偷(偷+收集物1+收集物2+收集物3)
- $changeIds=[2,12,13,14];
- }else if($gid==4){//特殊收集打(打+收集物1+收集物2+收集物3)
- $changeIds=[1,12,13,14];
- }else if($gid==5){//偷
- $changeIds=[2];
- }else if($gid==6){//打
- $changeIds=[1];
- }else if($gid==8){//偷收集(偷3,偷1+偷2)
- $changeIds=[2,18,19];
- }else if($gid==9){//打收集(打3+打1+打2)
- $changeIds=[1,20,21];
- }else{
- $changeIds = [];
- }
- if(!empty($changeIds)){
- foreach ($changeIds as $k=>$v){
- $sumWeight +=$slotWeightCfg[$v];
- }
- if($sumWeight>0){
- foreach ($changeIds as $k=>$id){
- $this->changeResSpinsLost($uid,$id,$spins*$slotWeightCfg[$id]/$sumWeight);
- }
- }
- }
- // }
- return true;
- }
- /**
- * Notes:添加老虎机累计次数及体力消耗记录(6小时内)
- * User: wsc
- * Time: 2021/2/25 11:45
- * @param $uid
- * @param int $num
- * @return array
- */
- public function addSlotExpendLog($uid,$num=1){
- $key = okeys::userSlotDayLog($uid);
- $resNum1 = oo::commonOprRedis('common')->hIncrBy($key,1,1);//累计次数
- $resNum2 = oo::commonOprRedis('common')->hIncrBy($key,2,$num);//累计消耗体力数
- if($resNum1==1){
- oo::commonOprRedis('common')->expire($key,6*3600);//12小时重新刷新
- }
- return [$resNum1,$resNum2];
- }
- /**
- * Notes:获取各类型权重调整系数配置
- * User: wsc
- * Time: 2021/2/25 16:41
- * @return array
- */
- public function getConfig(){
- $cfg =[];
- $cfg['spinsLost'] =funs::getArrFromJsonArr(oo::commonOprRedis('config')->hGetAll(okeys::slotCoefficientCfg('spinsLost')));
- ksort($cfg['spinsLost']);
- $cfg['spinsLostDay'] =funs::getArrFromJsonArr(oo::commonOprRedis('config')->hGetAll(okeys::slotCoefficientCfg('spinsLostDay')));
- ksort($cfg['spinsLostDay']);
- $cfg['slotLimitDay'] =funs::getArrFromJsonArr(oo::commonOprRedis('config')->hGetAll(okeys::slotCoefficientCfg('slotLimitDay')));
- ksort($cfg['slotLimitDay']);
- if(!$cfg['spinsLost']){
- $cfg['spinsLost'] = $this->defaultSpinsLostCfg;
- }
- if(!$cfg['spinsLostDay']){
- $cfg['spinsLostDay'] = $this->defaultSpinsLostDayCfg;
- }
- if(!$cfg['slotLimitDay']){
- $cfg['slotLimitDay'] = $this->defaultSlotLimitDayCfg;
- }
- return $cfg;
- }
- public function getThisSlotWeight($uid,$lv,$bet,$actChildType,$changeType=0,$otherData = []){
- $slotWeightCfg = $this->getWeightByLv($lv);
- $lastSlotWeight = $slotWeightCfg = array_column($slotWeightCfg,'v','id');
- $cfg = $this->getConfig();
- $coefCfg_1 = $coefCfg_2 = $coefCfg_3 =[1=>1,2=>1,3=>1,4=>1,5=>1,6=>1,7=>1,8=>1,9=>1,10=>1,11=>1,12=>1,13=>1,14=>1,15=>1,16=>1,17=>1,18=>1,19=>1,20=>1,21=>1,22=>1,23=>1];
- $slotResSpinsLost =oo::commonOprRedis('common')->hGetAll(okeys::userSlotResSpinsLost($uid));
- // ksort($cfg['slotLimitDay']);
- // foreach ($cfg['slotLimitDay'] as $k=>$v){
- // if($slotLimitDay<=$k){
- // $coefCfg_1 = $v;
- // $have_a =1;
- // break;
- // }
- // }
- // if(!isset($have_a)){
- // $coefCfg_1=end($cfg['slotLimitDay']);
- // }
- // ksort($cfg['spinsLostDay']);
- // if(!isset($have_b)){
- // $coefCfg_2=end($cfg['spinsLostDay']);
- // }
- //老虎机体力返比控制
- $returnRate = 1;
- // if(!IS_DEBUF)$otherData=[];//wsc-2021.10.09-临时关闭修正 - 2021-10-18 测试环境开启修正
- if(!empty($otherData)){
- $config = oo::commonOprModel('config')->getConfigByUserGroup($otherData['groupId']);
- //[ * 1、累计预设消耗体力 sumExpectSpins, 2、累计预设分数 sumExpectGrade]
- $getCollectSumNum = oo::commonOprModel('config')->getCollectSumNum($otherData['aid'], 'all', $otherData['rid'], $otherData['stage'], $otherData['groupId']);
- $getCollectActSpins = intval(oo::commonOprRedis('activity')->hGet(okeys::getCollectActSpins($otherData['aid']),$uid));//累计消耗体力
- $getCollectActAdd = intval(oo::commonOprRedis('activity')->hGet(okeys::getCollectActAdd($otherData['aid']),$uid));//累计获取
- $a = empty($getCollectSumNum['sumExpectSpins']) ? 0 : $getCollectActSpins / $getCollectSumNum['sumExpectSpins'];
- $b = empty($getCollectSumNum['sumExpectGrade']) ? 0 : $getCollectActAdd / $getCollectSumNum['sumExpectGrade'];
- $getCollectSumNum['currentSpins'] = $getCollectActSpins;
- $getCollectSumNum['currentGrade'] = $getCollectActAdd;
- $getCollectSumNum['a'] = $a;
- $getCollectSumNum['b'] = $b;
- $bArr = [];
- if(!empty($config['config'] ) && is_array($config['config'])){
- krsort($config['config']);
- foreach ($config['config'] as $ak => $values){
- $bArr = $values;
- if($a >= $ak)break;
- }
- $bMap = [1=>"0", 2=>"0.1", 3=>"0.2", 4=>"0.3", 5=>"0.4", 6=>"0.5", 7=>"0.6", 8=>"0.7", 9=>"0.8", 10=>"0.9", 11=>"1.0"];
- $bk = 1;
- for($k = 11; $k > 0; $k--){
- $v = $bMap[$k];
- $bk = $k;
- if($b >= $v)break;
- }
- if(isset($bArr[$bk]))$returnRate = $bArr[$bk];
- }
- $log = [
- 'spinsReturn' => [
- 'uid' => $uid,
- 'stage' => $otherData['stage'],
- 'getGradeExcept' => $getCollectSumNum['sumExpectGrade'],
- 'spendSpinsExpect' => $getCollectSumNum['sumExpectSpins'],
- 'getGradeTotal' => $getCollectActAdd,
- 'spendSpinsTotal' => $getCollectActSpins,
- 'A' => $a,
- 'B' => $b,
- 'modifyRate' => $returnRate,
- ]
- ];
- if(IS_DEBUF && time() < strtotime('2021-10-19'))oo::logs()->debug3($log,'returnRate.log');
- #收集活动卡点,触发条件:当前收集层的奖励为体力;当前收集层数大于10;
- $reward = oo::commonOprModel('activitynew')->getActReward($otherData['aid']);
- $hasSpins = false;
- $rid = max(intval($otherData['rid']), 1);
- if(!empty($reward['extra_reward']) && $reward['type'] == 'super_collect'){
- $stagePrizes = $reward['extra_reward'][$rid]['list'][$otherData['stage']]['prize'] ?? [];
- foreach ($stagePrizes as $item){#奖励中是否包含体力
- if(!empty($item['type']) && $item['type'] == 15){
- $hasSpins = true;
- break;
- }
- }
- }
- #当前层大于10 且有体力奖励
- $freezePointRate = 1;
- $freezePointMinStage = intval(oo::commonOprRedis('config')->get(okeys::slotFreezePointMinStage()));
- if($otherData['stage'] > $freezePointMinStage && $hasSpins){
- #取上一层的累计值
- $getCollectSumNumPreStage = oo::commonOprModel('config')->getCollectSumNum($otherData['aid'], 'all', $otherData['rid'], $otherData['stage'] - 1, $otherData['groupId']);
- #当前层总分 = 当前层累积预设分数 - 上一层累积预设分数
- $currentStageGrade = $getCollectSumNum['sumExpectGrade'] - $getCollectSumNumPreStage['sumExpectGrade'];
- #当前层预设体力 = 当前层累积预设体力 - 上一层累积预设体力
- $currentStageSpins = $getCollectSumNum['sumExpectSpins'] - $getCollectSumNumPreStage['sumExpectSpins'];
- #当前层获得分数 = 当累积获取 - 上层累积预设分数
- $currentGrade = $getCollectActAdd - $getCollectSumNumPreStage['sumExpectGrade'];
- #收集活动卡点修正
- #A =(当前层总分-当前层获得分数)/ 当前层总分
- $a = empty($currentStageGrade) ? 0 : ($currentStageGrade - $currentGrade ) / $currentStageGrade;
- #B =( 剩余体力 / 当前收集层预设体力
- $b = empty($currentStageSpins) ? 0 : $otherData['leftSpins'] / $currentStageSpins;
- #根据用户组获取收集卡点配置
- $config = oo::commonOprModel('config')->getFreezePointConfigByUserGroup($otherData['groupId']);
- if(time() < strtotime('2021-10-14'))oo::logs()->debug3($config,'returnRate.log');
- #根据 A、B 获取具体的修正值
- if(!empty($config['config'] ) && is_array($config['config'])){
- ksort($config['config']);
- foreach ($config['config'] as $ak => $values){
- $bArr = $values;
- if($a <= $ak)break;
- }
- $bMap = [
- 1=>"0",
- 2=>"0.1",
- 3=>"0.2",
- 4=>"0.3",
- 5=>"0.4",
- 6=>"0.5",
- 7=>"0.6",
- 8=>"0.7",
- 9=>"0.8",
- 10=>"0.9",
- 11=>"1",
- 12=>"1.1",
- 13=>"1.2",
- 14=>"1.3",
- 15=>"1.4",
- 16=>"1.5",
- ];
- $bk = 1;
- foreach ($bMap as $k => $v){
- $bk = $k;
- if($b <= $v)break;
- }
- #将修正值乘上体力返比修正值
- if(isset($bArr[$bk]))$freezePointRate *= $bArr[$bk];
- }
- }
- $returnRate *= $freezePointRate;
- $log = [
- 'collectFreeze' => [
- 'uid' => $uid,
- 'minStageCfg' => $freezePointMinStage,
- 'currentStage' => $otherData['stage'],
- 'minStageCfg' => $freezePointMinStage,
- 'hasSpins' => $hasSpins ? 1 : 0,
- 'currentStageGradeTotal' => $currentStageGrade,
- 'currentStageGrade' => $currentGrade,
- 'currentStageSpinsTotal' => $currentStageSpins,
- 'leftSpins' => $otherData['leftSpins'],
- 'A' => $a,
- 'B' => $b,
- 'modifyRate' => $freezePointRate,
- ]
- ];
- if(IS_DEBUF && time() < strtotime('2021-10-19'))oo::logs()->debug3($log,'returnRate.log');
- }
- foreach ($slotResSpinsLost as $key=>$val){
- $spins_bet = $val/$bet;
- $have=0;
- foreach ($cfg['spinsLost'] as $k=>$v){
- if($spins_bet<=$k){
- $coefCfg_3[$key] = $v[$key];
- $have =1;
- break;
- }
- }
- if(!$have){//大于所有值时
- $coefCfg_3[$key] = end($cfg['spinsLost'])[$key];
- }
- }
- foreach ($this->defaultLostSpinsArr as $k=>$v){
- //防止异常-处理
- $coefCfg_1[$k]=$coefCfg_1[$k]?$coefCfg_1[$k]:1;
- $coefCfg_2[$k]=$coefCfg_2[$k]?$coefCfg_2[$k]:1;
- $coefCfg_3[$k]=$coefCfg_3[$k]?$coefCfg_3[$k]:1;
- //权重从新计算
- $lastSlotWeight[$k] = intval($coefCfg_1[$k]*$coefCfg_2[$k]*$coefCfg_3[$k]*intval($slotWeightCfg[$k]));
- }
- $slotWeightBf= $lastSlotWeight;
- unset($lastSlotWeight[12],$lastSlotWeight[13],$lastSlotWeight[14],$lastSlotWeight[15],$lastSlotWeight[16],$lastSlotWeight[17],$lastSlotWeight[18],$lastSlotWeight[19],$lastSlotWeight[20],$lastSlotWeight[21],$lastSlotWeight[22],$lastSlotWeight[23]);
- //收集活动过滤权重
- if($actChildType==1){//普通收集
- $lastSlotWeight[14] = $slotWeightBf[14] * $returnRate;
- }
- if($actChildType==2){//特殊收集,特殊收集偷,特殊收集打 (收集物1,2,3)
- $lastSlotWeight[12] = $slotWeightBf[12] * $returnRate;
- $lastSlotWeight[13] = $slotWeightBf[13] * $returnRate;
- $lastSlotWeight[14] = $slotWeightBf[14] * $returnRate;
- }
- if($actChildType==4){//偷收集
- $lastSlotWeight[18] = $slotWeightBf[18] * $returnRate;
- $lastSlotWeight[19] = $slotWeightBf[19] * $returnRate;
- }
- if($actChildType==5){//打收集
- $lastSlotWeight[20] = $slotWeightBf[20] * $returnRate;
- $lastSlotWeight[21] = $slotWeightBf[21] * $returnRate;
- }
- switch($changeType){
- case 1: //小玩法收集活动
- $lastSlotWeight[15] = $slotWeightBf[15];
- $lastSlotWeight[16] = $slotWeightBf[16];
- $lastSlotWeight[17] = $slotWeightBf[17];
- break;
- case 2: //体力存钱罐
- $lastSlotWeight[22] = $slotWeightBf[22];
- $lastSlotWeight[23] = $slotWeightBf[23];
- break;
- case 3: //小玩法和体力存钱罐同开
- $lastSlotWeight[15] = $slotWeightBf[15];
- $lastSlotWeight[16] = $slotWeightBf[16];
- $lastSlotWeight[17] = $slotWeightBf[17];
- $lastSlotWeight[22] = $slotWeightBf[22];
- $lastSlotWeight[23] = $slotWeightBf[23];
- break;
- }
- //收集活动体力返比
- if($returnRate != 1){
- if($otherData['actGroupId'] == 1 || $otherData['actGroupId'] == 7){
- $lastSlotWeight[1] *= $returnRate;//打
- $lastSlotWeight[2] *= $returnRate;//偷
- }else if($otherData['actGroupId'] == 3 || $otherData['actGroupId'] == 5 || $otherData['actGroupId'] == 8){
- $lastSlotWeight[2] *= $returnRate;//偷
- }else if($otherData['actGroupId'] == 4 || $otherData['actGroupId'] == 6 || $otherData['actGroupId'] == 9){
- $lastSlotWeight[1] *= $returnRate;//打
- }
- }
- return $lastSlotWeight;
- }
- public function getSlotResult($uid,$lv,$bet,$actChildType,$change=0,$n=0,$otherData = []){
- if($n){
- $ret['rid'] =$n;
- }else{
- $weight = $this->getThisSlotWeight($uid,$lv,$bet,$actChildType,$change,$otherData);
- $ret['rid'] = funs::get_randByProb($weight);
- }
- $slotWeightCfg = $this->getWeightByLv($lv);
- $lastSlotWeight = array_column($slotWeightCfg,null,'id');
- $ret['type'] = (int)$lastSlotWeight[$ret['rid']]['type'];
- $ret['prize'] = $lastSlotWeight[$ret['rid']];
- return $ret;
- }
- }
|