diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 00d92925..006c93c0 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -115,22 +115,31 @@ function getSpecial2($leader, $power, $intel, $nodex=1, $dex0=0, $dex10=0, $dex2 } function getGenDex($general, $type) { - $type = intdiv($type, 10) * 10; - return $general["dex{$type}"]; + $ntype = GameUnitCons::byId($type)->armType * 10; + return $general["dex{$ntype}"]??0; } function addGenDex($no, $atmos, $train, $type, $exp) { $db = DB::db(); - $connect=$db->get(); - $type = intdiv($type, 10) * 10; - $dexType = "dex{$type}"; - if($type == 30) { $exp = Util::round($exp * 0.90); } //귀병은 90%효율 - elseif($type == 40) { $exp = Util::round($exp * 0.90); } //차병은 90%효율 - $exp = Util::round($exp * ($atmos+$train) / 200); // 사기 + 훈련 / 200 + $armType = GameUnitConst::byId($type)->armType; + if($armType < 0){ + return; + } + + $ntype = $armType*10; + $dexType = "dex{$ntype}"; + if($armType == GameUnitConst::T_WIZARD) { + $exp = Util::round($exp * 0.90); + } + else if($armType == GameUnitConst::T_SIEGE) { + $exp = Util::round($exp * 0.90); + } + $exp = Util::round($exp * ($atmos + $train) / 200); // 사기 + 훈련 / 200 - $query = "update general set {$dexType}={$dexType}+{$exp} where no='$no'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('general', [ + $dexType=>$db->sqleval('%b + %i', $dexType, $exp) + ], 'no=%i', $no); } diff --git a/hwe/preprocessing.php b/hwe/preprocessing.php index 8f807e08..84e00242 100644 --- a/hwe/preprocessing.php +++ b/hwe/preprocessing.php @@ -57,8 +57,8 @@ switch($commandtype) { case 8: command_Single($turn, 8); break; //치안 강화 case 9: command_Single($turn, 9); break; //자금 조달 -// case 11: command_11( $turn, 11); break; //징병 -// case 12: command_12( $turn, 12); break; //모병 +// case 11: command_11( $turn, 11, false); break; //징병 +// case 12: command_11( $turn, 12, true); break; //모병 case 13: command_Single($turn, 13); break; //훈련 case 14: command_Single($turn, 14); break; //사기진작 case 15: command_Single($turn, 0); break; //전투태세 diff --git a/hwe/processing.php b/hwe/processing.php index 935db56f..6979ff25 100644 --- a/hwe/processing.php +++ b/hwe/processing.php @@ -49,8 +49,8 @@ switch($commandtype) { case 8: command_Single($turn, 8); break; //치안 강화 case 9: command_Single($turn, 9); break; //자금 조달 - case 11: command_11( $turn, 11); break; //징병 - case 12: command_12( $turn, 12); break; //모병 + case 11: command_11( $turn, 11, false); break; //징병 + case 12: command_11( $turn, 12, true); break; //모병 case 13: command_Single($turn, 13); break; //훈련 case 14: command_Single($turn, 14); break; //사기진작 //case 15: command_Single($turn, 0); break; //전투태세 @@ -193,416 +193,125 @@ function command_99($turn) { header('location:b_chiefcenter.php'); } -function command_11($turn, $command) { +function command_11($turn, $command, bool $is모병 = false) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); $userID = Session::getUserID(); - starter("징병"); + $me = $db->queryFirstRow( + 'SELECT no,nation,level,personal,special2,level,city,crew,horse,injury,leader,crewtype,gold + from general where owner=%i', + $userID + ); - $query = "select no,nation,level,personal,special2,level,city,crew,horse,injury,leader,crewtype,gold from general where owner='{$userID}'"; - $result = MYDB_query($query, $connect) or Error("aaa_processing.php ".MYDB_error($connect),""); - $me = MYDB_fetch_array($result); + [$nationLevel, $tech] = $db->queryFirstList('SELECT level,tech FROM nation WHERE nation=%i', $me['nation']); - $query = "select level,tech from nation where nation='{$me['nation']}'"; - $result = MYDB_query($query, $connect) or Error("process53 ".MYDB_error($connect),""); - $nation = MYDB_fetch_array($result); - - if($me['level'] == 12) { - $lbonus = $nation['level'] * 2; - } elseif($me['level'] >= 5) { - $lbonus = $nation['level']; - } else { - $lbonus = 0; - } + $lbonus = setLeadershipBonus($general, $nationLevel); $ownCities = []; $ownRegions = []; - $relativeYear = $gameStor->year - $gameStor->startyear; - $tech = $nation['tech']; + [$year, $startYear] = $gameStor->getValuesAsArray(['year','startyear']); + + $relativeYear = $year - $startyear; foreach(DB::db()->query('SELECT city, region from city where nation = %i', $me['nation']) as $city){ $ownCities[$city['city']] = 1; $ownRegions[$city['region']] = 1; } - $leader = intdiv($me['leader'] * (100 - $me['injury']), 100) + getHorseEff($me['horse']) + $lbonus; - $crew = $leader - Util::round($me['crew']/100); + $leader = getGeneralLeadership($general, true, true, true); + $maxCrew = $leader - Util::round($me['crew']/100); $abil = getTechAbil($nation['tech']); - $cost = getTechCost($nation['tech']); - echo " -병사를 모집합니다. 훈련과 사기치는 낮지만 가격이 저렴합니다.
-가능한 수보다 많게 입력하면 가능한 최대 병사를 모집합니다.
-이미 병사가 있는 경우 추가징병되며, 병종이 다를경우는 기존의 병사는 소집해제됩니다.
-현재 징병 가능한 병종은 녹색으로 표시되며,
-현재 징병 가능한 특수병종은 초록색으로 표시됩니다.
- - - - - - - - - - - - - - - - - "; - foreach(GameUnitConst::all() as $i=>$unit) { - if($i == 0){ - echo ''; - } - else if($i == 10){ - echo ''; - } - else if($i == 20){ - echo ''; - } - else if($i == 30){ - echo ''; - } - else if($i == 40){ - echo ''; - } + $armTypes = []; - if(!$unit->isValid($ownCities, $ownRegions, $relativeYear, $tech)){ - continue; //TODO: 불가능한 병종도 보여줄 필요가 있음. - } + foreach(GameUnitConst::allType() as $armType => $armName){ + $armTypeCrews = []; - if($unit->recruitType == 0){ - $l = 'green'; - } - else{ - $l = 'limegreen'; - } - - $baseRice = $unit->rice * $cost; - $baseCost = $unit->cost * $cost; - $baseCost = CharCost($baseCost, $me['personal']); - - $unitBaseType = intdiv($unit->id, 10); - if($me['special2'] == 50 && $unitBaseType == 0){ - $baseCost *= 0.9; - } - else if($me['special2'] == 51 && $unitBaseType == 1){ - $baseCost *= 0.9; - } - else if($me['special2'] == 52 && $unitBaseType == 2){ - $baseCost *= 0.9; - } - else if($me['special2'] == 53 && $unitBaseType == 3){ - $baseCost *= 0.9; - } - else if($me['special2'] == 54 && $unitBaseType == 4){ - $baseCost *= 0.9; - } - else if($me['special2'] == 72) { - $baseCost *= 0.5; - } - - $name = $unit->name; - $attack = $unit->attack + $abil; - $defence = $unit->defence + $abil; - $speed = $unit->speed; - $avoid = $unit->avoid; - $weapImage = ServConfig::$gameImagePath."/weap{$i}.png"; - if($gameStor->show_img_level < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; } - - $baseRiceShort = round($baseRice, 1); - $baseCostShort = round($baseCost, 1); - - $info = join('
', $unit->info); - - echo " - - - - - - - - - - - - - - "; - } - - echo " -
- 현재 기술력 : - 현재 통솔 : - 현재 병종 : - 현재 병사 : - 현재 자금 : -
사진병종공격방어기동회피군량가격병사수특징
보병 계열
궁병 계열
기병 계열
귀병 계열
차병 계열
{$name}{$attack}{$defence}{$speed}{$avoid}{$baseRiceShort}{$baseCostShort}
- 00명
- - - "; - - for($j=0; $j < count($turn); $j++) { - echo " - "; - } - echo " -
$info
"; - - ender(); -} - -function command_12($turn, $command) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); - $userID = Session::getUserID(); - - starter("모병"); - - $query = "select no,nation,level,personal,special2,level,city,crew,horse,injury,leader,crewtype,gold from general where owner='{$userID}'"; - $result = MYDB_query($query, $connect) or Error("aaa_processing.php ".MYDB_error($connect),""); - $me = MYDB_fetch_array($result); - - $query = "select level,tech from nation where nation='{$me['nation']}'"; - $result = MYDB_query($query, $connect) or Error("process53 ".MYDB_error($connect),""); - $nation = MYDB_fetch_array($result); - - if($me['level'] == 12) { - $lbonus = $nation['level'] * 2; - } elseif($me['level'] >= 5) { - $lbonus = $nation['level']; - } else { - $lbonus = 0; - } - - $ownCities = []; - $ownRegions = []; - $relativeYear = $gameStor->year - $gameStor->startyear; - $tech = $nation['tech']; - - foreach(DB::db()->query('SELECT city, region from city where nation = %i', $me['nation']) as $city){ - $ownCities[$city['city']] = 1; - $ownRegions[$city['region']] = 1; - } - - $leader = intdiv($me['leader'] * (100 - $me['injury']), 100) + getHorseEff($me['horse']) + $lbonus; - $crew = $leader - round($me['crew']/100); - $abil = getTechAbil($nation['tech']); - $cost = getTechCost($nation['tech']); - echo " -병사를 모집합니다. 훈련과 사기치는 높지만 자금이 많이 듭니다.
-가능한 수보다 많게 입력하면 가능한 최대 병사를 모집합니다.
-이미 병사가 있는 경우 추가징병되며, 병종이 다를경우는 기존의 병사는 소집해제됩니다.
-현재 모병 가능한 병종은 녹색으로 표시되며,
-현재 모병 가능한 특수병종은 초록색으로 표시됩니다.
- - - - - - - - - - - - - - - - - - "; + foreach(GameUnitConst::byType($armType) as $unit){ + $crewObj = new stdClass; + if(!$unit->isValid($ownCities, $ownRegions, $relativeYear, $tech)){ + continue; //TODO: 불가능한 병종도 보여줄 필요가 있음. + } + $crewObj->id = $unit->id; + + if($unit->reqTech == 0){ + $crewObj->bgcolor = 'green'; + } + else{ + $crewObj->bgcolor = 'limegreen'; + } - foreach(GameUnitConst::all() as $i=>$unit) { - if($i == 0){ - echo ''; - } - else if($i == 10){ - echo ''; - } - else if($i == 20){ - echo ''; - } - else if($i == 30){ - echo ''; - } - else if($i == 40){ - echo ''; - } + $crewObj->baseRice = $unit->rice * getTechCost($tech); + $crewObj->baseCost = CharCost($unit->getTechCost($tech), $me['personal']); - if(!$unit->isValid($ownCities, $ownRegions, $relativeYear, $tech)){ - continue; //TODO: 불가능한 병종도 보여줄 필요가 있음. - } - - if($unit->recruitType == 0){ - $l = 'green'; - } - else{ - $l = 'limegreen'; - } + $armType = $unit->armType; + if($me['special2'] == 50 && $armType == GameUnitConst::T_FOOTMAN){ + $crewObj->baseCost *= 0.9; + } + else if($me['special2'] == 51 && $armType == GameUnitConst::T_ARCHER){ + $crewObj->baseCost *= 0.9; + } + else if($me['special2'] == 52 && $armType == GameUnitConst::T_CAVALRY){ + $crewObj->baseCost *= 0.9; + } + else if($me['special2'] == 53 && $armType == GameUnitConst::T_WIZARD){ + $crewObj->baseCost *= 0.9; + } + else if($me['special2'] == 54 && $armType == GameUnitConst::T_SIEGE){ + $crewObj->baseCost *= 0.9; + } + else if($me['special2'] == 72) { + $crewObj->baseCost *= 0.5; + } + + $crewObj->name = $unit->name; + $crewObj->attack = $unit->attack + $abil; + $crewObj->defence = $unit->defence + $abil; + $crewObj->speed = $unit->speed; + $crewObj->avoid = $unit->avoid; + if($gameStor->show_img_level < 2) { + $crewObj->img = ServConfig::$sharedIconPath."/default.jpg"; + } + else{ + $crewObj->img = ServConfig::$gameImagePath."/weap{$unit->id}.png"; + } + + $crewObj->baseRiceShort = round($crewObj->baseRice, 1); + $crewObj->baseCostShort = round($crewObj->baseCost, 1); + + $crewObj->info = join('
', $unit->info); - $baseRice = $unit->rice * $cost; - $baseCost = $unit->cost * $cost; - $baseCost = CharCost($baseCost, $me['personal']); - $unitBaseType = intdiv($unit->id, 10); - if($me['special2'] == 50 && $unitBaseType == 0){ - $baseCost *= 0.9; + $armTypeCrews[] = $crewObj; } - else if($me['special2'] == 51 && $unitBaseType == 1){ - $baseCost *= 0.9; - } - else if($me['special2'] == 52 && $unitBaseType == 2){ - $baseCost *= 0.9; - } - else if($me['special2'] == 53 && $unitBaseType == 3){ - $baseCost *= 0.9; - } - else if($me['special2'] == 54 && $unitBaseType == 4){ - $baseCost *= 0.9; - } - else if($me['special2'] == 72) { - $baseCost *= 0.5; - } - - $name = $unit->name; - $attack = $unit->attack + $abil; - $defence = $unit->defence + $abil; - $speed = $unit->speed; - $avoid = $unit->avoid; - $weapImage = ServConfig::$gameImagePath."/weap{$i}.png"; - if($gameStor->show_img_level < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; } - - $baseRiceShort = round($baseRice, 1); - $baseCostShort = round($baseCost, 1); - - $info = join('
', $unit->info); - - echo " - - - - - - - - - - - - - - "; + $armTypes[] = [$armName, $armTypeCrews]; + } + if($is모병){ + $commandName = '모병'; + starter("모병"); + } + else{ + $commandName = '징병'; + starter("징병"); } - echo " -
모병은 가격 2배의 자금이 소요됩니다.
- 현재 기술력 : - 현재 통솔 : - 현재 병종 : - 현재 병사 : - 현재 자금 : -
사진병종공격방어기동회피군량가격병사수특징
보병 계열
궁병 계열
기병 계열
귀병 계열
차병 계열
{$name}{$attack}{$defence}{$speed}{$avoid}{$baseRiceShort}{$baseCostShort}
- 00명
- - - "; - - for($j=0; $j < count($turn); $j++) { - echo " - "; - } - echo " -
$info
"; + $templates = new \League\Plates\Engine('templates'); + echo $templates->render('recruitCrewForm', [ + 'command'=>$command, + 'commandName'=>$commandName, + 'techLevelText'=>getTechCall($tech), + 'tech'=>$tech, + 'leader'=>$leader, + 'crewTypeName'=>GameUnitConst::byId($general['crewtype'])->name, + 'crew'=>$general['crew'], + 'maxCrew'=>$maxCrew, + 'gold'=>$general['gold'], + 'turn'=>$turn, + 'armTypes'=>$armTypes, + ]); + ender(); } diff --git a/hwe/sammo/GameUnitConstBase.php b/hwe/sammo/GameUnitConstBase.php index 739f4fb1..6d9a80c6 100644 --- a/hwe/sammo/GameUnitConstBase.php +++ b/hwe/sammo/GameUnitConstBase.php @@ -4,15 +4,17 @@ namespace sammo; class GameUnitConstBase{ protected function __construct(){ - } + } - const T_CASTLE = 0; - const T_FOOTMAN = 1; - const T_ARCHER = 2; - const T_CAVALRY = 3; - const T_WIZARD = 4; - const T_SIEGE = 5; - const T_MISC = 6; + const T_CASTLE = -1; + const T_MISC = -2; + const T_FOOTMAN = 0; + const T_ARCHER = 1; + const T_CAVALRY = 2; + const T_WIZARD = 3; + const T_SIEGE = 4; + + protected static $constID = null; protected static $constName = null; diff --git a/hwe/templates/recruitCrewForm.php b/hwe/templates/recruitCrewForm.php new file mode 100644 index 00000000..d35d55bd --- /dev/null +++ b/hwe/templates/recruitCrewForm.php @@ -0,0 +1,96 @@ + + +병사를 모집합니다. + +훈련과 사기치는 낮지만 가격이 저렴합니다.
+ +훈련과 사기치는 높지만 자금이 많이 듭니다. + +가능한 수보다 많게 입력하면 가능한 최대 병사를 모집합니다.
+이미 병사가 있는 경우 추가되며, 병종이 다를경우는 기존의 병사는 소집해제됩니다.
+현재 가능한 병종은 녹색으로 표시되며,
+현재 가능한 특수병종은 초록색으로 표시됩니다.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
모병은 가격 2배의 자금이 소요됩니다.
+ 현재 기술력 : + 현재 통솔 : + 현재 병종 : + 현재 병사 : + 현재 자금 : +
사진병종공격방어기동회피군량가격병사수특징
name?>attack?>defence?>speed?>avoid?>baseRiceShort?>baseCostShort?>
+ style=text-align:right;color:white;background-color:black + >00명
+ + + + + + + +
info?>
\ No newline at end of file