diff --git a/hwe/_119_b.php b/hwe/_119_b.php
index e0042ce8..15f17f86 100644
--- a/hwe/_119_b.php
+++ b/hwe/_119_b.php
@@ -101,15 +101,16 @@ case "쌀지급":
processRiceIncome();
break;
case "락걸기":
- $db->update('plock', [
- 'plock'=>1,
- 'locktime'=>TimeUtil::now(true)
- ], true);
+ for($i = 0; $i < 10; $i++){
+ if(tryLock()){
+ $locked = true;
+ break;
+ }
+ usleep(500000);
+ }
break;
case "락풀기":
- $db->update('plock', [
- 'plock'=>0
- ], true);
+ unlock();
break;
}
diff --git a/hwe/b_betting.php b/hwe/b_betting.php
index f3d2040c..ab9acdca 100644
--- a/hwe/b_betting.php
+++ b/hwe/b_betting.php
@@ -393,31 +393,84 @@ if ($admin['tournament'] == 6) {
[
+ '종합',
+ function(General $general){return $general->getVar('leadership')+$general->getVar('strength')+$general->getVar('intel');},
+ 'tt',
+ ],
+ '통 솔 전'=>[
+ '통솔',
+ function(General $general){return $general->getVar('leadership');},
+ 'tl',
+ ],
+ '일 기 토'=>[
+ '무력',
+ function(General $general){return $general->getVar('strength');},
+ 'ts',
+ ],
+ '설 전'=>[
+ '지력',
+ function(General $general){return $general->getVar('intel');},
+ 'ti',
+ ],
+];
+
$type1 = array("전 력 전", "통 솔 전", "일 기 토", "설 전");
$type2 = array("종합", "통솔", "무력", "지력");
$type3 = array("tt", "tl", "ts", "ti");
$type4 = array("total", "leadership", "strength", "intel");
-for ($i=0; $i < 4; $i++) {
- $grp = $i;
- echo "
+foreach($tournamentType as $tournamentTypeText=>[$statTypeText,$statFunc,$rankColumn]): ?>
- | {$type1[$i]} |
- | 순 | 장수 | {$type2[$i]} | 경 | 승 | 무 | 패 | 점 | 勝 | ";
-
- $query = "select npc,name,leadership,strength,intel,leadership+strength+intel as total,{$type3[$i]}p as prize,{$type3[$i]}w+{$type3[$i]}d+{$type3[$i]}l as game,{$type3[$i]}w as win,{$type3[$i]}d as draw,{$type3[$i]}l as lose,{$type3[$i]}g as gl from general order by gl desc, game desc, win desc, draw desc, lose, no limit 0,30";
- $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
- for ($k=1; $k <= 30; $k++) {
- $general = MYDB_fetch_array($result);
- printRow($k, $general['npc'], $general['name'], $general[$type4[$i]], $general['game'], $general['win'], $general['draw'], $general['lose'], $general['gl'], $general['prize'], 0);
+ | =$tournamentTypeText?> |
+ | 순 | 장수 | =$statTypeText?> | 경 | 승 | 무 | 패 | 점 | 勝 |
+queryFirstColumn('SELECT general_id FROM rank_data WHERE `type`= %s ORDER BY value DESC LIMIT 40', $gameColumn),
+ [$prizeColumn, $gameColumn, $winColumn, $drawColumn, $loseColumn,'leadership', 'strength', 'intel', 'no', 'npc', 'name'],
+ 0
+ );
+ usort($tournamentRankerList, function(General $lhs, General $rhs) use($gameColumn, $winColumn, $drawColumn, $loseColumn){
+ $result = -($lhs->getRankVar($gameColumn) <=> $rhs->getRankVar($gameColumn));
+ if($result !== 0) return $result;
+ $result = -(
+ ($lhs->getRankVar($winColumn)+$lhs->getRankVar($drawColumn)+$lhs->getRankVar($loseColumn))
+ <=>
+ ($rhs->getRankVar($winColumn)+$rhs->getRankVar($drawColumn)+$rhs->getRankVar($loseColumn))
+ );
+ if($result !== 0) return $result;
+ $result = -($lhs->getRankVar($winColumn) <=> $rhs->getRankVar($winColumn));
+ if($result !== 0) return $result;
+ $result = -($lhs->getRankVar($drawColumn) <=> $rhs->getRankVar($drawColumn));
+ if($result !== 0) return $result;
+ return $lhs->getRankVar($loseColumn) <=> $rhs->getRankVar($loseColumn);
+ });
+ $tournamentRankerList = array_splice($tournamentRankerList, 0, 30);
+ foreach($tournamentRankerList as $rank=>$ranker){
+ printRow(
+ $rank+1,
+ $ranker->getVar('npc'),
+ $ranker->getName(),
+ ($statFunc)($ranker),
+ $ranker->getRankVar($winColumn)+$ranker->getRankVar($drawColumn)+$ranker->getRankVar($loseColumn),
+ $ranker->getRankVar($winColumn),
+ $ranker->getRankVar($drawColumn),
+ $ranker->getRankVar($loseColumn),
+ $ranker->getRankVar($gameColumn),
+ $ranker->getRankVar($prizeColumn),
+ 0
+ );
}
- echo "
-
- | ";
-}
-
?>
+
+
|
diff --git a/hwe/func.php b/hwe/func.php
index 2016b8b2..0e1021a5 100644
--- a/hwe/func.php
+++ b/hwe/func.php
@@ -1733,11 +1733,11 @@ function calcCityDistance(int $from, int $to, ?array $linkNationList):?int{
$db = DB::db();
//TODO: 도시-국가 캐싱이 있으면 쓸모 있지 않을까
$allowedCityList = [];
- foreach($db->queryAllLists(
+ foreach($db->queryFirstColumn(
'SELECT city FROM city WHERE nation IN %li',
$linkNationList
- ) as [$cityID, $nationID]){
- $allowedCityList[$cityID] = $nationID;
+ ) as $cityID){
+ $allowedCityList[$cityID] = $cityID;
}
diff --git a/hwe/func_tournament.php b/hwe/func_tournament.php
index 4b2cc874..dffac605 100644
--- a/hwe/func_tournament.php
+++ b/hwe/func_tournament.php
@@ -979,7 +979,7 @@ function fight($tnmt_type, $tnmt, $phs, $group, $g1, $g2, $type) {
} else {
$ratio = rand() % 1000;
if($critical1 == 0 && $gen1[$tp] >= $ratio) {
- $damage2 *= Util::round((rand() % 151 + 150) / 100); // 150 ~ 300%
+ $damage2 *= Util::randRangeInt(150, 300) / 100; // 150 ~ 300%
$critical1 = 1;
if ($tnmt_type == 0) { switch(rand()%6) { case 0: $str = "참격"; break; case 1: $str = "집중"; break; case 2: $str = "역공"; break; case 3: $str = "반격"; break; case 4: $str = "선제"; break; case 5: $str = "도발"; break; } }
elseif($tnmt_type == 1) { switch(rand()%6) { case 0: $str = "추행진"; break; case 1: $str = "학익진"; break; case 2: $str = "장사진"; break; case 3: $str = "형액진"; break; case 4: $str = "기형진"; break; case 5: $str = "구행진"; break; } }
@@ -989,7 +989,7 @@ function fight($tnmt_type, $tnmt, $phs, $group, $g1, $g2, $type) {
}
$ratio = rand() % 1000;
if($critical2 == 0 && $gen2[$tp] >= $ratio) {
- $damage1 *= Util::round((rand() % 151 + 150) / 100); // 150 ~ 300%
+ $damage1 *= Util::randRangeInt(150, 300) / 100; // 150 ~ 300%
$critical2 = 1;
if ($tnmt_type == 0) { switch(rand()%6) { case 0: $str = "참격"; break; case 1: $str = "집중"; break; case 2: $str = "역공"; break; case 3: $str = "반격"; break; case 4: $str = "선제"; break; case 5: $str = "도발"; break; } }
elseif($tnmt_type == 1) { switch(rand()%6) { case 0: $str = "추행진"; break; case 1: $str = "학익진"; break; case 2: $str = "장사진"; break; case 3: $str = "형액진"; break; case 4: $str = "기형진"; break; case 5: $str = "구행진"; break; } }
@@ -999,6 +999,9 @@ function fight($tnmt_type, $tnmt, $phs, $group, $g1, $g2, $type) {
}
}
+ Util::setRound($damage1);
+ Util::setRound($damage2);
+
$energy1 -= $damage1;
$energy2 -= $damage2;
$tDamage1 = $damage1; $tDamage2 = $damage2;
diff --git a/hwe/join.php b/hwe/join.php
index 1e21607b..acf84563 100644
--- a/hwe/join.php
+++ b/hwe/join.php
@@ -43,7 +43,7 @@ var charInfoText = getInfo();
- $charInfoText[$personalityID];
+ $charInfoText[$personalityID] = $personalityInfo;
}
echo Json::encode((object)$charInfoText);
?>;
diff --git a/hwe/sammo/Command/General/che_인재탐색.php b/hwe/sammo/Command/General/che_인재탐색.php
index e656a7a6..b556eed2 100644
--- a/hwe/sammo/Command/General/che_인재탐색.php
+++ b/hwe/sammo/Command/General/che_인재탐색.php
@@ -108,6 +108,9 @@ class che_인재탐색 extends Command\GeneralCommand{
$currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2);
$remainSlot = $maxGenCnt - $currCnt;
+ if($remainSlot < 0){
+ $remainSlot = 0;
+ }
$avgCnt = $currCnt / $nationCnt;
diff --git a/hwe/sammo/Command/Nation/che_천도.php b/hwe/sammo/Command/Nation/che_천도.php
index e79a2371..a2479150 100644
--- a/hwe/sammo/Command/Nation/che_천도.php
+++ b/hwe/sammo/Command/Nation/che_천도.php
@@ -205,7 +205,7 @@ class che_천도 extends Command\NationCommand{
'capset' => $db->sqleval('capset + 1'),
], 'nation=%i', $nationID);
- $logger->pushGeneralActionLog("{$destCityName}>{$josaRo} 천도했습니다. <1>$date");
+ $logger->pushGeneralActionLog("{$destCityName}>{$josaRo} 천도했습니다. <1>$date>");
$logger->pushGeneralHistoryLog("{$destCityName}>{$josaRo} 천도>명령");
$logger->pushNationalHistoryLog("{$generalName}>{$josaYi} {$destCityName}>{$josaRo} 천도> 명령");
$logger->pushGlobalActionLog("{$generalName}>{$josaYi} {$destCityName}>{$josaRo} 천도>를 명령하였습니다.");
diff --git a/hwe/sammo/Command/Nation/che_허보.php b/hwe/sammo/Command/Nation/che_허보.php
index f76ccd32..ae49a405 100644
--- a/hwe/sammo/Command/Nation/che_허보.php
+++ b/hwe/sammo/Command/Nation/che_허보.php
@@ -31,6 +31,9 @@ class che_허보 extends Command\NationCommand{
static public $reqArg = true;
protected function argTest():bool{
+ if($this->arg === null){
+ return null;
+ }
if(!key_exists('destCityID', $this->arg)){
return false;
}
diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php
index 287551bb..13d19365 100644
--- a/hwe/sammo/General.php
+++ b/hwe/sammo/General.php
@@ -44,8 +44,10 @@ class General implements iAction{
const RANK_COLUMN = [
'firenum'=>1, 'warnum'=>1, 'killnum'=>1, 'deathnum'=>1, 'killcrew'=>1, 'deathcrew'=>1,
- 'ttw'=>1, 'ttd'=>1, 'ttl'=>1, 'ttg'=>1, 'ttp'=>1, 'tlw'=>1, 'tld'=>1, 'tll'=>1, 'tlg'=>1, 'tlp'=>1,
- 'tsw'=>1, 'tsd'=>1, 'tsl'=>1, 'tsg'=>1, 'tsp'=>1, 'tiw'=>1, 'tid'=>1, 'til'=>1, 'tig'=>1, 'tip'=>1,
+ 'ttw'=>1, 'ttd'=>1, 'ttl'=>1, 'ttg'=>1, 'ttp'=>1,
+ 'tlw'=>1, 'tld'=>1, 'tll'=>1, 'tlg'=>1, 'tlp'=>1,
+ 'tsw'=>1, 'tsd'=>1, 'tsl'=>1, 'tsg'=>1, 'tsp'=>1,
+ 'tiw'=>1, 'tid'=>1, 'til'=>1, 'tig'=>1, 'tip'=>1,
'betwin'=>1, 'betgold'=>1, 'betwingold'=>1,
];
@@ -97,6 +99,10 @@ class General implements iAction{
$this->initLogger($year, $month);
}
+ if($rawRank){
+ $this->rankVarRead = $rawRank;
+ }
+
if(!$fullConstruct){
return;
}
@@ -113,10 +119,6 @@ class General implements iAction{
$this->itemObjs['weapon'] = buildItemClass($raw['weapon']);
$this->itemObjs['book'] = buildItemClass($raw['book']);
$this->itemObjs['item'] = buildItemClass($raw['item']);
-
- if($rawRank){
- $this->rankVarRead = $rawRank;
- }
}
function initLogger(int $year, int $month){
@@ -978,7 +980,10 @@ class General implements iAction{
$result[$generalID] = new DummyGeneral($constructMode > 0);
continue;
}
- $result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID], null, $year, $month, $constructMode > 1);
+ if(key_exists($generalID, $rawRanks) && count($rawRanks[$generalID]??[]) !== count($rankColumn)){
+ throw new \RuntimeException('column의 수가 일치하지 않음 : '.$generalID);
+ }
+ $result[$generalID] = new static($rawGenerals[$generalID], $rawRanks[$generalID]??null, null, $year, $month, $constructMode > 1);
}
return $result;
diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php
index 821cf1e8..f2c13706 100644
--- a/hwe/sammo/GeneralAI.php
+++ b/hwe/sammo/GeneralAI.php
@@ -453,10 +453,10 @@ class GeneralAI
if($generalID == $this->general->getID()){
continue;
}
- $city = $this->supplyCities[$userGeneral->getCityID()];
- if(!key_exists($generalID, $this->supplyCities)){
+ if(!key_exists($userGeneral->getCityID(), $this->supplyCities)){
continue;
}
+ $city = $this->supplyCities[$userGeneral->getCityID()];
$troopLeaderID = $userGeneral->getVar('troop');
if(!$troopLeaderID || !key_exists($troopLeaderID, $this->troopLeaders)){
continue;
@@ -559,10 +559,10 @@ class GeneralAI
if($generalID == $this->general->getID()){
continue;
}
- $city = $this->supplyCities[$userGeneral->getCityID()];
- if(!key_exists($generalID, $this->supplyCities)){
+ if(!key_exists($userGeneral->getCityID(), $this->supplyCities)){
continue;
}
+ $city = $this->supplyCities[$userGeneral->getCityID()];
if($userGeneral->getVar('troop') !== 0){
continue;
}
@@ -1057,7 +1057,7 @@ class GeneralAI
}
$crewtype = $targetUserGeneral->getCrewTypeObj();
- $reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetUserGeneral->getLeadership()) * 2 * 4 * 1.1;
+ $reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetUserGeneral->getLeadership(false)) * 2 * 4 * 1.1;
if ($this->env['year'] > $this->env['startyear'] + 5) {
$reqMoney = max($reqMoney, $reqHumanMinRes);
}
@@ -1157,7 +1157,7 @@ class GeneralAI
}
$crewtype = $targetUserGeneral->getCrewTypeObj();
- $reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetUserGeneral->getLeadership()) * 2 * 4 * 1.1;
+ $reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetUserGeneral->getLeadership(false)) * 2 * 4 * 1.1;
if ($this->env['year'] > $this->env['startyear'] + 5) {
$reqMoney = max($reqMoney, $reqHumanMinRes);
}
@@ -1239,7 +1239,7 @@ class GeneralAI
}
$crewtype = $targetNPCGeneral->getCrewTypeObj();
- $reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetNPCGeneral->getLeadership()) * 2 * 4 * 1.1;
+ $reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetNPCGeneral->getLeadership(false)) * 2 * 4 * 1.1;
if ($this->env['year'] > $this->env['startyear'] + 5) {
$reqMoney = max($reqMoney, $reqNPCMinWarRes);
}
@@ -1325,7 +1325,7 @@ class GeneralAI
}
$crewtype = $targetNPCGeneral->getCrewTypeObj();
- $reqMoney = $crewtype->costWithTech($nation['tech'], $targetNPCGeneral->getLeadership()) * 2 * 4 * 1.1;
+ $reqMoney = $crewtype->costWithTech($nation['tech'], $targetNPCGeneral->getLeadership(false)) * 2 * 4 * 1.1;
if ($this->env['year'] > $this->env['startyear'] + 5) {
$reqMoney = max($reqMoney, $reqNPCMinWarRes);
}
@@ -2995,7 +2995,7 @@ class GeneralAI
else{
$userCivilGenerals[$generalID] = $nationGeneral;
}
- } else if ($nationGeneral->getLeadership() >= $this->nationPolicy->minNPCWarLeadership) {
+ } else if ($nationGeneral->getLeadership(false) >= $this->nationPolicy->minNPCWarLeadership) {
$npcWarGenerals[$generalID] = $nationGeneral;
} else {
$npcCivilGenerals[$generalID] = $nationGeneral;
|