Compare commits

...
25 Commits
Author SHA1 Message Date
Hide_D 220d1d821d fix: 삼황내문 로직 누락 수정 2024-06-19 13:23:07 +09:00
Hide_D 2b16c3c1a9 fix: 삼황내문을 새 저지 로직에 맞게 변경 2024-06-19 13:22:20 +09:00
Hide_D d731acdaef Revert "fix: 삼황내문을 새 저지 로직에 맞게 수정"
This reverts commit 3511b159a8.
2024-06-19 13:19:30 +09:00
Hide_D 3511b159a8 fix: 삼황내문을 새 저지 로직에 맞게 수정 2024-06-19 13:18:15 +09:00
Hide_D 28cea4ee09 fix: 메시지 수정 2024-06-08 18:55:48 +00:00
Hide_D 8e7227c29d fix: DummyGeneral에 penaltyList 2024-06-08 18:52:47 +00:00
Hide_D f0cc22d9d8 fix: NoChief 처리 부실 2024-06-08 18:48:46 +00:00
Hide_D b6f19fa38b feat: 유산포인트로 장수 소유자 확인 2024-06-08 18:42:39 +00:00
Hide_D 86305087f7 Revert "장수목록에서 장수명에 마우스를 올리면 본닉 공개"
This reverts commit a3d7ef30dd.
2024-06-08 17:52:13 +00:00
Hide_D 7b6f64db61 fix: 유저장이 수뇌 금지 장수밖에 없을때 NPC 임명 동작 2024-06-08 17:47:35 +00:00
Hide_D 06f086bcf0 fix: penalty 오타 2024-06-08 17:37:43 +00:00
Hide_D 606c1664f2 feat: 내정보에 징계목록 출력 2024-06-08 17:37:33 +00:00
Hide_D 0c07060f4d feat: 메시지 전송 페널티 2024-06-08 17:22:10 +00:00
Hide_D 8bd0cc1c64 feat: 건국 금지, 지정 임관 금지 패널티 2024-06-08 17:21:55 +00:00
Hide_D f12262b946 feat: 건국 불가 페널티 2024-06-08 16:16:52 +00:00
Hide_D 9415d79a3a feat: Constraint 시스템에 NoPaneltyKey 추가 2024-06-08 16:15:19 +00:00
Hide_D ad223a9c75 feat: NPC 임명로직에 NoChief, NoAmbassador 반영 2024-06-08 16:06:22 +00:00
Hide_D 8737b19e79 fix: 이미 수뇌인 장수는 NPC에게 외교권을 못받는 버그 수정 2024-06-08 15:58:52 +00:00
Hide_D 552d73430c feat: 유저장의 수뇌 임명 불가 penalty 2024-06-08 15:55:26 +00:00
Hide_D fba5fbdb6b feat: PenaltyKey::NoChiefTurnInput 2024-06-08 15:48:01 +00:00
Hide_D 3da11bf21c feat: 내 정보 설정 저장지 페널티 갱신 2024-06-08 15:41:27 +00:00
Hide_D c83f9a0465 game: 휴전 -> 종전 2024-06-08 14:43:40 +00:00
Hide_D 9f67ae1f4e feat: General::penaltyList 2024-06-08 14:38:31 +00:00
Hide_D 383431b79f feat: PenaltyKey enum 2024-06-08 14:06:12 +00:00
Hide_D d5c0d16758 game: 저지 작동 방식 변경
- 최대 페이즈를 1 깎는 형태로 변경
2024-06-08 13:24:32 +00:00
24 changed files with 765 additions and 292 deletions
+6 -17
View File
@@ -32,8 +32,10 @@ if ($type <= 0 || $type > 15) {
} }
$ownerNameList = []; $ownerNameList = [];
foreach (RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]) { if ($gameStor->isunited) {
$ownerNameList[$ownerID] = $ownerName; foreach (RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]) {
$ownerNameList[$ownerID] = $ownerName;
}
} }
?> ?>
@@ -52,15 +54,6 @@ foreach (RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID
<?= WebUtil::printDist('vue', [], true) ?> <?= WebUtil::printDist('vue', [], true) ?>
<?= WebUtil::printDist('ts', 'common') ?> <?= WebUtil::printDist('ts', 'common') ?>
<style>
.hidden {
display: none;
}
.generalName:hover > .hidden {
display: block;
}
</style>
</head> </head>
<body> <body>
@@ -175,11 +168,7 @@ foreach (RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID
$name = formatName($general['name'], $general['npc']); $name = formatName($general['name'], $general['npc']);
if (key_exists($general['owner'], $ownerNameList)) { if (key_exists($general['owner'], $ownerNameList)) {
if ($gameStor->isunited) { $name = $name . '<br><small>(' . $ownerNameList[$general['owner']] . ')</small>';
$name = $name . '<br><small class=\'userName\'>(' . $ownerNameList[$general['owner']] . ')</small>';
} else {
$name = $name . '<br><small class=\'userName hidden\'>(' . $ownerNameList[$general['owner']] . ')</small>';
}
} }
$general['refresh_score_total'] = Util::round($general['refresh_score_total'], -1); $general['refresh_score_total'] = Util::round($general['refresh_score_total'], -1);
@@ -196,7 +185,7 @@ foreach (RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID
data-npc-type='{$general['npc']}' data-npc-type='{$general['npc']}'
> >
<td align=center><img class='generalIcon' width='64' height='64' src='{$imageTemp}/{$general['picture']}'></img></td> <td align=center><img class='generalIcon' width='64' height='64' src='{$imageTemp}/{$general['picture']}'></img></td>
<td align=center class='generalName'>$name</td> <td align=center>$name</td>
<td align=center>{$general['age']}세</td> <td align=center>{$general['age']}세</td>
<td align=center>" . displayCharInfo($general['personal']) . "</td> <td align=center>" . displayCharInfo($general['personal']) . "</td>
<td align=center>" . displaySpecialDomesticInfo($general['special']) . " / " . displaySpecialWarInfo($general['special2']) . "</td> <td align=center>" . displaySpecialDomesticInfo($general['special']) . " / " . displaySpecialWarInfo($general['special2']) . "</td>
+11 -3
View File
@@ -136,13 +136,21 @@ $changeDefence999Atmos = $me->onCalcDomestic('changeDefenceTrain', "atmos999", $
<option value='<?= $targetDefenceTrain ?>' <?= $me->getVar('defence_train') == $targetDefenceTrain ? "selected" : ""; ?>><?= formatDefenceTrain($targetDefenceTrain) ?>(훈사<?= $targetDefenceTrain ?>)</option> <option value='<?= $targetDefenceTrain ?>' <?= $me->getVar('defence_train') == $targetDefenceTrain ? "selected" : ""; ?>><?= formatDefenceTrain($targetDefenceTrain) ?>(훈사<?= $targetDefenceTrain ?>)</option>
<?php endforeach; ?> <?php endforeach; ?>
<option value=999 <?= $me->getVar('defence_train') == 999 ? "selected" : ""; ?>><?= formatDefenceTrain(999) ?> <option value=999 <?= $me->getVar('defence_train') == 999 ? "selected" : ""; ?>><?= formatDefenceTrain(999) ?>
<?php if($changeDefence999Train != 0 || $changeDefence999Train != 0): <?php if ($changeDefence999Train != 0 || $changeDefence999Train != 0) :
?>[<?=$changeDefence999Train!=0?"훈련 {$changeDefence999Train},":''?><?=$changeDefence999Atmos!=0?"사기 {$changeDefence999Atmos}":'' ?>[<?= $changeDefence999Train != 0 ? "훈련 {$changeDefence999Train}," : '' ?><?= $changeDefence999Atmos != 0 ? "사기 {$changeDefence999Atmos}" : ''
?>]<?php endif?></option> ?>]<?php endif ?></option>
</select> </select>
】<br><br> 】<br><br>
<input type=<?= $submit ?> id='set_my_setting' name=btn style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px; value=설정저장><br> <input type=<?= $submit ?> id='set_my_setting' name=btn style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px; value=설정저장><br>
∞<span style='color:orange'>설정저장은 이달중 <?= $myset ?>회 남았습니다.</span><br><br> ∞<span style='color:orange'>설정저장은 이달중 <?= $myset ?>회 남았습니다.</span><br><br>
<?php if ($me->getPenaltyList()->count()) : ?>
징계 목록(저장 시 갱신)<br>
<?php foreach ($me->getPenaltyList() as $penaltyKey => $penalty) : ?>
<span style='color:red'><?= $penaltyKey->getHelptext() ?> : <?= $penalty ?></span><br>
<?php endforeach; ?>
<br />
<?php endif; ?>
<?php if (!($gameStor->autorun_user['limit_minutes'] ?? false)) : ?> <?php if (!($gameStor->autorun_user['limit_minutes'] ?? false)) : ?>
휴 가 신 청<br> 휴 가 신 청<br>
<button type="button" id='vacation' style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>휴가 신청</button><br><br> <button type="button" id='vacation' style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>휴가 신청</button><br><br>
+5 -4
View File
@@ -9,6 +9,7 @@ use sammo\Enums\GeneralAccessLogColumn;
use sammo\Enums\GeneralColumn; use sammo\Enums\GeneralColumn;
use sammo\Enums\GeneralQueryMode; use sammo\Enums\GeneralQueryMode;
use sammo\Enums\InheritanceKey; use sammo\Enums\InheritanceKey;
use sammo\Enums\PenaltyKey;
use sammo\Enums\RankColumn; use sammo\Enums\RankColumn;
require_once 'process_war.php'; require_once 'process_war.php';
@@ -376,11 +377,11 @@ function myNationInfo(General $generalObj)
function checkSecretMaxPermission($penalty) function checkSecretMaxPermission($penalty)
{ {
$secretMax = 4; $secretMax = 4;
if ($penalty['noTopSecret'] ?? false) { if ($penalty[PenaltyKey::NoTopSecret->value] ?? false) {
$secretMax = 1; $secretMax = 1;
} else if ($penalty['noChief'] ?? false) { } else if ($penalty[PenaltyKey::NoChief->value] ?? false) {
$secretMax = 1; $secretMax = 1;
} else if ($penalty['noAmbassador'] ?? false) { } else if ($penalty[PenaltyKey::NoAmbassador->value] ?? false) {
$secretMax = 2; $secretMax = 2;
} }
return $secretMax; return $secretMax;
@@ -403,7 +404,7 @@ function checkSecretPermission(array $me, $checkSecretLimit = true)
} }
if ($penalty['noSecret'] ?? false) { if ($penalty[PenaltyKey::NoChief->value] ?? false) {
return 0; return 0;
} }
+8
View File
@@ -3,6 +3,7 @@ namespace sammo;
use sammo\Command\GeneralCommand; use sammo\Command\GeneralCommand;
use sammo\Command\NationCommand; use sammo\Command\NationCommand;
use sammo\Enums\PenaltyKey;
function getGeneralTurnBrief(General $generalObj, array $turnList) { function getGeneralTurnBrief(General $generalObj, array $turnList) {
$result = []; $result = [];
@@ -434,6 +435,13 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
]; ];
} }
if($general->hasPenalty(PenaltyKey::NoChiefTurnInput)){
return [
'result'=>false,
'reason'=>'수뇌 턴 입력 불가능'
];
}
try{ try{
$commandObj = buildNationCommandClass($command, $general, $env, $general->getLastTurn(), $arg); $commandObj = buildNationCommandClass($command, $general, $env, $general->getLastTurn(), $arg);
} }
+2 -2
View File
@@ -372,7 +372,7 @@ function postUpdateMonthly(RandUtil $rng)
continue; continue;
} }
//양측 기간 모두 0이 되는 상황이면 //양측 기간 모두 0이 되는 상황이면
$nation1 = getNationStaticInfo($me); $nation1 = getNationStaticInfo($me);
$name1 = $nation1['name']; $name1 = $nation1['name'];
$nation2 = getNationStaticInfo($you); $nation2 = getNationStaticInfo($you);
@@ -381,7 +381,7 @@ function postUpdateMonthly(RandUtil $rng)
$josaWa = JosaUtil::pick($name1, '와'); $josaWa = JosaUtil::pick($name1, '와');
$josaYi = JosaUtil::pick($name2, '이'); $josaYi = JosaUtil::pick($name2, '이');
$globalLogger->pushGlobalHistoryLog("<R><b>【전】</b></><D><b>$name1</b></>{$josaWa} <D><b>$name2</b></>{$josaYi} <S>전</>합니다."); $globalLogger->pushGlobalHistoryLog("<R><b>【전】</b></><D><b>$name1</b></>{$josaWa} <D><b>$name2</b></>{$josaYi} <S>전</>합니다.");
$db->update('diplomacy', [ $db->update('diplomacy', [
'state' => 2, 'state' => 2,
'term' => 0, 'term' => 0,
+116 -97
View File
@@ -1,9 +1,12 @@
<?php <?php
namespace sammo; namespace sammo;
use sammo\Enums\GeneralColumn;
use sammo\Enums\GeneralLiteQueryMode; use sammo\Enums\GeneralLiteQueryMode;
use sammo\Enums\GeneralQueryMode; use sammo\Enums\GeneralQueryMode;
use sammo\Enums\MessageType; use sammo\Enums\MessageType;
use sammo\Enums\PenaltyKey;
include "lib.php"; include "lib.php";
include "func.php"; include "func.php";
@@ -21,92 +24,99 @@ $userID = Session::getUserID();
$db = DB::db(); $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor = KVStorage::getStorage($db, 'game_env');
$gameStor->cacheValues(['startyear','year','month','scenario']); $gameStor->cacheValues(['startyear', 'year', 'month', 'scenario']);
$me = $db->queryFirstRow('SELECT no,nation,officer_level from general where owner=%i', $userID); $me = $db->queryFirstRow('SELECT no,nation,officer_level,penalty from general where owner=%i', $userID);
$myOfficerLevel = $me['officer_level']; $myOfficerLevel = $me['officer_level'];
$nationID = $me['nation']; $nationID = $me['nation'];
$myPenalty = Json::decode($me['penalty'] ?? '{}');
//수뇌가 아니면 아무것도 할 수 없음 //수뇌가 아니면 아무것도 할 수 없음
if($myOfficerLevel < 5){ if ($myOfficerLevel < 5) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>'수뇌가 아닙니다.' 'reason' => '수뇌가 아닙니다.'
]); ]);
} }
if($action === '추방' && $destGeneralID==0){ if ($action === '추방' && $destGeneralID == 0) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>'장수가 지정되지 않았습니다.' 'reason' => '장수가 지정되지 않았습니다.'
]); ]);
} }
if($destGeneralID==0){ if ($destGeneralID == 0) {
$general = new DummyGeneral(true); $general = new DummyGeneral(true);
$general->setVar('nation', $nationID); $general->setVar('nation', $nationID);
} } else {
else{
$general = General::createObjFromDB($destGeneralID); $general = General::createObjFromDB($destGeneralID);
if($general instanceof DummyGeneral){ if ($general instanceof DummyGeneral) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>'올바르지 않은 장수입니다.' 'reason' => '올바르지 않은 장수입니다.'
]); ]);
} }
if($nationID != $general->getNationID()){ if ($nationID != $general->getNationID()) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>'아국 장수가 아닙니다' 'reason' => '아국 장수가 아닙니다'
]); ]);
} }
} }
if($officerLevel == 12){ if ($officerLevel == 12) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>'군주를 대상으로 할 수 없습니다.' 'reason' => '군주를 대상으로 할 수 없습니다.'
]); ]);
} }
function do수뇌임명(General $general, int $targetOfficerLevel):?string{ function do수뇌임명(General $general, int $targetOfficerLevel): ?string
{
global $myPenalty;
if ($myPenalty[PenaltyKey::NoChiefChange->value] ?? false) {
return '수뇌를 임명할 수 없는 상태입니다.';
}
$generalID = $general->getID(); $generalID = $general->getID();
$nationID = $general->getNationID(); $nationID = $general->getNationID();
if($general->hasPenalty(PenaltyKey::NoChief)){
return '수뇌가 될 수 없는 상태입니다.';
}
$db = DB::db(); $db = DB::db();
[$chiefSet, $nationLevel] = $db->queryFirstList('SELECT chief_set,level FROM nation WHERE nation = %i',$nationID); [$chiefSet, $nationLevel] = $db->queryFirstList('SELECT chief_set,level FROM nation WHERE nation = %i', $nationID);
// 임명가능 레벨 // 임명가능 레벨
$lv = getNationChiefLevel($nationLevel); $lv = getNationChiefLevel($nationLevel);
if($targetOfficerLevel < $lv){ if ($targetOfficerLevel < $lv) {
return '임명불가능한 관직입니다.'; return '임명불가능한 관직입니다.';
} }
if(isOfficerSet($chiefSet, $targetOfficerLevel)){ if (isOfficerSet($chiefSet, $targetOfficerLevel)) {
return '지금은 임명할 수 없습니다.'; return '지금은 임명할 수 없습니다.';
} }
//기존 장수 일반으로 //기존 장수 일반으로
$db->update('general', [ $db->update('general', [
'officer_level'=>1, 'officer_level' => 1,
'officer_city'=>0, 'officer_city' => 0,
], 'nation=%i AND officer_level=%i AND no!=%i', $nationID, $targetOfficerLevel, $generalID); ], 'nation=%i AND officer_level=%i AND no!=%i', $nationID, $targetOfficerLevel, $generalID);
if($targetOfficerLevel === 11){ if ($targetOfficerLevel === 11) {
} else if ($targetOfficerLevel % 2 == 0) {
} if ($general->getVar('strength') < GameConst::$chiefStatMin) {
else if($targetOfficerLevel % 2 == 0){
if($general->getVar('strength') < GameConst::$chiefStatMin){
return '무력이 부족합니다.'; return '무력이 부족합니다.';
} }
} else {
} if ($general->getVar('intel') < GameConst::$chiefStatMin) {
else{
if($general->getVar('intel') < GameConst::$chiefStatMin){
return '지력이 부족합니다.'; return '지력이 부족합니다.';
} }
} }
@@ -115,52 +125,59 @@ function do수뇌임명(General $general, int $targetOfficerLevel):?string{
$general->setVar('officer_level', $targetOfficerLevel); $general->setVar('officer_level', $targetOfficerLevel);
$general->setVar('officer_city', 0); $general->setVar('officer_city', 0);
$db->update('nation', [ $db->update('nation', [
'chief_set'=> $db->sqleval('chief_set | %i', doOfficerSet(0, $targetOfficerLevel)), 'chief_set' => $db->sqleval('chief_set | %i', doOfficerSet(0, $targetOfficerLevel)),
], 'nation=%i', $nationID); ], 'nation=%i', $nationID);
$general->applyDB($db); $general->applyDB($db);
return null; return null;
} }
function do도시임명(General $general, int $cityID, int $targetOfficerLevel):?string{ function do도시임명(General $general, int $cityID, int $targetOfficerLevel): ?string
{
global $myPenalty;
$nationID = $general->getNationID(); $nationID = $general->getNationID();
$db = DB::db(); $db = DB::db();
if(CityConst::byID($cityID) === null){ if (CityConst::byID($cityID) === null) {
return '올바르지 않은 도시입니다'; return '올바르지 않은 도시입니다';
} }
if ($general->getVar(GeneralColumn::officer_level) >= 4 && $myPenalty[PenaltyKey::NoChiefChange->value] ?? false) {
return '수뇌인 장수를 변경할 수 없는 상태입니다.';
}
$officerSet = $db->queryFirstField('SELECT officer_set FROM city WHERE nation=%i AND city=%i', $nationID, $cityID); $officerSet = $db->queryFirstField('SELECT officer_set FROM city WHERE nation=%i AND city=%i', $nationID, $cityID);
if($officerSet === null){ if ($officerSet === null) {
return '아국 도시가 아닙니다'; return '아국 도시가 아닙니다';
} }
if(isOfficerSet($officerSet, $targetOfficerLevel)){ if (isOfficerSet($officerSet, $targetOfficerLevel)) {
return '이미 다른 장수가 임명되어있습니다'; return '이미 다른 장수가 임명되어있습니다';
} }
//기존 장수 일반으로 //기존 장수 일반으로
$db->update('general', [ $db->update('general', [
'officer_level'=>1, 'officer_level' => 1,
'officer_city'=>0, 'officer_city' => 0,
], 'officer_level=%i AND officer_city=%i AND no!=%i', $targetOfficerLevel, $cityID, $general->getID()); ], 'officer_level=%i AND officer_city=%i AND no!=%i', $targetOfficerLevel, $cityID, $general->getID());
if($general instanceof DummyGeneral){ if ($general instanceof DummyGeneral) {
return null; return null;
} }
if($targetOfficerLevel === 4 && $general->getVar('strength') < GameConst::$chiefStatMin){ if ($targetOfficerLevel === 4 && $general->getVar('strength') < GameConst::$chiefStatMin) {
return '무력이 부족합니다.'; return '무력이 부족합니다.';
} }
if($targetOfficerLevel === 3 && $general->getVar('intel') < GameConst::$chiefStatMin){ if ($targetOfficerLevel === 3 && $general->getVar('intel') < GameConst::$chiefStatMin) {
return '지력이 부족합니다.'; return '지력이 부족합니다.';
} }
//신임 장수 //신임 장수
$db->update('city', [ $db->update('city', [
'officer_set'=>$db->sqleval('officer_set | %i', doOfficerSet(0, $targetOfficerLevel)), 'officer_set' => $db->sqleval('officer_set | %i', doOfficerSet(0, $targetOfficerLevel)),
], 'city=%i AND nation=%i', $cityID, $nationID); ], 'city=%i AND nation=%i', $cityID, $nationID);
$general->setVar('officer_level', $targetOfficerLevel); $general->setVar('officer_level', $targetOfficerLevel);
$general->setVar('officer_city', $cityID); $general->setVar('officer_city', $cityID);
@@ -169,22 +186,25 @@ function do도시임명(General $general, int $cityID, int $targetOfficerLevel):
return null; return null;
} }
function do추방(General $general, int $myOfficerLevel):?string{ function do추방(General $general, int $myOfficerLevel): ?string
{
$generalID = $general->getID(); $generalID = $general->getID();
$generalName = $general->getVar('name'); $generalName = $general->getVar('name');
$nationID = $general->getNationID(); $nationID = $general->getNationID();
if ($myPenalty[PenaltyKey::NoBanGeneral->value] ?? false) {
return '추방할 수 없는 상태입니다.';
}
//추방할사람이 외교권자이면 불가 //추방할사람이 외교권자이면 불가
$permission = checkSecretPermission($general->getRaw()); $permission = checkSecretPermission($general->getRaw());
if($permission == 4){ if ($permission == 4) {
return '외교권자는 추방할 수 없습니다.'; return '외교권자는 추방할 수 없습니다.';
} }
$db = DB::db(); $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor = KVStorage::getStorage($db, 'game_env');
$env = $gameStor->getValues(['startyear','year','month','scenario']); $env = $gameStor->getValues(['startyear', 'year', 'month', 'scenario']);
$nation = $db->queryFirstRow('SELECT name,chief_set,color FROM nation WHERE nation=%i', $nationID); $nation = $db->queryFirstRow('SELECT name,chief_set,color FROM nation WHERE nation=%i', $nationID);
$nationName = $nation['name']; $nationName = $nation['name'];
@@ -192,17 +212,17 @@ function do추방(General $general, int $myOfficerLevel):?string{
$logger = $general->getLogger(); $logger = $general->getLogger();
//이미 지정했다면 무시 //이미 지정했다면 무시
if(isOfficerSet($nation['chief_set'], $myOfficerLevel) || ($myOfficerLevel == 0 && $myOfficerLevel == 12)) { if (isOfficerSet($nation['chief_set'], $myOfficerLevel) || ($myOfficerLevel == 0 && $myOfficerLevel == 12)) {
return '이미 추방 권한을 사용했습니다.'; return '이미 추방 권한을 사용했습니다.';
} }
$gold = 0; $gold = 0;
$rice = 0; $rice = 0;
// 금쌀1000이상은 남김 // 금쌀1000이상은 남김
if($general->getVar('gold') > GameConst::$defaultGold) { if ($general->getVar('gold') > GameConst::$defaultGold) {
$gold = $general->getVar('gold') - GameConst::$defaultGold; $gold = $general->getVar('gold') - GameConst::$defaultGold;
$general->setVar('gold', GameConst::$defaultGold); $general->setVar('gold', GameConst::$defaultGold);
} }
if($general->getVar('rice') > GameConst::$defaultRice) { if ($general->getVar('rice') > GameConst::$defaultRice) {
$rice = $general->getVar('rice') - GameConst::$defaultRice; $rice = $general->getVar('rice') - GameConst::$defaultRice;
$general->setVar('rice', GameConst::$defaultRice); $general->setVar('rice', GameConst::$defaultRice);
} }
@@ -220,27 +240,26 @@ function do추방(General $general, int $myOfficerLevel):?string{
$logger->pushGeneralActionLog("<D><b>{$nationName}</b></>에서 <R>추방</>당했습니다.", ActionLogger::PLAIN); $logger->pushGeneralActionLog("<D><b>{$nationName}</b></>에서 <R>추방</>당했습니다.", ActionLogger::PLAIN);
// 명성/공헌 N*10%감소 // 명성/공헌 N*10%감소
if($env['year'] <= $env['startyear'] && $general->getNPCType() < 2){ if ($env['year'] <= $env['startyear'] && $general->getNPCType() < 2) {
$general->setVar('makelimit', $oldMakeLimit); $general->setVar('makelimit', $oldMakeLimit);
} } else {
else{
$betrayCnt = $general->getVar('betray'); $betrayCnt = $general->getVar('betray');
$general->addExperience(-$general->getVar('experience')*0.15*$betrayCnt); $general->addExperience(-$general->getVar('experience') * 0.15 * $betrayCnt);
$general->addDedication(-$general->getVar('dedication')*0.15*$betrayCnt); $general->addDedication(-$general->getVar('dedication') * 0.15 * $betrayCnt);
$general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt); $general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt);
} }
//부대장일 경우 //부대장일 경우
if($general->getVar('troop') == $generalID){ if ($general->getVar('troop') == $generalID) {
// 모두 탈퇴 // 모두 탈퇴
$db->update('general', [ $db->update('general', [
'troop'=>0, 'troop' => 0,
], 'troop = %i', $generalID); ], 'troop = %i', $generalID);
$db->delete('troop', 'troop_leader=%i', $generalID); $db->delete('troop', 'troop_leader=%i', $generalID);
} }
$general->setVar('troop', 0); $general->setVar('troop', 0);
if($general->getNPCType() >= 2){ if ($general->getNPCType() >= 2) {
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize( $rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
UniqueConst::$hiddenSeed, UniqueConst::$hiddenSeed,
'BanNPC', 'BanNPC',
@@ -279,24 +298,24 @@ function do추방(General $general, int $myOfficerLevel):?string{
} }
} }
if($env['year'] < $env['startyear']+3) { if ($env['year'] < $env['startyear'] + 3) {
//초반엔 군주 부상 증가(엔장 임관지양) //초반엔 군주 부상 증가(엔장 임관지양)
$db->update('general', [ $db->update('general', [
'injury'=>$db->sqleval('least(injury + 1, %i)', 80), 'injury' => $db->sqleval('least(injury + 1, %i)', 80),
], 'nation=%i AND officer_level=12', $nationID); ], 'nation=%i AND officer_level=12', $nationID);
$db->update('nation', [ $db->update('nation', [
'gennum'=>$db->sqleval('gennum - %i', $general->getNPCType()!=5?1:0), 'gennum' => $db->sqleval('gennum - %i', $general->getNPCType() != 5 ? 1 : 0),
'gold'=>$db->sqleval('gold + %i', $gold), 'gold' => $db->sqleval('gold + %i', $gold),
'rice'=>$db->sqleval('rice + %i', $rice), 'rice' => $db->sqleval('rice + %i', $rice),
], 'nation = %i', $nationID); ], 'nation = %i', $nationID);
} else { } else {
//이번분기는 추방불가(초반 제외) //이번분기는 추방불가(초반 제외)
$db->update('nation', [ $db->update('nation', [
'chief_set'=>$db->sqleval('chief_set | %i', doOfficerSet(0, $myOfficerLevel)), 'chief_set' => $db->sqleval('chief_set | %i', doOfficerSet(0, $myOfficerLevel)),
'gennum'=>$db->sqleval('gennum - %i', $general->getNPCType()!=5?1:0), 'gennum' => $db->sqleval('gennum - %i', $general->getNPCType() != 5 ? 1 : 0),
'gold'=>$db->sqleval('gold + %i', $gold), 'gold' => $db->sqleval('gold + %i', $gold),
'rice'=>$db->sqleval('rice + %i', $rice), 'rice' => $db->sqleval('rice + %i', $rice),
], 'nation = %i', $nationID); ], 'nation = %i', $nationID);
} }
@@ -308,62 +327,62 @@ function do추방(General $general, int $myOfficerLevel):?string{
if($action == "임명") { if ($action == "임명") {
if(2 <= $officerLevel && $officerLevel <= 4){ if (2 <= $officerLevel && $officerLevel <= 4) {
if(!$destCityID){ if (!$destCityID) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>'도시가 지정되지 않았습니다.' 'reason' => '도시가 지정되지 않았습니다.'
]); ]);
} }
$result = do도시임명($general, $destCityID, $officerLevel); $result = do도시임명($general, $destCityID, $officerLevel);
if($result !== null){ if ($result !== null) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>$result 'reason' => $result
]); ]);
} }
Json::die([ Json::die([
'result'=>true, 'result' => true,
'reason'=>'success' 'reason' => 'success'
]); ]);
} }
if(5 <= $officerLevel && $officerLevel < 12){ if (5 <= $officerLevel && $officerLevel < 12) {
$result = do수뇌임명($general, $officerLevel); $result = do수뇌임명($general, $officerLevel);
if($result !== null){ if ($result !== null) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>$result 'reason' => $result
]); ]);
} }
Json::die([ Json::die([
'result'=>true, 'result' => true,
'reason'=>'success' 'reason' => 'success'
]); ]);
} }
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>'올바르지 않은 지정입니다.' 'reason' => '올바르지 않은 지정입니다.'
]); ]);
} }
if($action == "추방") { if ($action == "추방") {
$result = do추방($general, $myOfficerLevel); $result = do추방($general, $myOfficerLevel);
if($result !== null){ if ($result !== null) {
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>$result 'reason' => $result
]); ]);
} }
Json::die([ Json::die([
'result'=>true, 'result' => true,
'reason'=>'success' 'reason' => 'success'
]); ]);
} }
Json::die([ Json::die([
'result'=>false, 'result' => false,
'reason'=>'올바르지 않은 명령입니다.' 'reason' => '올바르지 않은 명령입니다.'
]); ]);
+36 -14
View File
@@ -1,4 +1,5 @@
<?php <?php
namespace sammo; namespace sammo;
include "lib.php"; include "lib.php";
@@ -24,14 +25,13 @@ if ($defence_train <= 40) {
$defence_train = 40; $defence_train = 40;
} }
if($defence_train <= 90){ if ($defence_train <= 90) {
$defence_train = Util::round($defence_train, -1); $defence_train = Util::round($defence_train, -1);
} } else {
else{
$defence_train = 999; $defence_train = 999;
} }
if($tnmt < 0 || $tnmt > 1){ if ($tnmt < 0 || $tnmt > 1) {
$tnmt = 1; $tnmt = 1;
} }
@@ -39,8 +39,8 @@ $db = DB::db();
$me = General::createObjFromDB($generalID); $me = General::createObjFromDB($generalID);
if($defence_train !== $me->getVar('defence_train')){ if ($defence_train !== $me->getVar('defence_train')) {
if($defence_train == 999){ if ($defence_train == 999) {
$me->increaseVar('myset', -1); $me->increaseVar('myset', -1);
$me->setVar('defence_train', $defence_train); $me->setVar('defence_train', $defence_train);
$affectedTrain = -3; $affectedTrain = -3;
@@ -49,8 +49,7 @@ if($defence_train !== $me->getVar('defence_train')){
$affectedAtmos = $me->onCalcDomestic('changeDefenceTrain', "atmos{$defence_train}", $affectedAtmos); $affectedAtmos = $me->onCalcDomestic('changeDefenceTrain', "atmos{$defence_train}", $affectedAtmos);
$me->increaseVarWithLimit('train', $affectedTrain, 20, GameConst::$maxTrainByWar); $me->increaseVarWithLimit('train', $affectedTrain, 20, GameConst::$maxTrainByWar);
$me->increaseVarWithLimit('atmos', $affectedAtmos, 20, GameConst::$maxAtmosByWar); $me->increaseVarWithLimit('atmos', $affectedAtmos, 20, GameConst::$maxAtmosByWar);
} } else {
else{
$me->increaseVar('myset', -1); $me->increaseVar('myset', -1);
$me->setVar('defence_train', $defence_train); $me->setVar('defence_train', $defence_train);
} }
@@ -60,21 +59,44 @@ $me->setAuxVar('use_treatment', Util::valueFit($use_treatment, 10, 100));
$me->setAuxVar('use_auto_nation_turn', $use_auto_nation_turn); $me->setAuxVar('use_auto_nation_turn', $use_auto_nation_turn);
$me->setVar('tnmt', $tnmt); $me->setVar('tnmt', $tnmt);
if($me->getNPCType() == 1 && $detachNPC){ if ($me->getNPCType() == 1 && $detachNPC) {
$turnterm = $gameStor->turnterm; $turnterm = $gameStor->turnterm;
if($turnterm < 10){ if ($turnterm < 10) {
$targetKillTurn = 30 / $turnterm; $targetKillTurn = 30 / $turnterm;
} } else {
else{
$targetKillTurn = 60 / $turnterm; $targetKillTurn = 60 / $turnterm;
} }
$me->setVar('killturn', $targetKillTurn); $me->setVar('killturn', $targetKillTurn);
} }
$rootDB = RootDB::db();
//회원 테이블에서 정보확인
$member = $rootDB->queryFirstRow('SELECT `no`, id, picture, grade, `name`, imgsvr, `penalty` FROM member WHERE no=%i', $userID);
if (!$member) {
//이런 경우가 있나?
//TODO: 로그 남겨둘 것
Json::die([
'result' => false,
'reason' => '회원 정보를 찾을 수 없습니다.'
]);
}
$memberPenalty = Json::decode($member['penalty'] ?? "{}");
$penaltyInfo = array_merge($memberPenalty['any'] ?? [], $memberPenalty[DB::prefix()] ?? []);
$penalty = [];
foreach ($penaltyInfo as $penaltyKey => $penaltyValue) {
if ($penaltyValue['expire'] ?? 0 > TimeUtil::now()) {
$penalty[$penaltyKey] = $penaltyValue['value'];
}
}
$me->setVar('penalty', Json::encode($penalty));
$me->applyDB($db); $me->applyDB($db);
Json::die([ Json::die([
'result'=>true, 'result' => true,
'reason'=>'success' 'reason' => 'success'
]); ]);
+154
View File
@@ -0,0 +1,154 @@
<?php
namespace sammo\API\InheritAction;
use sammo\Session;
use DateTimeInterface;
use sammo\DB;
use sammo\Enums\APIRecoveryType;
use sammo\Enums\MessageType;
use sammo\Enums\RankColumn;
use sammo\GameConst;
use sammo\General;
use sammo\KVStorage;
use sammo\Message;
use sammo\MessageTarget;
use sammo\RootDB;
use sammo\TimeUtil;
use sammo\UserLogger;
use sammo\Validator;
use function sammo\GetImageURL;
use function sammo\getNationStaticInfo;
/**
*
* 유산 포인트 1000 포인트를 사용하면 지정한 상대의 본래 유저명을 확인 가능.
* 개인 메시지로 전달되며, 이 기능이 사용되었음을 상대에게도 알림.
*/
class CheckOwner extends \sammo\BaseAPI
{
public function validateArgs(): ?string
{
$v = new Validator($this->args);
$v->rule('required', [
'destGeneralID',
])
->rule('int', 'destGeneralID')
->rule('min', 'destGeneralID', 1);
if (!$v->validate()) {
return $v->errorStr();
}
return null;
}
public function getRequiredSessionMode(): int
{
return static::REQ_GAME_LOGIN;
}
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag): null|string|array|APIRecoveryType
{
$userID = $session->userID;
$generalID = $session->generalID;
$destGeneralID = $this->args['destGeneralID'];
if ($generalID == $destGeneralID) {
return '자신의 정보는 확인할 수 없습니다.';
}
$general = General::createObjFromDB($generalID);
if ($userID != $general->getVar('owner')) {
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
}
$db = DB::db();
$destRawGeneral = $db->queryFirstRow('SELECT no,name,nation,owner,owner_name,imgsvr,picture FROM general WHERE no = %i', $destGeneralID);
if (!$destRawGeneral) {
return '대상 장수가 존재하지 않습니다.';
}
if (!$destRawGeneral['owner']) {
return '대상 장수는 NPC입니다.';
}
$gameStor = KVStorage::getStorage($db, 'game_env');
if ($gameStor->isunited) {
return '이미 천하가 통일되었습니다.';
}
$reqPoint = GameConst::$inheritCheckOwnerPoint;
$inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}");
$previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0];
if ($previousPoint < $reqPoint) {
return '충분한 유산 포인트를 가지고 있지 않습니다.';
}
$userLogger = new UserLogger($userID);
$userLogger->push("{$reqPoint} 포인트로 장수 소유자 확인", "inheritPoint");
$userLogger->flush();
$destGeneralName = $destRawGeneral['name'];
$destGeneralOwnerName = $destRawGeneral['owner_name'];
if (!$destGeneralOwnerName) {
$rootDB = RootDB::db();
$destGeneralOwnerName = $rootDB->queryFirstField('SELECT name FROM member WHERE no = %i', $destRawGeneral['owner']) ?? '알수없음';
}
$src = new MessageTarget(0, '', 0, 'System', '#000000');
if (true) {
$staticNation = $general->getStaticNation();
$dest = new MessageTarget(
$generalID,
$general->getName(),
$general->getNationID(),
$staticNation['name'],
$staticNation['color'],
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
);
$msg = new Message(
MessageType::private,
$src,
$dest,
"{$destGeneralName}의 소유자는 {$destGeneralOwnerName} 입니다.",
new \DateTime(),
new \DateTime('9999-12-31'),
[]
);
$msg->send(true);
}
$inheritStor->setValue('previous', [$previousPoint - $reqPoint, null]);
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $reqPoint);
$general->applyDB($db);
if(true){
$destStaticNation = getNationStaticInfo($destRawGeneral['nation']);
$dest = new MessageTarget(
$destGeneralID,
$destGeneralName,
$destRawGeneral['nation'],
$destStaticNation['name'],
$destStaticNation['color'],
GetImageURL($destRawGeneral['imgsvr'], $destRawGeneral['picture'])
);
$msg = new Message(
MessageType::private,
$src,
$dest,
"소유자명이 누군가에 의해 확인되었습니다.",
new \DateTime(),
new \DateTime('9999-12-31'),
[]
);
$msg->send(true);
}
return null;
}
}
+9 -1
View File
@@ -7,6 +7,7 @@ use DateTimeInterface;
use sammo\DB; use sammo\DB;
use sammo\Enums\APIRecoveryType; use sammo\Enums\APIRecoveryType;
use sammo\Enums\MessageType; use sammo\Enums\MessageType;
use sammo\Enums\PenaltyKey;
use sammo\Json; use sammo\Json;
use sammo\Message; use sammo\Message;
use sammo\MessageTarget; use sammo\MessageTarget;
@@ -191,6 +192,9 @@ class SendMessage extends \sammo\BaseAPI
// 전체 메세지 // 전체 메세지
if ($mailbox === Message::MAILBOX_PUBLIC) { if ($mailbox === Message::MAILBOX_PUBLIC) {
if($penalty[PenaltyKey::NoSendPublicMsg->value] ?? 0) {
return '공개 메세지를 보낼 수 없습니다.';
}
$msgID = $this->genPublicMessage($src, $text)->send(); $msgID = $this->genPublicMessage($src, $text)->send();
return [ return [
'msgType' => 'public', 'msgType' => 'public',
@@ -231,7 +235,11 @@ class SendMessage extends \sammo\BaseAPI
$lastMsg = new \DateTime($session->lastMsg ?? '0000-00-00'); $lastMsg = new \DateTime($session->lastMsg ?? '0000-00-00');
$msg_interval = $now->getTimestamp() - $lastMsg->getTimestamp(); $msg_interval = $now->getTimestamp() - $lastMsg->getTimestamp();
$msg_min_interval = $penalty['sendPrivateMsgDelay'] ?? 2; if($penalty[PenaltyKey::NoSendPrivateMsg->value] ?? 0) {
return '개인 메세지를 보낼 수 없습니다.';
}
$msg_min_interval = $penalty[PenaltyKey::SendPrivateMsgDelay->value] ?? 2;
if ($msg_interval < $msg_min_interval) { if ($msg_interval < $msg_min_interval) {
return "개인메세지는 {$msg_min_interval}초당 1건만 보낼 수 있습니다!"; return "개인메세지는 {$msg_min_interval}초당 1건만 보낼 수 있습니다!";
} }
@@ -19,10 +19,14 @@ class che_저지_삼황내문 extends \sammo\BaseItem{
if($unit->isAttacker()){ if($unit->isAttacker()){
return null; return null;
} }
if($unit->getPhase() >= 2){
if($unit->getPhase() > 0){
return null; return null;
} }
if($unit->getPhase() == 1 && $unit->rng->nextBool(0.5)){ if($unit->hasActivatedSkillOnLog('저지') >= 2){
return null;
}
if($unit->hasActivatedSkillOnLog('저지') == 1 && $unit->getPhase() == 0 && $unit->rng->nextBool(0.5)){
return null; return null;
} }
+4 -1
View File
@@ -18,6 +18,7 @@ use function \sammo\getAllNationStaticInfo;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey; use sammo\Enums\InheritanceKey;
use sammo\Enums\PenaltyKey;
use function sammo\buildNationTypeClass; use function sammo\buildNationTypeClass;
use function sammo\genGenericUniqueRNGFromGeneral; use function sammo\genGenericUniqueRNGFromGeneral;
@@ -81,7 +82,8 @@ class che_건국 extends Command\GeneralCommand
$this->minConditionConstraints = [ $this->minConditionConstraints = [
ConstraintHelper::BeOpeningPart($relYear + 1), ConstraintHelper::BeOpeningPart($relYear + 1),
ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.') ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.'),
ConstraintHelper::NoPenalty(PenaltyKey::NoFoundNation),
]; ];
} }
@@ -102,6 +104,7 @@ class che_건국 extends Command\GeneralCommand
ConstraintHelper::CheckNationNameDuplicate($nationName), ConstraintHelper::CheckNationNameDuplicate($nationName),
ConstraintHelper::AllowJoinAction(), ConstraintHelper::AllowJoinAction(),
ConstraintHelper::ConstructableCity(), ConstraintHelper::ConstructableCity(),
ConstraintHelper::NoPenalty(PenaltyKey::NoFoundNation),
]; ];
} }
+5 -2
View File
@@ -17,6 +17,7 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey; use sammo\Enums\InheritanceKey;
use sammo\Enums\PenaltyKey;
class che_임관 extends Command\GeneralCommand class che_임관 extends Command\GeneralCommand
{ {
@@ -66,7 +67,8 @@ class che_임관 extends Command\GeneralCommand
$this->minConditionConstraints = [ $this->minConditionConstraints = [
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'), ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
ConstraintHelper::BeNeutral(), ConstraintHelper::BeNeutral(),
ConstraintHelper::AllowJoinAction() ConstraintHelper::AllowJoinAction(),
ConstraintHelper::NoPenalty(PenaltyKey::NoChosenAssignment),
]; ];
} }
@@ -92,7 +94,8 @@ class che_임관 extends Command\GeneralCommand
ConstraintHelper::BeNeutral(), ConstraintHelper::BeNeutral(),
ConstraintHelper::ExistsDestNation(), ConstraintHelper::ExistsDestNation(),
ConstraintHelper::AllowJoinDestNation($relYear), ConstraintHelper::AllowJoinDestNation($relYear),
ConstraintHelper::AllowJoinAction() ConstraintHelper::AllowJoinAction(),
ConstraintHelper::NoPenalty(PenaltyKey::NoChosenAssignment),
]; ];
} }
+126 -65
View File
@@ -1,9 +1,11 @@
<?php <?php
namespace sammo\Constraint; namespace sammo\Constraint;
abstract class Constraint{ abstract class Constraint
private function __construct(){ {
private function __construct()
{
} }
const REQ_GENERAL = 0x10; const REQ_GENERAL = 0x10;
@@ -18,6 +20,7 @@ abstract class Constraint{
const REQ_NUMERIC_ARG = self::REQ_ARG | 0x4000; const REQ_NUMERIC_ARG = self::REQ_ARG | 0x4000;
const REQ_BOOLEAN_ARG = self::REQ_ARG | 0x8000; const REQ_BOOLEAN_ARG = self::REQ_ARG | 0x8000;
const REQ_ARRAY_ARG = self::REQ_ARG | 0x10000; const REQ_ARRAY_ARG = self::REQ_ARG | 0x10000;
const REQ_BACKED_ENUM_ARG = self::REQ_ARG | 0x20000;
const REQ_VALUES = 0; const REQ_VALUES = 0;
@@ -37,182 +40,241 @@ abstract class Constraint{
protected $tested = false; protected $tested = false;
protected $reason = null; protected $reason = null;
abstract public function test():bool; abstract public function test(): bool;
static public function requiredValueType():int{ static public function requiredValueType(): int
{
return static::REQ_VALUES; return static::REQ_VALUES;
} }
public function setGeneral(array $general){ public function setGeneral(array $general)
{
$this->general = $general; $this->general = $general;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
public function setCity(array $city){ public function setCity(array $city)
{
$this->city = $city; $this->city = $city;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
public function setNation(array $nation){ public function setNation(array $nation)
{
$this->nation = $nation; $this->nation = $nation;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
public function setArg($arg){ public function setArg($arg)
{
$this->arg = $arg; $this->arg = $arg;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
public function setEnv($env){ public function setEnv($env)
{
$this->env = $env; $this->env = $env;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
public function setCmdArg($cmd_arg){ public function setCmdArg($cmd_arg)
{
$this->cmd_arg = $cmd_arg; $this->cmd_arg = $cmd_arg;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
public function setDestGeneral(array $general){ public function setDestGeneral(array $general)
{
$this->destGeneral = $general; $this->destGeneral = $general;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
public function setDestCity(array $city){ public function setDestCity(array $city)
{
$this->destCity = $city; $this->destCity = $city;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
public function setDestNation(array $nation){ public function setDestNation(array $nation)
{
$this->destNation = $nation; $this->destNation = $nation;
$this->tested = false; $this->tested = false;
$this->reason = null; $this->reason = null;
} }
static public function build(array $input):self{ static public function build(array $input): self
{
$self = new static(); $self = new static();
foreach($input as $key=>$value){ foreach ($input as $key => $value) {
if($value === null){ if ($value === null) {
continue; continue;
} }
switch($key){ switch ($key) {
case 'general': $self->setGeneral($value); break; case 'general':
case 'city': $self->setCity($value); break; $self->setGeneral($value);
case 'nation': $self->setNation($value); break; break;
case 'cmd_arg': $self->setCmdArg($value); break; case 'city':
$self->setCity($value);
break;
case 'nation':
$self->setNation($value);
break;
case 'cmd_arg':
$self->setCmdArg($value);
break;
case 'destGeneral': $self->setDestGeneral($value); break; case 'destGeneral':
case 'destCity': $self->setDestCity($value); break; $self->setDestGeneral($value);
case 'destNation': $self->setDestNation($value); break; break;
case 'destCity':
$self->setDestCity($value);
break;
case 'destNation':
$self->setDestNation($value);
break;
} }
} }
return $self; return $self;
} }
public function checkInputValues(bool $throwExeception=true):bool{ public function checkInputValues(bool $throwExeception = true): bool
{
$valueType = static::requiredValueType(); $valueType = static::requiredValueType();
if(($valueType&static::REQ_GENERAL) && $this->general === null){ if (($valueType & static::REQ_GENERAL) && $this->general === null) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require general'); throw new \InvalidArgumentException('require general');
} }
if(($valueType&static::REQ_CITY) && $this->city === null){ if (($valueType & static::REQ_CITY) && $this->city === null) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require city'); throw new \InvalidArgumentException('require city');
} }
if(($valueType&static::REQ_NATION) && $this->nation === null){ if (($valueType & static::REQ_NATION) && $this->nation === null) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require nation'); throw new \InvalidArgumentException('require nation');
} }
if(($valueType&static::REQ_DEST_GENERAL) && $this->destGeneral === null){ if (($valueType & static::REQ_DEST_GENERAL) && $this->destGeneral === null) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require dest general'); throw new \InvalidArgumentException('require dest general');
} }
if(($valueType&static::REQ_DEST_CITY) && $this->destCity === null){ if (($valueType & static::REQ_DEST_CITY) && $this->destCity === null) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require dest city'); throw new \InvalidArgumentException('require dest city');
} }
if(($valueType&static::REQ_DEST_NATION) && $this->destNation === null){ if (($valueType & static::REQ_DEST_NATION) && $this->destNation === null) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require dest nation'); throw new \InvalidArgumentException('require dest nation');
} }
if (!($valueType&static::REQ_ARG)) { if (!($valueType & static::REQ_ARG)) {
return true; return true;
} }
if($valueType === null){ if ($valueType === null) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require arg'); throw new \InvalidArgumentException('require arg');
} }
if((($valueType&static::REQ_STRING_ARG)===static::REQ_STRING_ARG) && !is_string($this->arg)){ if ((($valueType & static::REQ_STRING_ARG) === static::REQ_STRING_ARG) && !is_string($this->arg)) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require string arg'); throw new \InvalidArgumentException('require string arg');
} }
if((($valueType&static::REQ_BOOLEAN_ARG)===static::REQ_BOOLEAN_ARG) && !is_bool($this->arg)){ if ((($valueType & static::REQ_BOOLEAN_ARG) === static::REQ_BOOLEAN_ARG) && !is_bool($this->arg)) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require bool arg'); throw new \InvalidArgumentException('require bool arg');
} }
if((($valueType&static::REQ_INT_ARG)===static::REQ_INT_ARG) && !is_int($this->arg)){ if ((($valueType & static::REQ_INT_ARG) === static::REQ_INT_ARG) && !is_int($this->arg)) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require int arg'); throw new \InvalidArgumentException('require int arg');
} }
if((($valueType&static::REQ_NUMERIC_ARG)===static::REQ_NUMERIC_ARG) && !is_numeric($this->arg)){ if ((($valueType & static::REQ_NUMERIC_ARG) === static::REQ_NUMERIC_ARG) && !is_numeric($this->arg)) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require numeric arg'); throw new \InvalidArgumentException('require numeric arg');
} }
if((($valueType&static::REQ_ARRAY_ARG)===static::REQ_ARRAY_ARG) && !is_array($this->arg)){ if ((($valueType & static::REQ_ARRAY_ARG) === static::REQ_ARRAY_ARG) && !is_array($this->arg)) {
if(!$throwExeception){return false; } if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require array arg'); throw new \InvalidArgumentException('require array arg');
} }
if ((($valueType & static::REQ_BACKED_ENUM_ARG) === static::REQ_BACKED_ENUM_ARG) && !($this->arg instanceof \BackedEnum)) {
if (!$throwExeception) {
return false;
}
throw new \InvalidArgumentException('require backed enum arg');
}
return true; return true;
} }
public function reason():?string{ public function reason(): ?string
if($this->tested === false){ {
throw new \RuntimeException(get_class($this).'::test가 실행되지 않음'); if ($this->tested === false) {
throw new \RuntimeException(get_class($this) . '::test가 실행되지 않음');
} }
return $this->reason; return $this->reason;
} }
public static function testAll(array $constraintPacks, array $input, array $env):?array{ public static function testAll(array $constraintPacks, array $input, array $env): ?array
foreach($constraintPacks as $constraintArgs){ {
if (!$constraintArgs){ foreach ($constraintPacks as $constraintArgs) {
if (!$constraintArgs) {
continue; continue;
} }
$constraintName = $constraintArgs[0]; $constraintName = $constraintArgs[0];
$method = __NAMESPACE__.'\\'.$constraintName.'::build'; $method = __NAMESPACE__ . '\\' . $constraintName . '::build';
/** @var \sammo\Constraint\Constraint $contraint */ /** @var \sammo\Constraint\Constraint $contraint */
$constraint = call_user_func($method,$input); $constraint = call_user_func($method, $input);
assert($constraint instanceof Constraint); assert($constraint instanceof Constraint);
$constraint->setEnv($env); $constraint->setEnv($env);
if(count($constraintArgs) == 2){ if (count($constraintArgs) == 2) {
$arg = $constraintArgs[1]; $arg = $constraintArgs[1];
$constraint->setArg($arg); $constraint->setArg($arg);
} }
if(!$constraint->test()){ if (!$constraint->test()) {
if($constraint->reason() === null){ if ($constraint->reason() === null) {
throw new \RuntimeException('Reason is not set:'.$constraintName); throw new \RuntimeException('Reason is not set:' . $constraintName);
} }
return [$constraintName, $constraint->reason()]; return [$constraintName, $constraint->reason()];
} }
@@ -220,5 +282,4 @@ abstract class Constraint{
return null; return null;
} }
} }
@@ -2,6 +2,8 @@
namespace sammo\Constraint; namespace sammo\Constraint;
use sammo\Enums\PenaltyKey;
class ConstraintHelper{ class ConstraintHelper{
static function AdhocCallback(callable $callback):array{ static function AdhocCallback(callable $callback):array{
@@ -176,6 +178,10 @@ class ConstraintHelper{
return [__FUNCTION__]; return [__FUNCTION__];
} }
static function NoPenalty(PenaltyKey $penaltyKey):array{
return [__FUNCTION__, $penaltyKey];
}
static function OccupiedCity(bool $allowNeutral=false):array{ static function OccupiedCity(bool $allowNeutral=false):array{
return [__FUNCTION__, $allowNeutral]; return [__FUNCTION__, $allowNeutral];
} }
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace sammo\Constraint;
use sammo\Enums\PenaltyKey;
use sammo\Json;
class NoPenalty extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_ARG|Constraint::REQ_BACKED_ENUM_ARG;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
return false;
}
if(!key_exists('penalty', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require penalty in general");
}
if(!($this->arg instanceof PenaltyKey)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require penalty key");
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
/** @var PenaltyKey */
$checkKey = $this->arg;
$peneltyList = JSON::decode($this->general['penalty']);
if(!key_exists($checkKey->value, $peneltyList)){
return true;
}
$this->reason = "징계 사유: {$peneltyList[$checkKey->value]}";
return false;
}
}
+2
View File
@@ -2,6 +2,7 @@
namespace sammo; namespace sammo;
use Ds\Map;
use sammo\Enums\InheritanceKey; use sammo\Enums\InheritanceKey;
class DummyGeneral extends General class DummyGeneral extends General
@@ -31,6 +32,7 @@ class DummyGeneral extends General
$this->raw = $raw; $this->raw = $raw;
$this->resultTurn = new LastTurn(); $this->resultTurn = new LastTurn();
$this->penaltyList = new Map();
if ($initLogger) { if ($initLogger) {
$this->initLogger(1, 1); $this->initLogger(1, 1);
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace sammo\Enums;
/**
* Penalty Key
* general의 penalty 항목
*/
enum PenaltyKey: string
{
case SendPrivateMsgDelay = 'sendPrivateMsgDelay';
case NoSendPrivateMsg = 'noSendPrivateMsg';
case NoSendPublicMsg = 'noSendPublicMsg';
case NoTopSecret = 'noTopSecret';
case NoChief = 'noChief';
case NoAmbassador = 'noAmbassador';
case NoBanGeneral = 'noBanGeneral';
case NoChiefTurnInput = 'noChiefTurnInput';
case NoChiefChange = 'noChiefChange';
case NoFoundNation = 'noFoundNation';
case NoChosenAssignment = 'noChosenAssignment';
public function getHelptext(): string
{
return match ($this) {
PenaltyKey::SendPrivateMsgDelay => '개인 메세지 보내기 제한 시간',
PenaltyKey::NoSendPrivateMsg => '개인 메세지 보내기 금지',
PenaltyKey::NoSendPublicMsg => '공개 메세지 보내기 금지',
PenaltyKey::NoTopSecret => '암행부 열람 금지',
PenaltyKey::NoChief => '수뇌 금지',
PenaltyKey::NoAmbassador => '외교권자 금지',
PenaltyKey::NoBanGeneral => '장수 추방 금지',
PenaltyKey::NoChiefTurnInput => '수뇌 턴 입력 금지',
PenaltyKey::NoChiefChange => '수뇌 임명/해임 금지',
PenaltyKey::NoFoundNation => '건국 금지',
PenaltyKey::NoChosenAssignment => '지정 임관 금지',
default => "페널티({$this->value})",
};
}
}
+1
View File
@@ -224,6 +224,7 @@ class GameConstBase
public static $inheritBuffPoints = [0, 200, 600, 1200, 2000, 3000]; public static $inheritBuffPoints = [0, 200, 600, 1200, 2000, 3000];
public static $inheritSpecificSpecialPoint = 4000; public static $inheritSpecificSpecialPoint = 4000;
public static $inheritResetAttrPointBase = [1000, 1000, 2000, 3000];//필요하면 늘려서 쓰기 public static $inheritResetAttrPointBase = [1000, 1000, 2000, 3000];//필요하면 늘려서 쓰기
public static $inheritCheckOwnerPoint = 1000;
/** @var ?string */ /** @var ?string */
public static $scenarioEffect = null; public static $scenarioEffect = null;
+26
View File
@@ -7,6 +7,7 @@ use sammo\Command\GeneralCommand;
use sammo\Enums\GeneralAccessLogColumn; use sammo\Enums\GeneralAccessLogColumn;
use sammo\Enums\GeneralQueryMode; use sammo\Enums\GeneralQueryMode;
use sammo\Enums\InheritanceKey; use sammo\Enums\InheritanceKey;
use sammo\Enums\PenaltyKey;
use sammo\Enums\RankColumn; use sammo\Enums\RankColumn;
use sammo\WarUnitTrigger as WarUnitTrigger; use sammo\WarUnitTrigger as WarUnitTrigger;
@@ -28,6 +29,10 @@ class General extends GeneralBase implements iAction
protected $logActivatedSkill = []; protected $logActivatedSkill = [];
protected $isFinished = false; protected $isFinished = false;
/** @var Map<PenaltyKey,int|float|string> */
protected Map $penaltyList;
/** @var ?iAction */ /** @var ?iAction */
protected $nationType = null; protected $nationType = null;
/** @var ?iAction */ /** @var ?iAction */
@@ -86,6 +91,16 @@ class General extends GeneralBase implements iAction
$this->rankVarRead = new Map(); $this->rankVarRead = new Map();
} }
$penaltyList = new Map();
foreach(Json::decode($raw['penalty'] ?? '{}') as $rawPenaltyKey => $penaltyValue){
$penaltyKey = PenaltyKey::tryFrom($rawPenaltyKey);
if($penaltyKey === null){
throw new \InvalidArgumentException('Invalid PenaltyKey: ' . $rawPenaltyKey);
}
$penaltyList[$penaltyKey] = $penaltyValue;
}
$this->penaltyList = $penaltyList;
$this->accessLogRead = $rawAccessLog; $this->accessLogRead = $rawAccessLog;
@@ -244,6 +259,17 @@ class General extends GeneralBase implements iAction
return $this->crewType; return $this->crewType;
} }
function hasPenalty(PenaltyKey $penaltyKey): bool
{
return $this->penaltyList->hasKey($penaltyKey);
}
/** @return Map<PenaltyKey,int|float|string> */
function getPenaltyList(): Map
{
return $this->penaltyList;
}
function calcRecentWarTurn(int $turnTerm): int function calcRecentWarTurn(int $turnTerm): int
{ {
$cacheKey = "recent_war_turn_{$turnTerm}"; $cacheKey = "recent_war_turn_{$turnTerm}";
+42 -4
View File
@@ -5,6 +5,7 @@ namespace sammo;
use sammo\Command\GeneralCommand; use sammo\Command\GeneralCommand;
use sammo\Command\NationCommand; use sammo\Command\NationCommand;
use sammo\Enums\MessageType; use sammo\Enums\MessageType;
use sammo\Enums\PenaltyKey;
use sammo\Enums\RankColumn; use sammo\Enums\RankColumn;
use sammo\Scenario\NPC; use sammo\Scenario\NPC;
@@ -3979,9 +3980,10 @@ class GeneralAI
continue; continue;
} }
$chief = $this->chiefGenerals[$chiefLevel]; $chief = $this->chiefGenerals[$chiefLevel];
if ($chief->getNPCType() < 2 && $chief->getVar('killturn') >= $minUserKillturn) { if ($chief->getNPCType() < 2 && $chief->getVar('killturn') >= $minUserKillturn && !$chief->hasPenalty(PenaltyKey::NoAmbassador)) {
$userChiefCnt += 1; $userChiefCnt += 1;
$chief->setVar('permission', 'ambassador'); $chief->setVar('permission', 'ambassador');
$chief->applyDB($db);
} }
} }
@@ -3993,12 +3995,41 @@ class GeneralAI
/** @var General[] */ /** @var General[] */
$nextChiefs = []; $nextChiefs = [];
if ($userChiefCnt == 0 && $this->userGenerals && !isOfficerSet($nation['chief_set'], 11)) { $availableUserChiefCnt = 0;
foreach($this->userGenerals as $general){
if ($general->getVar('killturn') < $minUserKillturn) {
continue;
}
if ($general->getVar('belong') < $minBelong) {
continue;
}
if($general->hasPenalty(PenaltyKey::NoChief)){
continue;
}
$availableUserChiefCnt += 1;
}
if ($userChiefCnt == 0 && $availableUserChiefCnt && !isOfficerSet($nation['chief_set'], 11)) {
$userGenerals = $this->userGenerals; $userGenerals = $this->userGenerals;
uasort($userGenerals, function (General $lhs, General $rhs) { uasort($userGenerals, function (General $lhs, General $rhs) {
if ($lhs->hasPenalty(PenaltyKey::NoChief) && !$rhs->hasPenalty(PenaltyKey::NoChief)) {
return 1;
}
if (!$lhs->hasPenalty(PenaltyKey::NoChief) && $rhs->hasPenalty(PenaltyKey::NoChief)) {
return -1;
}
if ($lhs->hasPenalty(PenaltyKey::NoAmbassador) && !$rhs->hasPenalty(PenaltyKey::NoAmbassador)) {
return 1;
}
if (!$lhs->hasPenalty(PenaltyKey::NoAmbassador) && $rhs->hasPenalty(PenaltyKey::NoAmbassador)) {
return -1;
}
return - ($lhs->getVar('leadership') <=> $rhs->getVar('leadership')); return - ($lhs->getVar('leadership') <=> $rhs->getVar('leadership'));
}); });
foreach ($userGenerals as $general) { foreach ($userGenerals as $general) {
if ($general->hasPenalty(PenaltyKey::NoChief)) {
continue;
}
if ($general->getVar('killturn') < $minUserKillturn) { if ($general->getVar('killturn') < $minUserKillturn) {
continue; continue;
} }
@@ -4011,7 +4042,9 @@ class GeneralAI
$nextChiefs[11] = $general; $nextChiefs[11] = $general;
$general->setVar('officer_level', 11); $general->setVar('officer_level', 11);
$general->setVar('officer_city', 0); $general->setVar('officer_city', 0);
$general->setVar('permission', 'ambassador'); if(!$general->hasPenalty(PenaltyKey::NoAmbassador)){
$general->setVar('permission', 'ambassador');
}
$nation['chief_set'] |= doOfficerSet(0, 11); $nation['chief_set'] |= doOfficerSet(0, 11);
$updatedChiefSet |= doOfficerSet(0, 11); $updatedChiefSet |= doOfficerSet(0, 11);
$userChiefCnt += 1; $userChiefCnt += 1;
@@ -4069,6 +4102,9 @@ class GeneralAI
if ($general->getNPCType() >= 2 && $general->getVar('killturn') < $minNPCKillturn) { if ($general->getNPCType() >= 2 && $general->getVar('killturn') < $minNPCKillturn) {
continue; continue;
} }
if($general->hasPenalty(PenaltyKey::NoChief)){
continue;
}
if ($chiefLevel == 11) { if ($chiefLevel == 11) {
} else if ($chiefLevel % 2 == 0 && $general->getStrength(false, false, false, false) < GameConst::$chiefStatMin) { } else if ($chiefLevel % 2 == 0 && $general->getStrength(false, false, false, false) < GameConst::$chiefStatMin) {
@@ -4091,7 +4127,9 @@ class GeneralAI
if ($newChief->getNPCType() < 2) { if ($newChief->getNPCType() < 2) {
$userChiefCnt += 1; $userChiefCnt += 1;
$newChief->setVar('permission', 'ambassador'); if(!$newChief->hasPenalty(PenaltyKey::NoAmbassador)){
$newChief->setVar('permission', 'ambassador');
}
} }
$nextChiefs[$chiefLevel] = $newChief; $nextChiefs[$chiefLevel] = $newChief;
@@ -24,6 +24,12 @@ class che_저지발동 extends BaseWarUnitTrigger{
} }
$selfEnv['저지발동'] = true; $selfEnv['저지발동'] = true;
$self->addPhase(-1);
$oppose->addPhase(-1);
if($self->getPhase() < $self->getMaxPhase()){
$oppose->addBonusPhase(-1);
}
$self->getLogger()->pushGeneralBattleDetailLog("상대를 <C>저지</>했다!", ActionLogger::PLAIN); $self->getLogger()->pushGeneralBattleDetailLog("상대를 <C>저지</>했다!", ActionLogger::PLAIN);
$oppose->getLogger()->pushGeneralBattleDetailLog("저지</>당했다!", ActionLogger::PLAIN); $oppose->getLogger()->pushGeneralBattleDetailLog("저지</>당했다!", ActionLogger::PLAIN);
+92 -70
View File
@@ -1,25 +1,17 @@
<template> <template>
<TopBackBar :title="title" /> <TopBackBar :title="title" />
<div <div id="container" class="bg0 px-2"
id="container" style="max-width: 1000px; margin: auto; border: solid 1px #888888; overflow: hidden">
class="bg0 px-2"
style="max-width: 1000px; margin: auto; border: solid 1px #888888; overflow: hidden"
>
<div id="inheritance_list" class="row"> <div id="inheritance_list" class="row">
<template v-for="(text, key) in inheritanceViewText" :key="key"> <template v-for="(text, key) in inheritanceViewText" :key="key">
<div :id="`inherit_${key}`" class="col col-sm-4 col-12 inherit_item inherit_template_item"> <div :id="`inherit_${key}`" class="col col-sm-4 col-12 inherit_item inherit_template_item">
<div class="row"> <div class="row">
<label :id="`inherit_${key}_head`" class="inherit_head col col-lg-6 col-sm-7 col-6 col-form-label">{{ <label :id="`inherit_${key}_head`" class="inherit_head col col-lg-6 col-sm-7 col-6 col-form-label">{{
text.title text.title
}}</label> }}</label>
<div class="col col-lg-6 col-sm-5 col-6"> <div class="col col-lg-6 col-sm-5 col-6">
<input <input :id="`inherit_${key}_value`" type="text" class="form-control inherit_value f_tnum" readonly
:id="`inherit_${key}_value`" :value="Math.floor(items[key]).toLocaleString()" />
type="text"
class="form-control inherit_value f_tnum"
readonly
:value="Math.floor(items[key]).toLocaleString()"
/>
</div> </div>
</div> </div>
@@ -53,13 +45,9 @@
</div> </div>
</div> </div>
<div class="a-right"> <div class="a-right">
<small class="form-text text-muted" <small class="form-text text-muted"><!-- eslint-disable-next-line vue/no-v-html -->
><!-- eslint-disable-next-line vue/no-v-html -->
<span style="color: white" v-html="availableSpecialWar[nextSpecialWar].info" /><br />다음에 얻을 전투 <span style="color: white" v-html="availableSpecialWar[nextSpecialWar].info" /><br />다음에 얻을 전투
특기를 정합니다.<br /><span style="color: white" 특기를 정합니다.<br /><span style="color: white">필요 포인트: {{ inheritActionCost.nextSpecial }}</span></small>
>필요 포인트: {{ inheritActionCost.nextSpecial }}</span
></small
>
</div> </div>
<div class="row px-4"> <div class="row px-4">
<BButton class="col-6 offset-6" variant="primary" @click="setNextSpecialWar"> 구입 </BButton> <BButton class="col-6 offset-6" variant="primary" @click="setNextSpecialWar"> 구입 </BButton>
@@ -79,17 +67,12 @@
</div> </div>
<div class="row px-4"> <div class="row px-4">
<div class="col f_tnum"> <div class="col f_tnum">
<NumberInputWithInfo <NumberInputWithInfo v-model="specificUniqueAmount" title="입찰 포인트"
v-model="specificUniqueAmount" :min="inheritActionCost.minSpecificUnique" :max="items.previous" />
title="입찰 포인트"
:min="inheritActionCost.minSpecificUnique"
:max="items.previous"
/>
</div> </div>
</div> </div>
<div class="a-right"> <div class="a-right">
<small class="form-text text-muted" <small class="form-text text-muted">얻고자 하는 유니크 아이템으로 경매를 시작합니다. 24 동안 진행됩니다.<br />
>얻고자 하는 유니크 아이템으로 경매를 시작합니다. 24 동안 진행됩니다.<br />
<!-- eslint-disable-next-line vue/no-v-html --> <!-- eslint-disable-next-line vue/no-v-html -->
<span style="color: white" v-html="specificUnique == null ? '' : availableUnique[specificUnique].info" /> <span style="color: white" v-html="specificUnique == null ? '' : availableUnique[specificUnique].info" />
</small> </small>
@@ -110,11 +93,8 @@
<BButton class="col-6" variant="primary" @click="tryResestTurnTime()"> 구입 </BButton> <BButton class="col-6" variant="primary" @click="tryResestTurnTime()"> 구입 </BButton>
</div> </div>
<div class="a-right"> <div class="a-right">
<small class="form-text text-muted" <small class="form-text text-muted">다다음턴부터 시간이 랜덤하게 바뀝니다. (필요 포인트가 피보나치식으로 증가합니다)<br /><span
>다다음턴부터 시간이 랜덤하게 바뀝니다. (필요 포인트가 피보나치식으로 증가합니다)<br /><span style="color: white" style="color: white">필요 포인트: {{ inheritActionCost.resetTurnTime }}</span></small>
>필요 포인트: {{ inheritActionCost.resetTurnTime }}</span
></small
>
</div> </div>
</div> </div>
<div class="col col-lg-4 col-sm-6 col-12 py-2"> <div class="col col-lg-4 col-sm-6 col-12 py-2">
@@ -123,11 +103,8 @@
<BButton class="col-6" variant="primary" @click="buySimple('BuyRandomUnique')"> 구입 </BButton> <BButton class="col-6" variant="primary" @click="buySimple('BuyRandomUnique')"> 구입 </BButton>
</div> </div>
<div class="a-right"> <div class="a-right">
<small class="form-text text-muted" <small class="form-text text-muted">다음 턴에 랜덤 유니크를 얻습니다.<br /><span style="color: white">필요 포인트: {{
>다음 턴에 랜덤 유니크를 얻습니다.<br /><span style="color: white" inheritActionCost.randomUnique }}</span></small>
>필요 포인트: {{ inheritActionCost.randomUnique }}</span
></small
>
</div> </div>
</div> </div>
<div class="col col-lg-4 col-sm-6 col-12 py-2"> <div class="col col-lg-4 col-sm-6 col-12 py-2">
@@ -136,11 +113,9 @@
<BButton class="col-6" variant="primary" @click="buySimple('ResetSpecialWar')"> 구입 </BButton> <BButton class="col-6" variant="primary" @click="buySimple('ResetSpecialWar')"> 구입 </BButton>
</div> </div>
<div class="a-right"> <div class="a-right">
<small class="form-text text-muted" <small class="form-text text-muted">즉시 전투 특기를 초기화합니다. (필요 포인트가 피보나치식으로 증가합니다)<br /><span
>즉시 전투 특기를 초기화합니다. (필요 포인트가 피보나치식으로 증가합니다)<br /><span style="color: white" style="color: white">필요
>필요 포인트: {{ inheritActionCost.resetSpecialWar }}</span 포인트: {{ inheritActionCost.resetSpecialWar }}</span></small>
></small
>
</div> </div>
</div> </div>
</div> </div>
@@ -153,33 +128,48 @@
<div class="row"> <div class="row">
<label class="col col-sm-6 col-form-label" :for="`buff-${buffKey}`">{{ info.title }}</label> <label class="col col-sm-6 col-form-label" :for="`buff-${buffKey}`">{{ info.title }}</label>
<div class="col col-sm-6 f_tnum"> <div class="col col-sm-6 f_tnum">
<b-form-input <b-form-input :id="`buff-${buffKey}`" v-model.number="inheritBuff[buffKey]" type="number"
:id="`buff-${buffKey}`" :min="prevInheritBuff[buffKey] ?? 0" :max="maxInheritBuff" />
v-model.number="inheritBuff[buffKey]"
type="number"
:min="prevInheritBuff[buffKey] ?? 0"
:max="maxInheritBuff"
/>
</div> </div>
</div> </div>
<div style="text-align: right"> <div style="text-align: right">
<small class="form-text text-muted f_tnum" <small class="form-text text-muted f_tnum">{{ info.info }}<br /><span style="color: white">필요 포인트:
>{{ info.info }}<br /><span style="color: white"
>필요 포인트:
{{ {{
inheritActionCost.buff[inheritBuff[buffKey]] - inheritActionCost.buff[prevInheritBuff[buffKey] ?? 0] inheritActionCost.buff[inheritBuff[buffKey]] - inheritActionCost.buff[prevInheritBuff[buffKey] ?? 0]
}}</span }}</span></small>
></small
>
</div> </div>
<div class="row px-4" style="margin-bottom: 1em"> <div class="row px-4" style="margin-bottom: 1em">
<BButton <BButton variant="secondary" class="col col-lg-6 col-4 offset-lg-0 offset-4"
variant="secondary" @click="inheritBuff[buffKey] = prevInheritBuff[buffKey] ?? 0">
class="col col-lg-6 col-4 offset-lg-0 offset-4" 리셋 </BButton>
@click="inheritBuff[buffKey] = prevInheritBuff[buffKey] ?? 0" <BButton variant="primary" class="col col-lg-6 col-4" @click="buyInheritBuff(buffKey)"> 구입 </BButton>
> </div>
리셋 </BButton </div>
><BButton variant="primary" class="col col-lg-6 col-4" @click="buyInheritBuff(buffKey)"> 구입 </BButton> </div>
<div style="width: 100%; padding: 0 10px">
<hr :style="{ opacity: 0.5 }" />
</div>
<div class="row">
<div class="col col-lg-4 col-sm-6 col-12 py-2">
<div class="row px-4">
<div class="a-right col-6 align-self-center">장수 소유자 확인</div>
<div class="col-6">
<select v-model="targetOwner" class="form-select col-6">
<option disabled selected :value="null">장수 선택</option>
<option v-for="(name, key) in availableTargetGeneral" :key="key" :value="key">
{{ name }}
</option>
</select>
</div>
</div>
<div class="a-right">
<small class="form-text text-muted">장수의 소유자를 찾습니다.<br />
</small>
<span style="color: white">필요 포인트: {{ inheritActionCost.checkOwner }}</span>
</div>
<div class="row px-4">
<BButton class="col-6 offset-6" variant="primary" @click="checkOwner"> 소유자 찾기 </BButton>
</div> </div>
</div> </div>
</div> </div>
@@ -196,7 +186,9 @@
{{ log.text }} {{ log.text }}
</div> </div>
</div> </div>
<div class="d-grid"><BButton @click="getMoreLog()"> 가져오기</BButton></div> <div class="d-grid">
<BButton @click="getMoreLog()"> 가져오기</BButton>
</div>
</div> </div>
</template> </template>
@@ -231,6 +223,7 @@ declare const staticValues: {
randomUnique: number; randomUnique: number;
nextSpecial: number; nextSpecial: number;
minSpecificUnique: number; minSpecificUnique: number;
checkOwner: number;
}; };
resetTurnTimeLevel: number; resetTurnTimeLevel: number;
resetSpecialWarLevel: number; resetSpecialWarLevel: number;
@@ -252,6 +245,7 @@ declare const staticValues: {
info: string; info: string;
} }
>; >;
availableTargetGeneral: Record<number, string>;
}; };
</script> </script>
<script lang="ts" setup> <script lang="ts" setup>
@@ -394,6 +388,7 @@ const {
currentInheritBuff: prevInheritBuff, currentInheritBuff: prevInheritBuff,
availableSpecialWar, availableSpecialWar,
availableUnique, availableUnique,
availableTargetGeneral,
} = staticValues; } = staticValues;
const nextSpecialWar = ref(Object.keys(availableSpecialWar)[0]); const nextSpecialWar = ref(Object.keys(availableSpecialWar)[0]);
@@ -450,7 +445,7 @@ async function buyInheritBuff(buffKey: inheritBuffType) {
location.reload(); location.reload();
} }
async function tryResestTurnTime(){ async function tryResestTurnTime() {
const cost = inheritActionCost.resetTurnTime; const cost = inheritActionCost.resetTurnTime;
if (items.value.previous < cost) { if (items.value.previous < cost) {
@@ -586,16 +581,43 @@ async function openUniqueItemAuction() {
location.reload(); location.reload();
} }
async function getMoreLog(): Promise<void>{ const targetOwner = ref<string | null>(null);
try{
async function checkOwner(): Promise<void> {
if (targetOwner.value === null) {
alert("장수를 선택해주세요.");
return;
}
const targetName = availableTargetGeneral[parseInt(targetOwner.value)];
if (!confirm(`${targetName}의 소유자를 찾겠습니까? 대상에게도 알림이 전송됩니다.`)) {
return;
}
try {
const result = await SammoAPI.InheritAction.CheckOwner({
destGeneralID: parseInt(targetOwner.value)
});
alert('결과가 개인 메시지로 전송되었습니다.');
} catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
}
async function getMoreLog(): Promise<void> {
try {
const result = await SammoAPI.InheritAction.GetMoreLog({ const result = await SammoAPI.InheritAction.GetMoreLog({
lastID: lastLogID.value lastID: lastLogID.value
}); });
for(const log of result.log){ for (const log of result.log) {
inheritPointLogs.value.set(log.id, log); inheritPointLogs.value.set(log.id, log);
lastLogID.value = Math.min(lastLogID.value, log.id); lastLogID.value = Math.min(lastLogID.value, log.id);
} }
}catch(e){ } catch (e) {
console.error(e); console.error(e);
alert(`실패했습니다: ${e}`); alert(`실패했습니다: ${e}`);
return; return;
+4 -1
View File
@@ -179,7 +179,10 @@ const apiRealPath = {
}>, }>,
GetMoreLog: GET as APICallT<{ GetMoreLog: GET as APICallT<{
lastID: number lastID: number
}, InheritLogResponse> }, InheritLogResponse>,
CheckOwner: PUT as APICallT<{
destGeneralID: number;
}>,
}, },
Message: { Message: {
DeleteMessage: PATCH as APICallT<{ DeleteMessage: PATCH as APICallT<{
+6 -1
View File
@@ -16,7 +16,10 @@ $gameStor = KVStorage::getStorage($db, 'game_env');
$me = General::createObjFromDB($generalID); $me = General::createObjFromDB($generalID);
$availableTargetGeneral = [];
foreach ($db->query('SELECT no, name FROM general WHERE npc < 2') as $row) {
$availableTargetGeneral[$row['no']] = $row['name'];
}
$currentInheritBuff = []; $currentInheritBuff = [];
foreach ($me->getAuxVar('inheritBuff') ?? [] as $buff => $buffLevel) { foreach ($me->getAuxVar('inheritBuff') ?? [] as $buff => $buffLevel) {
@@ -95,10 +98,12 @@ $lastInheritPointLogs = $db->query('SELECT id, server_id, year, month, date, tex
'randomUnique' => GameConst::$inheritItemRandomPoint, 'randomUnique' => GameConst::$inheritItemRandomPoint,
'nextSpecial' => GameConst::$inheritSpecificSpecialPoint, 'nextSpecial' => GameConst::$inheritSpecificSpecialPoint,
'minSpecificUnique' => GameConst::$inheritItemUniqueMinPoint, 'minSpecificUnique' => GameConst::$inheritItemUniqueMinPoint,
'checkOwner' => GameConst::$inheritCheckOwnerPoint,
], ],
'availableSpecialWar' => $avilableSpecialWar, 'availableSpecialWar' => $avilableSpecialWar,
'availableUnique' => $availableUnique, 'availableUnique' => $availableUnique,
'lastInheritPointLogs' => $lastInheritPointLogs, 'lastInheritPointLogs' => $lastInheritPointLogs,
'availableTargetGeneral' => $availableTargetGeneral,
] ]
]) ?> ]) ?>
</head> </head>