환약 사용 여부가 안보이는 버그 수정

This commit is contained in:
2020-06-06 13:45:31 +09:00
parent 522f5c8a86
commit cbe8b4012b
3 changed files with 154 additions and 154 deletions
+5 -5
View File
@@ -78,11 +78,11 @@ var availableDieImmediately = <?=$availableDieImmediately?'true':'false'?>;
∞<span style='color:orange'>개막직전 남는자리가 있을경우 랜덤하게 참여합니다.</span><br><br> ∞<span style='color:orange'>개막직전 남는자리가 있을경우 랜덤하게 참여합니다.</span><br><br>
환약 사용 【<select id='use_treatment' name='use_treatment'> 환약 사용 【<select id='use_treatment' name='use_treatment'>
<option value=10 <?=$use_treatment==10?"selected":""; ?>>경상</option> <option value=10 <?=($use_treatment==10)?"selected":""; ?>>경상</option>
<option value=20 <?=$use_treatment==21?"selected":""; ?>>중상</option> <option value=21 <?=($use_treatment==21)?"selected":""; ?>>중상</option>
<option value=40 <?=$use_treatment==41?"selected":""; ?>>심각</option> <option value=41 <?=($use_treatment==41)?"selected":""; ?>>심각</option>
<option value=60 <?=$use_treatment==61?"selected":""; ?>>위독</option> <option value=61 <?=($use_treatment==61)?"selected":""; ?>>위독</option>
<option value=100 <?=$use_treatment==100?"selected":""; ?>>사용안함</option> <option value=100 <?=($use_treatment==100)?"selected":""; ?>>사용안함</option>
</select>】<br> </select>】<br>
∞<span style='color:orange'>부상을 입었을 때 환약을 사용하는 기준입니다.</span><br><br> ∞<span style='color:orange'>부상을 입었을 때 환약을 사용하는 기준입니다.</span><br><br>
<?php if(($gameStor->autorun_user['options']['chief'])??false) : ?> <?php if(($gameStor->autorun_user['options']['chief'])??false) : ?>
+2 -2
View File
@@ -52,12 +52,12 @@ if($defence_train != $me->getVar('defence_train')){
} }
} }
$me->setAuxVar('use_treatment', Util::valueFit($use_treatment, 10, 100));
if($use_auto_nation_turn != $me->getAuxVar('use_auto_nation_turn')){ if($use_auto_nation_turn != $me->getAuxVar('use_auto_nation_turn')){
$me->setAuxVar('use_auto_nation_turn', $use_auto_nation_turn); $me->setAuxVar('use_auto_nation_turn', $use_auto_nation_turn);
} }
$me->setAuxVar('use_treatment', Util::valueFit($use_treatment, 10, 100));
if($me->getVar('tnmt') != $tnmt){ if($me->getVar('tnmt') != $tnmt){
$me->setVar('tnmt', $tnmt); $me->setVar('tnmt', $tnmt);
} }
+147 -147
View File
@@ -1,148 +1,148 @@
<?php <?php
namespace sammo; namespace sammo;
trait LazyVarUpdater{ trait LazyVarUpdater{
protected $raw = []; protected $raw = [];
protected $updatedVar = []; protected $updatedVar = [];
protected $auxVar = null; protected $auxVar = null;
protected $auxUpdated = false; protected $auxUpdated = false;
function getRaw(bool $extractAux=false):array{ function getRaw(bool $extractAux=false):array{
if($extractAux){ if($extractAux){
$this->getAuxVar(''); $this->getAuxVar('');
} }
return $this->raw; return $this->raw;
} }
function getVar(string $key){ function getVar(string $key){
return $this->raw[$key]; return $this->raw[$key];
} }
function getVars(string ...$keys){ function getVars(string ...$keys){
return array_map([$this, 'getVar'], $keys); return array_map([$this, 'getVar'], $keys);
} }
function touchVar(string $key):bool{ function touchVar(string $key):bool{
if(key_exists($key, $this->raw)){ if(key_exists($key, $this->raw)){
return false; return false;
} }
$this->raw[$key] = null; $this->raw[$key] = null;
return true; return true;
} }
function unpackAux(){ function unpackAux(){
if(($this->raw['auxVar']??null) === null){ if(!key_exists('auxVar', $this->raw)){
if(!key_exists('aux', $this->raw)){ if(!key_exists('aux', $this->raw)){
throw new \RuntimeException('aux is not set'); throw new \RuntimeException('aux is not set');
} }
$this->raw['auxVar'] = Json::decode($this->raw['aux']??'{}'); $this->raw['auxVar'] = Json::decode($this->raw['aux']??'{}');
} }
} }
function setVar(string $key, $value){ function setVar(string $key, $value){
return $this->updateVar($key, $value); return $this->updateVar($key, $value);
} }
function getAuxVar(string $key){ function getAuxVar(string $key){
$this->unpackAux(); $this->unpackAux();
return $this->raw['auxVar'][$key]??null; return $this->raw['auxVar'][$key]??null;
} }
function setAuxVar(string $key, $var){ function setAuxVar(string $key, $var){
$oldVar = $this->getAuxVar($key); $oldVar = $this->getAuxVar($key);
if($oldVar === $var){ if($oldVar === $var){
return; return;
} }
if($var === null){ if($var === null){
unset($this->auxVar[$key]); unset($this->auxVar[$key]);
$this->auxUpdated = true; $this->auxUpdated = true;
return; return;
} }
$this->raw['auxVar'][$key] = $var; $this->raw['auxVar'][$key] = $var;
$this->auxUpdated = true; $this->auxUpdated = true;
} }
function updateVar(string $key, $value){ function updateVar(string $key, $value){
if(($this->raw[$key]??null) === $value){ if(($this->raw[$key]??null) === $value){
return; return;
} }
if(!key_exists($key, $this->updatedVar)){ if(!key_exists($key, $this->updatedVar)){
$this->updatedVar[$key] = true; $this->updatedVar[$key] = true;
} }
$this->raw[$key] = $value; $this->raw[$key] = $value;
} }
function updateVarWithLimit(string $key, $value, $min = null, $max = null){ function updateVarWithLimit(string $key, $value, $min = null, $max = null){
if($min !== null && $value < $min){ if($min !== null && $value < $min){
$value = $min; $value = $min;
} }
if($max !== null && $value > $max){ if($max !== null && $value > $max){
$value = $max; $value = $max;
} }
$this->updateVar($key, $value); $this->updateVar($key, $value);
} }
function increaseVar(string $key, $value) function increaseVar(string $key, $value)
{ {
if($value === 0){ if($value === 0){
return; return;
} }
$targetValue = $this->raw[$key] + $value; $targetValue = $this->raw[$key] + $value;
$this->updateVar($key, $targetValue); $this->updateVar($key, $targetValue);
} }
function increaseVarWithLimit(string $key, $value, $min = null, $max = null){ function increaseVarWithLimit(string $key, $value, $min = null, $max = null){
$targetValue = $this->raw[$key] + $value; $targetValue = $this->raw[$key] + $value;
if($min !== null && $targetValue < $min){ if($min !== null && $targetValue < $min){
$targetValue = $min; $targetValue = $min;
} }
if($max !== null && $targetValue > $max){ if($max !== null && $targetValue > $max){
$targetValue = $max; $targetValue = $max;
} }
$this->updateVar($key, $targetValue); $this->updateVar($key, $targetValue);
} }
function multiplyVar(string $key, $value) function multiplyVar(string $key, $value)
{ {
if($value === 1){ if($value === 1){
return; return;
} }
$targetValue = $this->raw[$key] * $value; $targetValue = $this->raw[$key] * $value;
$this->updateVar($key, $targetValue); $this->updateVar($key, $targetValue);
} }
function multiplyVarWithLimit(string $key, $value, $min = null, $max = null){ function multiplyVarWithLimit(string $key, $value, $min = null, $max = null){
$targetValue = $this->raw[$key] * $value; $targetValue = $this->raw[$key] * $value;
if($min !== null && $targetValue < $min){ if($min !== null && $targetValue < $min){
$targetValue = $min; $targetValue = $min;
} }
if($max !== null && $targetValue > $max){ if($max !== null && $targetValue > $max){
$targetValue = $max; $targetValue = $max;
} }
$this->updateVar($key, $targetValue); $this->updateVar($key, $targetValue);
} }
function getUpdatedValues():array { function getUpdatedValues():array {
if($this->auxUpdated){ if($this->auxUpdated){
$this->setVar('aux', Json::encode($this->raw['auxVar'])); $this->setVar('aux', Json::encode($this->raw['auxVar']));
$this->auxUpdated = false; $this->auxUpdated = false;
} }
$updateVals = []; $updateVals = [];
foreach(array_keys($this->updatedVar) as $key){ foreach(array_keys($this->updatedVar) as $key){
$updateVals[$key] = $this->raw[$key]; $updateVals[$key] = $this->raw[$key];
} }
return $updateVals; return $updateVals;
} }
function flushUpdateValues():void { function flushUpdateValues():void {
$this->updatedVar = []; $this->updatedVar = [];
if(key_exists('auxVar', $this->raw)){ if(key_exists('auxVar', $this->raw)){
$this->auxUpdated = false; $this->auxUpdated = false;
unset($this->raw['auxVar']); unset($this->raw['auxVar']);
} }
} }
} }