Util::range 추가
This commit is contained in:
@@ -39,14 +39,14 @@ var maxChiefTurn = <?=GameConst::$maxChiefTurn?>;
|
|||||||
<div class="chiefSubTable" style='height:<?=22*(GameConst::$maxChiefTurn+1)?>px;'
|
<div class="chiefSubTable" style='height:<?=22*(GameConst::$maxChiefTurn+1)?>px;'
|
||||||
><div class='chiefTurnIdxPanel'
|
><div class='chiefTurnIdxPanel'
|
||||||
><div class='bg1 chiefTurnIdx'>.</div
|
><div class='bg1 chiefTurnIdx'>.</div
|
||||||
<?php foreach(range(1, 12) as $idx):?>
|
<?php foreach(Util::range(GameConst::$maxChiefTurn) as $idx):?>
|
||||||
><div class='bg0 chiefTurnIdx'><?=$idx?></div
|
><div class='bg0 chiefTurnIdx'><?=$idx?></div
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
></div
|
></div
|
||||||
<?php foreach([12, 10, 8, 6] as $chiefIdx): ?>
|
<?php foreach([12, 10, 8, 6] as $chiefIdx): ?>
|
||||||
><div class='bg2 chiefPlate' style='flex-grow:1;' id='chief_<?=$chiefIdx?>'
|
><div class='bg2 chiefPlate' style='flex-grow:1;' id='chief_<?=$chiefIdx?>'
|
||||||
><div class='bg1 chiefNamePlate'><span class='chiefLevelText'>-</span> : <span class='chiefName'> </span></div
|
><div class='bg1 chiefNamePlate'><span class='chiefLevelText'>-</span> : <span class='chiefName'> </span></div
|
||||||
<?php foreach(range(1, GameConst::$maxChiefTurn) as $turnIdx): ?>
|
<?php foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx): ?>
|
||||||
><div class='chiefTurnBox turn<?=$turnIdx?>'
|
><div class='chiefTurnBox turn<?=$turnIdx?>'
|
||||||
><div class='chiefTurnTime'> </div
|
><div class='chiefTurnTime'> </div
|
||||||
><div class='chiefTurnPad'><span class='chiefTurnText'> </span></div
|
><div class='chiefTurnPad'><span class='chiefTurnText'> </span></div
|
||||||
@@ -56,7 +56,7 @@ var maxChiefTurn = <?=GameConst::$maxChiefTurn?>;
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
><div class='chiefTurnIdxPanel tail'
|
><div class='chiefTurnIdxPanel tail'
|
||||||
><div class='bg1 chiefTurnIdx'>.</div
|
><div class='bg1 chiefTurnIdx'>.</div
|
||||||
<?php foreach(range(1, GameConst::$maxChiefTurn) as $idx):?>
|
<?php foreach(Util::range(GameConst::$maxChiefTurn) as $idx):?>
|
||||||
><div class='bg0 chiefTurnIdx'><?=$idx?></div
|
><div class='bg0 chiefTurnIdx'><?=$idx?></div
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
></div
|
></div
|
||||||
@@ -79,14 +79,14 @@ var maxChiefTurn = <?=GameConst::$maxChiefTurn?>;
|
|||||||
><div class="chiefSubTable" style='height:<?=22*(GameConst::$maxChiefTurn+1)?>px;'
|
><div class="chiefSubTable" style='height:<?=22*(GameConst::$maxChiefTurn+1)?>px;'
|
||||||
><div class='chiefTurnIdxPanel'
|
><div class='chiefTurnIdxPanel'
|
||||||
><div class='bg1 chiefTurnIdx'>.</div
|
><div class='bg1 chiefTurnIdx'>.</div
|
||||||
<?php foreach(range(1, GameConst::$maxChiefTurn) as $idx):?>
|
<?php foreach(Util::range(GameConst::$maxChiefTurn) as $idx):?>
|
||||||
><div class='bg0 chiefTurnIdx'><?=$idx?></div
|
><div class='bg0 chiefTurnIdx'><?=$idx?></div
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
></div
|
></div
|
||||||
<?php foreach([11, 9, 7, 5] as $chiefIdx): ?>
|
<?php foreach([11, 9, 7, 5] as $chiefIdx): ?>
|
||||||
><div class='bg2 chiefPlate' style='flex-grow:1;' id='chief_<?=$chiefIdx?>'
|
><div class='bg2 chiefPlate' style='flex-grow:1;' id='chief_<?=$chiefIdx?>'
|
||||||
><div class='bg1 chiefNamePlate'><span class='chiefLevelText'>-</span> : <span class='chiefName'> </span></div
|
><div class='bg1 chiefNamePlate'><span class='chiefLevelText'>-</span> : <span class='chiefName'> </span></div
|
||||||
<?php foreach(range(1, GameConst::$maxChiefTurn) as $turnIdx): ?>
|
<?php foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx): ?>
|
||||||
><div class='chiefTurnBox turn<?=$turnIdx?>'
|
><div class='chiefTurnBox turn<?=$turnIdx?>'
|
||||||
><div class='chiefTurnTime'> </div
|
><div class='chiefTurnTime'> </div
|
||||||
><div class='chiefTurnPad'><span class='chiefTurnText'> </span></div
|
><div class='chiefTurnPad'><span class='chiefTurnText'> </span></div
|
||||||
@@ -96,7 +96,7 @@ var maxChiefTurn = <?=GameConst::$maxChiefTurn?>;
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
><div class='chiefTurnIdxPanel tail'
|
><div class='chiefTurnIdxPanel tail'
|
||||||
><div class='bg1 chiefTurnIdx'>.</div
|
><div class='bg1 chiefTurnIdx'>.</div
|
||||||
<?php foreach(range(1, 12) as $idx):?>
|
<?php foreach(Util::range(GameConst::$maxChiefTurn) as $idx):?>
|
||||||
><div class='bg0 chiefTurnIdx'><?=$idx?></div
|
><div class='bg0 chiefTurnIdx'><?=$idx?></div
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
></div
|
></div
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ var defaultSpecialDomestic = <?=GameConst::$defaultSpecialDomestic?>;
|
|||||||
<span class="input-group-text">명마</span>
|
<span class="input-group-text">명마</span>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_general_horse">
|
<select class="custom-select form_general_horse">
|
||||||
<?php foreach(range(0, 26) as $horseID): ?>
|
<?php foreach(GameConst::$allItems['horse'] as $horseID=>$cnt): ?>
|
||||||
<option value="<?=$horseID?>"><?=getItemName($horseID)?></option>
|
<option value="<?=$horseID?>"><?=getItemName($horseID)?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
@@ -299,15 +299,15 @@ var defaultSpecialDomestic = <?=GameConst::$defaultSpecialDomestic?>;
|
|||||||
<span class="input-group-text">무기</span>
|
<span class="input-group-text">무기</span>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_general_weap">
|
<select class="custom-select form_general_weap">
|
||||||
<?php foreach(range(0, 26) as $weapID): ?>
|
<?php foreach(GameConst::$allItems['weapon'] as $weaponID=>$cnt): ?>
|
||||||
<option value="<?=$weapID?>"><?=getItemName($weapID)?></option>
|
<option value="<?=$weaponID?>"><?=getItemName($weaponID)?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text">서적</span>
|
<span class="input-group-text">서적</span>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_general_book">
|
<select class="custom-select form_general_book">
|
||||||
<?php foreach(range(0, 26) as $bookID): ?>
|
<?php foreach(GameConst::$allItems['book'] as $bookID=>$cnt): ?>
|
||||||
<option value="<?=$bookID?>"><?=getItemName($bookID)?></option>
|
<option value="<?=$bookID?>"><?=getItemName($bookID)?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
@@ -328,8 +328,8 @@ var defaultSpecialDomestic = <?=GameConst::$defaultSpecialDomestic?>;
|
|||||||
<span class="input-group-text">도구</span>
|
<span class="input-group-text">도구</span>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_general_item">
|
<select class="custom-select form_general_item">
|
||||||
<?php foreach(range(0, 26) as $bookID): ?>
|
<?php foreach(GameConst::$allItems['item'] as $itemID=>$cnt): ?>
|
||||||
<option value="<?=$bookID?>"><?=getItemName($bookID)?></option>
|
<option value="<?=$itemID?>"><?=getItemName($itemID)?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -92,13 +92,7 @@ function repeatGeneralCommand(int $generalId, int $turnCnt){
|
|||||||
$turnList = $db->query('SELECT turn_idx, `action`, arg, brief FROM general_turn WHERE general_id=%i AND turn_idx < %i', $generalId, $reqTurn);
|
$turnList = $db->query('SELECT turn_idx, `action`, arg, brief FROM general_turn WHERE general_id=%i AND turn_idx < %i', $generalId, $reqTurn);
|
||||||
foreach($turnList as $turnItem){
|
foreach($turnList as $turnItem){
|
||||||
$turnIdx = $turnItem['turn_idx'];
|
$turnIdx = $turnItem['turn_idx'];
|
||||||
$nextTurnIdx = $turnIdx+$turnCnt;
|
$turnTarget = iterator_to_array(Util::range($turnIdx+$turnCnt, GameConst::$maxTurn, $turnCnt));
|
||||||
$turnTarget = [];
|
|
||||||
while($nextTurnIdx < GameConst::$maxTurn){
|
|
||||||
//NOTE: range(15, 24, 12) 가 PHP에선 에러다. 그러니 직접 짠다.
|
|
||||||
$turnTarget[] = $nextTurnIdx;
|
|
||||||
$nextTurnIdx += $turnCnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->update('general_turn', [
|
$db->update('general_turn', [
|
||||||
'action'=>$turnItem['action'],
|
'action'=>$turnItem['action'],
|
||||||
|
|||||||
@@ -931,8 +931,8 @@ function updateNationState() {
|
|||||||
], 'nation=%i', $nation['nation']);
|
], 'nation=%i', $nation['nation']);
|
||||||
|
|
||||||
$turnRows = [];
|
$turnRows = [];
|
||||||
foreach(range(12, getNationChiefLevel($nation['level']), -1) as $chiefLevel){
|
foreach(Util::range(getNationChiefLevel($nation['level']), 12) as $chiefLevel){
|
||||||
foreach(range(0, GameConst::$maxChiefTurn - 1) as $turnIdx){
|
foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx){
|
||||||
$turnRows[] = [
|
$turnRows[] = [
|
||||||
'nation_id'=>$nation['nation'],
|
'nation_id'=>$nation['nation'],
|
||||||
'level'=>$chiefLevel,
|
'level'=>$chiefLevel,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ function getFormattedFileLogAll(string $path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function eraseTnmtFightLogAll(){
|
function eraseTnmtFightLogAll(){
|
||||||
foreach(range(0, 49) as $i){
|
foreach(Util::range(50) as $i){
|
||||||
eraseTnmtFightLog($i);
|
eraseTnmtFightLog($i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function turnTable() {
|
|||||||
|
|
||||||
$turnList = [];
|
$turnList = [];
|
||||||
$turnList[] = "<option selected value='0'>1턴</option>";
|
$turnList[] = "<option selected value='0'>1턴</option>";
|
||||||
foreach(\range(1, GameConst::$maxTurn - 1) as $turnIdx){
|
foreach(Util::range(1, GameConst::$maxTurn) as $turnIdx){
|
||||||
$turnText = $turnIdx + 1;
|
$turnText = $turnIdx + 1;
|
||||||
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
|
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ function turnTable() {
|
|||||||
function chiefTurnTable() {
|
function chiefTurnTable() {
|
||||||
$turnList = [];
|
$turnList = [];
|
||||||
$turnList[] = "<option selected value='0'>1턴</option>";
|
$turnList[] = "<option selected value='0'>1턴</option>";
|
||||||
foreach(range(1, GameConst::$maxChiefTurn - 1) as $turnIdx){
|
foreach(Util::range(1, GameConst::$maxChiefTurn) as $turnIdx){
|
||||||
$turnText = $turnIdx + 1;
|
$turnText = $turnIdx + 1;
|
||||||
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
|
$turnList[] = "<option value='{$turnIdx}'>{$turnText}턴</option>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ $avgWar = 0;
|
|||||||
$attackerActivatedSkills = [];
|
$attackerActivatedSkills = [];
|
||||||
$defendersActivatedSkills = [];
|
$defendersActivatedSkills = [];
|
||||||
|
|
||||||
foreach(range(1, $repeatCnt) as $repeatIdx){
|
foreach(Util::range($repeatCnt) as $repeatIdx){
|
||||||
[$attacker, $city, $battleResult, $conquerCity, $attackerRice, $defenderRice] = simulateBattle(
|
[$attacker, $city, $battleResult, $conquerCity, $attackerRice, $defenderRice] = simulateBattle(
|
||||||
$rawAttacker, $rawAttackerCity, $rawAttackerNation,
|
$rawAttacker, $rawAttackerCity, $rawAttackerNation,
|
||||||
$defenderList, $rawDefenderCity, $rawDefenderNation,
|
$defenderList, $rawDefenderCity, $rawDefenderNation,
|
||||||
|
|||||||
+1
-1
@@ -254,7 +254,7 @@ $db->insert('general', [
|
|||||||
]);
|
]);
|
||||||
$generalID = $db->insertId();
|
$generalID = $db->insertId();
|
||||||
$turnRows = [];
|
$turnRows = [];
|
||||||
foreach(range(0, GameConst::$maxTurn - 1) as $turnIdx){
|
foreach(Util::range(GameConst::$maxTurn) as $turnIdx){
|
||||||
$turnRows[] = [
|
$turnRows[] = [
|
||||||
'general_id'=>$generalID,
|
'general_id'=>$generalID,
|
||||||
'turn_idx'=>$turnIdx,
|
'turn_idx'=>$turnIdx,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ function genChiefTableObj(){
|
|||||||
var $name = $plate.find('.chiefName');
|
var $name = $plate.find('.chiefName');
|
||||||
var turn = [];
|
var turn = [];
|
||||||
for(var turnIdx=0;turnIdx<maxChiefTurn;turnIdx++){
|
for(var turnIdx=0;turnIdx<maxChiefTurn;turnIdx++){
|
||||||
var $turn = $plate.find('.turn{0}'.format(turnIdx+1));
|
var $turn = $plate.find('.turn{0}'.format(turnIdx));
|
||||||
var $turnTime = $turn.find('.chiefTurnTime');
|
var $turnTime = $turn.find('.chiefTurnTime');
|
||||||
var $turnPad = $turn.find('.chiefTurnPad');
|
var $turnPad = $turn.find('.chiefTurnPad');
|
||||||
var $turnText = $turn.find('.chiefTurnText');
|
var $turnText = $turn.find('.chiefTurnText');
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class che_거병 extends Command\GeneralCommand{
|
|||||||
|
|
||||||
$turnRows = [];
|
$turnRows = [];
|
||||||
foreach([12, 11] as $chiefLevel){
|
foreach([12, 11] as $chiefLevel){
|
||||||
foreach(range(0, GameConst::$maxChiefTurn - 1) as $turnIdx){
|
foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx){
|
||||||
$turnRows[] = [
|
$turnRows[] = [
|
||||||
'nation_id'=>$nationID,
|
'nation_id'=>$nationID,
|
||||||
'level'=>$chiefLevel,
|
'level'=>$chiefLevel,
|
||||||
|
|||||||
@@ -275,12 +275,12 @@ class che_불가침제의 extends Command\NationCommand{
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>에게
|
</select>에게
|
||||||
<select class='formInput' name="year" id="year" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="year" id="year" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach(range($currYear+1, $currYear+20) as $formYear): ?>
|
<?php foreach(Util::range($currYear+1, $currYear+20+1) as $formYear): ?>
|
||||||
<option value='<?=$formYear?>'><?=$formYear?></option>
|
<option value='<?=$formYear?>'><?=$formYear?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>년
|
</select>년
|
||||||
<select class='formInput' name="month" id="month" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="month" id="month" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach(range(1, 12) as $formMonth): ?>
|
<?php foreach(Util::range(1, 12+1) as $formMonth): ?>
|
||||||
<option value='<?=$formMonth?>'><?=$formMonth?></option>
|
<option value='<?=$formMonth?>'><?=$formMonth?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>월 전까지
|
</select>월 전까지
|
||||||
|
|||||||
@@ -255,12 +255,12 @@ class che_원조 extends Command\NationCommand{
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
국고 <select class='formInput' name="amountList[]" class="amountList" size='1' style='color:white;background-color:black;'>
|
국고 <select class='formInput' name="amountList[]" class="amountList" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach(range(0, $currentNationLevel) as $nationLevel): ?>
|
<?php foreach(Util::range($currentNationLevel+1) as $nationLevel): ?>
|
||||||
<option value='<?=$nationLevel*GameConst::$coefAidAmount?>'><?=$nationLevel*GameConst::$coefAidAmount?></option>
|
<option value='<?=$nationLevel*GameConst::$coefAidAmount?>'><?=$nationLevel*GameConst::$coefAidAmount?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
병량 <select class='formInput' name="amountList[]" class="amountList" size='1' style='color:white;background-color:black;'>
|
병량 <select class='formInput' name="amountList[]" class="amountList" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach(range(0, $currentNationLevel) as $nationLevel): ?>
|
<?php foreach(Util::range($currentNationLevel+1) as $nationLevel): ?>
|
||||||
<option value='<?=$nationLevel*GameConst::$coefAidAmount?>'><?=$nationLevel*GameConst::$coefAidAmount?></option>
|
<option value='<?=$nationLevel*GameConst::$coefAidAmount?>'><?=$nationLevel*GameConst::$coefAidAmount?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ class General implements iAction{
|
|||||||
$rawCmds = $db->queryFirstRow('SELECT * FROM general_turn WHERE general_id = %i AND %i <= turn_idx AND turn_idx < %i ORDER BY turn_idx ASC', $generalID, $turnIdxFrom, $turnIdxTo);
|
$rawCmds = $db->queryFirstRow('SELECT * FROM general_turn WHERE general_id = %i AND %i <= turn_idx AND turn_idx < %i ORDER BY turn_idx ASC', $generalID, $turnIdxFrom, $turnIdxTo);
|
||||||
|
|
||||||
if(!$rawCmds){
|
if(!$rawCmds){
|
||||||
foreach(range($turnIdxFrom, $turnIdxTo-1) as $turnIdx){
|
foreach(Util::range($turnIdxFrom, $turnIdxTo) as $turnIdx){
|
||||||
$result[$turnIdx] = buildGeneralCommandClass(null, $this, $env);
|
$result[$turnIdx] = buildGeneralCommandClass(null, $this, $env);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
@@ -1025,7 +1025,7 @@ class General implements iAction{
|
|||||||
$generalID = $general->getID();
|
$generalID = $general->getID();
|
||||||
$result[$generalID] = [];
|
$result[$generalID] = [];
|
||||||
if(!key_exists($generalID, $orderedRawCmds)){
|
if(!key_exists($generalID, $orderedRawCmds)){
|
||||||
foreach(range($turnIdxFrom, $turnIdxTo-1) as $turnIdx){
|
foreach(Util::range($turnIdxFrom, $turnIdxTo) as $turnIdx){
|
||||||
$result[$generalID][$turnIdx] = buildGeneralCommandClass(null, $general, $env);
|
$result[$generalID][$turnIdx] = buildGeneralCommandClass(null, $general, $env);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -455,6 +455,10 @@ class GeneralAI
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(!$generalCadidates){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if(count($this->supplyCities) == 1){
|
if(count($this->supplyCities) == 1){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1887,7 +1891,7 @@ class GeneralAI
|
|||||||
$generalID = $general->getID();
|
$generalID = $general->getID();
|
||||||
|
|
||||||
$cmd = buildGeneralCommandClass('che_집합', $general, $this->env);
|
$cmd = buildGeneralCommandClass('che_집합', $general, $this->env);
|
||||||
_setGeneralCommand($generalID, range(0, GameConst::$maxTurn - 1), $cmd->getRawClassName(), $cmd->getArg(), $cmd->getBrief());
|
_setGeneralCommand($generalID, iterator_to_array(Util::range(GameConst::$maxTurn)), $cmd->getRawClassName(), $cmd->getArg(), $cmd->getBrief());
|
||||||
|
|
||||||
return $cmd;
|
return $cmd;
|
||||||
}
|
}
|
||||||
@@ -3538,7 +3542,7 @@ class GeneralAI
|
|||||||
$iterCandChiefStrength = new \ArrayIterator($candChiefStrength);
|
$iterCandChiefStrength = new \ArrayIterator($candChiefStrength);
|
||||||
$iterCandChiefIntel = new \ArrayIterator($candChiefIntel);
|
$iterCandChiefIntel = new \ArrayIterator($candChiefIntel);
|
||||||
|
|
||||||
foreach (range(10, $minChiefLevel, -1) as $chiefLevel) {
|
foreach (Util::range(10, $minChiefLevel-1, -1) as $chiefLevel) {
|
||||||
if (key_exists($chiefLevel, $chiefCandidate)) {
|
if (key_exists($chiefLevel, $chiefCandidate)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class ResetHelper{
|
|||||||
]);
|
]);
|
||||||
$generalID = $db->insertId();
|
$generalID = $db->insertId();
|
||||||
$turnRows = [];
|
$turnRows = [];
|
||||||
foreach(range(0, GameConst::$maxTurn - 1) as $turnIdx){
|
foreach(Util::range(GameConst::$maxTurn) as $turnIdx){
|
||||||
$turnRows[] = [
|
$turnRows[] = [
|
||||||
'general_id'=>$generalID,
|
'general_id'=>$generalID,
|
||||||
'turn_idx'=>$turnIdx,
|
'turn_idx'=>$turnIdx,
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ class NPC{
|
|||||||
]);
|
]);
|
||||||
$this->generalID = $db->insertId();
|
$this->generalID = $db->insertId();
|
||||||
$turnRows = [];
|
$turnRows = [];
|
||||||
foreach(range(0, GameConst::$maxTurn - 1) as $turnIdx){
|
foreach(Util::range(GameConst::$maxTurn) as $turnIdx){
|
||||||
$turnRows[] = [
|
$turnRows[] = [
|
||||||
'general_id'=>$this->generalID,
|
'general_id'=>$this->generalID,
|
||||||
'turn_idx'=>$turnIdx,
|
'turn_idx'=>$turnIdx,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\Scenario;
|
namespace sammo\Scenario;
|
||||||
use \sammo\DB;
|
use \sammo\DB;
|
||||||
use \sammo\GameConst;
|
use \sammo\GameConst;
|
||||||
|
use \sammo\Util;
|
||||||
use function \sammo\getNationChiefLevel;
|
use function \sammo\getNationChiefLevel;
|
||||||
|
|
||||||
class Nation{
|
class Nation{
|
||||||
@@ -150,8 +151,8 @@ class Nation{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$turnRows = [];
|
$turnRows = [];
|
||||||
foreach(range(getNationChiefLevel(0) - 1, getNationChiefLevel($this->nationLevel), -1) as $chiefLevel){
|
foreach(Util::range(12, getNationChiefLevel($this->nationLevel)-1, -1) as $chiefLevel){
|
||||||
foreach(range(0, GameConst::$maxChiefTurn - 1) as $turnIdx){
|
foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx){
|
||||||
$turnRows[] = [
|
$turnRows[] = [
|
||||||
'nation_id'=>$this->id,
|
'nation_id'=>$this->id,
|
||||||
'level'=>$chiefLevel,
|
'level'=>$chiefLevel,
|
||||||
@@ -162,7 +163,7 @@ class Nation{
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->insert('nation_turn', $turnRows);
|
$db->insertIgnore('nation_turn', $turnRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrief(){
|
public function getBrief(){
|
||||||
|
|||||||
+36
-1
@@ -721,10 +721,45 @@ class Util extends \utilphp\util
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPowerOfTwo(int $number):bool{
|
public static function isPowerOfTwo(int $number):bool{
|
||||||
if($number <= 0){
|
if($number <= 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ($number & ($number - 1)) == 0;
|
return ($number & ($number - 1)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Python 3의 range와 동일
|
||||||
|
* @param int $from
|
||||||
|
* @param null|int $to
|
||||||
|
* @param null|int $step
|
||||||
|
* @return \Traversable
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public static function range(int $from, ?int $to=null, ?int $step=null):\Traversable{
|
||||||
|
if($to === null){
|
||||||
|
$to = $from;
|
||||||
|
$from = 0;
|
||||||
|
}
|
||||||
|
if($step === null){
|
||||||
|
$step = 1;
|
||||||
|
}
|
||||||
|
else if($step === 0){
|
||||||
|
throw new \InvalidArgumentException('xrange() arg 3 must not be zero');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($step > 0){
|
||||||
|
while($from < $to){
|
||||||
|
yield $from;
|
||||||
|
$from += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
while($from > $to){
|
||||||
|
yield $from;
|
||||||
|
$from -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user