diff --git a/LICENSE b/LICENSE
index f44828e6..774cd674 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2020 Hide_D, 62che
+Copyright (c) 2021 Hide_D, 62che
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/api.php b/api.php
new file mode 100644
index 00000000..a6d67bae
--- /dev/null
+++ b/api.php
@@ -0,0 +1,8 @@
+getMessage());
-}
-
-if (!key_exists('path', $input)) {
- Json::dieWithReason('path가 지정되지 않았습니다.');
-}
-
-if (key_exists('args', $input) && !is_array($input['args'])) {
- Json::dieWithReason('args가 array가 아닙니다.' . gettype($input['args']));
-}
-
-try {
- $obj = buildAPIExecutorClass($input['path'], $input['args'] ?? []);
- $api =
- $validateResult = $obj->validateArgs();
- if ($validateResult !== null) {
- Json::dieWithReason($validateResult);
- }
-
- $sessionMode = $obj->getRequiredSessionMode();
- if ($sessionMode === BaseAPI::NO_SESSION) {
- $session = null;
- } else {
- if ($sessionMode & BaseAPI::REQ_GAME_LOGIN) {
- $session = Session::requireGameLogin();
- } else if ($sessionMode & BaseAPI::REQ_LOGIN) {
- $session = Session::requireLogin();
- } else {
- Json::dieWithReason("올바르지 않은 SessionMode: {$sessionMode}");
- }
-
- if ($sessionMode & BaseAPI::REQ_READ_ONLY) {
- $session->setReadOnly();
- }
- }
-
- $modifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
- ? new \DateTimeImmutable($_SERVER['HTTP_IF_MODIFIED_SINCE'], new \DateTimeZone("UTC"))
- : null;
- $reqEtags = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : null;
-
- $result = $obj->launch($session, $modifiedSince, $reqEtags);
- if (is_string($result)) {
- Json::dieWithReason($result);
- }
-
- $cacheResult = $obj->tryCache();
- if ($cacheResult !== null) {
- /** @var \DateTimeInterface $lastModified */
- [$lastModified, $etag] = $cacheResult;
-
- if ($lastModified !== null) {
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", TimeUtil::DateTimeToSeconds($lastModified, true)) . " GMT");
- }
- if ($etag !== null) {
- header("Etag: $etag");
- }
-
- if ($modifiedSince !== null && $lastModified !== null && TimeUtil::DateIntervalToSeconds($modifiedSince->diff($lastModified)) == 0) {
- header("HTTP/1.1 304 Not Modified");
- die();
- }
- if ($reqEtags !== null && $reqEtags === $etag) {
- header("HTTP/1.1 304 Not Modified");
- die();
- }
- }
-
- if ($result === null) {
- Json::die([
- 'result' => true,
- 'reason' => 'success'
- ], $cacheResult === null ? Json::NO_CACHE : 0);
- }
- Json::die($result, $cacheResult === null ? Json::NO_CACHE : 0);
-} catch (\Exception $e) {
- Json::dieWithReason($e->getMessage());
-} catch (mixed $e) {
- Json::dieWithReason($e);
-}
+APIHelper::launch(dirname(__FILE__));
\ No newline at end of file
diff --git a/hwe/func.php b/hwe/func.php
index 68ac8331..24d3a532 100644
--- a/hwe/func.php
+++ b/hwe/func.php
@@ -2,6 +2,7 @@
namespace sammo;
+use DateTime;
use sammo\Event\Action;
require_once 'process_war.php';
@@ -189,7 +190,7 @@ function myNationInfo(General $generalObj)
$templates = new \League\Plates\Engine(__DIR__ . '/templates');
$nationID = $generalObj->getNationID();
- $nation = $db->queryFirstRow('SELECT * FROM nation WHERE nation = %i', $nationID)??getNationStaticInfo(0);
+ $nation = $db->queryFirstRow('SELECT * FROM nation WHERE nation = %i', $nationID) ?? getNationStaticInfo(0);
$city = $db->queryFirstRow(
'SELECT COUNT(*) as cnt, SUM(pop) as totpop, SUM(pop_max) as maxpop from city where nation=%i',
$nationID
@@ -198,16 +199,16 @@ function myNationInfo(General $generalObj)
$topChiefs = Util::convertArrayToDict($db->query('SELECT officer_level, no, name, npc FROM general WHERE nation = %i AND officer_level >= 11', $nationID), 'officer_level');
- $level12Name = key_exists(12, $topChiefs)?getColoredName($topChiefs[12]['name'], $topChiefs[12]['npc']):'-';
- $level11Name = key_exists(11, $topChiefs)?getColoredName($topChiefs[11]['name'], $topChiefs[11]['npc']):'-';
+ $level12Name = key_exists(12, $topChiefs) ? getColoredName($topChiefs[12]['name'], $topChiefs[12]['npc']) : '-';
+ $level11Name = key_exists(11, $topChiefs) ? getColoredName($topChiefs[11]['name'], $topChiefs[11]['npc']) : '-';
$impossibleStrategicCommandLists = [];
$strategicCommandLists = GameConst::$availableChiefCommand['전략'];
$yearMonth = Util::joinYearMonth($admin['year'], $admin['month']);
- foreach($strategicCommandLists as $command){
+ foreach ($strategicCommandLists as $command) {
$cmd = buildNationCommandClass($command, $generalObj, $admin, new LastTurn());
$nextAvailableTurn = $cmd->getNextAvailableTurn();
- if($nextAvailableTurn > $yearMonth){
+ if ($nextAvailableTurn > $yearMonth) {
$impossibleStrategicCommandLists[] = [$cmd->getName(), $nextAvailableTurn - $yearMonth];
}
}
@@ -239,28 +240,28 @@ function myNationInfo(General $generalObj)
| 총주민 |
";
- echo $nationID===0 ? "해당 없음" : "{$city['totpop']}/{$city['maxpop']}";
+ echo $nationID === 0 ? "해당 없음" : "{$city['totpop']}/{$city['maxpop']}";
echo " |
총병사 |
";
- echo $nationID===0 ? "해당 없음" : "{$general['totcrew']}/{$general['maxcrew']}";
+ echo $nationID === 0 ? "해당 없음" : "{$general['totcrew']}/{$general['maxcrew']}";
echo " |
| 국 고 |
";
- echo $nationID===0 ? "해당 없음" : "{$nation['gold']}";
+ echo $nationID === 0 ? "해당 없음" : "{$nation['gold']}";
echo " |
병 량 |
";
- echo $nationID===0 ? "해당 없음" : "{$nation['rice']}";
+ echo $nationID === 0 ? "해당 없음" : "{$nation['rice']}";
echo " |
| 지급률 |
";
- if ($nationID===0) {
+ if ($nationID === 0) {
echo "해당 없음";
} else {
echo $nation['bill'] == 0 ? "0 %" : "{$nation['bill']} %";
@@ -269,7 +270,7 @@ function myNationInfo(General $generalObj)
|
세 율 |
";
- if ($nationID===0) {
+ if ($nationID === 0) {
echo "해당 없음";
} else {
echo $nation['rate'] == 0 ? "0 %" : "{$nation['rate']} %";
@@ -285,7 +286,7 @@ function myNationInfo(General $generalObj)
$nation['tech'] = "$techCall / {$nation['tech']}";
- if ($nationID===0) {
+ if ($nationID === 0) {
$nation['strategic_cmd_limit'] = "해당 없음";
$nation['surlimit'] = "해당 없음";
$nation['scout'] = "해당 없음";
@@ -294,20 +295,20 @@ function myNationInfo(General $generalObj)
} else {
if ($nation['strategic_cmd_limit'] != 0) {
$nation['strategic_cmd_limit'] = "{$nation['strategic_cmd_limit']}턴";
- } else if($impossibleStrategicCommandLists) {
+ } else if ($impossibleStrategicCommandLists) {
$nation['strategic_cmd_limit'] = "가 능";
- } else{
+ } else {
$nation['strategic_cmd_limit'] = "가 능";
}
- if($impossibleStrategicCommandLists){
+ if ($impossibleStrategicCommandLists) {
$text = [];
- foreach($impossibleStrategicCommandLists as [$cmdName, $remainTurn]){
+ foreach ($impossibleStrategicCommandLists as [$cmdName, $remainTurn]) {
$text[] = "{$cmdName}: {$remainTurn}턴 뒤";
}
$nation['strategic_cmd_limit'] = $templates->render('tooltip', [
- 'text'=>''.$nation['strategic_cmd_limit'].'',
- 'info'=>''.join(' ', $text).'',
+ 'text' => '' . $nation['strategic_cmd_limit'] . '',
+ 'info' => '' . join(' ', $text) . '',
]);
}
@@ -336,11 +337,11 @@ function myNationInfo(General $generalObj)
|
| 속 령 |
";
- echo $nationID===0 ? "-" : "{$city['cnt']}";
+ echo $nationID === 0 ? "-" : "{$city['cnt']}";
echo " |
장 수 |
";
- echo $nationID===0 ? "-" : "{$general['cnt']}";
+ echo $nationID === 0 ? "-" : "{$general['cnt']}";
echo " |
@@ -348,7 +349,7 @@ function myNationInfo(General $generalObj)
| {$nation['power']} |
기술력 |
";
- echo $nationID===0 ? "-" : "{$nation['tech']}";
+ echo $nationID === 0 ? "-" : "{$nation['tech']}";
echo " |
@@ -904,7 +905,7 @@ function nationMsg(General $general)
$nationID = $general->getNationID();
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
- return $nationStor->notice??'';
+ return $nationStor->notice ?? '';
}
function banner()
@@ -1227,13 +1228,13 @@ function updateOnline()
$onlineNum = count($onlineUser);
$onlineNationUsers = Util::arrayGroupBy($onlineUser, 'nation');
- uasort($onlineNationUsers, function(array $lhs, array $rhs){
- return -(count($lhs)<=>count($rhs));
+ uasort($onlineNationUsers, function (array $lhs, array $rhs) {
+ return - (count($lhs) <=> count($rhs));
});
$onlineNation = [];
- foreach($onlineNationUsers as $nationID=>$rawOnlineUser){
+ foreach ($onlineNationUsers as $nationID => $rawOnlineUser) {
$nationName = getNationStaticInfo($nationID)['name'];
$onlineNation[] = "【{$nationName}】";
$userList = join(', ', Util::squeezeFromArray($rawOnlineUser, 'name'));
@@ -1265,7 +1266,7 @@ function addAge()
$generalID = $general['no'];
$special = SpecialityHelper::pickSpecialDomestic(
$general,
- (Json::decode($general['aux'])['prev_types_special'])??[]
+ (Json::decode($general['aux'])['prev_types_special']) ?? []
);
$specialClass = buildGeneralSpecialDomesticClass($special);
$specialText = $specialClass->getName();
@@ -1282,16 +1283,26 @@ function addAge()
foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5,aux from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general) {
$generalID = $general['no'];
- $special2 = SpecialityHelper::pickSpecialWar(
- $general,
- (Json::decode($general['aux'])['prev_types_special2'])??[]
- );
+ $generalAux = Json::decode($general['aux']);
+
+ $updateVars = [];
+ if(key_exists('inheritSpecificSpecialWar', $generalAux)){
+ $special2 = $generalAux['inheritSpecificSpecialWar'];
+ unset($generalAux['inheritSpecificSpecialWar']);
+ $updateVars['aux'] = Json::encode($generalAux);
+ }
+ else{
+ $special2 = SpecialityHelper::pickSpecialWar(
+ $general,
+ ($generalAux['prev_types_special2']) ?? []
+ );
+ }
+
$specialClass = buildGeneralSpecialWarClass($special2);
$specialText = $specialClass->getName();
- $db->update('general', [
- 'special2' => $special2
- ], 'no=%i', $general['no']);
+ $updateVars['special2'] = $special2;
+ $db->update('general', $updateVars, 'no=%i', $general['no']);
$logger = new ActionLogger($generalID, $general['nation'], $year, $month);
@@ -1537,15 +1548,15 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool
$occupiedUnique = [];
$invalidItemType = [];
- foreach(array_keys(GameConst::$allItems) as $itemType){
- $ownItem = $general->getItems()[$itemType]??null;
- if($ownItem !== null && !$ownItem->isBuyable()){
+ foreach (array_keys(GameConst::$allItems) as $itemType) {
+ $ownItem = $general->getItems()[$itemType] ?? null;
+ if ($ownItem !== null && !$ownItem->isBuyable()) {
$invalidItemType[$itemType] = true;
}
}
foreach (array_keys(GameConst::$allItems) as $itemType) {
- if(key_exists($itemType, $invalidItemType)){
+ if (key_exists($itemType, $invalidItemType)) {
continue;
}
foreach ($db->queryAllLists('SELECT %b, count(*) as cnt FROM general GROUP BY %b', $itemType, $itemType) as [$itemCode, $cnt]) {
@@ -1561,11 +1572,11 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool
}
foreach (GameConst::$allItems as $itemType => $itemCategories) {
- if(key_exists($itemType, $invalidItemType)){
+ if (key_exists($itemType, $invalidItemType)) {
continue;
}
foreach ($itemCategories as $itemCode => $cnt) {
- if($cnt == 0){
+ if ($cnt == 0) {
continue;
}
if (!key_exists($itemCode, $occupiedUnique)) {
@@ -1607,6 +1618,192 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool
return true;
}
+function rollbackInheritUniqueTrial(General $general, string $itemKey, string $reason)
+{
+
+ $ownerID = $general->getVar('owner');
+
+ $db = DB::db();
+
+ $itemTrials = $general->getAuxVar('inheritUniqueTrial');
+ LogText("선택유니크 롤백:{$ownerID}", [$itemKey, $itemTrials]);
+ unset($itemTrials[$itemKey]);
+ $general->setAuxVar('inheritUniqueTrial', $itemTrials);
+
+
+ $trialStor = KVStorage::getStorage($db, "ut_{$itemKey}");
+ $ownTrial = $trialStor->getValue("u{$ownerID}");
+
+ if ($ownTrial) {
+ //두 값이 general, KVStorage 둘다 있고, 이중에선 KVStorage 값을 기준으로 하자 따르자
+ [,, $amount] = $ownTrial;
+ $trialStor->deleteValue("u{$ownerID}");
+ $general->increaseInheritancePoint('previous', $amount);
+ LogText("선택유니크 롤백포인트:{$ownerID}", $amount);
+ }
+
+ $itemObj = buildItemClass($itemKey);
+ $itemName = $itemObj->getName();
+ //메시지
+
+ $staticNation = $general->getStaticNation();
+
+ $unlimited = new \DateTime('9999-12-31');
+ $src = new MessageTarget(0, '', 0, 'System', '#000000');
+ $dest = new MessageTarget($general->getID(), $general->getName(), $general->getNationID(), $staticNation['name'], $staticNation['color'], GetImageURL($general->getVar('imgsvr'), $general->getVar('picture')));
+ $josaUl = JosaUtil::pick($itemName, '을');
+ $msg = new Message(
+ Message::MSGTYPE_PRIVATE,
+ $src,
+ $dest,
+ "{$itemName}{$josaUl} 얻지 못했습니다. {$reason}",
+ new DateTime(),
+ $unlimited,
+ []
+ );
+
+ $msg->send(true);
+ $general->applyDB($db);
+}
+
+function tryInheritUniqueItem(General $general, string $acquireType = '아이템'): bool
+{
+ $ownerID = $general->getVar('owner');
+ if (!$ownerID) {
+ LogText("선택유니크 실패???: {$ownerID}", $general->getName());
+ return false;
+ }
+
+ $itemTrials = $general->getAuxVar('inheritUniqueTrial') ?? [];
+ arsort($itemTrials);
+ LogText("선택유니크항목: {$ownerID}", $itemTrials);
+
+ $db = DB::db();
+
+ $ownTarget = null;
+ $ownType = null;
+
+ foreach ($itemTrials as $itemKey => $amount) {
+ $availableItemTypes = [];
+ $reasons = [];
+ foreach (GameConst::$allItems as $itemType => $itemList) {
+ //아직은 그런 경우는 없지만 동일 유니크를 여러 부위에 장착할 수 있을지도 모름
+ if (!key_exists($itemKey, $itemList)) {
+ continue;
+ }
+
+ $ownItem = $general->getItem($itemType);
+ if ($ownItem->getRawClassName() == $itemKey) {
+ $reasons[] = '이미 그 유니크를 가지고 있습니다.';
+ continue;
+ }
+ /*
+ if (!$ownItem->isBuyable()) {
+ $reasons[] = '이미 다른 유니크를 가지고 있습니다.';
+ continue;
+ }
+ */
+
+ $availableCnt = $itemList[$itemKey];
+ $occupiedCnt = $db->queryFirstField('SELECT count(*) FROM general WHERE %b = %s', $itemType, $itemKey);
+ if ($occupiedCnt >= $availableCnt) {
+ $reasons[] = '그 유니크는 모두 점유되었습니다.';
+ continue;
+ }
+ $availableItemTypes[] = $itemType;
+ }
+
+ if (!$availableItemTypes) {
+ rollbackInheritUniqueTrial($general, $itemKey, join(' ', $reasons));
+ continue;
+ }
+ $reasons = [];
+
+ $itemType = Util::choiceRandom($availableItemTypes);
+
+ $trialStor = KVStorage::getStorage($db, "ut_{$itemKey}"); //혹시 itemKey의 크기가 37이 넘을 수 있을까?
+ $anyTrials = $trialStor->getAll();
+ if (!$anyTrials) {
+ //순서가 꼬였던 모양, 실제 값은 storage를 우선시하자
+ rollbackInheritUniqueTrial($general, $itemKey, '절차상의 오류입니다.');
+ continue;
+ }
+
+ //XXX: 정렬할 필요 없지 않나?
+ usort($anyTrials, function ($lhsTrial, $rhsTrial) {
+ [,, $lhsAmount] = $lhsTrial;
+ [,, $rhsAmount] = $rhsTrial;
+ return $rhsAmount <=> $lhsAmount; //큰 값이 앞에 오도록
+ });
+
+ LogText("선택유니크상태 {$ownerID} {$itemKey}", $anyTrials);
+
+ //공동 1등인데 본인이 있을 수도 있다.
+ [,, $topAmount] = $anyTrials[0];
+ if ($amount < $topAmount) {
+ $compAmount = $topAmount / $amount;
+ if ($compAmount > 2.0) {
+ $compText = '엄청난 차이로 ';
+ } else if ($compAmount > 1.2) {
+ $compText = '큰 차이로 ';
+ } else if ($compAmount > 1.05) {
+ $compText = '';
+ } else {
+ $compText = '아슬아슬한 차이로 ';
+ }
+ rollbackInheritUniqueTrial($general, $itemKey, "{$compText}상위 입찰한 장수가 있습니다.");
+ continue;
+ }
+
+ //내가 1위다
+ if ($ownTarget !== null) {
+ //이미 다른 아이템을 얻기로 되어있다.
+ continue;
+ }
+ $ownTarget = $itemKey;
+ $ownType = $itemType;
+ }
+ unset($itemKey);
+ unset($itemType);
+
+ if ($ownTarget === null) {
+ return false;
+ }
+
+ LogText("선택유니크획득{$ownerID}", $ownTarget);
+
+ $trialStor = KVStorage::getStorage($db, "ut_{$ownTarget}");
+ $trialStor->deleteValue("u{$ownerID}");
+
+ //rollbackInheritUniqueTrial 과정 때문에 새로 받아와야함
+ $itemTrials = $general->getAuxVar('inheritUniqueTrial');
+ unset($itemTrials[$ownTarget]);
+ $general->setAuxVar('inheritUniqueTrial', $itemTrials);
+
+ $nationName = $general->getStaticNation()['name'];
+ $generalName = $general->getName();
+ $josaYi = JosaUtil::pick($generalName, '이');
+ $itemObj = buildItemClass($ownTarget);
+ $itemName = $itemObj->getName();
+ $itemRawName = $itemObj->getRawName();
+ $josaUl = JosaUtil::pick($itemRawName, '을');
+
+
+ $general->setVar($ownType, $ownTarget);
+
+
+ $logger = $general->getLogger();
+
+ $logger->pushGeneralActionLog("{$itemName}>{$josaUl} 습득했습니다!");
+ $logger->pushGeneralHistoryLog("{$itemName}>{$josaUl} 습득");
+ $logger->pushGlobalActionLog("{$generalName}>{$josaYi} {$itemName}>{$josaUl} 습득했습니다!");
+ $logger->pushGlobalHistoryLog("【{$acquireType}】>{$nationName}>의 {$generalName}>{$josaYi} {$itemName}>{$josaUl} 습득했습니다!");
+
+ $general->applyDB($db);
+
+ return true;
+}
+
function tryUniqueItemLottery(General $general, string $acquireType = '아이템'): bool
{
$db = DB::db();
@@ -1616,8 +1813,13 @@ function tryUniqueItemLottery(General $general, string $acquireType = '아이템
return false;
}
- if ($general->getNPCType() > 6) {
- return false;
+ $inheritUnique = $general->getAuxVar('inheritUniqueTrial');
+ if ($inheritUnique && count($inheritUnique)) {
+ LogText("유니크 준비?? {$general->getID()}", $inheritUnique);
+ $trialResult = tryInheritUniqueItem($general, $acquireType);
+ if ($trialResult) {
+ return true;
+ }
}
$itemTypeCnt = count(GameConst::$allItems);
@@ -1629,7 +1831,7 @@ function tryUniqueItemLottery(General $general, string $acquireType = '아이템
}
}
- if($trialCnt <= 0){
+ if ($trialCnt <= 0) {
LogText("{$general->getName()}, {$general->getID()} 모든 아이템", $trialCnt);
return false;
}
@@ -1653,18 +1855,27 @@ function tryUniqueItemLottery(General $general, string $acquireType = '아이템
$prob = 1 / ($genCount * $itemTypeCnt / 10 / 4); // 건국시 4개(20%) 등장(200명시 20국 정도 됨)
}
- $prob = Util::valueFit($prob, null, 1 / 4);//최대치 감소
+ $prob = Util::valueFit($prob, null, 1 / 4); //최대치 감소
$result = false;
+ $prob /= sqrt(2);
+ $moreProb = pow(2, 1/4);
+ if($general->getAuxVar('inheritRandomUnique')){
+ //포인트로 랜덤 유니크 획득
+ $prob = 1;
+ LogText("{$general->getName()}, {$general->getID()} 유산 포인트 유니크", $prob);
+ $general->setAuxVar('inheritRandomUnique', null);
+ }
- foreach(Util::range($trialCnt) as $_idx){
+ foreach (Util::range($trialCnt) as $_idx) {
if (Util::randBool($prob)) {
$result = true;
break;
}
+ $prob *= $moreProb;
}
- if(!$result){
+ if (!$result) {
LogText("{$general->getName()}, {$general->getID()} 유니크 실패 {$trialCnt}", $prob);
return false;
}
@@ -1681,7 +1892,7 @@ function getAdmin()
}
/** @return General[] */
-function deleteNation(General $lord, bool $applyDB):array
+function deleteNation(General $lord, bool $applyDB): array
{
$lordID = $lord->getID();
$nationID = $lord->getNationID();
@@ -1706,7 +1917,8 @@ function deleteNation(General $lord, bool $applyDB):array
$nationID,
$lordID
),
- ['npc', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'belong', 'aux'], 1
+ ['npc', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'belong', 'aux'],
+ 1
);
$nationGeneralList[$lordID] = $lord;
@@ -1722,11 +1934,12 @@ function deleteNation(General $lord, bool $applyDB):array
$destroyHistoryLog = "{$nationName}>{$josaYi} 멸망>";
// 전 장수 재야로
- foreach($nationGeneralList as $general){
- $general->setAuxVar('max_belong',
+ foreach ($nationGeneralList as $general) {
+ $general->setAuxVar(
+ 'max_belong',
max(
$general->getVar('belong'),
- $general->getAuxVar('max_belong')??0
+ $general->getAuxVar('max_belong') ?? 0
)
);
$general->setVar('belong', 0);
@@ -1739,7 +1952,7 @@ function deleteNation(General $lord, bool $applyDB):array
$logger->pushGeneralActionLog($destroyLog, ActionLogger::PLAIN);
$logger->pushGeneralHistoryLog($destroyHistoryLog);
- if($applyDB){
+ if ($applyDB) {
$general->applyDB($db);
}
}
@@ -2158,7 +2371,7 @@ function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null)
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
$randFraction = Util::randRangeInt(0, 999999) / 1000000; //6자리 소수
- return $baseDateTime->add(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s.u');
+ return TimeUtil::format($baseDateTime->add(TimeUtil::secondsToDateInterval($randSecond + $randFraction)), true);
}
function getRandTurn2($term, ?\DateTimeInterface $baseDateTime = null)
diff --git a/hwe/func_converter.php b/hwe/func_converter.php
index 9508b13a..4d0f3716 100644
--- a/hwe/func_converter.php
+++ b/hwe/func_converter.php
@@ -369,7 +369,7 @@ function getAPIExecutorClass($path){
throw new \InvalidArgumentException("{$path}는 올바른 API 지시자가 아님");
}
- $classPath = ($basePath.$path);
+ $classPath = str_replace('/', '\\', $basePath.$path);
if(class_exists($classPath)){
return $classPath;
@@ -377,9 +377,9 @@ function getAPIExecutorClass($path){
throw new \InvalidArgumentException("{$path}는 올바른 API 경로가 아님");
}
-function buildAPIExecutorClass(string $type, array $args):\sammo\BaseAPI{
+function buildAPIExecutorClass($type, string $rootPath, array $args):\sammo\BaseAPI{
$class = getAPIExecutorClass($type);
- return new $class($args);
+ return new $class($rootPath, $args);
}
function getWarUnitTriggerClass(string $type){
diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php
index a6faafe4..a4d9b355 100644
--- a/hwe/func_gamerule.php
+++ b/hwe/func_gamerule.php
@@ -623,7 +623,7 @@ function updateNationState()
$nation['nation'],
$targetKillTurn
);
- $nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc'], 2);
+ $nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux'], 2);
$chiefObj = null;
$uniqueLotteryWeightList = [];
@@ -1158,13 +1158,13 @@ function resetInheritanceUser(int $userID, bool $isRebirth=false):float{
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
$totalPoint = 0;
$allPoints = $inheritStor->getAll();
- if(count($allPoints) == 0){
+ if(!$allPoints || count($allPoints) == 0){
//비었으므로 리셋 안함
return 0;
}
if(count($allPoints) == 1 && key_exists('previous', $allPoints)){
//이미 리셋되었으므로 리셋 안함
- return $allPoints['previous'];
+ return $allPoints['previous'][0];
}
foreach($allPoints as $key=>[$value,]){
if($isRebirth && key_exists($key, $rebirthDegraded)){
diff --git a/hwe/join.php b/hwe/join.php
deleted file mode 100644
index 5d08dabd..00000000
--- a/hwe/join.php
+++ /dev/null
@@ -1,182 +0,0 @@
-setReadOnly();
-$userID = Session::getUserID();
-
-if (!$userID) {
- MessageBox("잘못된 접근입니다!!!");
- echo "";
- exit(1);
-}
-
-//회원 테이블에서 정보확인
-$member = RootDB::db()->queryFirstRow("select no,name,picture,imgsvr,grade from member where no= %i", $userID);
-
-if (!$member) {
- MessageBox("잘못된 접근입니다!!!");
- echo "";
- exit(1);
-}
-
-$db = DB::db();
-$gameStor = KVStorage::getStorage($db, 'game_env');
-$admin = $gameStor->getValues(['block_general_create','show_img_level','maxgeneral']);
-if($admin['block_general_create']){
- MessageBox("잘못된 접근입니다!!!");
- echo "";
- exit(1);
-}
-?>
-
-
-
-=UniqueConst::$serverName?>: 장수생성
-
-
-
-
-=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
-=WebUtil::printCSS('../d_shared/common.css')?>
-=WebUtil::printCSS('css/common.css')?>
-=WebUtil::printJS('../d_shared/common_path.js')?>
-=WebUtil::printJS('dist_js/vendors.js')?>
-=WebUtil::printJS('dist_js/common.js')?>
-=WebUtil::printJS('dist_js/join.js')?>
-
-
-
-
- 장 수 생 성 =backButton()?> |
-
-
-queryFirstField('SELECT count(no) FROM general WHERE npc<2');
-
-if ($gencount >= $admin['maxgeneral']) {
- echo "";
- echo "";
- exit();
-}
-
-$nationList = $db->query('SELECT nation,`name`,color,scout FROM nation');
-shuffle($nationList);
-$nationList = Util::convertArrayToDict($nationList, 'nation');
-//NOTE: join 안할것임
-$scoutMsgs = KVStorage::getValuesFromInterNamespace($db, 'nation_env', 'scout_msg');
-foreach($scoutMsgs as $nationID=>$scoutMsg){
- $nationList[$nationID]['scoutmsg'] = $scoutMsg;
-}
-
-echo getInvitationList($nationList);
-?>
-
-
-
- | =backButton()?> |
- | =banner()?> |
-
-
-
diff --git a/hwe/join_post.php b/hwe/join_post.php
deleted file mode 100644
index e9fb0d22..00000000
--- a/hwe/join_post.php
+++ /dev/null
@@ -1,410 +0,0 @@
-