From b0113a785653bdc00f7fa4a462584f29a116d408 Mon Sep 17 00:00:00 2001 From: hide_d Date: Fri, 10 Sep 2021 02:33:47 +0900 Subject: [PATCH 01/32] =?UTF-8?q?inheritBuff=20=EC=A4=80=EB=B9=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/General.php | 18 +++++++++++++++++- hwe/sammo/TriggerInheritBuff.php | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 hwe/sammo/TriggerInheritBuff.php diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 206a2b8d..91adcf4d 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -35,6 +35,8 @@ class General implements iAction{ protected $personalityObj = null; /** @var iAction[] */ protected $itemObjs = []; + /** @var iAction */ + protected $inheritBuffObj = null; protected $lastTurn = null; protected $resultTurn = null; @@ -136,6 +138,11 @@ class General implements iAction{ $this->itemObjs['weapon'] = buildItemClass($raw['weapon']); $this->itemObjs['book'] = buildItemClass($raw['book']); $this->itemObjs['item'] = buildItemClass($raw['item']); + + $rawInheritBuff = $this->getAuxVar('inheritBuff'); + if($rawInheritBuff !== null){ + $this->inheritBuffObj = new TriggerInheritBuff($rawInheritBuff); + } } function initLogger(int $year, int $month){ @@ -410,7 +417,8 @@ class General implements iAction{ $this->officerLevelObj, $this->specialDomesticObj, $this->specialWarObj, - $this->personalityObj + $this->personalityObj, + $this->inheritBuffObj, ] as $actionObj){ if($actionObj !== null){ $statValue = $actionObj->onCalcStat($this, $statName, $statValue); @@ -785,6 +793,7 @@ class General implements iAction{ $this->specialWarObj, $this->personalityObj, $this->getCrewTypeObj(), + $this->inheritBuffObj, ], $this->itemObjs) as $iObj){ if(!$iObj){ @@ -804,6 +813,7 @@ class General implements iAction{ $this->specialWarObj, $this->personalityObj, $this->getCrewTypeObj(), + $this->inheritBuffObj, ], $this->itemObjs) as $iObj){ if(!$iObj){ continue; @@ -823,6 +833,7 @@ class General implements iAction{ $this->specialWarObj, $this->personalityObj, $this->getCrewTypeObj(), + $this->inheritBuffObj, ], $this->itemObjs) as $iObj){ if(!$iObj){ continue; @@ -841,6 +852,7 @@ class General implements iAction{ $this->specialWarObj, $this->personalityObj, $this->getCrewTypeObj(), + $this->inheritBuffObj, ], $this->itemObjs) as $iObj){ if(!$iObj){ continue; @@ -859,6 +871,7 @@ class General implements iAction{ $this->specialWarObj, $this->personalityObj, $this->getCrewTypeObj(), + $this->inheritBuffObj, ], $this->itemObjs) as $iObj){ if(!$iObj){ continue; @@ -880,6 +893,7 @@ class General implements iAction{ $this->specialWarObj, $this->personalityObj, $this->getCrewTypeObj(), + $this->inheritBuffObj, ], $this->itemObjs) as $iObj){ if(!$iObj){ continue; @@ -900,6 +914,7 @@ class General implements iAction{ $this->specialWarObj, $this->personalityObj, $this->getCrewTypeObj(), + $this->inheritBuffObj, ], $this->itemObjs) as $iObj){ if(!$iObj){ continue; @@ -927,6 +942,7 @@ class General implements iAction{ $this->specialWarObj, $this->personalityObj, $this->getCrewTypeObj(), + $this->inheritBuffObj, ], $this->itemObjs) as $iObj){ if(!$iObj){ continue; diff --git a/hwe/sammo/TriggerInheritBuff.php b/hwe/sammo/TriggerInheritBuff.php new file mode 100644 index 00000000..a0029997 --- /dev/null +++ b/hwe/sammo/TriggerInheritBuff.php @@ -0,0 +1,16 @@ +inheritBuffList = $inheritBuffList; + } + + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ + return $value; + } +} \ No newline at end of file -- 2.54.0 From 4531f3a2739b3157518cabd5c9638f1d110f7c2f Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 11 Sep 2021 21:22:06 +0900 Subject: [PATCH 02/32] =?UTF-8?q?feat:=20=EC=A0=84=ED=88=AC=20=EC=83=81?= =?UTF-8?q?=EB=8C=80=EB=B0=A9=EC=9D=98=20=ED=8A=B9=EC=A0=95=20=EC=88=98?= =?UTF-8?q?=EC=B9=98=EB=A5=BC=20=EC=A0=91=EA=B7=BC=ED=95=A0=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20callback=EB=A5=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/DefaultAction.php | 4 + hwe/sammo/General.php | 20 +++ hwe/sammo/WarUnitGeneral.php | 206 +++++++++++++--------- hwe/sammo/WarUnitTrigger/che_계략발동.php | 4 +- hwe/sammo/WarUnitTrigger/che_계략시도.php | 11 +- hwe/sammo/WarUnitTrigger/che_계략실패.php | 3 +- hwe/sammo/iAction.php | 1 + 7 files changed, 156 insertions(+), 93 deletions(-) diff --git a/hwe/sammo/DefaultAction.php b/hwe/sammo/DefaultAction.php index 8b8f2c9d..f6aec8e8 100644 --- a/hwe/sammo/DefaultAction.php +++ b/hwe/sammo/DefaultAction.php @@ -25,6 +25,10 @@ trait DefaultAction{ return $value; } + public function onCalcOpposeStat(General $general, string $statName, $value, $aux=null){ + return $value; + } + public function onCalcStrategic(string $turnType, string $varType, $value){ return $value; } diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 91adcf4d..ea58e4ff 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -844,6 +844,26 @@ class General implements iAction{ return $value; } + public function onCalcOpposeStat(General $general, string $statName, $value, $aux=null){ + //xxx: $general? + foreach(array_merge([ + $this->nationType, + $this->officerLevelObj, + $this->specialDomesticObj, + $this->specialWarObj, + $this->personalityObj, + $this->getCrewTypeObj(), + $this->inheritBuffObj, + ], $this->itemObjs) as $iObj){ + if(!$iObj){ + continue; + } + /** @var iAction $iObj */ + $value = $iObj->onCalcOpposeStat($this, $statName, $value, $aux); + } + return $value; + } + public function onCalcStrategic(string $turnType, string $varType, $value){ foreach(array_merge([ $this->nationType, diff --git a/hwe/sammo/WarUnitGeneral.php b/hwe/sammo/WarUnitGeneral.php index a243c536..b0e8cc7e 100644 --- a/hwe/sammo/WarUnitGeneral.php +++ b/hwe/sammo/WarUnitGeneral.php @@ -1,10 +1,13 @@ general = $general; $this->raw = $general->getRaw(); $this->rawNation = $rawNation; //read-only @@ -15,43 +18,43 @@ class WarUnitGeneral extends WarUnit{ $cityLevel = $this->getCityVar('level'); - if($isAttacker){ + if ($isAttacker) { //공격자 보정 - if($cityLevel == 2){ + if ($cityLevel == 2) { $this->atmosBonus += 5; } - if($rawNation['capital'] == $this->getCityVar('city')){ + if ($rawNation['capital'] == $this->getCityVar('city')) { $this->atmosBonus += 5; } - } - else{ + } else { //수비자 보정 - if($cityLevel == 1){ + if ($cityLevel == 1) { $this->trainBonus += 5; - } - else if($cityLevel == 3){ + } else if ($cityLevel == 3) { $this->trainBonus += 5; } } } - function getName():string{ + function getName(): string + { return $this->general->getName(); } - function getCityVar(string $key){ + function getCityVar(string $key) + { return $this->general->getRawCity()[$key]; } - - function setOppose(?WarUnit $oppose){ + + function setOppose(?WarUnit $oppose) + { parent::setOppose($oppose); $general = $this->general; $this->general->increaseRankVar('warnum', 1); - if($this->isAttacker){ + if ($this->isAttacker) { $semiTurn = $general->getTurnTime(); - } - else if($oppose !== null){ + } else if ($oppose !== null) { $semiTurn = $oppose->getGeneral()->getTurnTime(); } $phase = $this->getRealPhase(); @@ -60,75 +63,94 @@ class WarUnitGeneral extends WarUnit{ $general->setVar('recent_war', $semiTurn); } - function getMaxPhase():int{ + function getMaxPhase(): int + { $phase = $this->getCrewType()->speed; - $phase = $this->general->onCalcStat($this->general, 'initWarPhase', $phase, ['isAttacker'=>$this->isAttacker]); + $phase = $this->general->onCalcStat($this->general, 'initWarPhase', $phase, ['isAttacker' => $this->isAttacker]); + $phase = $this->oppose->general->onCalcOpposeStat($this->general, 'initWarPhase', $phase, ['isAttacker' => $this->isAttacker]); return $phase + $this->bonusPhase; } - function addTrain(int $train){ + function addTrain(int $train) + { $this->general->increaseVarWithLimit('train', $train, 0, GameConst::$maxTrainByWar); } - function addAtmos(int $atmos){ + function addAtmos(int $atmos) + { $this->general->increaseVarWithLimit('atmos', $atmos, 0, GameConst::$maxAtmosByWar); } - function getDex(GameUnitDetail $crewType){ - $rawDex = $this->general->getDex($crewType); - return $this->general->onCalcStat($this->general, 'dex'.$crewType->armType, $rawDex, [ - 'isAttacker'=>$this->isAttacker, - 'opposeType'=>$this->oppose->getCrewType() + function getDex(GameUnitDetail $crewType) + { + $dex = $this->general->getDex($crewType); + $dex = $this->general->onCalcStat($this->general, 'dex' . $crewType->armType, $dex, [ + 'isAttacker' => $this->isAttacker, + 'opposeType' => $this->oppose->getCrewType() ]); + $dex = $this->oppose->general->onCalcOpposeStat($this->general, 'dex' . $crewType->armType, $dex, [ + 'isAttacker' => $this->isAttacker, + 'opposeType' => $this->oppose->getCrewType() + ]); + return $dex; } - function getComputedTrain(){ + function getComputedTrain() + { $train = $this->general->getVar('train'); - $train = $this->general->onCalcStat($this->general, 'bonusTrain', $train, ['isAttacker'=>$this->isAttacker]); + $train = $this->general->onCalcStat($this->general, 'bonusTrain', $train, ['isAttacker' => $this->isAttacker]); + $train = $this->oppose->general->onCalcOpposeStat($this->general, 'bonusTrain', $train, ['isAttacker' => $this->isAttacker]); $train += $this->trainBonus; - + return $train; } - function getComputedAtmos(){ + function getComputedAtmos() + { $atmos = $this->general->getVar('atmos'); - $atmos = $this->general->onCalcStat($this->general, 'bonusAtmos', $atmos, ['isAttacker'=>$this->isAttacker]); + $atmos = $this->general->onCalcStat($this->general, 'bonusAtmos', $atmos, ['isAttacker' => $this->isAttacker]); + $atmos = $this->oppose->general->onCalcOpposeStat($this->general, 'bonusAtmos', $atmos, ['isAttacker' => $this->isAttacker]); $atmos += $this->atmosBonus; - + return $atmos; } - function getComputedCriticalRatio():float{ + function getComputedCriticalRatio(): float + { $general = $this->general; $criticalRatio = $this->getCrewType()->getCriticalRatio($general); /** @var float $criticalRatio */ - $criticalRatio = $general->onCalcStat($general, 'warCriticalRatio', $criticalRatio, ['isAttacker'=>$this->isAttacker]); + $criticalRatio = $general->onCalcStat($general, 'warCriticalRatio', $criticalRatio, ['isAttacker' => $this->isAttacker]); + $criticalRatio = $this->oppose->general->onCalcOpposeStat($general, 'warCriticalRatio', $criticalRatio, ['isAttacker' => $this->isAttacker]); return $criticalRatio; } - function getComputedAvoidRatio():float{ + function getComputedAvoidRatio(): float + { $general = $this->general; $avoidRatio = $this->getCrewType()->avoid / 100; $avoidRatio *= $this->getComputedTrain() / 100; /** @var float $avoidRatio */ - $avoidRatio = $general->onCalcStat($general, 'warAvoidRatio', $avoidRatio, ['isAttacker'=>$this->isAttacker]); + $avoidRatio = $general->onCalcStat($general, 'warAvoidRatio', $avoidRatio, ['isAttacker' => $this->isAttacker]); + $avoidRatio = $this->oppose->general->onCalcOpposeStat($general, 'warAvoidRatio', $avoidRatio, ['isAttacker' => $this->isAttacker]); - if($this->getOppose()->getCrewType()->armType == GameUnitConst::T_FOOTMAN){ + if ($this->getOppose()->getCrewType()->armType == GameUnitConst::T_FOOTMAN) { $avoidRatio *= 0.75; } return $avoidRatio; } - function addWin(){ + function addWin() + { $general = $this->general; $general->increaseRankVar('killnum', 1); $oppose = $this->getOppose(); - if($oppose instanceof WarUnitCity){ + if ($oppose instanceof WarUnitCity) { $general->increaseRankVar('occupied', 1); } @@ -137,74 +159,74 @@ class WarUnitGeneral extends WarUnit{ $this->addStatExp(1); } - function addStatExp(int $value = 1){ + function addStatExp(int $value = 1) + { $general = $this->general; - if($this->crewType->armType == GameUnitConst::T_WIZARD) { // 귀병 + if ($this->crewType->armType == GameUnitConst::T_WIZARD) { // 귀병 $general->increaseVar('intel_exp', $value); - } elseif($this->crewType->armType == GameUnitConst::T_SIEGE) { // 차병 + } elseif ($this->crewType->armType == GameUnitConst::T_SIEGE) { // 차병 $general->increaseVar('leadership_exp', $value); } else { $general->increaseVar('strength_exp', $value); } } - function addLevelExp(float $value){ + function addLevelExp(float $value) + { $general = $this->general; - if(!$this->isAttacker){ + if (!$this->isAttacker) { $value *= 0.8; } $general->addExperience($value); } - function addDedication(float $value){ + function addDedication(float $value) + { $general = $this->general; $general->addDedication($value); } - function addLose(){ + function addLose() + { $general = $this->general; $general->increaseRankVar('deathnum', 1); $this->addStatExp(1); } - function computeWarPower(){ - [$warPower,$opposeWarPowerMultiply] = parent::computeWarPower(); + function computeWarPower() + { + [$warPower, $opposeWarPowerMultiply] = parent::computeWarPower(); $general = $this->general; $cityID = $general->getCityID(); $officerLevel = $general->getVar('officer_level'); $officerCity = $general->getVar('officer_city'); - if($this->isAttacker){ - if($officerLevel == 12){ + if ($this->isAttacker) { + if ($officerLevel == 12) { $warPower *= 1.10; - } - else if($officerLevel == 11 | $officerLevel == 10 || $officerLevel == 8 || $officerLevel == 6){ + } else if ($officerLevel == 11 | $officerLevel == 10 || $officerLevel == 8 || $officerLevel == 6) { $warPower *= 1.05; } - } - else{ - if($officerLevel == 12){ + } else { + if ($officerLevel == 12) { $opposeWarPowerMultiply *= 0.90; - } - else if($officerLevel == 11 || $officerLevel == 9 || $officerLevel == 7 || $officerLevel == 5){ + } else if ($officerLevel == 11 || $officerLevel == 9 || $officerLevel == 7 || $officerLevel == 5) { $opposeWarPowerMultiply *= 0.95; - } - else if(2 <= $officerLevel && $officerLevel <= 4 && $officerCity == $cityID){ + } else if (2 <= $officerLevel && $officerLevel <= 4 && $officerCity == $cityID) { $opposeWarPowerMultiply *= 0.95; } } $expLevel = $general->getVar('explevel'); - if($this->getOppose() instanceof WarUnitCity){ + if ($this->getOppose() instanceof WarUnitCity) { $warPower *= 1 + $expLevel / 600; - } - else{ + } else { $warPower /= max(0.01, 1 - $expLevel / 300); $opposeWarPowerMultiply *= max(0.01, 1 - $expLevel / 300); } - + [$specialMyWarPowerMultiply, $specialOpposeWarPowerMultiply] = $this->general->getWarPowerMultiplier($this); $warPower *= $specialMyWarPowerMultiply; @@ -212,18 +234,21 @@ class WarUnitGeneral extends WarUnit{ $this->warPower = $warPower; $this->oppose->setWarPowerMultiply($opposeWarPowerMultiply); - return [$warPower,$opposeWarPowerMultiply]; + return [$warPower, $opposeWarPowerMultiply]; } - function getHP():int{ + function getHP(): int + { return $this->general->getVar('crew'); } - function addDex(GameUnitDetail $crewType, float $exp){ + function addDex(GameUnitDetail $crewType, float $exp) + { $this->general->addDex($crewType, $exp, false); } - function decreaseHP(int $damage):int{ + function decreaseHP(int $damage): int + { $general = $this->general; $damage = min($damage, $general->getVar('crew')); @@ -232,7 +257,7 @@ class WarUnitGeneral extends WarUnit{ $general->increaseVar('crew', -$damage); $addDex = $damage; - if(!$this->isAttacker){ + if (!$this->isAttacker) { $addDex *= 0.9; } $this->addDex($this->oppose->getCrewType(), $addDex); @@ -240,12 +265,13 @@ class WarUnitGeneral extends WarUnit{ return $general->getVar('crew'); } - function increaseKilled(int $damage):int{ + function increaseKilled(int $damage): int + { $general = $this->general; $this->addLevelExp($damage / 50); $rice = $damage / 100; - if(!$this->isAttacker){ + if (!$this->isAttacker) { $rice *= 0.8; } @@ -253,9 +279,9 @@ class WarUnitGeneral extends WarUnit{ $rice *= getTechCost($this->getNationVar('tech')); $general->increaseVarWithLimit('rice', -$rice, 0); - + $addDex = $damage; - if(!$this->isAttacker){ + if (!$this->isAttacker) { $addDex *= 0.9; } $this->addDex($this->getCrewType(), $addDex); @@ -265,15 +291,16 @@ class WarUnitGeneral extends WarUnit{ return $this->killed; } - function tryWound():bool{ + function tryWound(): bool + { $general = $this->general; - if($this->hasActivatedSkillOnLog('부상무효')){ + if ($this->hasActivatedSkillOnLog('부상무효')) { return false; } - if($this->hasActivatedSkillOnLog('퇴각부상무효')){ + if ($this->hasActivatedSkillOnLog('퇴각부상무효')) { return false; } - if(!Util::randBool(0.05)){ + if (!Util::randBool(0.05)) { return false; } @@ -285,25 +312,28 @@ class WarUnitGeneral extends WarUnit{ return true; } - function continueWar(&$noRice):bool{ + function continueWar(&$noRice): bool + { $general = $this->general; - if($this->getHP() <= 0){ + if ($this->getHP() <= 0) { $noRice = false; return false; } - if($general->getVar('rice') <= $this->getHP() / 100){ + if ($general->getVar('rice') <= $this->getHP() / 100) { $noRice = true; return false; } return true; } - function checkStatChange():bool{ + function checkStatChange(): bool + { return $this->general->checkStatChange(); } - function finishBattle(){ - if($this->isFinished){ + function finishBattle() + { + if ($this->isFinished) { return; } $this->clearActivatedSkill(); @@ -313,11 +343,11 @@ class WarUnitGeneral extends WarUnit{ $general->increaseRankVar('killcrew', $this->killed); $general->increaseRankVar('deathcrew', $this->dead); - if($this->getOppose() instanceof WarUnitGeneral){ + if ($this->getOppose() instanceof WarUnitGeneral) { $general->increaseRankVar('killcrew_person', $this->killed); $general->increaseRankVar('deathcrew_person', $this->dead); } - + $general->updateVar('rice', Util::round($general->getVar('rice'))); $general->updateVar('experience', Util::round($general->getVar('experience'))); $general->updateVar('dedication', Util::round($general->getVar('dedication'))); @@ -325,10 +355,10 @@ class WarUnitGeneral extends WarUnit{ $this->checkStatChange(); } - function applyDB(\MeekroDB $db):bool{ + function applyDB(\MeekroDB $db): bool + { $affected = $this->getGeneral()->applyDB($db); $this->getLogger()->flush(); return $affected; } - -} \ No newline at end of file +} diff --git a/hwe/sammo/WarUnitTrigger/che_계략발동.php b/hwe/sammo/WarUnitTrigger/che_계략발동.php index dd73a342..ea961424 100644 --- a/hwe/sammo/WarUnitTrigger/che_계략발동.php +++ b/hwe/sammo/WarUnitTrigger/che_계략발동.php @@ -25,10 +25,12 @@ class che_계략발동 extends BaseWarUnitTrigger{ $general = $self->getGeneral(); [$magic, $damage] = $selfEnv['magic']; - + $damage = $general->onCalcStat($general, 'warMagicFailDamage', $damage, $magic); + $damage = $oppose->getGeneral()->onCalcOpposeStat($general, 'warMagicFailDamage', $damage, $magic); $josaUl = \sammo\JosaUtil::pick($magic, '을'); + $general->getLogger()->pushGeneralBattleDetailLog("{$magic}{$josaUl} 성공했다!", ActionLogger::PLAIN); $oppose->getLogger()->pushGeneralBattleDetailLog("{$magic}에 당했다!", ActionLogger::PLAIN); diff --git a/hwe/sammo/WarUnitTrigger/che_계략시도.php b/hwe/sammo/WarUnitTrigger/che_계략시도.php index db532dec..f4c78f44 100644 --- a/hwe/sammo/WarUnitTrigger/che_계략시도.php +++ b/hwe/sammo/WarUnitTrigger/che_계략시도.php @@ -33,11 +33,13 @@ class che_계략시도 extends BaseWarUnitTrigger{ if($self->hasActivatedSkill('계략불가')){ return true; } - + $magicTrialProb = $general->getIntel(true, true, true, false) / 100; $magicTrialProb *= $crewType->magicCoef; $magicTrialProb = $general->onCalcStat($general, 'warMagicTrialProb', $magicTrialProb); + $magicTrialProb = $oppose->getGeneral()->onCalcOpposeStat($general, 'warMagicTrialProb', $magicTrialProb); + if($magicTrialProb <= 0){ return true; } @@ -45,13 +47,14 @@ class che_계략시도 extends BaseWarUnitTrigger{ if($self->getPhase() == 0){ $magicTrialProb *= 3; } - + if(!Util::randBool($magicTrialProb)){ return true; } $magicSuccessProb = 0.7; $magicSuccessProb = $general->onCalcStat($general, 'warMagicSuccessProb', $magicSuccessProb); + $magicSuccessProb = $oppose->getGeneral()->onCalcOpposeStat($general, 'warMagicSuccessProb', $magicSuccessProb); if($self->hasActivatedSkill('계략약화')){ $magicSuccessProb -= 0.1; //NOTE: 앞으로 이건 oppose의 onCalcStat에 들어가야하지 않을까? } @@ -66,6 +69,8 @@ class che_계략시도 extends BaseWarUnitTrigger{ } $successDamage = $general->onCalcStat($general, 'warMagicSuccessDamage', $successDamage, $magic); + $successDamage = $oppose->getGeneral()->onCalcOpposeStat($general, 'warMagicSuccessDamage', $successDamage, $magic); + $self->activateSkill('계략시도', $magic); if(Util::randBool($magicSuccessProb)){ @@ -76,7 +81,7 @@ class che_계략시도 extends BaseWarUnitTrigger{ $self->activateSkill('계략실패'); $selfEnv['magic'] = [$magic, $failDamage]; } - + return true; } } \ No newline at end of file diff --git a/hwe/sammo/WarUnitTrigger/che_계략실패.php b/hwe/sammo/WarUnitTrigger/che_계략실패.php index 8d3c3793..5545c795 100644 --- a/hwe/sammo/WarUnitTrigger/che_계략실패.php +++ b/hwe/sammo/WarUnitTrigger/che_계략실패.php @@ -27,11 +27,12 @@ class che_계략실패 extends BaseWarUnitTrigger{ [$magic, $damage] = $selfEnv['magic']; $damage = $general->onCalcStat($general, 'warMagicFailDamage', $damage, $magic); + $damage = $oppose->getGeneral()->onCalcOpposeStat($general, 'warMagicFailDamage', $damage, $magic); $josaUl = \sammo\JosaUtil::pick($magic, '을'); $general->getLogger()->pushGeneralBattleDetailLog("{$magic}{$josaUl} 실패했다!", ActionLogger::PLAIN); $oppose->getLogger()->pushGeneralBattleDetailLog("{$magic}{$josaUl} 간파했다!", ActionLogger::PLAIN); - + $self->multiplyWarPowerMultiply(1/$damage); $oppose->multiplyWarPowerMultiply($damage); diff --git a/hwe/sammo/iAction.php b/hwe/sammo/iAction.php index bad753b7..d0393dec 100644 --- a/hwe/sammo/iAction.php +++ b/hwe/sammo/iAction.php @@ -10,6 +10,7 @@ interface iAction{ public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float; public function onCalcStat(General $general, string $statName, $value, $aux=null); + public function onCalcOpposeStat(General $general, string $statName, $value, $aux=null); public function onCalcStrategic(string $turnType, string $varType, $value); public function onCalcNationalIncome(string $type, $amount); -- 2.54.0 From bfddce340909fa2429f45ca41ff41a336f30753e Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 11 Sep 2021 21:28:00 +0900 Subject: [PATCH 03/32] =?UTF-8?q?feat:=20'=EA=B3=84=EB=9E=B5=EC=95=BD?= =?UTF-8?q?=ED=99=94'=20=ED=8A=B9=EC=84=B1=EC=9D=84=20onCalcOpposeStat?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/ActionItem/che_반계_백우선.php | 9 ++- hwe/sammo/ActionItem/che_반계_파초선.php | 9 ++- hwe/sammo/ActionItem/che_서적_07_논어.php | 10 ++-- hwe/sammo/ActionItem/che_서적_11_춘추전.php | 10 ++-- .../ActionItem/che_치트_HideD의_사인검.php | 55 ++++++++++++------- hwe/sammo/ActionItem/event_전투특기_반계.php | 9 ++- .../ActionSpecialDomestic/che_event_견고.php | 10 +++- .../ActionSpecialDomestic/che_event_반계.php | 9 ++- hwe/sammo/ActionSpecialWar/che_견고.php | 10 +++- hwe/sammo/ActionSpecialWar/che_반계.php | 9 ++- hwe/sammo/WarUnitTrigger/che_계략시도.php | 3 - 11 files changed, 105 insertions(+), 38 deletions(-) diff --git a/hwe/sammo/ActionItem/che_반계_백우선.php b/hwe/sammo/ActionItem/che_반계_백우선.php index 4e10f5c4..4a38e014 100644 --- a/hwe/sammo/ActionItem/che_반계_백우선.php +++ b/hwe/sammo/ActionItem/che_반계_백우선.php @@ -19,9 +19,16 @@ class che_반계_백우선 extends \sammo\BaseItem{ protected $cost = 200; protected $consumable = false; + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; + } + public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM +BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*301, false, '계략약화'), new che_반계시도($unit, BaseWarUnitTrigger::TYPE_ITEM +BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*301), new che_반계발동($unit) ); diff --git a/hwe/sammo/ActionItem/che_반계_파초선.php b/hwe/sammo/ActionItem/che_반계_파초선.php index 5c19edfd..3a277e3e 100644 --- a/hwe/sammo/ActionItem/che_반계_파초선.php +++ b/hwe/sammo/ActionItem/che_반계_파초선.php @@ -19,9 +19,16 @@ class che_반계_파초선 extends \sammo\BaseItem{ protected $cost = 200; protected $consumable = false; + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; + } + public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM +BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*302, false, '계략약화'), new che_반계시도($unit, BaseWarUnitTrigger::TYPE_ITEM +BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*302), new che_반계발동($unit) ); diff --git a/hwe/sammo/ActionItem/che_서적_07_논어.php b/hwe/sammo/ActionItem/che_서적_07_논어.php index c92a5bd8..0212b932 100644 --- a/hwe/sammo/ActionItem/che_서적_07_논어.php +++ b/hwe/sammo/ActionItem/che_서적_07_논어.php @@ -18,9 +18,11 @@ class che_서적_07_논어 extends \sammo\BaseStatItem{ $this->info .= "
[전투] 상대의 계략 성공 확률 -10%p"; } - public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ - return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM+BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*207, false, '계략약화') - ); + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; } } \ No newline at end of file diff --git a/hwe/sammo/ActionItem/che_서적_11_춘추전.php b/hwe/sammo/ActionItem/che_서적_11_춘추전.php index 0fa0ca84..7dc51ae5 100644 --- a/hwe/sammo/ActionItem/che_서적_11_춘추전.php +++ b/hwe/sammo/ActionItem/che_서적_11_춘추전.php @@ -18,9 +18,11 @@ class che_서적_11_춘추전 extends \sammo\BaseStatItem{ $this->info .= "
[전투] 상대의 계략 성공 확률 -10%p"; } - public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ - return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM+BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*211, false, '계략약화') - ); + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; } } \ No newline at end of file diff --git a/hwe/sammo/ActionItem/che_치트_HideD의_사인검.php b/hwe/sammo/ActionItem/che_치트_HideD의_사인검.php index e95310c9..820c372e 100644 --- a/hwe/sammo/ActionItem/che_치트_HideD의_사인검.php +++ b/hwe/sammo/ActionItem/che_치트_HideD의_사인검.php @@ -1,5 +1,7 @@ 30, - 'bonusAtmos'=>30, - 'leadership'=>100, - 'strength'=>100, - 'intel'=>100, - 'warMagicSuccessProb'=>1, - ][$statName]??0; + 'bonusTrain' => 30, + 'bonusAtmos' => 30, + 'leadership' => 100, + 'strength' => 100, + 'intel' => 100, + 'warMagicSuccessProb' => 1, + ][$statName] ?? 0; return $bonus + $value; } - public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; + } + + public function getPreTurnExecuteTriggerList(General $general): ?GeneralTriggerCaller + { return new GeneralTriggerCaller( new GeneralTrigger\che_도시치료($general) ); } - public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ + public function getBattleInitSkillTriggerList(WarUnit $unit): ?WarUnitTriggerCaller + { return new WarUnitTriggerCaller( new che_부상무효($unit, BaseWarUnitTrigger::TYPE_NONE), new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '저격불가') @@ -73,10 +88,10 @@ EOT; public function getBattlePhaseSkillTriggerList(\sammo\WarUnit $unit): ?WarUnitTriggerCaller { return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '필살불가', '위압불가', '격노불가', '계략약화', '저격불가'), + new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_NONE, false, '필살불가', '위압불가', '격노불가', '저격불가'), new che_전투치료시도($unit), new che_전투치료발동($unit), - new che_저격시도($unit, che_저격시도::TYPE_NONE, 1/2, 20, 60), + new che_저격시도($unit, che_저격시도::TYPE_NONE, 1 / 2, 20, 60), new che_저격발동($unit), new che_격노시도($unit), new che_격노발동($unit), @@ -84,8 +99,8 @@ EOT; ); } - public function getWarPowerMultiplier(WarUnit $unit):array{ + public function getWarPowerMultiplier(WarUnit $unit): array + { return [1, 0.95]; } - -} \ No newline at end of file +} diff --git a/hwe/sammo/ActionItem/event_전투특기_반계.php b/hwe/sammo/ActionItem/event_전투특기_반계.php index 372d4de1..3e2da17a 100644 --- a/hwe/sammo/ActionItem/event_전투특기_반계.php +++ b/hwe/sammo/ActionItem/event_전투특기_반계.php @@ -28,9 +28,16 @@ class event_전투특기_반계 extends \sammo\BaseItem{ return $value; } + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; + } + public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM + BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*401, false, '계략약화'), new che_반계시도($unit), new che_반계발동($unit) ); diff --git a/hwe/sammo/ActionSpecialDomestic/che_event_견고.php b/hwe/sammo/ActionSpecialDomestic/che_event_견고.php index 902682da..1cd1131d 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_event_견고.php +++ b/hwe/sammo/ActionSpecialDomestic/che_event_견고.php @@ -21,6 +21,14 @@ class che_event_견고 extends \sammo\BaseSpecial{ SpecialityHelper::STAT_STRENGTH ]; + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; + } + public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ return new WarUnitTriggerCaller( new che_부상무효($unit, BaseWarUnitTrigger::TYPE_ITEM), @@ -30,7 +38,7 @@ class che_event_견고 extends \sammo\BaseSpecial{ public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM + BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*402, false, '필살불가', '계략약화', '저격불가') + new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM + BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE*402, false, '필살불가', '저격불가') ); } diff --git a/hwe/sammo/ActionSpecialDomestic/che_event_반계.php b/hwe/sammo/ActionSpecialDomestic/che_event_반계.php index ec5b6c28..4bf5256d 100644 --- a/hwe/sammo/ActionSpecialDomestic/che_event_반계.php +++ b/hwe/sammo/ActionSpecialDomestic/che_event_반계.php @@ -33,10 +33,17 @@ class che_event_반계 extends \sammo\BaseSpecial return $value; } + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; + } + public function getBattlePhaseSkillTriggerList(WarUnit $unit): ?WarUnitTriggerCaller { return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM + BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE * 403, false, '계략약화'), new che_반계시도($unit), new che_반계발동($unit) ); diff --git a/hwe/sammo/ActionSpecialWar/che_견고.php b/hwe/sammo/ActionSpecialWar/che_견고.php index 3e3e0d5b..ed8bd76c 100644 --- a/hwe/sammo/ActionSpecialWar/che_견고.php +++ b/hwe/sammo/ActionSpecialWar/che_견고.php @@ -24,6 +24,14 @@ class che_견고 extends \sammo\BaseSpecial SpecialityHelper::STAT_STRENGTH ]; + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; + } + public function getBattleInitSkillTriggerList(WarUnit $unit): ?WarUnitTriggerCaller { return new WarUnitTriggerCaller( @@ -35,7 +43,7 @@ class che_견고 extends \sammo\BaseSpecial public function getBattlePhaseSkillTriggerList(WarUnit $unit): ?WarUnitTriggerCaller { return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM + BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE * 404, false, '필살불가', '계략약화', '저격불가') + new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM + BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE * 404, false, '필살불가', '저격불가') ); } diff --git a/hwe/sammo/ActionSpecialWar/che_반계.php b/hwe/sammo/ActionSpecialWar/che_반계.php index 4d2117d5..2239a6df 100644 --- a/hwe/sammo/ActionSpecialWar/che_반계.php +++ b/hwe/sammo/ActionSpecialWar/che_반계.php @@ -29,9 +29,16 @@ class che_반계 extends \sammo\BaseSpecial{ return $value; } + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + $debuff = [ + 'warMagicSuccessProb' => 0.1, + ][$statName] ?? 0; + return $value - $debuff; + } + public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{ return new WarUnitTriggerCaller( - new WarActivateSkills($unit, BaseWarUnitTrigger::TYPE_ITEM + BaseWarUnitTrigger::TYPE_DEDUP_TYPE_BASE * 406, false, '계략약화'), new che_반계시도($unit), new che_반계발동($unit) ); diff --git a/hwe/sammo/WarUnitTrigger/che_계략시도.php b/hwe/sammo/WarUnitTrigger/che_계략시도.php index f4c78f44..a348804d 100644 --- a/hwe/sammo/WarUnitTrigger/che_계략시도.php +++ b/hwe/sammo/WarUnitTrigger/che_계략시도.php @@ -55,9 +55,6 @@ class che_계략시도 extends BaseWarUnitTrigger{ $magicSuccessProb = 0.7; $magicSuccessProb = $general->onCalcStat($general, 'warMagicSuccessProb', $magicSuccessProb); $magicSuccessProb = $oppose->getGeneral()->onCalcOpposeStat($general, 'warMagicSuccessProb', $magicSuccessProb); - if($self->hasActivatedSkill('계략약화')){ - $magicSuccessProb -= 0.1; //NOTE: 앞으로 이건 oppose의 onCalcStat에 들어가야하지 않을까? - } if($oppose instanceof WarUnitCity){ $magic = Util::choiceRandom(array_keys(static::$tableToCity)); -- 2.54.0 From 1fb1e1a1700663b3058db1f66e47b138496502b3 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 11 Sep 2021 22:18:31 +0900 Subject: [PATCH 04/32] =?UTF-8?q?feat:=20TriggerInheritBuff=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/TriggerInheritBuff.php | 124 +++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 5 deletions(-) diff --git a/hwe/sammo/TriggerInheritBuff.php b/hwe/sammo/TriggerInheritBuff.php index a0029997..63769a60 100644 --- a/hwe/sammo/TriggerInheritBuff.php +++ b/hwe/sammo/TriggerInheritBuff.php @@ -1,16 +1,130 @@ 'warAvoidRatio', + self::WAR_CRITICAL_RATIO => 'warCriticalRatio', + self::WAR_MAGIC_TRIAL_PROB => 'warMagicTrialProb', + + self::DOMESTIC_SUCCESS_PROB => 'success', + self::DOMESTIC_FAIL_PROB => 'fail', + + self::OPPOSE_WAR_AVOID_RATIO => 'warAvoidRatio', + self::OPPOSE_WAR_CRITICAL_RATIO => 'warCriticalRatio', + self::OPPOSE_WAR_MAGIC_TRIAL_PROB => 'warMagicTrialProb', + ]; + + const CALC_DOMESTIC = [ + self::BUFF_KEY_MAP[self::DOMESTIC_SUCCESS_PROB] => [self::DOMESTIC_SUCCESS_PROB, 0.01], + self::BUFF_KEY_MAP[self::DOMESTIC_FAIL_PROB] => [self::DOMESTIC_FAIL_PROB, -0.01], + ]; + + const CALC_STAT = [ + self::BUFF_KEY_MAP[self::WAR_AVOID_RATIO] => [self::WAR_AVOID_RATIO, 0.01], + self::BUFF_KEY_MAP[self::WAR_CRITICAL_RATIO] => [self::WAR_CRITICAL_RATIO, 0.01], + self::BUFF_KEY_MAP[self::WAR_MAGIC_TRIAL_PROB] => [self::WAR_MAGIC_TRIAL_PROB, 0.01], + ]; + + const CALC_OPPOSE_STAT = [ + self::BUFF_KEY_MAP[self::OPPOSE_WAR_AVOID_RATIO] => [self::OPPOSE_WAR_AVOID_RATIO, -0.01], + self::BUFF_KEY_MAP[self::OPPOSE_WAR_CRITICAL_RATIO] => [self::OPPOSE_WAR_CRITICAL_RATIO, -0.01], + self::BUFF_KEY_MAP[self::OPPOSE_WAR_MAGIC_TRIAL_PROB] => [self::OPPOSE_WAR_MAGIC_TRIAL_PROB, -0.01], + ]; + + + const BUFF_KEY_TEXT = [ + self::WAR_AVOID_RATIO => '회피 확률 증가', + self::WAR_CRITICAL_RATIO => '필살 확률 증가', + self::WAR_MAGIC_TRIAL_PROB => '전투계략 시도 확률 증가', + + self::DOMESTIC_SUCCESS_PROB => '내정 성공률 증가', + self::DOMESTIC_FAIL_PROB => '내정 실패율 감소', + + self::OPPOSE_WAR_AVOID_RATIO => '상대 회피 확률 감소', + self::OPPOSE_WAR_CRITICAL_RATIO => '상대 필살 확률 감소', + self::OPPOSE_WAR_MAGIC_TRIAL_PROB => '상대 전투계략 시도 확률 감소', + ]; + + const DOMESTIC_TARGET = [ + '상업' => 1, + '농업' => 1, + '치안' => 1, + '성벽' => 1, + '수비' => 1, + '민심' => 1, + '인구' => 1, + '기술' => 1, + ]; + protected array $inheritBuffList; - public function __construct(array $inheritBuffList){ + public function __construct(array $inheritBuffList) + { $this->inheritBuffList = $inheritBuffList; } - public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ - return $value; + public function onCalcDomestic(string $turnType, string $varType, float $value, $aux = null): float + { + if (count($this->inheritBuffList) == 0) { + return $value; + } + if (!key_exists($turnType, self::DOMESTIC_TARGET)) { + return $value; + } + if(!key_exists($varType, static::CALC_DOMESTIC)){ + return $value; + } + [$iKey, $coeff] = static::CALC_DOMESTIC[$varType]; + if(!key_exists($iKey, $this->inheritBuffList)){ + return $value; + } + return $value + $coeff * $this->inheritBuffList[$iKey]; } -} \ No newline at end of file + + public function onCalcStat(General $general, string $statName, $value, $aux = null) + { + if (count($this->inheritBuffList) == 0) { + return $value; + } + if(!key_exists($statName, static::CALC_STAT)){ + return $value; + } + [$iKey, $coeff] = static::CALC_STAT[$statName]; + if(!key_exists($iKey, $this->inheritBuffList)){ + return $value; + } + return $value + $coeff * $this->inheritBuffList[$iKey]; + } + + public function onCalcOpposeStat(General $general, string $statName, $value, $aux = null) + { + if (count($this->inheritBuffList) == 0) { + return $value; + } + if(!key_exists($statName, static::CALC_OPPOSE_STAT)){ + return $value; + } + [$iKey, $coeff] = static::CALC_OPPOSE_STAT[$statName]; + if(!key_exists($iKey, $this->inheritBuffList)){ + return $value; + } + return $value + $coeff * $this->inheritBuffList[$iKey]; + } +} -- 2.54.0 From a57ba1c6e348dfc0c52d5eebfd394450a066f0a2 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 11 Sep 2021 22:38:35 +0900 Subject: [PATCH 05/32] =?UTF-8?q?balance:=20=EC=9C=A0=EB=8B=88=ED=81=AC=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=ED=85=9C=EC=9D=84=20=EC=96=BB=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EB=8A=94=20=EC=BB=A4=EB=A7=A8=EB=93=9C=20?= =?UTF-8?q?=EC=A6=9D=EA=B0=80=20-=20=EA=B0=95=ED=96=89,=20=EA=B1=B0?= =?UTF-8?q?=EB=B3=91,=20=EA=B2=AC=EB=AC=B8,=20=EA=B5=B0=EB=9F=89=EB=A7=A4?= =?UTF-8?q?=EB=A7=A4,=20=EA=B7=80=ED=99=98,=20=EB=93=B1=EC=9A=A9,=20?= =?UTF-8?q?=EB=AC=BC=EC=9E=90=EC=A1=B0=EB=8B=AC,=20=EC=9D=B4=EB=8F=99,=20?= =?UTF-8?q?=EC=9E=A5=EB=B9=84=EB=A7=A4=EB=A7=A4,=20=EC=A6=9D=EC=97=AC,=20?= =?UTF-8?q?=ED=97=8C=EB=82=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Command/General/che_강행.php | 3 ++ hwe/sammo/Command/General/che_거병.php | 39 +++++++++++----------- hwe/sammo/Command/General/che_견문.php | 11 +++--- hwe/sammo/Command/General/che_군량매매.php | 20 ++++++----- hwe/sammo/Command/General/che_귀환.php | 14 ++++---- hwe/sammo/Command/General/che_등용.php | 11 +++--- hwe/sammo/Command/General/che_물자조달.php | 17 ++++++---- hwe/sammo/Command/General/che_이동.php | 3 ++ hwe/sammo/Command/General/che_장비매매.php | 10 +++--- hwe/sammo/Command/General/che_증여.php | 3 ++ hwe/sammo/Command/General/che_헌납.php | 3 ++ 11 files changed, 82 insertions(+), 52 deletions(-) diff --git a/hwe/sammo/Command/General/che_강행.php b/hwe/sammo/Command/General/che_강행.php index 426b7a75..392698f0 100644 --- a/hwe/sammo/Command/General/che_강행.php +++ b/hwe/sammo/Command/General/che_강행.php @@ -13,6 +13,7 @@ use \sammo\LastTurn; use \sammo\Command; use function \sammo\printCitiesBasedOnDistance; +use function sammo\tryUniqueItemLottery; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; @@ -161,6 +162,8 @@ class che_강행 extends Command\GeneralCommand $general->increaseVar('leadership_exp', 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_거병.php b/hwe/sammo/Command/General/che_거병.php index 02c3262d..c2dafdca 100644 --- a/hwe/sammo/Command/General/che_거병.php +++ b/hwe/sammo/Command/General/che_거병.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -16,13 +16,12 @@ use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; use function sammo\refreshNationStaticInfo; use function sammo\getAllNationStaticInfo; - - +use function sammo\tryUniqueItemLottery; class che_거병 extends Command\GeneralCommand{ static protected $actionName = '거병'; - protected function argTest():bool{ + protected function argTest():bool{ $this->arg = []; return true; @@ -38,7 +37,7 @@ class che_거병 extends Command\GeneralCommand{ $this->setNation(); $relYear = $env['year'] - $env['startyear']; - + $this->fullConditionConstraints=[ ConstraintHelper::BeNeutral(), ConstraintHelper::BeOpeningPart($relYear+1), @@ -49,7 +48,7 @@ class che_거병 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -93,15 +92,15 @@ class che_거병 extends Command\GeneralCommand{ DB::db()->insert('nation', [ 'name'=>$nationName, - 'color'=>'#330000', - 'gold'=>0, - 'rice'=>GameConst::$baserice, - 'rate'=>20, - 'bill'=>100, - 'strategic_cmd_limit'=>12, - 'surlimit'=>72, + 'color'=>'#330000', + 'gold'=>0, + 'rice'=>GameConst::$baserice, + 'rate'=>20, + 'bill'=>100, + 'strategic_cmd_limit'=>12, + 'surlimit'=>72, 'secretlimit'=>$secretlimit, - 'type'=>GameConst::$neutralNationType, + 'type'=>GameConst::$neutralNationType, 'gennum'=>1 ]); $nationID = DB::db()->insertId(); @@ -114,7 +113,7 @@ class che_거병 extends Command\GeneralCommand{ if($nationID == $destNationID){ continue; } - + $diplomacyInit[] = [ 'me'=>$destNationID, 'you'=>$nationID, @@ -132,9 +131,9 @@ class che_거병 extends Command\GeneralCommand{ if($diplomacyInit){ $db->insert('diplomacy', $diplomacyInit); } - - + + $turnRows = []; foreach([12, 11] as $chiefLevel){ foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx){ @@ -147,7 +146,7 @@ class che_거병 extends Command\GeneralCommand{ 'brief'=>'휴식', ]; } - + } $db->insert('nation_turn', $turnRows); @@ -172,10 +171,12 @@ class che_거병 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_견문.php b/hwe/sammo/Command/General/che_견문.php index 480f955f..c7903fd5 100644 --- a/hwe/sammo/Command/General/che_견문.php +++ b/hwe/sammo/Command/General/che_견문.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -14,10 +14,11 @@ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; use \sammo\TextDecoration\SightseeingMessage; +use function sammo\tryUniqueItemLottery; class che_견문 extends Command\GeneralCommand{ static protected $actionName = '견문'; - + protected function argTest():bool{ $this->arg = null; return true; @@ -41,7 +42,7 @@ class che_견문 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -111,10 +112,12 @@ class che_견문 extends Command\GeneralCommand{ $general->addExperience($exp); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_군량매매.php b/hwe/sammo/Command/General/che_군량매매.php index 91e723cc..052d5b17 100644 --- a/hwe/sammo/Command/General/che_군량매매.php +++ b/hwe/sammo/Command/General/che_군량매매.php @@ -5,7 +5,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -16,6 +16,8 @@ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; use sammo\MustNotBeReachedException; +use function sammo\tryUniqueItemLottery; + class che_군량매매 extends Command\GeneralCommand{ static protected $actionName = '군량매매'; static public $reqArg = true; @@ -57,7 +59,7 @@ class che_군량매매 extends Command\GeneralCommand{ $general = $this->generalObj; $this->setCity(); - $this->setNation(); + $this->setNation(); $this->minConditionConstraints=[ ConstraintHelper::ReqCityTrader($general->getNPCType()), @@ -69,7 +71,7 @@ class che_군량매매 extends Command\GeneralCommand{ protected function initWithArg() { $general = $this->generalObj; - + $this->fullConditionConstraints=[ ConstraintHelper::ReqCityTrader($general->getNPCType()), ConstraintHelper::OccupiedCity(true), @@ -87,7 +89,7 @@ class che_군량매매 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -120,7 +122,7 @@ class che_군량매매 extends Command\GeneralCommand{ else{ $tradeRate /= 100; } - + if($buyRice){ $buyKey = 'rice'; $sellKey = 'gold'; @@ -153,7 +155,7 @@ class che_군량매매 extends Command\GeneralCommand{ else{ $logger->pushGeneralActionLog("군량 {$sellAmountText}을 팔아 자금 {$buyAmountText}을 얻었습니다. <1>$date"); } - + $general->increaseVar($buyKey, $buyAmount); $general->increaseVarWithLimit($sellKey, -$sellAmount, 0); @@ -163,7 +165,7 @@ class che_군량매매 extends Command\GeneralCommand{ $exp = 30; $ded = 50; - + $incStat = Util::choiceRandomUsingWeight([ 'leadership_exp'=>$general->getLeadership(false, false, false, false), 'strength_exp'=>$general->getStrength(false, false, false, false), @@ -176,6 +178,8 @@ class che_군량매매 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); return true; @@ -199,5 +203,5 @@ class che_군량매매 extends Command\GeneralCommand{ return ob_get_clean(); } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_귀환.php b/hwe/sammo/Command/General/che_귀환.php index b8c97942..7ca7c1f4 100644 --- a/hwe/sammo/Command/General/che_귀환.php +++ b/hwe/sammo/Command/General/che_귀환.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -14,7 +14,7 @@ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; - +use function sammo\tryUniqueItemLottery; class che_귀환 extends Command\GeneralCommand{ static protected $actionName = '귀환'; @@ -33,7 +33,7 @@ class che_귀환 extends Command\GeneralCommand{ $this->setNation(); [$reqGold, $reqRice] = $this->getCost(); - + $this->fullConditionConstraints=[ ConstraintHelper::NotBeNeutral(), ConstraintHelper::NotWanderingNation(), @@ -49,7 +49,7 @@ class che_귀환 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -87,7 +87,7 @@ class che_귀환 extends Command\GeneralCommand{ $exp = 70; $ded = 100; - + $general->setVar('city', $destCityID); $general->addExperience($exp); @@ -95,10 +95,12 @@ class che_귀환 extends Command\GeneralCommand{ $general->increaseVar('leadership_exp', 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_등용.php b/hwe/sammo/Command/General/che_등용.php index ec6b9949..72a4cc77 100644 --- a/hwe/sammo/Command/General/che_등용.php +++ b/hwe/sammo/Command/General/che_등용.php @@ -15,6 +15,7 @@ use \sammo\{ use function \sammo\getAllNationStaticInfo; use function \sammo\getNationStaticInfo; use function \sammo\newColor; +use function sammo\tryUniqueItemLottery; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; @@ -64,7 +65,7 @@ class che_등용 extends Command\GeneralCommand{ $this->minConditionConstraints=[ ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'), - ConstraintHelper::NotBeNeutral(), + ConstraintHelper::NotBeNeutral(), ConstraintHelper::OccupiedCity(), ConstraintHelper::SuppliedCity(), ]; @@ -80,7 +81,7 @@ class che_등용 extends Command\GeneralCommand{ $this->fullConditionConstraints=[ ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'), - ConstraintHelper::NotBeNeutral(), + ConstraintHelper::NotBeNeutral(), ConstraintHelper::OccupiedCity(), ConstraintHelper::SuppliedCity(), ConstraintHelper::ExistsDestGeneral(), @@ -110,7 +111,7 @@ class che_등용 extends Command\GeneralCommand{ ) * 10; return [$reqGold, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -141,7 +142,7 @@ class che_등용 extends Command\GeneralCommand{ $destGeneralName = $this->destGeneralObj->getName(); $destGeneralID = $this->destGeneralObj->getID(); - + $msg = ScoutMessage::buildScoutMessage($general->getID(), $destGeneralID, $reason, new \DateTime($general->getTurnTime())); if($msg){ @@ -164,6 +165,8 @@ class che_등용 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_물자조달.php b/hwe/sammo/Command/General/che_물자조달.php index 6123c5a1..ed63bc7b 100644 --- a/hwe/sammo/Command/General/che_물자조달.php +++ b/hwe/sammo/Command/General/che_물자조달.php @@ -3,7 +3,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, LastTurn, @@ -13,6 +13,7 @@ use \sammo\{ use function \sammo\getDomesticExpLevelBonus; use function \sammo\CriticalScoreEx; +use function sammo\tryUniqueItemLottery; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; @@ -33,9 +34,9 @@ class che_물자조달 extends Command\GeneralCommand{ $this->setCity(); $this->setNation(); - + $this->fullConditionConstraints=[ - ConstraintHelper::NotBeNeutral(), + ConstraintHelper::NotBeNeutral(), ConstraintHelper::NotWanderingNation(), ConstraintHelper::OccupiedCity(), ConstraintHelper::SuppliedCity() @@ -50,7 +51,7 @@ class che_물자조달 extends Command\GeneralCommand{ public function getCost():array{ return [0, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -84,11 +85,11 @@ class che_물자조달 extends Command\GeneralCommand{ 'normal'=>0.6 ]); $score *= CriticalScoreEx($pick); - + $score = Util::round($score); $scoreText = number_format($score, 0); - + $logger = $general->getLogger(); if($pick == 'fail'){ @@ -120,10 +121,12 @@ class che_물자조달 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); return true; } - + } \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_이동.php b/hwe/sammo/Command/General/che_이동.php index 34fed929..db4fc213 100644 --- a/hwe/sammo/Command/General/che_이동.php +++ b/hwe/sammo/Command/General/che_이동.php @@ -13,6 +13,7 @@ use \sammo\LastTurn; use \sammo\Command; use function \sammo\printCitiesBasedOnDistance; +use function sammo\tryUniqueItemLottery; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; @@ -169,6 +170,8 @@ class che_이동 extends Command\GeneralCommand $general->increaseVar('leadership_exp', 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_장비매매.php b/hwe/sammo/Command/General/che_장비매매.php index 29879470..9904a40a 100644 --- a/hwe/sammo/Command/General/che_장비매매.php +++ b/hwe/sammo/Command/General/che_장비매매.php @@ -5,7 +5,7 @@ namespace sammo\Command\General; use \sammo\{ DB, Util, JosaUtil, - General, + General, ActionLogger, GameConst, GameUnitConst, LastTurn, @@ -13,6 +13,7 @@ use \sammo\{ }; use function \sammo\buildItemClass; +use function sammo\tryUniqueItemLottery; use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; @@ -97,14 +98,14 @@ class che_장비매매 extends Command\GeneralCommand{ if(!$this->isArgValid){ return [0, 0]; } - + $itemCode = $this->arg['itemCode']; $itemObj = buildItemClass($itemCode); $reqGold = $itemObj->getCost(); return [$reqGold, 0]; } - + public function getPreReqTurn():int{ return 0; } @@ -176,6 +177,7 @@ class che_장비매매 extends Command\GeneralCommand{ $general->addExperience($exp); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); + tryUniqueItemLottery($general); $general->applyDB($db); return true; @@ -208,7 +210,7 @@ $('#customSubmit').click(function(){ 현재 구입 불가능한 것은 붉은색으로 표시됩니다.
현재 도시 치안 :    현재 자금 :
장비 : (전각 9글자, 반각 18글자 이내) - - -= 1 && $member['grade'] >= 1 && $member['picture'] != "") { - $imageTemp = GetImageURL($member['imgsvr']); - echo " - - 전콘 사용 여부 - - - - - 사용 - - - "; -} -?> - - - 계정관리에서 자신만을 표현할 수 있는 아이콘을 업로드 해보세요! - - - - 성격 - - - - - - 통솔 - - - - 무력 - - - - 지력 - - - - 능력치 조정 - - - - - - - - - - 모든 능력치는 ( <= 능력치 <= ) 사이로 잡으셔야 합니다.
- 그 외의 능력치는 가입되지 않습니다.
- - - - - 능력치의 총합은 입니다. 가입후 0~10의 능력치 보너스를 받게 됩니다.
- 임의의 도시에서 재야로 시작하며 건국과 임관은 게임 내에서 실행합니다. - - - - - - - - - - - -
- - diff --git a/hwe/join_post.php b/hwe/join_post.php deleted file mode 100644 index 2bf8b8b9..00000000 --- a/hwe/join_post.php +++ /dev/null @@ -1,410 +0,0 @@ -"; - exit(1); -} - -$v = new Validator($_POST); -$v - ->rule('required', [ - 'name', - 'leadership', - 'strength', - 'intel' - ]) - ->rule('integer', [ - 'leadership', - 'strength', - 'intel', - ]) - ->rule('stringWidthBetween', 'name', 1, 18) - ->rule('min', [ - 'leadership', - 'strength', - 'intel' - ], GameConst::$defaultStatMin) - ->rule('max', [ - 'leadership', - 'strength', - 'intel' - ], GameConst::$defaultStatMax) - ->rule('in', 'character', array_merge(GameConst::$availablePersonality, ['Random'])) - ->rule('in', 'inheritSpecial', GameConst::$availableSpecialWar) - ->rule('integer', 'inheritTurntime') - ->rule('min', 'inheritTurntime', 0) - ->rule('in', 'inheritCity', array_keys(CityConst::all())) - ->rule('integerArray', 'inheritBonusStat'); - -if (!$v->validate()) { - dieMsg($v->errorStr()); -} - -$session = Session::requireLogin()->setReadOnly(); -$userID = Session::getUserID(); -//NOTE: 이 페이지에서는 세션에 데이터를 등록하지 않음. 로그인은 이후에. - -$name = Util::getPost('name'); -$name = htmlspecialchars($name); -$name = StringUtil::removeSpecialCharacter($name); -$name = WebUtil::htmlPurify($name); -$name = StringUtil::textStrip($name); -$pic = (int)Util::getPost('pic', 'bool', 0); -$character = Util::getPost('character'); - -$leadership = Util::getPost('leadership', 'int', 50); -$strength = Util::getPost('strength', 'int', 50); -$intel = Util::getPost('intel', 'int', 50); - -$inheritSpecial = Util::getPost('inheritSpecial'); -$inheritTurntime = Util::getPost('inheritTurntime', 'int'); -$inheritCity = Util::getPost('inheritCity', 'int'); -$inheritBonusStat = Util::getPost('inheritBonusStat', 'array_int'); - -$join = Util::getPost('join'); //쓸모 없음 - -$rootDB = RootDB::db(); -//회원 테이블에서 정보확인 -$member = $rootDB->queryFirstRow('SELECT `no`, id, picture, grade, `name`, imgsvr FROM member WHERE no=%i', $userID); - -if (!$member) { - dieMsg("잘못된 접근입니다!!!"); -} - -$db = DB::db(); -$gameStor = KVStorage::getStorage($db, 'game_env'); -$gameStor->cacheValues(['year', 'month', 'maxgeneral', 'scenario', 'show_img_level', 'turnterm', 'turntime', 'genius', 'npcmode']); -########## 동일 정보 존재여부 확인. ########## - -$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2'); -$oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i', $userID); -$oldName = $db->queryFirstField('SELECT `no` FROM general WHERE `name`=%s', $name); - -if ($oldGeneral) { - dieMsg("이미 등록하셨습니다!"); -} -if ($oldName) { - dieMsg("이미 있는 장수입니다. 다른 이름으로 등록해 주세요!"); -} -if ($gameStor->maxgeneral <= $gencount) { - dieMsg("더이상 등록할 수 없습니다!"); -} -if ($name == '') { - dieMsg("이름이 짧습니다. 다시 가입해주세요!"); -} -if (mb_strwidth($name) > 18) { - dieMsg("이름이 유효하지 않습니다. 다시 가입해주세요!"); -} -if ($leadership + $strength + $intel > GameConst::$defaultStatTotal) { - dieMsg("능력치가 " . GameConst::$defaultStatTotal . "을 넘어섰습니다. 다시 가입해주세요!"); -} - -if ($inheritBonusStat) { - if (count($inheritBonusStat) != 3) { - dieMsg("보너스 능력치가 잘못 지정되었습니다. 다시 가입해주세요!"); - } - $sum = array_sum($inheritBonusStat); - if ($sum < GameConst::$bornMinStatBonus || GameConst::$bornMaxStatBonus > 5) { - dieMsg("보너스 능력치 합이 잘못 지정되었습니다. 다시 가입해주세요!"); - } - foreach ($inheritBonusStat as $stat) { - if ($stat < 0) { - dieMsg("보너스 능력치가 음수입니다. 다시 가입해주세요!"); - } - } -} - -$admin = $gameStor->getValues(['scenario', 'turnterm', 'turntime', 'show_img_level', 'startyear', 'year']); - -$inheritTotalPoint = resetInheritanceUser($userID); -$inheritRequiredPoint = 0; - -if ($inheritCity !== null) { - $inheritRequiredPoint += GameConst::$inheritBornCityPoint; -} -if ($inheritBonusStat !== null) { - $inheritRequiredPoint += GameConst::$inheritBornMaxBonusStat; -} -if ($inheritSpecial !== null) { - $inheritRequiredPoint += GameConst::$inheritBornSpecialPoint; -} -if ($inheritTurntime !== null) { - $inheritRequiredPoint += GameConst::$inheritBornTurntimePoint; -} - -if ($inheritTotalPoint < $inheritRequiredPoint) { - dieMsg("유산 포인트가 부족합니다. 다시 가입해주세요!"); -} - -if ($inheritSpecial !== null && $gameStor->genius == 0) { - dieMsg("이미 천재가 모두 나타났습니다. 다시 가입해주세요!"); -} - -if ($inheritCity !== null && !key_exists($inheritCity, CityConst::all())) { - dieMsg("도시가 잘못 지정되었습니다. 다시 가입해주세요!"); -} - -if ($inheritSpecial) { - $genius = true; -} else { - // 현재 1% - $genius = Util::randBool(0.01); -} - -if ($genius && $gameStor->genius > 0) { - $gameStor->genius = $gameStor->genius - 1; -} else { - $genius = false; -} - -if ($inheritCity !== null) { - $city = $inheritCity; -} else { - // 공백지에서만 태어나게 - $city = $db->queryFirstField("select city from city where level>=5 and level<=6 and nation=0 order by rand() limit 0,1"); - if (!$city) { - $city = $db->queryFirstField("select city from city where level>=5 and level<=6 order by rand() limit 0,1"); - } -} - -if ($inheritBonusStat) { - [$pleadership, $pstrength, $pintel] = $inheritBonusStat; -} else { - $pleadership = 0; - $pstrength = 0; - $pintel = 0; - foreach (Util::range(Util::randRangeInt(GameConst::$bornMinStatBonus, GameConst::$bornMaxStatBonus)) as $statIdx) { - switch (Util::choiceRandomUsingWeight([$leadership, $strength, $intel])) { - case 0: - $pleadership++; - break; - case 1: - $pstrength++; - break; - case 2: - $pintel++; - break; - } - } -} - -$leadership = $leadership + $pleadership; -$strength = $strength + $pstrength; -$intel = $intel + $pintel; - -$relYear = Util::valueFit($admin['year'] - $admin['startyear'], 0); - -$age = 20 + ($pleadership + $pstrength + $pintel) * 2 - (mt_rand(0, 1)); -// 아직 남았고 천재등록상태이면 특기 부여 -if ($genius) { - $specage2 = $age; - if ($inheritSpecial) { - $special2 = $inheritSpecial; - } else { - $special2 = SpecialityHelper::pickSpecialWar([ - 'leadership' => $leadership, - 'strength' => $strength, - 'intel' => $intel, - 'dex1' => 0, - 'dex2' => 0, - 'dex3' => 0, - 'dex4' => 0, - 'dex5' => 0 - ]); - } -} else { - $specage2 = Util::valueFit(Util::round((GameConst::$retirementYear - $age) / 6 - $relYear / 2), 3) + $age; - $special2 = GameConst::$defaultSpecialWar; -} -//내특 -$specage = Util::valueFit(Util::round((GameConst::$retirementYear - $age) / 12 - $relYear / 2), 3) + $age; -$special = GameConst::$defaultSpecialDomestic; - -if ($admin['scenario'] >= 1000) { - $specage2 = $age + 3; - $specage = $age + 3; -} - -if ($relYear < 3) { - $experience = 0; -} else { - $expGenCount = $db->queryFirstField('SELECT count(*) FROM general WHERE nation != 0 AND npc < 4'); - $targetGenOrder = Util::round($expGenCount * 0.2); - $experience = $db->queryFirstField( - 'SELECT experience FROM general WHERE nation != 0 AND npc < 4 ORDER BY experience ASC LIMIT %i, 1', - $targetGenOrder - 1 - ); - $experience *= 0.8; -} - -if ($inheritTurntime === null) { - $inheritTurntime = $inheritTurntime % ($gameStor->turnterm * 60); - $inheritTurntime += Util::randRangeInt(0, 999999) / 1000000; - $turntime = cutTurn($admin['turntime'], $admin['turnterm']); - $turntime = TimeUtil::nowAddSeconds($inheritTurntime, true); -} else { - $turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime'])); -} - - -$now = TimeUtil::now(true); -if ($now >= $turntime) { - $turntime = addTurn($turntime, $admin['turnterm']); -} - -//특회 전콘 -if ($admin['show_img_level'] >= 1 && $member['grade'] >= 1 && $member['picture'] != "" && $pic) { - $face = $member['picture']; - $imgsvr = $member['imgsvr']; -} else { - $face = "default.jpg"; - $imgsvr = 0; -} - -//성격 랜덤시 -if (!in_array($character, GameConst::$availablePersonality)) { - $character = Util::choiceRandom(GameConst::$availablePersonality); -} -//상성 랜덤 -$affinity = rand() % 150 + 1; - -########## 회원정보 테이블에 입력값을 등록한다. ########## -$db->insert('general', [ - 'owner' => $userID, - 'name' => $name, - 'owner_name' => $member['name'], - 'picture' => $face, - 'imgsvr' => $imgsvr, - 'nation' => 0, - 'city' => $city, - 'troop' => 0, - 'affinity' => $affinity, - 'leadership' => $leadership, - 'strength' => $strength, - 'intel' => $intel, - 'experience' => $experience, - 'dedication' => 0, - 'gold' => GameConst::$defaultGold, - 'rice' => GameConst::$defaultRice, - 'crew' => 0, - 'train' => 0, - 'atmos' => 0, - 'officer_level' => 0, - 'turntime' => $turntime, - 'killturn' => 6, - 'lastconnect' => $now, - 'lastrefresh' => $now, - 'crewtype' => GameUnitConst::DEFAULT_CREWTYPE, - 'makelimit' => 0, - 'age' => $age, - 'startage' => $age, - 'personal' => $character, - 'specage' => $specage, - 'special' => $special, - 'specage2' => $specage2, - 'special2' => $special2 -]); -$generalID = $db->insertId(); -$turnRows = []; -foreach (Util::range(GameConst::$maxTurn) as $turnIdx) { - $turnRows[] = [ - 'general_id' => $generalID, - 'turn_idx' => $turnIdx, - 'action' => '휴식', - 'arg' => null, - 'brief' => '휴식' - ]; -} -$db->insert('general_turn', $turnRows); - -$rank_data = []; -foreach (array_keys(General::RANK_COLUMN) as $rankColumn) { - $rank_data[] = [ - 'general_id' => $generalID, - 'nation_id' => 0, - 'type' => $rankColumn, - 'value' => 0 - ]; -} -$db->insert('rank_data', $rank_data); -$db->insert('betting', [ - 'general_id' => $generalID, -]); -$cityname = CityConst::byID($city)->name; - -$me = [ - 'no' => $generalID -]; - -$log = []; -$mylog = []; - -$logger = new ActionLogger($generalID, 0, $gameStor->year, $gameStor->month); - -$josaRa = JosaUtil::pick($name, '라'); -$speicalText = getGeneralSpecialWarName($special2); -if ($genius) { - - $logger->pushGlobalActionLog("{$cityname}에서 {$name}{$josaRa}는 기재가 천하에 이름을 알립니다."); - $logger->pushGlobalActionLog("{$speicalText} 특기를 가진 천재의 등장으로 온 천하가 떠들썩합니다."); - $logger->pushGlobalHistoryLog("【천재】{$cityname}에 천재가 등장했습니다."); -} else { - $logger->pushGlobalActionLog("{$cityname}에서 {$name}{$josaRa}는 호걸이 천하에 이름을 알립니다."); -} - -$logger->pushGeneralHistoryLog("{$name}, {$cityname}에서 큰 뜻을 품다."); -$logger->pushGeneralActionLog("삼국지 모의전투 PHP의 세계에 오신 것을 환영합니다 ^o^", ActionLogger::PLAIN); -$logger->pushGeneralActionLog("처음 하시는 경우에는 도움말을 참고하시고,", ActionLogger::PLAIN); -$logger->pushGeneralActionLog("문의사항이 있으시면 게시판에 글을 남겨주시면 되겠네요~", ActionLogger::PLAIN); -$logger->pushGeneralActionLog("부디 즐거운 삼모전 되시길 바랍니다 ^^", ActionLogger::PLAIN); -$logger->pushGeneralActionLog("통솔 $pleadership 무력 $pstrength 지력 $pintel 의 보너스를 받으셨습니다.", ActionLogger::PLAIN); -$logger->pushGeneralActionLog("연령은 $age세로 시작합니다.", ActionLogger::PLAIN); - -if ($genius) { - $logger->pushGeneralActionLog("축하합니다! 천재로 태어나 처음부터 {$speicalText} 특기를 가지게 됩니다!", ActionLogger::PLAIN); - $logger->pushGeneralHistoryLog("{$speicalText} 특기를 가진 천재로 탄생."); -} - -$logger->flush(); - -pushAdminLog(["가입 : {$userID} // {$name} // {$generalID}" . getenv("REMOTE_ADDR")]); - -$rootDB->insert('member_log', [ - 'member_no' => $userID, - 'date' => TimeUtil::now(), - 'action_type' => 'make_general', - 'action' => Json::encode([ - 'server' => DB::prefix(), - 'type' => 'general', - 'generalID' => $generalID, - 'generalName' => $name - ]) -]); - -?> - - - - - - - - - - - \ No newline at end of file diff --git a/hwe/ts/Join.vue b/hwe/ts/Join.vue index b813774c..b6f366a1 100644 --- a/hwe/ts/Join.vue +++ b/hwe/ts/Join.vue @@ -295,20 +295,31 @@ export default defineComponent({ this.args.intel = Math.floor(stats.total / 3); }, async submitForm() { + //검증은 언제 되어야 하는가? const args = clone(this.args); - console.log(args); - const response = await axios({ - url: "api.php", - method: 'post', - responseType: 'json', - data: { - path: ["General", "Join"], - args, - }, - }); - console.log(response); - const result:InvalidResponse = response.data; - console.log(result); + let result: InvalidResponse; + try { + const response = await axios({ + url: "api.php", + method: "post", + responseType: "json", + data: { + path: ["General", "Join"], + args, + }, + }); + result = response.data; + if(!result.result){ + throw result.reason; + } + } catch (e) { + console.error(e); + alert(`실패했습니다: ${e}`); + return; + } + + alert('정상적으로 생성되었습니다. \n위키와 팁/강좌 게시판을 꼭 읽어보세요!'); + location.href = './'; }, }, }); -- 2.54.0 From 4605bb339f2e932800bf67c0df6493bae443e755 Mon Sep 17 00:00:00 2001 From: hide_d Date: Tue, 14 Sep 2021 02:37:37 +0900 Subject: [PATCH 17/32] =?UTF-8?q?inheritPoint:=20=EA=B0=80=EC=9E=85?= =?UTF-8?q?=ED=8F=BC=20-=20=EA=B8=B0=EB=B3=B8=20=EB=8F=99=EC=9E=91=20-=20?= =?UTF-8?q?=ED=84=B4=EC=8B=9C=EA=B0=84=EC=97=90=EB=8A=94=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=9E=88=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/General/Join.php | 23 ++- hwe/sammo/GameConstBase.php | 2 +- hwe/ts/Join.vue | 227 +++++++++++++++++++++- hwe/ts/components/NumberInputWithInfo.vue | 12 ++ hwe/v_join.php | 29 ++- 5 files changed, 277 insertions(+), 16 deletions(-) diff --git a/hwe/sammo/API/General/Join.php b/hwe/sammo/API/General/Join.php index 99a70b7c..5d50164c 100644 --- a/hwe/sammo/API/General/Join.php +++ b/hwe/sammo/API/General/Join.php @@ -143,15 +143,17 @@ class Join extends \sammo\BaseAPI if (count($inheritBonusStat) != 3) { return "보너스 능력치가 잘못 지정되었습니다. 다시 가입해주세요!"; } - $sum = array_sum($inheritBonusStat); - if ($sum < 3 || $sum > 5) { - return "보너스 능력치 합이 잘못 지정되었습니다. 다시 가입해주세요!"; - } foreach ($inheritBonusStat as $stat) { if ($stat < 0) { return "보너스 능력치가 음수입니다. 다시 가입해주세요!"; } } + $sum = array_sum($inheritBonusStat); + if ($sum == 0) { + $inheritBonusStat = null; + } else if ($sum < 3 || $sum > 5) { + return "보너스 능력치 합이 잘못 지정되었습니다. 다시 가입해주세요!"; + } } $admin = $gameStor->getValues(['scenario', 'turnterm', 'turntime', 'show_img_level', 'startyear', 'year']); @@ -163,7 +165,7 @@ class Join extends \sammo\BaseAPI $inheritRequiredPoint += GameConst::$inheritBornCityPoint; } if ($inheritBonusStat !== null) { - $inheritRequiredPoint += GameConst::$inheritBornMaxBonusStat; + $inheritRequiredPoint += GameConst::$inheritBornStatPoint; } if ($inheritSpecial !== null) { $inheritRequiredPoint += GameConst::$inheritBornSpecialPoint; @@ -278,6 +280,7 @@ class Join extends \sammo\BaseAPI } if ($inheritTurntime !== null) { + //FIXME: 오동작함 $inheritTurntime = $inheritTurntime % ($gameStor->turnterm * 60); $inheritTurntime += Util::randRangeInt(0, 999999) / 1000000; $turntime = new \DateTimeImmutable(cutTurn($admin['turntime'], $admin['turnterm'])); @@ -372,6 +375,16 @@ class Join extends \sammo\BaseAPI ]); $cityname = CityConst::byID($city)->name; + if ($inheritRequiredPoint > 0) { + $inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}"); + $inheritStor->setValue('previous', [$inheritTotalPoint - $inheritRequiredPoint, [ + 'inheritBonusStat'=>$inheritBonusStat, + 'inheritCity'=>$inheritCity, + 'inheritSpecial'=>$inheritSpecial, + 'inheritTurntime'=>$inheritTurntime, + ]]); + } + $me = [ 'no' => $generalID ]; diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 37b61b89..d36689df 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -198,7 +198,7 @@ class GameConstBase public static $inheritBornSpecialPoint = 12000; public static $inheritBornTurntimePoint = 3000; public static $inheritBornCityPoint = 1000; - public static $inheritBornMaxBonusStat = 1000; + public static $inheritBornStatPoint = 1000; public static $allItems = [ 'horse' => [ diff --git a/hwe/ts/Join.vue b/hwe/ts/Join.vue index b6f366a1..b4984534 100644 --- a/hwe/ts/Join.vue +++ b/hwe/ts/Join.vue @@ -135,6 +135,129 @@ 임의의 도시에서 재야로 시작하며 건국과 임관은 게임 내에서 실행합니다. + +
+
+ 유산 포인트 사용 +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
천재로 생성
+
+ +
+
+ +
+
+
+
도시
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
장수 생성 { + const rC = lhs[1].localeCompare(rhs[1]); + if (rC != 0) return rC; + return lhs[2].localeCompare(rhs[2]); + }); return { - displayTable: displayTable, + displayTable, + displayInherit, availablePersonality, + availableInheritSpecial, + availableInheritCity, member: member, stats, args, nationList: nationListShuffled, isBrightColor, + inheritTotalPoint, + inheritTurnTimeSet: false, + inheritTurnTimeMinute: 0, + inheritTurnTimeSecond: 0, + turnterm, }; }, watch: { @@ -260,6 +425,31 @@ export default defineComponent({ JSON.stringify(newValue) ); }, + displayInherit(newValue: boolean) { + localStorage.setItem( + `conf.${serverID}.join.displayInherit`, + JSON.stringify(newValue) + ); + }, + inheritTurnTimeMinute(newValue: number) { + if (!this.inheritTurnTimeSet) { + this.args.inheritTurntime = 0; + } + this.args.inheritTurntime = newValue * 60 + this.inheritTurnTimeSecond; + }, + inheritTurnTimeSecond(newValue: number) { + if (!this.inheritTurnTimeSet) { + this.args.inheritTurntime = 0; + } + this.args.inheritTurntime = this.inheritTurnTimeMinute * 60 + newValue; + }, + inheritTurnTimeSet(newValue: boolean) { + if (!newValue) { + this.args.inheritTurntime = 0; + } + this.args.inheritTurntime = + this.inheritTurnTimeMinute * 60 + this.inheritTurnTimeSecond; + }, }, computed: { iconPath() { @@ -268,6 +458,25 @@ export default defineComponent({ } return getIconPath(0, "default.jpg"); }, + inheritRequiredPoint() { + let inheritRequiredPoint = 0; + if (this.args.inheritCity !== undefined) { + inheritRequiredPoint += inheritPoints.city; + } + if (this.args.inheritSpecial !== undefined) { + inheritRequiredPoint += inheritPoints.special; + } + if (this.args.inheritTurntime !== undefined) { + inheritRequiredPoint += inheritPoints.turnTime; + } + if ( + this.args.inheritBonusStat !== undefined && + sum(this.args.inheritBonusStat) != 0 + ) { + inheritRequiredPoint += inheritPoints.stat; + } + return inheritRequiredPoint; + }, }, methods: { randStatRandom() { @@ -295,7 +504,7 @@ export default defineComponent({ this.args.intel = Math.floor(stats.total / 3); }, async submitForm() { - //검증은 언제 되어야 하는가? + //검증은 언제 되어야 하는가? const args = clone(this.args); let result: InvalidResponse; try { @@ -309,8 +518,8 @@ export default defineComponent({ }, }); result = response.data; - if(!result.result){ - throw result.reason; + if (!result.result) { + throw result.reason; } } catch (e) { console.error(e); @@ -318,8 +527,10 @@ export default defineComponent({ return; } - alert('정상적으로 생성되었습니다. \n위키와 팁/강좌 게시판을 꼭 읽어보세요!'); - location.href = './'; + alert( + "정상적으로 생성되었습니다. \n위키와 팁/강좌 게시판을 꼭 읽어보세요!" + ); + location.href = "./"; }, }, }); diff --git a/hwe/ts/components/NumberInputWithInfo.vue b/hwe/ts/components/NumberInputWithInfo.vue index 69fef342..c5e55cdf 100644 --- a/hwe/ts/components/NumberInputWithInfo.vue +++ b/hwe/ts/components/NumberInputWithInfo.vue @@ -17,6 +17,7 @@ { (this.$refs.input as HTMLInputElement).focus(); diff --git a/hwe/v_join.php b/hwe/v_join.php index e67a3e34..c6db78da 100644 --- a/hwe/v_join.php +++ b/hwe/v_join.php @@ -23,7 +23,7 @@ if (!$member) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); -$admin = $gameStor->getValues(['block_general_create', 'show_img_level', 'maxgeneral']); +$admin = $gameStor->getValues(['block_general_create', 'show_img_level', 'maxgeneral', 'turnterm']); if ($admin['block_general_create']) { die(WebUtil::errorBackMsg("잘못된 접근입니다!!!")); } @@ -38,6 +38,7 @@ if ($gencount >= $admin['maxgeneral']) { die(WebUtil::errorBackMsg("더 이상 등록할 수 없습니다.")); } +$inheritTotalPoint = resetInheritanceUser($userID); $nationList = $db->query('SELECT nation,`name`,color,scout FROM nation'); $nationList = Util::convertArrayToDict($nationList, 'nation'); @@ -57,6 +58,20 @@ foreach (GameConst::$availablePersonality as $personalityID) { ]; } +$availableInheritSpecial = []; +foreach (GameConst::$availableSpecialWar as $specialID){ + $specialObj = buildGeneralSpecialWarClass($specialID); + $availableInheritSpecial[$specialID] = [ + 'name' => $specialObj->getName(), + 'info' => $specialObj->getInfo(), + ]; +} + +$availableInheritCity = []; +foreach(CityConst::all() as $city){ + $availableInheritCity[] = [$city->id, CityConst::$regionMap[$city->region], $city->name]; +} + ?> @@ -93,7 +108,17 @@ foreach (GameConst::$availablePersonality as $personalityID) { 'total' => GameConst::$defaultStatTotal, 'bonusMin' => GameConst::$bornMinStatBonus, 'bonusMax' => GameConst::$bornMaxStatBonus, - ] + ], + 'inheritTotalPoint'=>$inheritTotalPoint, + 'inheritPoints'=>[ + 'special'=>GameConst::$inheritBornSpecialPoint, + 'turnTime'=>GameConst::$inheritBornTurntimePoint, + 'city'=>GameConst::$inheritBornCityPoint, + 'stat'=>GameConst::$inheritBornStatPoint + ], + 'availableInheritSpecial' => $availableInheritSpecial, + 'availableInheritCity'=> $availableInheritCity, + 'turnterm'=>$gameStor->turnterm, ]) ?> -- 2.54.0 From 6248d789588d739e635dffe2d9ccd94eaf4ab25b Mon Sep 17 00:00:00 2001 From: hide_d Date: Tue, 14 Sep 2021 22:45:04 +0900 Subject: [PATCH 18/32] =?UTF-8?q?fix:=20=EB=A9=94=EC=9D=B8=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=A7=80=EB=8F=84=EB=A5=BC=20=EB=B0=98?= =?UTF-8?q?=EC=9D=91=ED=98=95=EC=9C=BC=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/login.css | 73 ++++++++++++++++++++++++++++++++++++++++++++++++--- index.php | 9 ++++--- 2 files changed, 75 insertions(+), 7 deletions(-) diff --git a/css/login.css b/css/login.css index 0dc81843..c1aaf6d1 100644 --- a/css/login.css +++ b/css/login.css @@ -127,8 +127,75 @@ input::-webkit-input-placeholder { border-radius: .2rem; } -#running_map{ - overflow: hidden; +#running_map { border: none; - width:700px; + width: 700px; +} + + +#map-subframe { + display: none; + width: 700px; +} + +@media only screen and (min-width : 360px) { + #map-subframe { + display: block; + transform: scale(calc(330 / 700)); + transform-origin: 350px 0px; + margin-bottom: -400px; + } +} + + +@media only screen and (min-width : 440px) { + #map-subframe { + transform: scale(calc(410 / 700)); + margin-bottom: -300px; + } +} + +@media only screen and (min-width : 480px) { + #map-subframe { + transform: scale(calc(450 / 700)); + margin-bottom: -250px; + } +} + + +@media only screen and (min-width : 520px) { + #map-subframe { + transform: scale(calc(490 / 700)); + margin-bottom: -200px; + } +} + +@media only screen and (min-width : 576px) { + #map-subframe { + transform: scale(calc(546 / 700)); + margin-bottom: -150px; + } +} + +@media only screen and (min-width : 640px) { + #map-subframe { + transform: scale(calc(600/700)); + margin-bottom: -100px; + } +} + + +@media only screen and (min-width : 700px) { + #map-subframe { + transform: scale(calc(670 / 700)); + margin-bottom: -20px; + } +} + + +@media only screen and (min-width : 730px) { + #map-subframe { + transform: none; + margin-bottom: 0; + } } \ No newline at end of file diff --git a/index.php b/index.php index b3d3c979..86ea421c 100644 --- a/index.php +++ b/index.php @@ -80,8 +80,8 @@ foreach (ServConfig::getServerList() as $setting) {
-

삼국지 모의전투 HiDCHe

-
+

삼국지 모의전투 HiDCHe

+

@@ -126,13 +126,14 @@ foreach (ServConfig::getServerList() as $setting) {

-
-
+
+
+
개인정보처리방침 & 이용약관
© 2020 • HideD
크롬과 파이어폭스에 최적화되어있습니다. -- 2.54.0 From ca25f55cb30df24d3953db36a324825439221af0 Mon Sep 17 00:00:00 2001 From: hide_d Date: Tue, 14 Sep 2021 22:46:02 +0900 Subject: [PATCH 19/32] misc: License --- LICENSE | 2 +- index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index f44828e6..774cd674 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2020 Hide_D, 62che +Copyright (c) 2021 Hide_D, 62che Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/index.php b/index.php index 86ea421c..3e301fb9 100644 --- a/index.php +++ b/index.php @@ -135,7 +135,7 @@ foreach (ServConfig::getServerList() as $setting) {
-
개인정보처리방침 & 이용약관
© 2020 • HideD +
개인정보처리방침 & 이용약관
© 2021 • HideD
크롬과 파이어폭스에 최적화되어있습니다.
-- 2.54.0 From d6b06564e7fc11efb4234473993fb3d512be0d68 Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 15 Sep 2021 01:46:31 +0900 Subject: [PATCH 20/32] =?UTF-8?q?dep:=20bootstrap-vue-3=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20=EC=95=84=EC=A7=81=20=EC=97=86=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=9D=B4=20=EB=A7=8E=EC=9C=BC=EB=AF=80?= =?UTF-8?q?=EB=A1=9C=20=EB=8B=A8=EC=88=9C=20=EC=B6=9C=EB=A0=A5=EC=9D=80=20?= =?UTF-8?q?CoreUI=20Vue=20=EB=8F=99=EC=8B=9C=20=ED=99=9C=EC=9A=A9=20-=20?= =?UTF-8?q?=EB=B6=88=ED=8E=B8..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/ts/Join.vue | 22 ++++++++++------------ hwe/ts/NPCControl.vue | 13 ++++--------- hwe/ts/v_NPCControl.ts | 5 ++++- hwe/ts/v_board.ts | 5 ++++- hwe/ts/v_inheritPoint.ts | 6 ++++-- hwe/ts/v_join.ts | 5 ++++- package.json | 5 +++-- 7 files changed, 33 insertions(+), 28 deletions(-) diff --git a/hwe/ts/Join.vue b/hwe/ts/Join.vue index b4984534..b04d1863 100644 --- a/hwe/ts/Join.vue +++ b/hwe/ts/Join.vue @@ -106,17 +106,17 @@ 능력치 조절
- 랜덤형랜덤형 - 통솔무력형통솔무력형 - 통솔지력형통솔지력형 - 무력지력형무력지력형
@@ -260,8 +260,8 @@
- 장수 생성 다시 입력 + 장수 생성 다시 입력
@@ -273,7 +273,6 @@ import "../scss/game_bg.scss"; import { defineComponent } from "vue"; import TopBackBar from "./components/TopBackBar.vue"; import { - CButton, CTable, CTableBody, CTableRow, @@ -366,7 +365,6 @@ export default defineComponent({ name: "Join", components: { TopBackBar, - CButton, CTable, CTableBody, CTableRow, diff --git a/hwe/ts/NPCControl.vue b/hwe/ts/NPCControl.vue index 5350a017..57198e2f 100644 --- a/hwe/ts/NPCControl.vue +++ b/hwe/ts/NPCControl.vue @@ -298,9 +298,8 @@   {{ element.id }}
@@ -320,7 +319,7 @@   {{ element.id }} @@ -391,7 +390,7 @@   {{ element.id }} @@ -412,7 +411,7 @@   {{ element.id }} @@ -470,7 +469,6 @@ import { unwrap } from "./util/unwrap"; import { convertFormData } from "./util/convertFormData"; import axios from "axios"; import { NPCPriorityBtnHelpMessage } from "./helpTexts"; -import { CTooltip } from "@coreui/vue/src/directives/CTooltip"; import draggable from "vuedraggable"; import MyToast from "./components/MyToast.vue"; import TopBackBar from "./components/TopBackBar.vue"; @@ -512,9 +510,6 @@ export default defineComponent({ draggable, MyToast, }, - directives: { - "c-tooltip": CTooltip, - }, methods: { resetPolicy() { if (!confirm("초기 설정으로 되돌릴까요?")) { diff --git a/hwe/ts/v_NPCControl.ts b/hwe/ts/v_NPCControl.ts index 000b4d58..c9b96518 100644 --- a/hwe/ts/v_NPCControl.ts +++ b/hwe/ts/v_NPCControl.ts @@ -1,6 +1,9 @@ import { createApp } from 'vue' import NPCControl from './NPCControl.vue'; +import BootstrapVue3 from 'bootstrap-vue-3' +import "../scss/bootstrap5.scss"; +import 'bootstrap-vue-3/dist/bootstrap-vue-3.css' import { setAxiosXMLHttpRequest } from './util/setAxiosXMLHttpRequest'; setAxiosXMLHttpRequest(); -createApp(NPCControl).mount('#app') \ No newline at end of file +createApp(NPCControl).use(BootstrapVue3).mount('#app') \ No newline at end of file diff --git a/hwe/ts/v_board.ts b/hwe/ts/v_board.ts index cc70dc00..a0ae7a1a 100644 --- a/hwe/ts/v_board.ts +++ b/hwe/ts/v_board.ts @@ -1,5 +1,8 @@ import { createApp } from 'vue' import Board from './Board.vue'; +import BootstrapVue3 from 'bootstrap-vue-3' +import "../scss/bootstrap5.scss"; +import 'bootstrap-vue-3/dist/bootstrap-vue-3.css' import { setAxiosXMLHttpRequest } from './util/setAxiosXMLHttpRequest'; declare const isSecretBoard: boolean; @@ -8,4 +11,4 @@ declare const isSecretBoard: boolean; setAxiosXMLHttpRequest(); createApp(Board, { isSecretBoard -}).mount('#app') \ No newline at end of file +}).use(BootstrapVue3).mount('#app') \ No newline at end of file diff --git a/hwe/ts/v_inheritPoint.ts b/hwe/ts/v_inheritPoint.ts index 8fcab56a..cb8e5cf9 100644 --- a/hwe/ts/v_inheritPoint.ts +++ b/hwe/ts/v_inheritPoint.ts @@ -1,4 +1,6 @@ import { createApp } from 'vue' import InheritPoint from './inheritPoint.vue'; - -createApp(InheritPoint).mount('#app') \ No newline at end of file +import BootstrapVue3 from 'bootstrap-vue-3' +import "../scss/bootstrap5.scss"; +import 'bootstrap-vue-3/dist/bootstrap-vue-3.css' +createApp(InheritPoint).use(BootstrapVue3).mount('#app'); \ No newline at end of file diff --git a/hwe/ts/v_join.ts b/hwe/ts/v_join.ts index 7cbc524c..9b9c88b6 100644 --- a/hwe/ts/v_join.ts +++ b/hwe/ts/v_join.ts @@ -1,4 +1,7 @@ import { createApp } from 'vue' import Join from './Join.vue'; +import BootstrapVue3 from 'bootstrap-vue-3' +import "../scss/bootstrap5.scss"; +import 'bootstrap-vue-3/dist/bootstrap-vue-3.css' -createApp(Join).mount('#app') \ No newline at end of file +createApp(Join).use(BootstrapVue3).mount('#app') \ No newline at end of file diff --git a/package.json b/package.json index f5626f79..7f06e9b9 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "license": "MIT", "type": "module", "dependencies": { - "@coreui/vue": "^4.0.0-beta.2", "@types/downloadjs": "^1.4.2", "@types/linkifyjs": "^2.1.4", "@types/select2": "^4.0.54", @@ -48,6 +47,7 @@ "@babel/core": "^7.15.5", "@babel/preset-env": "^7.15.4", "@babel/preset-typescript": "^7.15.0", + "@coreui/vue": "^4.0.0-beta.2", "@types/bootstrap": "^5.1.4", "@types/jquery": "^3.5.6", "@types/lodash": "^4.14.172", @@ -59,6 +59,7 @@ "babel-loader": "^8.2.2", "babel-plugin-lodash": "^3.3.4", "babel-preset-modern-browsers": "^15.0.2", + "bootstrap-vue-3": "^0.0.3", "bootswatch": "^5.1.1", "clean-terminal-webpack-plugin": "^3.0.0", "css-loader": "^6.2.0", @@ -90,4 +91,4 @@ "not op_mini all", "not ie <= 11" ] -} \ No newline at end of file +} -- 2.54.0 From 96266bbff2480daf08abd864a1a6a3601d614caa Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 15 Sep 2021 02:21:06 +0900 Subject: [PATCH 21/32] =?UTF-8?q?InheritAction:=20=EC=9C=A0=EB=8B=88?= =?UTF-8?q?=ED=81=AC=20=EC=9E=85=EC=B0=B0,=20=EB=9E=9C=EB=8D=A4=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=ED=85=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 4 +- hwe/sammo/API/General/Join.php | 6 +- .../API/InheritAction/BuyRandomUnique.php | 52 ++++++++++++ .../API/InheritAction/BuySpecificUnique.php | 80 +++++++++++++++++++ hwe/sammo/BaseAPI.php | 2 +- hwe/sammo/GameConstBase.php | 2 + src/sammo/Validator.php | 11 ++- 7 files changed, 148 insertions(+), 9 deletions(-) create mode 100644 hwe/sammo/API/InheritAction/BuyRandomUnique.php create mode 100644 hwe/sammo/API/InheritAction/BuySpecificUnique.php diff --git a/hwe/func.php b/hwe/func.php index 5c89d774..cffdd747 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1711,6 +1711,8 @@ function tryInheritUniqueItem(General $general, string $acquireType = '아이템 rollbackInheritUniqueTrial($general, $itemKey, '절차상의 오류입니다.'); continue; } + + //XXX: 정렬할 필요 없지 않나? usort($anyTrials, function ($lhsTrial, $rhsTrial) { [,, $lhsAmount] = $lhsTrial; [,, $rhsAmount] = $rhsTrial; @@ -1718,7 +1720,7 @@ function tryInheritUniqueItem(General $general, string $acquireType = '아이템 }); //공동 1등인데 본인이 있을 수도 있다. - [,, $topAmount] = $anyTrials; + [,, $topAmount] = $anyTrials[0]; if ($amount < $topAmount) { $compAmount = $topAmount / $amount; if ($compAmount > 2.0) { diff --git a/hwe/sammo/API/General/Join.php b/hwe/sammo/API/General/Join.php index 5d50164c..5e3d4527 100644 --- a/hwe/sammo/API/General/Join.php +++ b/hwe/sammo/API/General/Join.php @@ -78,12 +78,8 @@ class Join extends \sammo\BaseAPI return static::REQ_LOGIN | static::REQ_READ_ONLY; } - public function launch(?Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag) + public function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag) { - if ($session === null) { - throw "invalid session"; - } - $userID = $session->userID; $name = $this->args['name']; diff --git a/hwe/sammo/API/InheritAction/BuyRandomUnique.php b/hwe/sammo/API/InheritAction/BuyRandomUnique.php new file mode 100644 index 00000000..dc94af23 --- /dev/null +++ b/hwe/sammo/API/InheritAction/BuyRandomUnique.php @@ -0,0 +1,52 @@ +userID; + $generalID = $session->generalID; + + $general = General::createGeneralObjFromDB($generalID); + if($userID != $general->getVar('owner')){ + return '로그인 상태가 이상합니다. 다시 로그인해 주세요.'; + } + + if($general->getAuxVar('inheritRandomUnique') !== null){ + return '이미 구입 명령을 내렸습니다. 다음 턴까지 기다려주세요.'; + } + + $db = DB::db(); + $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); + $previousPoint = $inheritStor->getValue('previous')??0; + if($previousPoint < GameConst::$inheritItemRandomPoint){ + return '충분한 유산 포인트를 가지고 있지 않습니다.'; + } + + $general->setAuxVar('inheritRandomUnique', TimeUtil::now()); + $inheritStor->setValue('previous', $previousPoint - GameConst::$inheritItemRandomPoint); + $general->flushUpdateValues(); + return null; + } +} diff --git a/hwe/sammo/API/InheritAction/BuySpecificUnique.php b/hwe/sammo/API/InheritAction/BuySpecificUnique.php new file mode 100644 index 00000000..cd76e5e1 --- /dev/null +++ b/hwe/sammo/API/InheritAction/BuySpecificUnique.php @@ -0,0 +1,80 @@ +$amount){ + if($amount == 0){ + continue; + } + $availableItems[$itemKey] = $amount; + } + } + + $v = new Validator($this->args); + $v->rule('required', [ + 'item', + 'amount', + ]) + ->rule('integer', 'amount') + ->rule('min', GameConst::$inheritItemUniqueMinPoint) + ->rule('keyExists', $availableItems); + + if (!$v->validate()) { + return $v->errorStr(); + } + return null; + } + + public function getRequiredSessionMode(): int + { + //KVStrorage, General.aux 모두 쓰므로 lock; + return static::REQ_GAME_LOGIN; + } + + public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag) + { + $itemKey = $this->args['item']; + $amount = $this->args['amount']; + + $userID = $session->userID; + $generalID = $session->generalID; + + $general = General::createGeneralObjFromDB($generalID); + if($userID != $general->getVar('owner')){ + return '로그인 상태가 이상합니다. 다시 로그인해 주세요.'; + } + + $itemTrials = $general->getAuxVar('inheritUniqueTrial') ?? []; + if(key_exists($itemKey, $itemTrials)){ + return '이미 입찰한 아이템입니다. 다음 턴에 시도해 주세요.'; + } + + $db = DB::db(); + $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); + $trialStor = KVStorage::getStorage($db, "ut_{$itemKey}"); + $previousPoint = $inheritStor->getValue('previous')??0; + if($previousPoint < $amount){ + return '충분한 유산 포인트를 가지고 있지 않습니다.'; + } + + $itemTrials[$itemKey] = $amount; + $general->setAuxVar('inheritUniqueTrial', $itemTrials); + $inheritStor->setValue('previous', $previousPoint - $amount); + $trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]); + $general->flushUpdateValues(); + return null; + } +} diff --git a/hwe/sammo/BaseAPI.php b/hwe/sammo/BaseAPI.php index c730b5f2..784a1193 100644 --- a/hwe/sammo/BaseAPI.php +++ b/hwe/sammo/BaseAPI.php @@ -20,7 +20,7 @@ abstract class BaseAPI abstract function validateArgs(): ?string; /** @return null|string|array */ - abstract function launch(?Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag); + abstract function launch(Session $session, ?\DateTimeInterface $modifiedSince, ?string $reqEtag); public function tryCache():?string{ return null; diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index d36689df..5f9344ce 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -199,6 +199,8 @@ class GameConstBase public static $inheritBornTurntimePoint = 3000; public static $inheritBornCityPoint = 1000; public static $inheritBornStatPoint = 1000; + public static $inheritItemUniqueMinPoint = 5000; + public static $inheritItemRandomPoint = 3000; public static $allItems = [ 'horse' => [ diff --git a/src/sammo/Validator.php b/src/sammo/Validator.php index dcd7fb74..5718421f 100644 --- a/src/sammo/Validator.php +++ b/src/sammo/Validator.php @@ -21,7 +21,7 @@ class Validator extends \Valitron\Validator * $rule에 함수를 넣는 대신 상속한 클래스에 추가하는 방식을 사용할 것. * * @suppress PhanUndeclaredFunctionInCallable - * + * * @param string $rule * @param array|string $fields * @return $this @@ -31,7 +31,7 @@ class Validator extends \Valitron\Validator $params = func_get_args(); return parent::rule(...$params); - + } /** @@ -98,4 +98,11 @@ class Validator extends \Valitron\Validator $width = mb_strwidth($value); return $params[0] <= $width && $width <= $params[1]; } + + protected function validateKeyExists($field, $value, $params){ + if(!is_string($value) && !is_numeric($value)){ + return false; + } + return key_exists($value, $params[0]); + } } -- 2.54.0 From 4040260ef79683e5bd693514f00a47f6e17d300a Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 15 Sep 2021 02:58:29 +0900 Subject: [PATCH 22/32] =?UTF-8?q?Inherit:=20Action=20=EC=99=84=EB=A3=8C=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/InheritAction/BuyHiddenBuff.php | 79 +++++++++++++++++++ .../API/InheritAction/BuySpecificUnique.php | 2 +- .../API/InheritAction/ResetSpecialWar.php | 64 +++++++++++++++ hwe/sammo/API/InheritAction/ResetTurnTime.php | 73 +++++++++++++++++ .../API/InheritAction/SetNextSpecialWar.php | 75 ++++++++++++++++++ hwe/sammo/GameConstBase.php | 3 + 6 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 hwe/sammo/API/InheritAction/BuyHiddenBuff.php create mode 100644 hwe/sammo/API/InheritAction/ResetSpecialWar.php create mode 100644 hwe/sammo/API/InheritAction/ResetTurnTime.php create mode 100644 hwe/sammo/API/InheritAction/SetNextSpecialWar.php diff --git a/hwe/sammo/API/InheritAction/BuyHiddenBuff.php b/hwe/sammo/API/InheritAction/BuyHiddenBuff.php new file mode 100644 index 00000000..74468fb1 --- /dev/null +++ b/hwe/sammo/API/InheritAction/BuyHiddenBuff.php @@ -0,0 +1,79 @@ +args); + $v->rule('required', [ + 'type', + 'level', + ]) + ->rule('integer', 'level') + ->rule('min', 'level', 1) + ->rule('max', 'level', TriggerInheritBuff::MAX_STEP) + ->rule('keyExists', 'type', TriggerInheritBuff::BUFF_KEY_TEXT); + + if (!$v->validate()) { + return $v->errorStr(); + } + return null; + } + + public function getRequiredSessionMode(): int + { + //General.aux 쓰므로 lock; + return static::REQ_GAME_LOGIN; + } + + public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag) + { + $userID = $session->userID; + $generalID = $session->generalID; + + $type = $this->args['type']; + $level = $this->args['level']; + + $general = General::createGeneralObjFromDB($generalID); + if ($userID != $general->getVar('owner')) { + return '로그인 상태가 이상합니다. 다시 로그인해 주세요.'; + } + + $inheritBuffList = $general->getAuxVar('inheritBuff') ?? []; + $prevLevel = $inheritBuffList[$type] ?? 0; + + if ($prevLevel == $level) { + return '이미 구입했습니다.'; + } + if ($prevLevel > $level) { + return '이미 더 높은 등급을 구입했습니다.'; + } + + $reqAmount = GameConst::$inheritBuffPoints[$level] - GameConst::$inheritBuffPoints[$prevLevel]; + + $db = DB::db(); + $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); + $previousPoint = $inheritStor->getValue('previous') ?? 0; + if ($previousPoint < $reqAmount) { + return '충분한 유산 포인트를 가지고 있지 않습니다.'; + } + + $inheritBuffList[$type] = $level; + $general->setAuxVar('inheritBuff', $inheritBuffList); + $inheritStor->setValue('previous', $previousPoint - $reqAmount); + $general->flushUpdateValues(); + return null; + } +} diff --git a/hwe/sammo/API/InheritAction/BuySpecificUnique.php b/hwe/sammo/API/InheritAction/BuySpecificUnique.php index cd76e5e1..a5f5b76d 100644 --- a/hwe/sammo/API/InheritAction/BuySpecificUnique.php +++ b/hwe/sammo/API/InheritAction/BuySpecificUnique.php @@ -30,7 +30,7 @@ class BuySpecificUnique extends \sammo\BaseAPI ]) ->rule('integer', 'amount') ->rule('min', GameConst::$inheritItemUniqueMinPoint) - ->rule('keyExists', $availableItems); + ->rule('keyExists', 'item', $availableItems); if (!$v->validate()) { return $v->errorStr(); diff --git a/hwe/sammo/API/InheritAction/ResetSpecialWar.php b/hwe/sammo/API/InheritAction/ResetSpecialWar.php new file mode 100644 index 00000000..815ce71e --- /dev/null +++ b/hwe/sammo/API/InheritAction/ResetSpecialWar.php @@ -0,0 +1,64 @@ +userID; + $generalID = $session->generalID; + + $general = General::createGeneralObjFromDB($generalID); + if ($userID != $general->getVar('owner')) { + return '로그인 상태가 이상합니다. 다시 로그인해 주세요.'; + } + + + $currentSpecialWar = $general->getVar('special2'); + if($currentSpecialWar === null || $currentSpecialWar == 'None'){ + return '이미 전투 특기가 공란입니다.'; + } + + $currentLevel = $general->getAuxVar('inheritResetSpecialWar') ?? -1; + $nextLevel = $currentLevel + 1; + while (count(GameConst::$inheritResetAttrPointBase) <= $nextLevel) { + $baseLen = count(GameConst::$inheritResetAttrPointBase); + GameConst::$inheritResetAttrPointBase[] = GameConst::$inheritResetAttrPointBase[$baseLen - 1] + GameConst::$inheritResetAttrPointBase[$baseLen - 2]; + } + + $reqPoint = GameConst::$inheritResetAttrPointBase[$nextLevel]; + + $db = DB::db(); + $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); + $previousPoint = $inheritStor->getValue('previous') ?? 0; + if ($previousPoint < $reqPoint) { + return '충분한 유산 포인트를 가지고 있지 않습니다.'; + } + + $general->setAuxVar('inheritResetSpecialWar', $nextLevel); + $general->setVar('special2', 'None'); + $inheritStor->setValue('previous', $previousPoint - $reqPoint); + $general->flushUpdateValues(); + return null; + } +} diff --git a/hwe/sammo/API/InheritAction/ResetTurnTime.php b/hwe/sammo/API/InheritAction/ResetTurnTime.php new file mode 100644 index 00000000..2b1226b3 --- /dev/null +++ b/hwe/sammo/API/InheritAction/ResetTurnTime.php @@ -0,0 +1,73 @@ +userID; + $generalID = $session->generalID; + + $general = General::createGeneralObjFromDB($generalID); + if ($userID != $general->getVar('owner')) { + return '로그인 상태가 이상합니다. 다시 로그인해 주세요.'; + } + + $currentLevel = $general->getAuxVar('inheritResetTurnTime') ?? -1; + $nextLevel = $currentLevel + 1; + while (count(GameConst::$inheritResetAttrPointBase) <= $nextLevel) { + $baseLen = count(GameConst::$inheritResetAttrPointBase); + GameConst::$inheritResetAttrPointBase[] = GameConst::$inheritResetAttrPointBase[$baseLen - 1] + GameConst::$inheritResetAttrPointBase[$baseLen - 2]; + } + + $reqPoint = GameConst::$inheritResetAttrPointBase[$nextLevel]; + + $db = DB::db(); + $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); + $previousPoint = $inheritStor->getValue('previous') ?? 0; + if ($previousPoint < $reqPoint) { + return '충분한 유산 포인트를 가지고 있지 않습니다.'; + } + + $gameStor = new KVStorage($db, 'game_env'); + [$turnTerm, $serverTurnTime] = $gameStor->getValuesAsArray(['turnterm', 'turntime']); + + $serverTurnTimeObj = new DateTimeImmutable($serverTurnTime); + $turnTime = new DateTimeImmutable($general->getTurnTime()); + + $afterTurn = Util::randRange($turnTerm * -60 / 2, $turnTerm * 60 / 2); + + $turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($afterTurn)); + if($turnTime <= $serverTurnTimeObj){ + $turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($turnTerm * 60)); + } + + $general->setVar('turntime', TimeUtil::format($turnTime, true)); + $general->setAuxVar('inheritResetTurnTime', $nextLevel); + $inheritStor->setValue('previous', $previousPoint - $reqPoint); + $general->flushUpdateValues(); + return null; + } +} diff --git a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php new file mode 100644 index 00000000..8f837353 --- /dev/null +++ b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php @@ -0,0 +1,75 @@ +args); + $v->rule('required', [ + 'type', + ]) + ->rule('in', 'type', GameConst::$availableSpecialWar); + + if (!$v->validate()) { + return $v->errorStr(); + } + return null; + } + + public function getRequiredSessionMode(): int + { + //General.aux 쓰므로 lock; + return static::REQ_GAME_LOGIN; + } + + public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag) + { + $userID = $session->userID; + $generalID = $session->generalID; + + $type = $this->args['type']; + + $general = General::createGeneralObjFromDB($generalID); + if ($userID != $general->getVar('owner')) { + return '로그인 상태가 이상합니다. 다시 로그인해 주세요.'; + } + + $inheritSpecificSpecialWar = $general->getAuxVar('inheritSpecificSpecialWar'); + $currentSpecialWar = $general->getVar('special2'); + + if ($currentSpecialWar == $type) { + return '이미 그 특기를 보유하고 있습니다.'; + } + if ($inheritSpecificSpecialWar == $type) { + return '이미 그 특기를 예약하였습니다.'; + } + + if($inheritSpecificSpecialWar !== null){ + return '이미 예약한 특기가 있습니다.'; + } + + $reqAmount = GameConst::$inheritSpecificSpecialPoint; + + $db = DB::db(); + $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); + $previousPoint = $inheritStor->getValue('previous') ?? 0; + if ($previousPoint < $reqAmount) { + return '충분한 유산 포인트를 가지고 있지 않습니다.'; + } + + $general->setAuxVar('inheritSpecificSpecialWar', $type); + $inheritStor->setValue('previous', $previousPoint - $reqAmount); + $general->flushUpdateValues(); + return null; + } +} diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 5f9344ce..ba8c86de 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -201,6 +201,9 @@ class GameConstBase public static $inheritBornStatPoint = 1000; public static $inheritItemUniqueMinPoint = 5000; public static $inheritItemRandomPoint = 3000; + public static $inheritBuffPoints = [0, 250, 750, 1500, 2500, 3750]; + public static $inheritSpecificSpecialPoint = 5000; + public static $inheritResetAttrPointBase = [1000, 1000, 2000, 3000];//필요하면 늘려서 쓰기 public static $allItems = [ 'horse' => [ -- 2.54.0 From a10bb03fef8005a0625d1bd5e02865a2f6da0dc7 Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 15 Sep 2021 03:09:57 +0900 Subject: [PATCH 23/32] =?UTF-8?q?inheritAction:=20=ED=8A=B9=EC=A0=95=20?= =?UTF-8?q?=EC=A0=84=ED=8A=B9=20=ED=9A=8D=EB=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 24 +++++++++++++------ .../API/InheritAction/ResetSpecialWar.php | 7 +++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index cffdd747..9029954a 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1283,16 +1283,26 @@ function addAge() foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5,aux from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general) { $generalID = $general['no']; - $special2 = SpecialityHelper::pickSpecialWar( - $general, - (Json::decode($general['aux'])['prev_types_special2']) ?? [] - ); + $generalAux = Json::decode($general['aux']); + + $updateVars = []; + if(key_exists('inheritSpecificSpecialWar', $generalAux)){ + $special2 = $generalAux['inheritSpecificSpecialWar']; + unset($generalAux['inheritSpecificSpecialWar']); + $updateVars['aux'] = Json::encode($generalAux); + } + else{ + $special2 = SpecialityHelper::pickSpecialWar( + $general, + ($generalAux['prev_types_special2']) ?? [] + ); + } + $specialClass = buildGeneralSpecialWarClass($special2); $specialText = $specialClass->getName(); - $db->update('general', [ - 'special2' => $special2 - ], 'no=%i', $general['no']); + $updateVars['special2'] = $special2; + $db->update('general', $updateVars, 'no=%i', $general['no']); $logger = new ActionLogger($generalID, $general['nation'], $year, $month); diff --git a/hwe/sammo/API/InheritAction/ResetSpecialWar.php b/hwe/sammo/API/InheritAction/ResetSpecialWar.php index 815ce71e..3b2a8869 100644 --- a/hwe/sammo/API/InheritAction/ResetSpecialWar.php +++ b/hwe/sammo/API/InheritAction/ResetSpecialWar.php @@ -35,7 +35,7 @@ class ResetSpecialWar extends \sammo\BaseAPI $currentSpecialWar = $general->getVar('special2'); - if($currentSpecialWar === null || $currentSpecialWar == 'None'){ + if ($currentSpecialWar === null || $currentSpecialWar == 'None') { return '이미 전투 특기가 공란입니다.'; } @@ -55,6 +55,11 @@ class ResetSpecialWar extends \sammo\BaseAPI return '충분한 유산 포인트를 가지고 있지 않습니다.'; } + $oldTypeKey = 'prev_types_special2'; + $oldSpecialList = $general->getAuxVar($oldTypeKey) ?? []; + $oldSpecialList[] = $currentSpecialWar; + $general->setAuxVar($oldTypeKey, $oldSpecialList); + $general->setAuxVar('inheritResetSpecialWar', $nextLevel); $general->setVar('special2', 'None'); $inheritStor->setValue('previous', $previousPoint - $reqPoint); -- 2.54.0 From b84aeb71e0cac3eabea02940023ec0c5f7587e15 Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 15 Sep 2021 23:49:20 +0900 Subject: [PATCH 24/32] =?UTF-8?q?inheritStore:=20=EB=B2=84=ED=94=84/?= =?UTF-8?q?=EB=94=94=EB=B2=84=ED=94=84=20=EA=B5=AC=EB=A7=A4=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/InheritAction/BuyHiddenBuff.php | 6 +- .../API/InheritAction/BuyRandomUnique.php | 2 +- .../API/InheritAction/BuySpecificUnique.php | 2 +- .../API/InheritAction/ResetSpecialWar.php | 2 +- hwe/sammo/API/InheritAction/ResetTurnTime.php | 2 +- .../API/InheritAction/SetNextSpecialWar.php | 2 +- hwe/ts/inheritPoint.vue | 182 +++++++++++++++++- hwe/v_inheritPoint.php | 13 +- src/sammo/APIHelper.php | 1 + 9 files changed, 202 insertions(+), 10 deletions(-) diff --git a/hwe/sammo/API/InheritAction/BuyHiddenBuff.php b/hwe/sammo/API/InheritAction/BuyHiddenBuff.php index 74468fb1..f3aa517f 100644 --- a/hwe/sammo/API/InheritAction/BuyHiddenBuff.php +++ b/hwe/sammo/API/InheritAction/BuyHiddenBuff.php @@ -65,15 +65,15 @@ class BuyHiddenBuff extends \sammo\BaseAPI $db = DB::db(); $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); - $previousPoint = $inheritStor->getValue('previous') ?? 0; + $previousPoint = ($inheritStor->getValue('previous') ?? [0,0])[0]; if ($previousPoint < $reqAmount) { return '충분한 유산 포인트를 가지고 있지 않습니다.'; } $inheritBuffList[$type] = $level; $general->setAuxVar('inheritBuff', $inheritBuffList); - $inheritStor->setValue('previous', $previousPoint - $reqAmount); - $general->flushUpdateValues(); + $inheritStor->setValue('previous', [$previousPoint - $reqAmount, [$type, $level]]); + $general->applyDB($db); return null; } } diff --git a/hwe/sammo/API/InheritAction/BuyRandomUnique.php b/hwe/sammo/API/InheritAction/BuyRandomUnique.php index dc94af23..4f707346 100644 --- a/hwe/sammo/API/InheritAction/BuyRandomUnique.php +++ b/hwe/sammo/API/InheritAction/BuyRandomUnique.php @@ -46,7 +46,7 @@ class BuyRandomUnique extends \sammo\BaseAPI $general->setAuxVar('inheritRandomUnique', TimeUtil::now()); $inheritStor->setValue('previous', $previousPoint - GameConst::$inheritItemRandomPoint); - $general->flushUpdateValues(); + $general->applyDB($db); return null; } } diff --git a/hwe/sammo/API/InheritAction/BuySpecificUnique.php b/hwe/sammo/API/InheritAction/BuySpecificUnique.php index a5f5b76d..a91d24bb 100644 --- a/hwe/sammo/API/InheritAction/BuySpecificUnique.php +++ b/hwe/sammo/API/InheritAction/BuySpecificUnique.php @@ -74,7 +74,7 @@ class BuySpecificUnique extends \sammo\BaseAPI $general->setAuxVar('inheritUniqueTrial', $itemTrials); $inheritStor->setValue('previous', $previousPoint - $amount); $trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]); - $general->flushUpdateValues(); + $general->applyDB($db); return null; } } diff --git a/hwe/sammo/API/InheritAction/ResetSpecialWar.php b/hwe/sammo/API/InheritAction/ResetSpecialWar.php index 3b2a8869..d2f2ef18 100644 --- a/hwe/sammo/API/InheritAction/ResetSpecialWar.php +++ b/hwe/sammo/API/InheritAction/ResetSpecialWar.php @@ -63,7 +63,7 @@ class ResetSpecialWar extends \sammo\BaseAPI $general->setAuxVar('inheritResetSpecialWar', $nextLevel); $general->setVar('special2', 'None'); $inheritStor->setValue('previous', $previousPoint - $reqPoint); - $general->flushUpdateValues(); + $general->applyDB($db); return null; } } diff --git a/hwe/sammo/API/InheritAction/ResetTurnTime.php b/hwe/sammo/API/InheritAction/ResetTurnTime.php index 2b1226b3..6c813b0d 100644 --- a/hwe/sammo/API/InheritAction/ResetTurnTime.php +++ b/hwe/sammo/API/InheritAction/ResetTurnTime.php @@ -67,7 +67,7 @@ class ResetTurnTime extends \sammo\BaseAPI $general->setVar('turntime', TimeUtil::format($turnTime, true)); $general->setAuxVar('inheritResetTurnTime', $nextLevel); $inheritStor->setValue('previous', $previousPoint - $reqPoint); - $general->flushUpdateValues(); + $general->applyDB($db); return null; } } diff --git a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php index 8f837353..9bd458de 100644 --- a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php +++ b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php @@ -69,7 +69,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI $general->setAuxVar('inheritSpecificSpecialWar', $type); $inheritStor->setValue('previous', $previousPoint - $reqAmount); - $general->flushUpdateValues(); + $general->applyDB($db); return null; } } diff --git a/hwe/ts/inheritPoint.vue b/hwe/ts/inheritPoint.vue index 093bd39b..ea5ff200 100644 --- a/hwe/ts/inheritPoint.vue +++ b/hwe/ts/inheritPoint.vue @@ -3,7 +3,7 @@
+
+
+
유산 포인트 상점
+
+
+
+
+ +
+ +
+
+
+ {{ info.info }}
필요 포인트: + {{ + inheritBuffCost[inheritBuff[buffKey]] - + inheritBuffCost[prevInheritBuff[buffKey] ?? 0] + }}
+
+
+ 리셋구입 +
+
+
+
+
@@ -45,6 +97,8 @@ import "../scss/game_bg.scss"; import TopBackBar from "./components/TopBackBar.vue"; import { sum } from "lodash"; import _ from "lodash"; +import { InvalidResponse } from "./defs"; +import axios from "axios"; type InheritanceType = | "previous" @@ -121,9 +175,73 @@ const inheritanceViewText: Record< }, }; +type inheritBuffType = + | "warAvoidRatio" + | "warCriticalRatio" + | "warMagicTrialProb" + | "domesticSuccessProb" + | "domesticFailProb" + | "warAvoidRatioOppose" + | "warCriticalRatioOppose" + | "warMagicTrialProbOppose"; + +declare const currentInheritBuff: { + [v in inheritBuffType]: number | undefined; +}; + +const inheritBuffHelpText: Record< + inheritBuffType, + { + title: string; + info: string; + } +> = { + warAvoidRatio: { + title: "회피 확률 증가", + info: "전투 시 회피 확률이 1%p ~ 5%p 증가합니다.", + }, + warCriticalRatio: { + title: "필살 확률 증가", + info: "전투 시 필살 확률이 1%p ~ 5%p 증가합니다.", + }, + warMagicTrialProb: { + title: "계략 시도 확률 증가", + info: "전투 시 계략을 시도할 확률이 1%p ~ 5%p 증가합니다. 무장도 계략을 시도합니다.", + }, + warAvoidRatioOppose: { + title: "상대 회피 확률 감소", + info: "전투 시 상대의 회피 확률이 1%p ~ 5%p 감소합니다.", + }, + warCriticalRatioOppose: { + title: "상대 필살 확률 감소", + info: "전투 시 상대의 필살 확률이 1%p ~ 5%p 감소합니다.", + }, + warMagicTrialProbOppose: { + title: "상대 계략 시도 확률 감소", + info: "전투 시 상대의 계략 시도 확률이 1%p ~ 5%p 감소합니다.", + }, + domesticSuccessProb: { + title: "내정 성공 확률 증가", + info: "민심, 인구, 농업, 상업, 치안, 수비, 성벽, 기술 내정의 성공 확률이 1%p ~ 5%p 증가합니다.", + }, + domesticFailProb: { + title: "내정 실패 확률 감소", + info: "민심, 인구, 농업, 상업, 치안, 수비, 성벽, 기술 내정의 실패 확률이 1%p ~ 5%p 감소합니다.", + }, +}; + +declare const maxInheritBuff: number; +declare const inheritBuffCost: number[]; + export default defineComponent({ name: "InheritPoint", data() { + const inheritBuff = {} as Record; + for (const buffKey of Object.keys( + inheritBuffHelpText + ) as inheritBuffType[]) { + inheritBuff[buffKey] = currentInheritBuff[buffKey] ?? 0; + } return { title: "유산 관리", inheritanceViewText, @@ -138,8 +256,70 @@ export default defineComponent({ }; return result; })(), + inheritBuffHelpText, + inheritBuff, + prevInheritBuff: currentInheritBuff, + maxInheritBuff, + inheritBuffCost, }; }, + methods: { + async buyInheritBuff(buffKey: inheritBuffType) { + const level = this.inheritBuff[buffKey]; + const prevLevel = this.prevInheritBuff[buffKey] ?? 0; + if (level == prevLevel) { + return; + } + if (level < prevLevel) { + alert("낮출 수 없습니다."); + return; + } + const cost = + this.inheritBuffCost[level] - this.inheritBuffCost[prevLevel]; + if (this.items.previous < cost) { + alert("유산 포인트가 부족합니다."); + return; + } + + const name = inheritBuffHelpText[buffKey].title; + + if ( + !confirm( + `${name}를 ${level}등급으로 올릴까요? ${cost} 포인트가 소모됩니다.` + ) + ) { + return; + } + + let result: InvalidResponse; + try { + const response = await axios({ + url: "api.php", + method: "post", + responseType: "json", + data: { + path: 'InheritAction/BuyHiddenBuff', + args: { + type: buffKey, + level, + } + }, + }); + result = response.data; + if (!result.result) { + throw result.reason; + } + } catch (e) { + console.error(e); + alert(`실패했습니다: ${e}`); + return; + } + + alert('성공했습니다.'); + //TODO: 페이지 새로고침 필요없이 하도록 + location.reload(); + }, + }, components: { TopBackBar, }, diff --git a/hwe/v_inheritPoint.php b/hwe/v_inheritPoint.php index e2b6800f..27a6da92 100644 --- a/hwe/v_inheritPoint.php +++ b/hwe/v_inheritPoint.php @@ -19,6 +19,14 @@ $items = []; foreach (array_keys(General::INHERITANCE_KEY) as $key) { $items[$key] = $me->getInheritancePoint($key) ?? 0; } + +$currentInheritBuff = []; +foreach ($me->getAuxVar('inheritBuff') as $buff=>$buffLevel){ + if(!key_exists($buff,TriggerInheritBuff::BUFF_KEY_TEXT)){ + continue; + } + $currentInheritBuff[$buff] = $buffLevel; +} ?> @@ -35,7 +43,10 @@ foreach (array_keys(General::INHERITANCE_KEY) as $key) { $items + 'items' => $items, + 'currentInheritBuff' => $currentInheritBuff, + 'maxInheritBuff' => TriggerInheritBuff::MAX_STEP, + 'inheritBuffCost' => GameConst::$inheritBuffPoints, ]) ?> diff --git a/src/sammo/APIHelper.php b/src/sammo/APIHelper.php index c1cb0435..e06d5665 100644 --- a/src/sammo/APIHelper.php +++ b/src/sammo/APIHelper.php @@ -11,6 +11,7 @@ class APIHelper public static function launch(string $rootPath) { + //TODO: path를 php://input에서 받는게 아니라 api.php?~~~~~ 로 받아오는것이 etag 캐시 측면에서 훨씬 나을 듯! try { $rawInput = file_get_contents('php://input'); $input = Json::decode($rawInput); -- 2.54.0 From 4159f9f830e27252960e9f2d5c907bf549c80d86 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 16 Sep 2021 00:31:28 +0900 Subject: [PATCH 25/32] =?UTF-8?q?InheritAction:=20UI=20=ED=84=B4=20?= =?UTF-8?q?=EC=B4=88=EA=B8=B0=ED=99=94,=20=EC=A0=84=ED=88=AC=20=ED=8A=B9?= =?UTF-8?q?=EA=B8=B0=20=EC=B4=88=EA=B8=B0=ED=99=94,=20=EB=9E=9C=EB=8D=A4?= =?UTF-8?q?=20=EC=9C=A0=EB=8B=88=ED=81=AC=20-=20=ED=84=B4=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=EC=97=90=20=EB=B2=84=EA=B7=B8=EA=B0=80=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=EB=93=AF=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/InheritAction/BuyRandomUnique.php | 2 +- .../API/InheritAction/BuySpecificUnique.php | 2 +- .../API/InheritAction/ResetSpecialWar.php | 4 +- hwe/sammo/API/InheritAction/ResetTurnTime.php | 6 +- .../API/InheritAction/SetNextSpecialWar.php | 6 +- hwe/ts/inheritPoint.vue | 154 ++++++++++++++++-- hwe/v_inheritPoint.php | 26 ++- 7 files changed, 174 insertions(+), 26 deletions(-) diff --git a/hwe/sammo/API/InheritAction/BuyRandomUnique.php b/hwe/sammo/API/InheritAction/BuyRandomUnique.php index 4f707346..6aaf56b4 100644 --- a/hwe/sammo/API/InheritAction/BuyRandomUnique.php +++ b/hwe/sammo/API/InheritAction/BuyRandomUnique.php @@ -45,7 +45,7 @@ class BuyRandomUnique extends \sammo\BaseAPI } $general->setAuxVar('inheritRandomUnique', TimeUtil::now()); - $inheritStor->setValue('previous', $previousPoint - GameConst::$inheritItemRandomPoint); + $inheritStor->setValue('previous', [$previousPoint - GameConst::$inheritItemRandomPoint, 'BuyRandomUnique']); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/BuySpecificUnique.php b/hwe/sammo/API/InheritAction/BuySpecificUnique.php index a91d24bb..ee355f5f 100644 --- a/hwe/sammo/API/InheritAction/BuySpecificUnique.php +++ b/hwe/sammo/API/InheritAction/BuySpecificUnique.php @@ -72,7 +72,7 @@ class BuySpecificUnique extends \sammo\BaseAPI $itemTrials[$itemKey] = $amount; $general->setAuxVar('inheritUniqueTrial', $itemTrials); - $inheritStor->setValue('previous', $previousPoint - $amount); + $inheritStor->setValue('previous', [$previousPoint - $amount, ['BuySpecificUnique', $itemKey, $amount]]); $trialStor->setValue("u{$userID}", [$userID, $generalID, $amount]); $general->applyDB($db); return null; diff --git a/hwe/sammo/API/InheritAction/ResetSpecialWar.php b/hwe/sammo/API/InheritAction/ResetSpecialWar.php index d2f2ef18..a22e6395 100644 --- a/hwe/sammo/API/InheritAction/ResetSpecialWar.php +++ b/hwe/sammo/API/InheritAction/ResetSpecialWar.php @@ -50,7 +50,7 @@ class ResetSpecialWar extends \sammo\BaseAPI $db = DB::db(); $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); - $previousPoint = $inheritStor->getValue('previous') ?? 0; + $previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0]; if ($previousPoint < $reqPoint) { return '충분한 유산 포인트를 가지고 있지 않습니다.'; } @@ -62,7 +62,7 @@ class ResetSpecialWar extends \sammo\BaseAPI $general->setAuxVar('inheritResetSpecialWar', $nextLevel); $general->setVar('special2', 'None'); - $inheritStor->setValue('previous', $previousPoint - $reqPoint); + $inheritStor->setValue('previous', [$previousPoint - $reqPoint, 'ResetSpecialWar']); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/ResetTurnTime.php b/hwe/sammo/API/InheritAction/ResetTurnTime.php index 6c813b0d..b4120874 100644 --- a/hwe/sammo/API/InheritAction/ResetTurnTime.php +++ b/hwe/sammo/API/InheritAction/ResetTurnTime.php @@ -46,7 +46,7 @@ class ResetTurnTime extends \sammo\BaseAPI $db = DB::db(); $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); - $previousPoint = $inheritStor->getValue('previous') ?? 0; + $previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0]; if ($previousPoint < $reqPoint) { return '충분한 유산 포인트를 가지고 있지 않습니다.'; } @@ -60,13 +60,13 @@ class ResetTurnTime extends \sammo\BaseAPI $afterTurn = Util::randRange($turnTerm * -60 / 2, $turnTerm * 60 / 2); $turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($afterTurn)); - if($turnTime <= $serverTurnTimeObj){ + if ($turnTime <= $serverTurnTimeObj) { $turnTime = $turnTime->add(TimeUtil::secondsToDateInterval($turnTerm * 60)); } $general->setVar('turntime', TimeUtil::format($turnTime, true)); $general->setAuxVar('inheritResetTurnTime', $nextLevel); - $inheritStor->setValue('previous', $previousPoint - $reqPoint); + $inheritStor->setValue('previous', [$previousPoint - $reqPoint, 'ResetTurnTime']); $general->applyDB($db); return null; } diff --git a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php index 9bd458de..195e50d8 100644 --- a/hwe/sammo/API/InheritAction/SetNextSpecialWar.php +++ b/hwe/sammo/API/InheritAction/SetNextSpecialWar.php @@ -54,7 +54,7 @@ class SetNextSpecialWar extends \sammo\BaseAPI return '이미 그 특기를 예약하였습니다.'; } - if($inheritSpecificSpecialWar !== null){ + if ($inheritSpecificSpecialWar !== null) { return '이미 예약한 특기가 있습니다.'; } @@ -62,13 +62,13 @@ class SetNextSpecialWar extends \sammo\BaseAPI $db = DB::db(); $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); - $previousPoint = $inheritStor->getValue('previous') ?? 0; + $previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0]; if ($previousPoint < $reqAmount) { return '충분한 유산 포인트를 가지고 있지 않습니다.'; } $general->setAuxVar('inheritSpecificSpecialWar', $type); - $inheritStor->setValue('previous', $previousPoint - $reqAmount); + $inheritStor->setValue('previous', [$previousPoint - $reqAmount, ['SetNextSpecialWar', $type]]); $general->applyDB($db); return null; } diff --git a/hwe/ts/inheritPoint.vue b/hwe/ts/inheritPoint.vue index ea5ff200..7edba2bd 100644 --- a/hwe/ts/inheritPoint.vue +++ b/hwe/ts/inheritPoint.vue @@ -62,14 +62,16 @@
{{ info.info }}
필요 포인트: - {{ - inheritBuffCost[inheritBuff[buffKey]] - - inheritBuffCost[prevInheritBuff[buffKey] ?? 0] - }}
{{ info.info }}
필요 포인트: + {{ + inheritActionCost.buff[inheritBuff[buffKey]] - + inheritActionCost.buff[prevInheritBuff[buffKey] ?? 0] + }}
-
+
-
+
+
+
+
랜덤 턴 초기화
+ 구입 +
+
+ 다음 턴이 랜덤으로 바뀝니다.
필요 포인트: {{ inheritActionCost.resetTurnTime }}
+
+
+
+
+
랜덤 유니크 획득
+ 구입 +
+
+ 다음 턴에 랜덤 유니크를 얻습니다.
필요 포인트: {{ inheritActionCost.randomUnique }}
+
+
+
+
+
+ 즉시 전투 특기 초기화 +
+ 구입 +
+
+ 즉시 전투 특기를 초기화합니다.
필요 포인트: {{ inheritActionCost.resetSpecialWar }}
+
+
+
+ + + + +
@@ -231,7 +295,15 @@ const inheritBuffHelpText: Record< }; declare const maxInheritBuff: number; -declare const inheritBuffCost: number[]; +declare const inheritActionCost: { + buff: number[]; + resetTurnTime: number; + resetSpecialWar: number; + randomUnique: number; +}; + +declare const resetTurnTimeLevel: number; +declare const resetSpecialWarLevel: number; export default defineComponent({ name: "InheritPoint", @@ -260,7 +332,9 @@ export default defineComponent({ inheritBuff, prevInheritBuff: currentInheritBuff, maxInheritBuff, - inheritBuffCost, + inheritActionCost, + resetTurnTimeLevel, + resetSpecialWarLevel, }; }, methods: { @@ -275,7 +349,8 @@ export default defineComponent({ return; } const cost = - this.inheritBuffCost[level] - this.inheritBuffCost[prevLevel]; + this.inheritActionCost.buff[level] - + this.inheritActionCost.buff[prevLevel]; if (this.items.previous < cost) { alert("유산 포인트가 부족합니다."); return; @@ -298,11 +373,11 @@ export default defineComponent({ method: "post", responseType: "json", data: { - path: 'InheritAction/BuyHiddenBuff', + path: "InheritAction/BuyHiddenBuff", args: { type: buffKey, level, - } + }, }, }); result = response.data; @@ -315,7 +390,60 @@ export default defineComponent({ return; } - alert('성공했습니다.'); + alert("성공했습니다."); + //TODO: 페이지 새로고침 필요없이 하도록 + location.reload(); + }, + async buySimple( + type: "ResetTurnTime" | "BuyRandomUnique" | "ResetSpecialWar" + ) { + const costMap: Record = { + ResetTurnTime: inheritActionCost.resetTurnTime, + ResetSpecialWar: inheritActionCost.resetSpecialWar, + BuyRandomUnique: inheritActionCost.randomUnique, + }; + + const cost = costMap[type]; + if (cost === undefined) { + alert(`올바르지 않은 타입:${type}`); + return; + } + + const messageMap: Record = { + ResetTurnTime: `${cost} 포인트로 턴을 초기화 하시겠습니까?`, + ResetSpecialWar: `${cost} 포인트로 전투 특기를 초기화 하시겠습니까?`, + BuyRandomUnique: `${cost} 포인트로 랜덤 유니크를 구입하시겠습니까?`, + }; + if (this.items.previous < cost) { + alert("유산 포인트가 부족합니다."); + return; + } + if (!confirm(messageMap[type])) { + return; + } + + let result: InvalidResponse; + try { + const response = await axios({ + url: "api.php", + method: "post", + responseType: "json", + data: { + path: `InheritAction/${type}`, + args: {}, + }, + }); + result = response.data; + if (!result.result) { + throw result.reason; + } + } catch (e) { + console.error(e); + alert(`실패했습니다: ${e}`); + return; + } + + alert("성공했습니다."); //TODO: 페이지 새로고침 필요없이 하도록 location.reload(); }, diff --git a/hwe/v_inheritPoint.php b/hwe/v_inheritPoint.php index 27a6da92..0b244dfc 100644 --- a/hwe/v_inheritPoint.php +++ b/hwe/v_inheritPoint.php @@ -21,12 +21,25 @@ foreach (array_keys(General::INHERITANCE_KEY) as $key) { } $currentInheritBuff = []; -foreach ($me->getAuxVar('inheritBuff') as $buff=>$buffLevel){ - if(!key_exists($buff,TriggerInheritBuff::BUFF_KEY_TEXT)){ +foreach ($me->getAuxVar('inheritBuff') as $buff => $buffLevel) { + if (!key_exists($buff, TriggerInheritBuff::BUFF_KEY_TEXT)) { continue; } $currentInheritBuff[$buff] = $buffLevel; } + +function calcResetAttrPoint($level) +{ + while (count(GameConst::$inheritResetAttrPointBase) <= $level) { + $baseLen = count(GameConst::$inheritResetAttrPointBase); + GameConst::$inheritResetAttrPointBase[] = GameConst::$inheritResetAttrPointBase[$baseLen - 1] + GameConst::$inheritResetAttrPointBase[$baseLen - 2]; + } + return GameConst::$inheritResetAttrPointBase[$level]; +} + + +$resetTurnTimeLevel = $me->getAuxVar('inheritResetTurnTime')??0; +$resetSpecialWarLevel = $me->getAuxVar('inheritResetSpecialWar')??0; ?> @@ -46,7 +59,14 @@ foreach ($me->getAuxVar('inheritBuff') as $buff=>$buffLevel){ 'items' => $items, 'currentInheritBuff' => $currentInheritBuff, 'maxInheritBuff' => TriggerInheritBuff::MAX_STEP, - 'inheritBuffCost' => GameConst::$inheritBuffPoints, + 'resetTurnTimeLevel' => $resetTurnTimeLevel, + 'resetSpecialWarLevel' => $resetSpecialWarLevel, + 'inheritActionCost' => [ + 'buff' => GameConst::$inheritBuffPoints, + 'resetTurnTime' => calcResetAttrPoint($resetTurnTimeLevel), + 'resetSpecialWar' => calcResetAttrPoint($resetSpecialWarLevel), + 'randomUnique' => GameConst::$inheritItemRandomPoint, + ], ]) ?> -- 2.54.0 From d09bf137aa15a7f3e1c29c24d626b3d222241123 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 16 Sep 2021 00:36:03 +0900 Subject: [PATCH 26/32] =?UTF-8?q?miisc:=20=EA=B0=84=EA=B2=A9=20=EC=A1=B0?= =?UTF-8?q?=EC=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/ts/inheritPoint.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hwe/ts/inheritPoint.vue b/hwe/ts/inheritPoint.vue index 7edba2bd..e345bf7b 100644 --- a/hwe/ts/inheritPoint.vue +++ b/hwe/ts/inheritPoint.vue @@ -86,9 +86,9 @@ -
-
-
+
+
+
랜덤 턴 초기화
-
-
+
+
랜덤 유니크 획득
-
-
+
+
즉시 전투 특기 초기화
-- 2.54.0 From 16ded97c7f11880f086e5e50926d9e3e30f03d46 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 16 Sep 2021 01:45:17 +0900 Subject: [PATCH 27/32] =?UTF-8?q?inheritAction:=20UI=201=EC=B0=A8=20?= =?UTF-8?q?=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/InheritAction/BuySpecificUnique.php | 16 +- hwe/scss/inheritPoint.scss | 23 -- hwe/ts/Board.vue | 1 - hwe/ts/inheritPoint.vue | 315 +++++++++++++++--- hwe/v_inheritPoint.php | 42 ++- 5 files changed, 308 insertions(+), 89 deletions(-) delete mode 100644 hwe/scss/inheritPoint.scss diff --git a/hwe/sammo/API/InheritAction/BuySpecificUnique.php b/hwe/sammo/API/InheritAction/BuySpecificUnique.php index ee355f5f..b2885d6f 100644 --- a/hwe/sammo/API/InheritAction/BuySpecificUnique.php +++ b/hwe/sammo/API/InheritAction/BuySpecificUnique.php @@ -14,9 +14,9 @@ class BuySpecificUnique extends \sammo\BaseAPI { public function validateArgs(): ?string { - foreach(GameConst::$allItems as $items){ - foreach($items as $itemKey=>$amount){ - if($amount == 0){ + foreach (GameConst::$allItems as $items) { + foreach ($items as $itemKey => $amount) { + if ($amount == 0) { continue; } $availableItems[$itemKey] = $amount; @@ -29,7 +29,7 @@ class BuySpecificUnique extends \sammo\BaseAPI 'amount', ]) ->rule('integer', 'amount') - ->rule('min', GameConst::$inheritItemUniqueMinPoint) + ->rule('min', 'amount', GameConst::$inheritItemUniqueMinPoint) ->rule('keyExists', 'item', $availableItems); if (!$v->validate()) { @@ -53,20 +53,20 @@ class BuySpecificUnique extends \sammo\BaseAPI $generalID = $session->generalID; $general = General::createGeneralObjFromDB($generalID); - if($userID != $general->getVar('owner')){ + if ($userID != $general->getVar('owner')) { return '로그인 상태가 이상합니다. 다시 로그인해 주세요.'; } $itemTrials = $general->getAuxVar('inheritUniqueTrial') ?? []; - if(key_exists($itemKey, $itemTrials)){ + if (key_exists($itemKey, $itemTrials)) { return '이미 입찰한 아이템입니다. 다음 턴에 시도해 주세요.'; } $db = DB::db(); $inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}"); $trialStor = KVStorage::getStorage($db, "ut_{$itemKey}"); - $previousPoint = $inheritStor->getValue('previous')??0; - if($previousPoint < $amount){ + $previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0]; + if ($previousPoint < $amount) { return '충분한 유산 포인트를 가지고 있지 않습니다.'; } diff --git a/hwe/scss/inheritPoint.scss b/hwe/scss/inheritPoint.scss deleted file mode 100644 index 25d69429..00000000 --- a/hwe/scss/inheritPoint.scss +++ /dev/null @@ -1,23 +0,0 @@ -#inheritance_list{ - display: flex; - flex-wrap: wrap; -} - -.inherit_padding{ - width: 33%; - padding: 10px 2px; -} - -.inherit_item{ - width: 33%; - padding: 10px 2px; -} - -.col-form-label{ - text-align:right; - padding-right:2ch; -} - -.inherit_value{ - text-align: right; -} \ No newline at end of file diff --git a/hwe/ts/Board.vue b/hwe/ts/Board.vue index 5f09c48b..b33ba3f5 100644 --- a/hwe/ts/Board.vue +++ b/hwe/ts/Board.vue @@ -61,7 +61,6 @@ \ No newline at end of file diff --git a/hwe/v_inheritPoint.php b/hwe/v_inheritPoint.php index 0b244dfc..433d4908 100644 --- a/hwe/v_inheritPoint.php +++ b/hwe/v_inheritPoint.php @@ -15,10 +15,6 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); $me = General::createGeneralObjFromDB($generalID); -$items = []; -foreach (array_keys(General::INHERITANCE_KEY) as $key) { - $items[$key] = $me->getInheritancePoint($key) ?? 0; -} $currentInheritBuff = []; foreach ($me->getAuxVar('inheritBuff') as $buff => $buffLevel) { @@ -37,9 +33,37 @@ function calcResetAttrPoint($level) return GameConst::$inheritResetAttrPointBase[$level]; } +$avilableSpecialWar = []; +foreach (GameConst::$availableSpecialWar as $specialWarKey) { + $specialWarObj = buildGeneralSpecialWarClass($specialWarKey); + $avilableSpecialWar[$specialWarKey] = [ + 'title' => $specialWarObj->getName(), + 'info' => $specialWarObj->getInfo(), + ]; +} -$resetTurnTimeLevel = $me->getAuxVar('inheritResetTurnTime')??0; -$resetSpecialWarLevel = $me->getAuxVar('inheritResetSpecialWar')??0; +$availableUnique = []; +foreach (GameConst::$allItems as $subItems){ + foreach($subItems as $itemKey=>$amount){ + if($amount == 0){ + continue; + } + $itemObj = buildItemClass($itemKey); + $availableUnique[$itemKey] = [ + 'title' => $itemObj->getName(), + 'info'=>$itemObj->getInfo(), + ]; + } +} + + +$items = []; +foreach (array_keys(General::INHERITANCE_KEY) as $key) { + $items[$key] = $me->getInheritancePoint($key) ?? 0; +} + +$resetTurnTimeLevel = $me->getAuxVar('inheritResetTurnTime') ?? 0; +$resetSpecialWarLevel = $me->getAuxVar('inheritResetSpecialWar') ?? 0; ?> @@ -48,7 +72,7 @@ $resetSpecialWarLevel = $me->getAuxVar('inheritResetSpecialWar')??0; <?= UniqueConst::$serverName ?>: 유산 관리 - + @@ -66,7 +90,11 @@ $resetSpecialWarLevel = $me->getAuxVar('inheritResetSpecialWar')??0; 'resetTurnTime' => calcResetAttrPoint($resetTurnTimeLevel), 'resetSpecialWar' => calcResetAttrPoint($resetSpecialWarLevel), 'randomUnique' => GameConst::$inheritItemRandomPoint, + 'nextSpecial' => GameConst::$inheritSpecificSpecialPoint, + 'minSpecificUnique'=>GameConst::$inheritItemUniqueMinPoint, ], + 'availableSpecialWar' => $avilableSpecialWar, + 'availableUnique' => $availableUnique, ]) ?> -- 2.54.0 From 8964998064e7c6ce853a8cdfd584298e191fb804 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 16 Sep 2021 01:58:58 +0900 Subject: [PATCH 28/32] misc: layout --- hwe/ts/components/BottomBar.vue | 2 +- hwe/ts/components/TopBackBar.vue | 2 +- hwe/ts/inheritPoint.vue | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hwe/ts/components/BottomBar.vue b/hwe/ts/components/BottomBar.vue index 72a6d348..1f7fd8f5 100644 --- a/hwe/ts/components/BottomBar.vue +++ b/hwe/ts/components/BottomBar.vue @@ -1,5 +1,5 @@