diff --git a/hwe/func_process.php b/hwe/func_process.php index ae69ee44..3979e638 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -551,69 +551,6 @@ function process_16(&$general) { pushGenLog($general, $log); } -function process_21(&$general) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); - - $log = []; - $alllog = []; - $history = []; - $date = substr($general['turntime'],11,5); - - - $db = DB::db(); - $admin = $gameStor->getValues(['year', 'month', 'develcost']); - $city = CityConst::byID($general['city']); - $command = DecodeCommand($general['turn0']); - $destination = $command[1]; - $destCity = CityConst::byID($destination); - - - $josaRo = JosaUtil::pick($destCity->name, '로'); - if(!key_exists($destCity->id, $city->path)) { - $log[] = "●{$admin['month']}월:인접도시가 아닙니다. {$destCity->name}{$josaRo} 이동 실패. <1>$date"; - } elseif($general['gold'] < $admin['develcost']) { - $log[] = "●{$admin['month']}월:자금이 부족합니다. {$destCity->name}{$josaRo} 이동 실패. <1>$date"; - } else { - $log[] = "●{$admin['month']}월:{$destCity->name}{$josaRo} 이동했습니다. <1>$date"; - $exp = 50; - - // 성격 보정 - $exp = CharExperience($exp, $general['personal']); - - // 이동, 경험치 상승, 명성 상승, 사기 감소 - $general['leader2']++; - $db->update('general',[ - 'resturn'=>'SUCCESS', - 'gold'=>$db->sqleval('gold - %i',$admin['develcost']), - 'city'=>$destCity->id, - 'atmos'=>$db->sqleval('atmos*0.95'), - 'leader2'=>$general['leader2'], - 'experience'=>$db->sqleval('experience + %i',$exp) - ], 'no = %i', $general['no']); - - if($general['level'] == 12) { - $nation = getNationStaticInfo($general['nation']); - - if($nation['level'] == 0) { - - $db->update('general', [ - 'city'=>$destCity->id - ], 'nation = %i', $general['nation']); - - $genlog = ["●방랑군 세력이 {$destCity->name}{$josaRo} 이동했습니다."]; - foreach($db->query('SELECT `no` FROM general WHERE nation=%i and `level`<12', $general['nation']) as $follower){ - pushGenLog($follower, $genlog); - } - } - } - - $log = checkAbility($general, $log); - } - pushGenLog($general, $log); -} - function process_26(&$general) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); @@ -746,74 +683,6 @@ function process_28(&$general) { //pushGenLog($you, $youlog); } -function process_30(&$general) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); - - $log = []; - $alllog = []; - $history = []; - $date = substr($general['turntime'],11,5); - - $admin = $gameStor->getValues(['year', 'month', 'develcost']); - - $query = "select path from city where city='{$general['city']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $city = MYDB_fetch_array($result); - - $dist = searchDistance($general['city'], 3, false); - $command = DecodeCommand($general['turn0']); - $destination = $command[1]; - - $query = "select name from city where city='$destination'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $destcity = MYDB_fetch_array($result); - - $cost = $admin['develcost'] * 5; - - $josaRo = JosaUtil::pick($destcity['name'], '로'); - if($destination == $general['city']){ - $log[] = "●{$admin['month']}월:같은 도시입니다. {$destcity['name']}{$josaRo} 강행 실패. <1>$date"; - } elseif(!key_exists($destination, $dist)) { - $log[] = "●{$admin['month']}월:거리가 멉니다. {$destcity['name']}{$josaRo} 강행 실패. <1>$date"; - } elseif($general['gold'] < $cost) { - $log[] = "●{$admin['month']}월:자금이 부족합니다. {$destcity['name']}{$josaRo} 강행 실패. <1>$date"; - } else { - $log[] = "●{$admin['month']}월:{$destcity['name']}{$josaRo} 강행했습니다. <1>$date"; - $exp = 100; - - // 성격 보정 - $exp = CharExperience($exp, $general['personal']); - - // 이동, 경험치 상승, 명성 상승, 병력/사기/훈련 감소 - $general['leader2']++; - $query = "update general set resturn='SUCCESS',gold=gold-'$cost',city='$destination',crew=crew*0.95,atmos=atmos*0.9,train=train*0.95,leader2='{$general['leader2']}',experience=experience+'$exp' where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - - if($general['level'] == 12) { - $nation = getNationStaticInfo($general['nation']); - - if($nation['level'] == 0) { - $query = "update general set city='$destination' where nation='{$general['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - - $query = "select no,name from general where nation='{$general['nation']}' and level<'12'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $gencount = MYDB_num_rows($result); - $genlog = ["●방랑군 세력이 {$destcity['name']}{$josaRo} 강행했습니다."]; - for($j=0; $j < $gencount; $j++) { - $gen = MYDB_fetch_array($result); - pushGenLog($gen, $genlog); - } - } - } - - $log = checkAbility($general, $log); - } - pushGenLog($general, $log); -} - function process_31(&$general) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); @@ -957,67 +826,6 @@ function process_31(&$general) { pushGenLog($general, $log); } -function process_41(&$general) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); - - $log = []; - $alllog = []; - $history = []; - $date = substr($general['turntime'],11,5); - - $admin = $gameStor->getValues(['year', 'month', 'develcost']); - - $ratio = rand() % 100; - $exp = $general['crew'] / 400; - $crewexp = $general['crew'] * $general['train'] * $general['atmos'] / 20 / 10000; - // 랜덤치 - $exp = Util::round($exp * (80 + rand() % 41)/100); // 80 ~ 120% - $crewexp = Util::round($crewexp * (80 + rand() % 41)/100); // 80 ~ 120% - - // 성격 보정 - $exp = CharExperience($exp, $general['personal']); - $ratio = CharCritical($ratio, $general['personal']); - - if($general['nation'] == 0) { - $log[] = "●{$admin['month']}월:재야입니다. 단련 실패. <1>$date"; - } elseif($general['gold'] < $admin['develcost']) { - $log[] = "●{$admin['month']}월:자금이 모자랍니다. 단련 실패. <1>$date"; - } elseif($general['rice'] < $admin['develcost']) { - $log[] = "●{$admin['month']}월:군량이 모자랍니다. 단련 실패. <1>$date"; - } elseif($general['train'] < 40) { - $log[] = "●{$admin['month']}월:훈련이 너무 낮습니다. 단련 실패. <1>$date"; - } elseif($general['atmos'] < 40) { - $log[] = "●{$admin['month']}월:사기가 너무 낮습니다. 단련 실패. <1>$date"; - } elseif($crewexp == 0) { - $log[] = "●{$admin['month']}월:병사가 모자랍니다. 단련 실패. <1>$date"; - } else { - $crewstr = GameUnitConst::allType()[GameUnitConst::byID($general['crewtype'])->armType]; - - if($ratio < 33) { - // 숙련도 증가 - addGenDex($general['no'], GameConst::$maxAtmosByCommand, GameConst::$maxTrainByCommand, $general['crewtype'], $crewexp); - $log[] = "●{$admin['month']}월:$crewstr 숙련도 향상이 지지부진했습니다. <1>$date"; - } elseif($ratio < 66) { - $exp = $exp * 2; - // 숙련도 증가 - addGenDex($general['no'], GameConst::$maxAtmosByCommand, GameConst::$maxTrainByCommand, $general['crewtype'], $crewexp * 2); - $log[] = "●{$admin['month']}월:$crewstr 숙련도가 향상되었습니다. <1>$date"; - } else { - $exp = $exp * 3; - // 숙련도 증가 - addGenDex($general['no'], GameConst::$maxAtmosByCommand, GameConst::$maxTrainByCommand, $general['crewtype'], $crewexp * 3); - $log[] = "●{$admin['month']}월:$crewstr 숙련도가 일취월장했습니다. <1>$date"; - } - - // 경험치 상승 // 명성 상승 - $query = "update general set resturn='SUCCESS',gold=gold-'{$admin['develcost']}',rice=rice-'{$admin['develcost']}',experience=experience+'$exp' where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - } - pushGenLog($general, $log); -} - function process_42(&$general) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); diff --git a/hwe/sammo/Command/General/che_강행.php b/hwe/sammo/Command/General/che_강행.php new file mode 100644 index 00000000..0f70b5cc --- /dev/null +++ b/hwe/sammo/Command/General/che_강행.php @@ -0,0 +1,119 @@ +generalObj; + + $this->setCity(); + $this->setNation(); + $this->setDestCity($this->arg['destCityID'], []); + + [$reqGold, $reqRice] = $this->getCost(); + + $this->runnableConstraints=[ + ['NotSameCity'], + ['NearCity', 3], + ['ReqGeneralGold', $reqGold], + ['ReqGeneralRice', $reqRice], + ]; + } + + protected function argTest():bool{ + if(!key_exists('destCityID', $this->arg)){ + return false; + } + if(!key_exists($this->arg['destCityID'], CityConst::all())){ + return false; + } + $this->arg = [ + 'destCityID'=>$this->arg['destCityID'] + ]; + return true; + } + + public function getCost():array{ + $env = $this->env; + return [$env['develcost'] * 5, 0]; + } + + public function getPreReqTurn():int{ + return 0; + } + + public function getPostReqTurn():int{ + return 0; + } + + public function run():bool{ + if(!$this->isRunnable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + $env = $this->env; + + $general = $this->generalObj; + $date = substr($general->getVar('turntime'),11,5); + + $destCityName = $this->destCity['name']; + $destCityID = $this->destCity['city']; + $josaRo = JosaUtil::pick($destCityName, '로'); + + $logger = $general->getLogger(); + + $logger->pushGeneralActionLog("{$destCityName}{$josaRo} 강행했습니다. <1>$date"); + + $exp = 100; + + $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $general->setVar('city', $destCityID); + + if($general->getVar('level') == 12 && $this->nation['level'] == 0){ + $generalList = $db->queryFirstColumn('SELECT no, name, city, nation, level FROM general WHERE nation=%i AND no!=%i', $general->getNationID(), $general->getID()); + foreach($generalList as $targetRawGeneral){ + $targetGeneralID = $targetRawGeneral['no']; + $targetGeneral = $this->getGeneralObjFromGeneralSource($targetGeneralID); + if($targetGeneral === null){ + $targetGeneral = new General($targetRawGeneral, null, $env['year'], $env['month'], false); + } + $targetGeneral->setVar('city', $destCityID); + $targetGeneral->getLogger()->pushGeneralActionLog("방랑군 세력이 {$destCityName}{$josaRo} 강행했습니다.", ActionLogger::PLAIN); + $targetGeneral = null; + } + } + + [$reqGold, $reqRice] = $this->getCost(); + $general->increaseVarWithLimit('gold', -$reqGold, 0); + $general->increaseVar('experience', $exp); + $general->increaseVar('leader2', 1); + $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->checkStatChange(); + $general->applyDB($db); + + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_단련.php b/hwe/sammo/Command/General/che_단련.php new file mode 100644 index 00000000..72a9c29d --- /dev/null +++ b/hwe/sammo/Command/General/che_단련.php @@ -0,0 +1,121 @@ +generalObj; + + $this->setCity(); + $this->setNation(); + + [$reqGold, $reqRice] = $this->getCost(); + + $this->runnableConstraints=[ + ['NoNeutral'], + ['ReqGeneralCrew'], + //TODO:훈련이 너무 낮습니다? + //TODO:사기가 너무 낮습니다? + ['ReqGeneralGold', $reqGold], + ['ReqGeneralRice', $reqRice], + ]; + + } + + protected function argTest():bool{ + $this->arg = null; + return true; + } + + public function getCost():array{ + $env = $this->env; + return [$env['develcost'], $env['develcost']]; + } + + public function getPreReqTurn():int{ + return 0; + } + + public function getPostReqTurn():int{ + return 0; + } + + public function run():bool{ + if(!$this->isRunnable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $date = substr($general->getVar('turntime'),11,5); + + [$pick, $multiplier] = Util::choiceRandomUsingWeightPair([ + [['success', 1], 0.34], + [['normal', 2], 0.33], + [['fail', 3], 0.33] + ]); + + $score = Util::round($general->getVar('crew') * $general->getVar('train') * $general->getVar('atmos') / 20 / 10000); + $score *= $multiplier; + $scoreText = number_format($score, 0); + + $armTypeText = GameUnitConst::allType()[$general->getCrewTypeObj()->armType]; + + $logger = $general->getLogger(); + + if($pick == 'fail'){ + $logger->pushGeneralActionLog("단련이 지지부진하여 {$armTypeText} 숙련도가 {$scoreText} 향상되었습니다. <1>$date"); + } + else if($pick == 'success'){ + $logger->pushGeneralActionLog("단련이 일취월장하여 {$armTypeText} 숙련도가 {$scoreText} 향상되었습니다. <1>$date"); + } + else{ + $logger->pushGeneralActionLog("{$armTypeText} 숙련도가 {$scoreText} 향상되었습니다. <1>$date"); + } + + $exp = $general->getVar('crew') / 400; + $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + + $general->addDex($general->getCrewTypeObj(), $score, false); + + $incStat = Util::choiceRandomUsingWeight([ + 'leader2'=>$general->getLeadership(false, false, false, false), + 'power2'=>$general->getPower(false, false, false, false), + 'intel2'=>$general->getIntel(false, false, false, false) + ]); + [$reqGold, $reqRice] = $this->getCost(); + + $general->increaseVarWithLimit('gold', -$reqGold, 0); + $general->increaseVarWithLimit('rice', -$reqRice, 0); + $general->increaseVar('experience', $exp); + $general->increaseVar($incStat, 1); + $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->checkStatChange(); + $general->applyDB($db); + + uniqueItemEx($general->getVar('no'), $logger); + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_사기진작.php b/hwe/sammo/Command/General/che_사기진작.php index 63236398..8bcd3d15 100644 --- a/hwe/sammo/Command/General/che_사기진작.php +++ b/hwe/sammo/Command/General/che_사기진작.php @@ -87,7 +87,7 @@ class che_사기진작 extends Command\GeneralCommand{ $general->increaseVarWithLimit('atmos', $score, 0, GameConst::$maAtmosByCommand); $general->setVar('train', $sideEffect); - $general->addDex($general->getVar('crew')/100, $score, false); + $general->addDex($general->getCrewTypeObj(), $score, false); $general->increaseVar('experience', $exp); $general->increaseVar('dedication', $ded); @@ -95,7 +95,7 @@ class che_사기진작 extends Command\GeneralCommand{ $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); $general->applyDB($db); - + uniqueItemEx($general->getVar('no'), $logger); } diff --git a/hwe/sammo/Command/General/che_훈련.php b/hwe/sammo/Command/General/che_훈련.php index f3416dc6..cba8be4a 100644 --- a/hwe/sammo/Command/General/che_훈련.php +++ b/hwe/sammo/Command/General/che_훈련.php @@ -84,7 +84,7 @@ class che_훈련 extends Command\GeneralCommand{ $general->increaseVarWithLimit('train', $score, 0, GameConst::$maxTrainByCommand); $general->setVar('atmos', $sideEffect); - $general->addDex($general->getVar('crew')/100, $score, false); + $general->addDex($general->getCrewTypeObj(), $score, false); $general->increaseVar('experience', $exp); $general->increaseVar('dedication', $ded); @@ -92,7 +92,7 @@ class che_훈련 extends Command\GeneralCommand{ $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); $general->applyDB($db); - + uniqueItemEx($general->getVar('no'), $logger); } diff --git a/hwe/sammo/Constraint/ReqGeneralCrew.php b/hwe/sammo/Constraint/ReqGeneralCrew.php index 0ad27e19..8cfae2a4 100644 --- a/hwe/sammo/Constraint/ReqGeneralCrew.php +++ b/hwe/sammo/Constraint/ReqGeneralCrew.php @@ -26,7 +26,7 @@ class ReqGeneralCrew extends Constraint{ return true; } - $this->reason = "병사들이 없습니다."; + $this->reason = "병사가 모자랍니다."; return false; } } \ No newline at end of file