Util::range 추가

This commit is contained in:
2020-04-09 02:07:50 +09:00
parent d540cd0a77
commit 09d28eff90
18 changed files with 77 additions and 43 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ class che_거병 extends Command\GeneralCommand{
$turnRows = [];
foreach([12, 11] as $chiefLevel){
foreach(range(0, GameConst::$maxChiefTurn - 1) as $turnIdx){
foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx){
$turnRows[] = [
'nation_id'=>$nationID,
'level'=>$chiefLevel,
@@ -275,12 +275,12 @@ class che_불가침제의 extends Command\NationCommand{
<?php endforeach; ?>
</select>에게
<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>
<?php endforeach; ?>
</select>년
<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>
<?php endforeach; ?>
</select>월 전까지
+2 -2
View File
@@ -255,12 +255,12 @@ class che_원조 extends Command\NationCommand{
<?php endforeach; ?>
</select>
국고 <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>
<?php endforeach; ?>
</select>
병량 <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>
<?php endforeach; ?>
</select>
+2 -2
View File
@@ -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);
if(!$rawCmds){
foreach(range($turnIdxFrom, $turnIdxTo-1) as $turnIdx){
foreach(Util::range($turnIdxFrom, $turnIdxTo) as $turnIdx){
$result[$turnIdx] = buildGeneralCommandClass(null, $this, $env);
}
return $result;
@@ -1025,7 +1025,7 @@ class General implements iAction{
$generalID = $general->getID();
$result[$generalID] = [];
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);
}
continue;
+7 -3
View File
@@ -455,6 +455,10 @@ class GeneralAI
}
});
if(!$generalCadidates){
return null;
}
if(count($this->supplyCities) == 1){
return null;
}
@@ -566,7 +570,7 @@ class GeneralAI
if (in_array($this->dipState, [self::d평화, self::d선포])) {
return null;
}
//고립 도시 장수 발령
$args = [];
foreach ($this->lostGenerals as $lostGeneral) {
@@ -1887,7 +1891,7 @@ class GeneralAI
$generalID = $general->getID();
$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;
}
@@ -3538,7 +3542,7 @@ class GeneralAI
$iterCandChiefStrength = new \ArrayIterator($candChiefStrength);
$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)) {
continue;
}
+1 -1
View File
@@ -272,7 +272,7 @@ class ResetHelper{
]);
$generalID = $db->insertId();
$turnRows = [];
foreach(range(0, GameConst::$maxTurn - 1) as $turnIdx){
foreach(Util::range(GameConst::$maxTurn) as $turnIdx){
$turnRows[] = [
'general_id'=>$generalID,
'turn_idx'=>$turnIdx,
+1 -1
View File
@@ -347,7 +347,7 @@ class NPC{
]);
$this->generalID = $db->insertId();
$turnRows = [];
foreach(range(0, GameConst::$maxTurn - 1) as $turnIdx){
foreach(Util::range(GameConst::$maxTurn) as $turnIdx){
$turnRows[] = [
'general_id'=>$this->generalID,
'turn_idx'=>$turnIdx,
+4 -3
View File
@@ -2,6 +2,7 @@
namespace sammo\Scenario;
use \sammo\DB;
use \sammo\GameConst;
use \sammo\Util;
use function \sammo\getNationChiefLevel;
class Nation{
@@ -150,8 +151,8 @@ class Nation{
}
$turnRows = [];
foreach(range(getNationChiefLevel(0) - 1, getNationChiefLevel($this->nationLevel), -1) as $chiefLevel){
foreach(range(0, GameConst::$maxChiefTurn - 1) as $turnIdx){
foreach(Util::range(12, getNationChiefLevel($this->nationLevel)-1, -1) as $chiefLevel){
foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx){
$turnRows[] = [
'nation_id'=>$this->id,
'level'=>$chiefLevel,
@@ -162,7 +163,7 @@ class Nation{
];
}
}
$db->insert('nation_turn', $turnRows);
$db->insertIgnore('nation_turn', $turnRows);
}
public function getBrief(){