징병 폼 완료
This commit is contained in:
+4
-2
@@ -48,8 +48,10 @@ function getNationStaticInfo($nationID, $forceRefresh=false)
|
|||||||
'type'=>GameConst::$neutralNationType,
|
'type'=>GameConst::$neutralNationType,
|
||||||
'level'=>0,
|
'level'=>0,
|
||||||
'capital'=>0,
|
'capital'=>0,
|
||||||
'gennum'=>1,
|
'gold'=>0,
|
||||||
'power'=>1
|
'rice'=>2000,
|
||||||
|
'tech'=>0,
|
||||||
|
'gennum'=>1
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ function reserveTurn(turnList, command, arg){
|
|||||||
|
|
||||||
jQuery(function($){
|
jQuery(function($){
|
||||||
|
|
||||||
$('#commonSubmit').click(function(){
|
window.submitAction = function(){
|
||||||
|
|
||||||
//checkCommandArg 참고
|
//checkCommandArg 참고
|
||||||
var availableArgumentList = {
|
var availableArgumentList = {
|
||||||
@@ -84,7 +84,9 @@ $('#commonSubmit').click(function(){
|
|||||||
|
|
||||||
console.log(argument);
|
console.log(argument);
|
||||||
reserveTurn(turnList, command, argument);
|
reserveTurn(turnList, command, argument);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
$('#commonSubmit').click(submitAction);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -15,8 +15,8 @@ $(function(){
|
|||||||
|
|
||||||
|
|
||||||
var $postForm = $('#post_form');
|
var $postForm = $('#post_form');
|
||||||
var $formAmount = $postForm.find('.form_amount');
|
var $formAmount = $('#amount');
|
||||||
var $formCrewtype = $postForm.find('.form_crewtype');
|
var $formCrewtype = $('#crewType');
|
||||||
$('.form_double').on('keyup change',function(e){
|
$('.form_double').on('keyup change',function(e){
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $parent = $this.parents('.input_form');
|
var $parent = $this.parents('.input_form');
|
||||||
@@ -26,7 +26,7 @@ $(function(){
|
|||||||
$formAmount.val($this.val());
|
$formAmount.val($this.val());
|
||||||
|
|
||||||
if(e.which === 13){
|
if(e.which === 13){
|
||||||
$postForm.submit();
|
submitAction();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -77,10 +77,21 @@ $(function(){
|
|||||||
var $input = $parent.find('.form_double');
|
var $input = $parent.find('.form_double');
|
||||||
|
|
||||||
$formCrewtype.val(crewtype);
|
$formCrewtype.val(crewtype);
|
||||||
$formAmount.val($input.val());
|
$formAmount.val($input.val()*100);
|
||||||
|
|
||||||
$postForm.submit();
|
submitAction();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn_fill').click();
|
$('.btn_fill').click();
|
||||||
|
|
||||||
|
$('#show_unavailable_troops').change(function(){
|
||||||
|
var show = $('#show_unavailable_troops').is(":checked");
|
||||||
|
if(show){
|
||||||
|
$('.show_default_false').show();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('.show_default_false').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.show_default_false').hide();
|
||||||
});
|
});
|
||||||
@@ -2,18 +2,20 @@
|
|||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil, Session, KVStorage,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst, GameUnitConst,
|
GameConst, GameUnitConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
Command
|
Command,
|
||||||
|
ServConfig
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
function getTechCall,
|
getTechCall,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery,
|
||||||
|
getTechAbil
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
@@ -112,6 +114,13 @@ class che_징병 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBrief():string{
|
||||||
|
$crewTypeName = $this->reqCrewType->name;
|
||||||
|
$amount = $this->reqCrew;
|
||||||
|
$commandName = static::getName();
|
||||||
|
return "【{$crewTypeName}】 {$amount}명 {$commandName}";
|
||||||
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
return "{$this->getName()}(통솔경험)";
|
return "{$this->getName()}(통솔경험)";
|
||||||
}
|
}
|
||||||
@@ -217,14 +226,10 @@ class che_징병 extends Command\GeneralCommand{
|
|||||||
public function getForm(): string
|
public function getForm(): string
|
||||||
{
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
|
||||||
$userID = Session::getUserID();
|
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
|
|
||||||
|
[$nationLevel, $tech] = $db->queryFirstList('SELECT level,tech FROM nation WHERE nation=%i', $general->getNationID());
|
||||||
[$nationLevel, $tech] = $db->queryFirstList('SELECT level,tech FROM nation WHERE nation=%i', $me['nation']);
|
|
||||||
if(!$nationLevel){
|
if(!$nationLevel){
|
||||||
$nationLevel = 0;
|
$nationLevel = 0;
|
||||||
}
|
}
|
||||||
@@ -233,20 +238,20 @@ class che_징병 extends Command\GeneralCommand{
|
|||||||
$tech = 0;
|
$tech = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$lbonus = setLeadershipBonus($me, $nationLevel);
|
|
||||||
|
|
||||||
$ownCities = [];
|
$ownCities = [];
|
||||||
$ownRegions = [];
|
$ownRegions = [];
|
||||||
[$year, $startyear] = $gameStor->getValuesAsArray(['year','startyear']);
|
$year = $this->env['year'];
|
||||||
|
$startyear = $this->env['startyear'];
|
||||||
|
|
||||||
$relativeYear = $year - $startyear;
|
$relativeYear = $year - $startyear;
|
||||||
|
|
||||||
foreach(DB::db()->query('SELECT city, region from city where nation = %i', $me['nation']) as $city){
|
foreach(DB::db()->query('SELECT city, region from city where nation = %i', $general->getNationID()) as $city){
|
||||||
$ownCities[$city['city']] = 1;
|
$ownCities[$city['city']] = 1;
|
||||||
$ownRegions[$city['region']] = 1;
|
$ownRegions[$city['region']] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$leadership = $general->getLeadership();$fullLeadership = $general->getLeadership(false);
|
$leadership = $general->getLeadership();
|
||||||
|
$fullLeadership = $general->getLeadership(false);
|
||||||
$abil = getTechAbil($tech);
|
$abil = getTechAbil($tech);
|
||||||
|
|
||||||
$armTypes = [];
|
$armTypes = [];
|
||||||
@@ -256,48 +261,31 @@ class che_징병 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
foreach(GameUnitConst::byType($armType) as $unit){
|
foreach(GameUnitConst::byType($armType) as $unit){
|
||||||
$crewObj = new \stdClass;
|
$crewObj = new \stdClass;
|
||||||
if(!$unit->isValid($ownCities, $ownRegions, $relativeYear, $tech)){
|
$crewObj->showDefault = 'true';
|
||||||
continue; //TODO: 불가능한 병종도 보여줄 필요가 있음.
|
|
||||||
}
|
|
||||||
|
|
||||||
$crewObj->id = $unit->id;
|
$crewObj->id = $unit->id;
|
||||||
|
|
||||||
if($unit->reqTech == 0){
|
if($unit->reqTech == 0){
|
||||||
$crewObj->bgcolor = 'green';
|
$crewObj->bgcolor = 'green';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$crewObj->bgcolor = 'limegreen';
|
$crewObj->bgcolor = 'limegreen';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$unit->isValid($ownCities, $ownRegions, $relativeYear, $tech)){
|
||||||
|
$crewObj->showDefault = 'false';
|
||||||
|
$crewObj->bgcolor = 'red';
|
||||||
|
}
|
||||||
|
|
||||||
$crewObj->baseRice = $unit->rice * getTechCost($tech);
|
$crewObj->baseRice = $general->onCalcDomestic($this->getName(), 'rice', $unit->riceWithTech($tech), ['armType'=>$unit->armType]);
|
||||||
$crewObj->baseCost = CharCost($unit->costWithTech($tech), $me['personal']);
|
$crewObj->baseCost = $general->onCalcDomestic($this->getName(), 'cost', $unit->costWithTech($tech), ['armType'=>$unit->armType]);
|
||||||
|
|
||||||
$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->name = $unit->name;
|
||||||
$crewObj->attack = $unit->attack + $abil;
|
$crewObj->attack = $unit->attack + $abil;
|
||||||
$crewObj->defence = $unit->defence + $abil;
|
$crewObj->defence = $unit->defence + $abil;
|
||||||
$crewObj->speed = $unit->speed;
|
$crewObj->speed = $unit->speed;
|
||||||
$crewObj->avoid = $unit->avoid;
|
$crewObj->avoid = $unit->avoid;
|
||||||
if($gameStor->show_img_level < 2) {
|
if($this->env['show_img_level'] < 2) {
|
||||||
$crewObj->img = ServConfig::$sharedIconPath."/default.jpg";
|
$crewObj->img = ServConfig::$sharedIconPath."/default.jpg";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -318,24 +306,10 @@ class che_징병 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
$techLevelText = getTechCall($tech);
|
$techLevelText = getTechCall($tech);
|
||||||
|
|
||||||
$crew = $general->getRaw('crew');
|
$crew = $general->getVar('crew');
|
||||||
$gold = $general->getRaw('gold');
|
$gold = $general->getVar('gold');
|
||||||
$crewTypeObj = $general->getCrewTypeObj();
|
$crewTypeObj = $general->getCrewTypeObj();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$templates = new \League\Plates\Engine('templates');
|
|
||||||
return $templates->render('recruitCrewForm', [
|
|
||||||
'crewType'=>GameUnitConst::byId($me['crewtype'])->id,
|
|
||||||
'crewTypeName'=>GameUnitConst::byId($me['crewtype'])->name,
|
|
||||||
'crew'=>$me['crew'],
|
|
||||||
'gold'=>$me['gold'],
|
|
||||||
'turn'=>$turn,
|
|
||||||
'armTypes'=>$armTypes,
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
$destRawGenerals = $db->query('SELECT no,name,level,npc,gold,rice FROM general WHERE nation != 0 AND nation = %i AND no != %i ORDER BY npc,binary(name)',$this->generalObj->getNationID(), $this->generalObj->getID());
|
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -352,9 +326,11 @@ class che_징병 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
<table class='tb_layout' style='margin:auto;'>
|
<table class='tb_layout' style='margin:auto;'>
|
||||||
<thead>
|
<thead>
|
||||||
|
<tr><td colspan=11><div style='float:right'><input type='checkbox' id="show_unavailable_troops">불가능한 병종 표시</input></div>
|
||||||
<?php if($commandName=='모병'): ?>
|
<?php if($commandName=='모병'): ?>
|
||||||
<tr><td align=center colspan=11>모병은 가격 2배의 자금이 소요됩니다.</td></tr>
|
<div style='text-align:center;'>모병은 가격 2배의 자금이 소요됩니다.</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
</td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan=11 align=center class='bg2'>
|
<td colspan=11 align=center class='bg2'>
|
||||||
현재 기술력 : <?=$techLevelText?>
|
현재 기술력 : <?=$techLevelText?>
|
||||||
@@ -384,6 +360,7 @@ class che_징병 extends Command\GeneralCommand{
|
|||||||
<?php foreach($armTypeCrews as $crewObj): ?>
|
<?php foreach($armTypeCrews as $crewObj): ?>
|
||||||
<tr
|
<tr
|
||||||
id="crewType<?=$crewObj->id?>"
|
id="crewType<?=$crewObj->id?>"
|
||||||
|
class="show_default_<?=$crewObj->showDefault?>"
|
||||||
style='height:64px;background-color:<?=$crewObj->bgcolor?>'
|
style='height:64px;background-color:<?=$crewObj->bgcolor?>'
|
||||||
data-rice="<?=$crewObj->baseRice?>"
|
data-rice="<?=$crewObj->baseRice?>"
|
||||||
data-cost="<?=$crewObj->baseCost?>"
|
data-cost="<?=$crewObj->baseCost?>"
|
||||||
@@ -418,8 +395,8 @@ class che_징병 extends Command\GeneralCommand{
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<input type='hidden' name='form_amount' class='form_amount' value='1'>
|
<input type='hidden' id='amount' value='1'>
|
||||||
<input type='hidden' name='form_crewType' class='form_crewType' value='<?=$crewTypeObj->id?>'>
|
<input type='hidden' id='crewType' value='<?=$crewTypeObj->id?>'>
|
||||||
<script>
|
<script>
|
||||||
window.currentTech = <?=$tech?>;
|
window.currentTech = <?=$tech?>;
|
||||||
window.leadership = <?=$leadership?>;
|
window.leadership = <?=$leadership?>;
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ class GameUnitDetail implements iAction{
|
|||||||
return StringUtil::subStringForWidth($this->name, 0, 4);
|
return StringUtil::subStringForWidth($this->name, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function riceWithTech(int $tech, int $crew=100):float{
|
||||||
|
return $this->rice * getTechCost($tech) * $crew / 100;
|
||||||
|
}
|
||||||
|
|
||||||
public function costWithTech(int $tech, int $crew=100):float{
|
public function costWithTech(int $tech, int $crew=100):float{
|
||||||
return $this->cost * getTechCost($tech) * $crew / 100;
|
return $this->cost * getTechCost($tech) * $crew / 100;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user