forked from devsam/core
Compare commits
35
Commits
c45758b054
...
3ad16d96be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ad16d96be | ||
|
|
d8870caf29 | ||
|
|
7c9d5d34f6 | ||
|
|
5268ce9b71 | ||
|
|
e395c98a6c | ||
|
|
d5897e2a49 | ||
|
|
c82003f982 | ||
|
|
5447274aa8 | ||
|
|
688162ffbf | ||
|
|
220d1d821d | ||
|
|
2b16c3c1a9 | ||
|
|
d731acdaef | ||
|
|
3511b159a8 | ||
|
|
28cea4ee09
|
||
|
|
8e7227c29d
|
||
|
|
f0cc22d9d8
|
||
|
|
b6f19fa38b
|
||
|
|
86305087f7
|
||
|
|
7b6f64db61
|
||
|
|
06f086bcf0
|
||
|
|
606c1664f2
|
||
|
|
0c07060f4d
|
||
|
|
8bd0cc1c64
|
||
|
|
f12262b946
|
||
|
|
9415d79a3a
|
||
|
|
ad223a9c75
|
||
|
|
8737b19e79
|
||
|
|
552d73430c
|
||
|
|
fba5fbdb6b
|
||
|
|
3da11bf21c
|
||
|
|
c83f9a0465
|
||
|
|
9f67ae1f4e
|
||
|
|
383431b79f
|
||
|
|
d5c0d16758
|
||
|
|
87294d5477 |
+6
-17
@@ -32,8 +32,10 @@ if ($type <= 0 || $type > 15) {
|
||||
}
|
||||
|
||||
$ownerNameList = [];
|
||||
foreach (RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]) {
|
||||
$ownerNameList[$ownerID] = $ownerName;
|
||||
if ($gameStor->isunited) {
|
||||
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('ts', 'common') ?>
|
||||
|
||||
<style>
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.generalName:hover > .hidden {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -175,11 +168,7 @@ foreach (RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID
|
||||
$name = formatName($general['name'], $general['npc']);
|
||||
|
||||
if (key_exists($general['owner'], $ownerNameList)) {
|
||||
if ($gameStor->isunited) {
|
||||
$name = $name . '<br><small class=\'userName\'>(' . $ownerNameList[$general['owner']] . ')</small>';
|
||||
} else {
|
||||
$name = $name . '<br><small class=\'userName hidden\'>(' . $ownerNameList[$general['owner']] . ')</small>';
|
||||
}
|
||||
$name = $name . '<br><small>(' . $ownerNameList[$general['owner']] . ')</small>';
|
||||
}
|
||||
|
||||
$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']}'
|
||||
>
|
||||
<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>" . displayCharInfo($general['personal']) . "</td>
|
||||
<td align=center>" . displaySpecialDomesticInfo($general['special']) . " / " . displaySpecialWarInfo($general['special2']) . "</td>
|
||||
|
||||
+11
-3
@@ -136,13 +136,21 @@ $changeDefence999Atmos = $me->onCalcDomestic('changeDefenceTrain', "atmos999", $
|
||||
<option value='<?= $targetDefenceTrain ?>' <?= $me->getVar('defence_train') == $targetDefenceTrain ? "selected" : ""; ?>><?= formatDefenceTrain($targetDefenceTrain) ?>(훈사<?= $targetDefenceTrain ?>)</option>
|
||||
<?php endforeach; ?>
|
||||
<option value=999 <?= $me->getVar('defence_train') == 999 ? "selected" : ""; ?>><?= formatDefenceTrain(999) ?>
|
||||
<?php if($changeDefence999Train != 0 || $changeDefence999Train != 0):
|
||||
?>[<?=$changeDefence999Train!=0?"훈련 {$changeDefence999Train},":''?><?=$changeDefence999Atmos!=0?"사기 {$changeDefence999Atmos}":''
|
||||
?>]<?php endif?></option>
|
||||
<?php if ($changeDefence999Train != 0 || $changeDefence999Train != 0) :
|
||||
?>[<?= $changeDefence999Train != 0 ? "훈련 {$changeDefence999Train}," : '' ?><?= $changeDefence999Atmos != 0 ? "사기 {$changeDefence999Atmos}" : ''
|
||||
?>]<?php endif ?></option>
|
||||
</select>
|
||||
】<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>
|
||||
∞<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)) : ?>
|
||||
휴 가 신 청<br>
|
||||
<button type="button" id='vacation' style=background-color:<?= GameConst::$basecolor2 ?>;color:white;width:160px;height:30px;font-size:14px;>휴가 신청</button><br><br>
|
||||
|
||||
+8
-6
@@ -9,6 +9,7 @@ use sammo\Enums\GeneralAccessLogColumn;
|
||||
use sammo\Enums\GeneralColumn;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
use sammo\Enums\PenaltyKey;
|
||||
use sammo\Enums\RankColumn;
|
||||
|
||||
require_once 'process_war.php';
|
||||
@@ -376,11 +377,11 @@ function myNationInfo(General $generalObj)
|
||||
function checkSecretMaxPermission($penalty)
|
||||
{
|
||||
$secretMax = 4;
|
||||
if ($penalty['noTopSecret'] ?? false) {
|
||||
if ($penalty[PenaltyKey::NoTopSecret->value] ?? false) {
|
||||
$secretMax = 1;
|
||||
} else if ($penalty['noChief'] ?? false) {
|
||||
} else if ($penalty[PenaltyKey::NoChief->value] ?? false) {
|
||||
$secretMax = 1;
|
||||
} else if ($penalty['noAmbassador'] ?? false) {
|
||||
} else if ($penalty[PenaltyKey::NoAmbassador->value] ?? false) {
|
||||
$secretMax = 2;
|
||||
}
|
||||
return $secretMax;
|
||||
@@ -403,7 +404,7 @@ function checkSecretPermission(array $me, $checkSecretLimit = true)
|
||||
}
|
||||
|
||||
|
||||
if ($penalty['noSecret'] ?? false) {
|
||||
if ($penalty[PenaltyKey::NoChief->value] ?? false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1668,8 +1669,6 @@ function tryUniqueItemLottery(RandUtil $rng, General $general, string $acquireTy
|
||||
$prob = 1 / ($genCount * $itemTypeCnt * 0.7 / 3); // 투표율 70%, 설문조사 한번에 2~3개 등장
|
||||
} else if ($acquireType == '랜덤 임관') {
|
||||
$prob = 1 / ($genCount * $itemTypeCnt / 10 / 2); // 랜임시 2개(10%) 등장(200명중 20명 랜임시도?)
|
||||
} else if ($acquireType == '건국') {
|
||||
$prob = 1 / ($genCount * $itemTypeCnt / 10 / 4); // 건국시 4개(20%) 등장(200명시 20국 정도 됨)
|
||||
}
|
||||
|
||||
$prob *= GameConst::$uniqueTrialCoef;
|
||||
@@ -1683,6 +1682,9 @@ function tryUniqueItemLottery(RandUtil $rng, General $general, string $acquireTy
|
||||
//포인트로 랜덤 유니크 획득
|
||||
$prob = 1;
|
||||
}
|
||||
else if ($acquireType == '건국') {
|
||||
$prob = 1; // 건국시 100%
|
||||
}
|
||||
|
||||
foreach (Util::range($maxCnt) as $_idx) {
|
||||
if ($rng->nextBool($prob)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo;
|
||||
|
||||
use sammo\Command\GeneralCommand;
|
||||
use sammo\Command\NationCommand;
|
||||
use sammo\Enums\PenaltyKey;
|
||||
|
||||
function getGeneralTurnBrief(General $generalObj, array $turnList) {
|
||||
$result = [];
|
||||
@@ -434,6 +435,13 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
|
||||
];
|
||||
}
|
||||
|
||||
if($general->hasPenalty(PenaltyKey::NoChiefTurnInput)){
|
||||
return [
|
||||
'result'=>false,
|
||||
'reason'=>'수뇌 턴 입력 불가능'
|
||||
];
|
||||
}
|
||||
|
||||
try{
|
||||
$commandObj = buildNationCommandClass($command, $general, $env, $general->getLastTurn(), $arg);
|
||||
}
|
||||
@@ -473,6 +481,13 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr
|
||||
}
|
||||
|
||||
_setNationCommand($commandObj, $turnList);
|
||||
|
||||
if($general->getNPCType() < 2){
|
||||
//유저장인 경우에는 턴 리필
|
||||
$general->updateVarWithLimit('killturn', $env['killturn'], $general->getVar('killturn'));
|
||||
$general->applyDB($db);
|
||||
}
|
||||
|
||||
return [
|
||||
'result'=>true,
|
||||
'brief'=>$commandObj->getBrief(),
|
||||
|
||||
@@ -372,7 +372,7 @@ function postUpdateMonthly(RandUtil $rng)
|
||||
continue;
|
||||
}
|
||||
|
||||
//양측 기간 모두 0이 되는 상황이면 휴전
|
||||
//양측 기간 모두 0이 되는 상황이면 종전
|
||||
$nation1 = getNationStaticInfo($me);
|
||||
$name1 = $nation1['name'];
|
||||
$nation2 = getNationStaticInfo($you);
|
||||
@@ -381,7 +381,7 @@ function postUpdateMonthly(RandUtil $rng)
|
||||
$josaWa = JosaUtil::pick($name1, '와');
|
||||
$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', [
|
||||
'state' => 2,
|
||||
'term' => 0,
|
||||
|
||||
+129
-98
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Enums\GeneralColumn;
|
||||
use sammo\Enums\GeneralLiteQueryMode;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\MessageType;
|
||||
use sammo\Enums\PenaltyKey;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
@@ -21,92 +24,99 @@ $userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$gameStor->cacheValues(['startyear','year','month','scenario']);
|
||||
$gameStor->cacheValues(['startyear', 'year', 'month', 'scenario', 'killturn']);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no,nation,officer_level from general where owner=%i', $userID);
|
||||
$me = $db->queryFirstRow('SELECT no,npc,nation,officer_level,penalty from general where owner=%i', $userID);
|
||||
$myOfficerLevel = $me['officer_level'];
|
||||
$nationID = $me['nation'];
|
||||
$myPenalty = Json::decode($me['penalty'] ?? '{}');
|
||||
|
||||
//수뇌가 아니면 아무것도 할 수 없음
|
||||
if($myOfficerLevel < 5){
|
||||
if ($myOfficerLevel < 5) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'수뇌가 아닙니다.'
|
||||
'result' => false,
|
||||
'reason' => '수뇌가 아닙니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($action === '추방' && $destGeneralID==0){
|
||||
if ($action === '추방' && $destGeneralID == 0) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'장수가 지정되지 않았습니다.'
|
||||
'result' => false,
|
||||
'reason' => '장수가 지정되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($destGeneralID==0){
|
||||
if ($destGeneralID == 0) {
|
||||
$general = new DummyGeneral(true);
|
||||
$general->setVar('nation', $nationID);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$general = General::createObjFromDB($destGeneralID);
|
||||
|
||||
if($general instanceof DummyGeneral){
|
||||
if ($general instanceof DummyGeneral) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 장수입니다.'
|
||||
'result' => false,
|
||||
'reason' => '올바르지 않은 장수입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($nationID != $general->getNationID()){
|
||||
if ($nationID != $general->getNationID()) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'아국 장수가 아닙니다'
|
||||
'result' => false,
|
||||
'reason' => '아국 장수가 아닙니다'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if($officerLevel == 12){
|
||||
if ($officerLevel == 12) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'군주를 대상으로 할 수 없습니다.'
|
||||
'result' => false,
|
||||
'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();
|
||||
$nationID = $general->getNationID();
|
||||
|
||||
if($general->hasPenalty(PenaltyKey::NoChief)){
|
||||
return '수뇌가 될 수 없는 상태입니다.';
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
if($targetOfficerLevel < $lv){
|
||||
if ($targetOfficerLevel < $lv) {
|
||||
return '임명불가능한 관직입니다.';
|
||||
}
|
||||
|
||||
if(isOfficerSet($chiefSet, $targetOfficerLevel)){
|
||||
if (isOfficerSet($chiefSet, $targetOfficerLevel)) {
|
||||
return '지금은 임명할 수 없습니다.';
|
||||
}
|
||||
|
||||
//기존 장수 일반으로
|
||||
$db->update('general', [
|
||||
'officer_level'=>1,
|
||||
'officer_city'=>0,
|
||||
'officer_level' => 1,
|
||||
'officer_city' => 0,
|
||||
], 'nation=%i AND officer_level=%i AND no!=%i', $nationID, $targetOfficerLevel, $generalID);
|
||||
|
||||
if($targetOfficerLevel === 11){
|
||||
|
||||
}
|
||||
else if($targetOfficerLevel % 2 == 0){
|
||||
if($general->getVar('strength') < GameConst::$chiefStatMin){
|
||||
if ($targetOfficerLevel === 11) {
|
||||
} else if ($targetOfficerLevel % 2 == 0) {
|
||||
if ($general->getVar('strength') < GameConst::$chiefStatMin) {
|
||||
return '무력이 부족합니다.';
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
if($general->getVar('intel') < GameConst::$chiefStatMin){
|
||||
} else {
|
||||
if ($general->getVar('intel') < GameConst::$chiefStatMin) {
|
||||
return '지력이 부족합니다.';
|
||||
}
|
||||
}
|
||||
@@ -115,52 +125,59 @@ function do수뇌임명(General $general, int $targetOfficerLevel):?string{
|
||||
$general->setVar('officer_level', $targetOfficerLevel);
|
||||
$general->setVar('officer_city', 0);
|
||||
$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);
|
||||
$general->applyDB($db);
|
||||
|
||||
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();
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
if(CityConst::byID($cityID) === null){
|
||||
if (CityConst::byID($cityID) === null) {
|
||||
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);
|
||||
if($officerSet === null){
|
||||
if ($officerSet === null) {
|
||||
return '아국 도시가 아닙니다';
|
||||
}
|
||||
|
||||
if(isOfficerSet($officerSet, $targetOfficerLevel)){
|
||||
if (isOfficerSet($officerSet, $targetOfficerLevel)) {
|
||||
return '이미 다른 장수가 임명되어있습니다';
|
||||
}
|
||||
|
||||
//기존 장수 일반으로
|
||||
$db->update('general', [
|
||||
'officer_level'=>1,
|
||||
'officer_city'=>0,
|
||||
'officer_level' => 1,
|
||||
'officer_city' => 0,
|
||||
], 'officer_level=%i AND officer_city=%i AND no!=%i', $targetOfficerLevel, $cityID, $general->getID());
|
||||
|
||||
if($general instanceof DummyGeneral){
|
||||
if ($general instanceof DummyGeneral) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($targetOfficerLevel === 4 && $general->getVar('strength') < GameConst::$chiefStatMin){
|
||||
if ($targetOfficerLevel === 4 && $general->getVar('strength') < GameConst::$chiefStatMin) {
|
||||
return '무력이 부족합니다.';
|
||||
}
|
||||
|
||||
if($targetOfficerLevel === 3 && $general->getVar('intel') < GameConst::$chiefStatMin){
|
||||
if ($targetOfficerLevel === 3 && $general->getVar('intel') < GameConst::$chiefStatMin) {
|
||||
return '지력이 부족합니다.';
|
||||
}
|
||||
|
||||
//신임 장수
|
||||
$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);
|
||||
$general->setVar('officer_level', $targetOfficerLevel);
|
||||
$general->setVar('officer_city', $cityID);
|
||||
@@ -169,22 +186,25 @@ function do도시임명(General $general, int $cityID, int $targetOfficerLevel):
|
||||
return null;
|
||||
}
|
||||
|
||||
function do추방(General $general, int $myOfficerLevel):?string{
|
||||
function do추방(General $general, int $myOfficerLevel): ?string
|
||||
{
|
||||
$generalID = $general->getID();
|
||||
$generalName = $general->getVar('name');
|
||||
$nationID = $general->getNationID();
|
||||
|
||||
|
||||
if ($myPenalty[PenaltyKey::NoBanGeneral->value] ?? false) {
|
||||
return '추방할 수 없는 상태입니다.';
|
||||
}
|
||||
|
||||
//추방할사람이 외교권자이면 불가
|
||||
$permission = checkSecretPermission($general->getRaw());
|
||||
if($permission == 4){
|
||||
if ($permission == 4) {
|
||||
return '외교권자는 추방할 수 없습니다.';
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$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);
|
||||
$nationName = $nation['name'];
|
||||
@@ -192,17 +212,17 @@ function do추방(General $general, int $myOfficerLevel):?string{
|
||||
$logger = $general->getLogger();
|
||||
|
||||
//이미 지정했다면 무시
|
||||
if(isOfficerSet($nation['chief_set'], $myOfficerLevel) || ($myOfficerLevel == 0 && $myOfficerLevel == 12)) {
|
||||
if (isOfficerSet($nation['chief_set'], $myOfficerLevel) || ($myOfficerLevel == 0 && $myOfficerLevel == 12)) {
|
||||
return '이미 추방 권한을 사용했습니다.';
|
||||
}
|
||||
$gold = 0;
|
||||
$rice = 0;
|
||||
// 금쌀1000이상은 남김
|
||||
if($general->getVar('gold') > GameConst::$defaultGold) {
|
||||
if ($general->getVar('gold') > GameConst::$defaultGold) {
|
||||
$gold = $general->getVar('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;
|
||||
$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);
|
||||
|
||||
// 명성/공헌 N*10%감소
|
||||
if($env['year'] <= $env['startyear'] && $general->getNPCType() < 2){
|
||||
if ($env['year'] <= $env['startyear'] && $general->getNPCType() < 2) {
|
||||
$general->setVar('makelimit', $oldMakeLimit);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$betrayCnt = $general->getVar('betray');
|
||||
$general->addExperience(-$general->getVar('experience')*0.15*$betrayCnt);
|
||||
$general->addDedication(-$general->getVar('dedication')*0.15*$betrayCnt);
|
||||
$general->addExperience(-$general->getVar('experience') * 0.15 * $betrayCnt);
|
||||
$general->addDedication(-$general->getVar('dedication') * 0.15 * $betrayCnt);
|
||||
$general->increaseVarWithLimit('betray', 1, null, GameConst::$maxBetrayCnt);
|
||||
}
|
||||
|
||||
//부대장일 경우
|
||||
if($general->getVar('troop') == $generalID){
|
||||
if ($general->getVar('troop') == $generalID) {
|
||||
// 모두 탈퇴
|
||||
$db->update('general', [
|
||||
'troop'=>0,
|
||||
'troop' => 0,
|
||||
], 'troop = %i', $generalID);
|
||||
$db->delete('troop', 'troop_leader=%i', $generalID);
|
||||
}
|
||||
$general->setVar('troop', 0);
|
||||
|
||||
if($general->getNPCType() >= 2){
|
||||
if ($general->getNPCType() >= 2) {
|
||||
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||
UniqueConst::$hiddenSeed,
|
||||
'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', [
|
||||
'injury'=>$db->sqleval('least(injury + 1, %i)', 80),
|
||||
'injury' => $db->sqleval('least(injury + 1, %i)', 80),
|
||||
], 'nation=%i AND officer_level=12', $nationID);
|
||||
|
||||
$db->update('nation', [
|
||||
'gennum'=>$db->sqleval('gennum - %i', $general->getNPCType()!=5?1:0),
|
||||
'gold'=>$db->sqleval('gold + %i', $gold),
|
||||
'rice'=>$db->sqleval('rice + %i', $rice),
|
||||
'gennum' => $db->sqleval('gennum - %i', $general->getNPCType() != 5 ? 1 : 0),
|
||||
'gold' => $db->sqleval('gold + %i', $gold),
|
||||
'rice' => $db->sqleval('rice + %i', $rice),
|
||||
], 'nation = %i', $nationID);
|
||||
} else {
|
||||
//이번분기는 추방불가(초반 제외)
|
||||
$db->update('nation', [
|
||||
'chief_set'=>$db->sqleval('chief_set | %i', doOfficerSet(0, $myOfficerLevel)),
|
||||
'gennum'=>$db->sqleval('gennum - %i', $general->getNPCType()!=5?1:0),
|
||||
'gold'=>$db->sqleval('gold + %i', $gold),
|
||||
'rice'=>$db->sqleval('rice + %i', $rice),
|
||||
'chief_set' => $db->sqleval('chief_set | %i', doOfficerSet(0, $myOfficerLevel)),
|
||||
'gennum' => $db->sqleval('gennum - %i', $general->getNPCType() != 5 ? 1 : 0),
|
||||
'gold' => $db->sqleval('gold + %i', $gold),
|
||||
'rice' => $db->sqleval('rice + %i', $rice),
|
||||
], 'nation = %i', $nationID);
|
||||
}
|
||||
|
||||
@@ -308,62 +327,74 @@ function do추방(General $general, int $myOfficerLevel):?string{
|
||||
|
||||
|
||||
|
||||
if($action == "임명") {
|
||||
if(2 <= $officerLevel && $officerLevel <= 4){
|
||||
if(!$destCityID){
|
||||
if ($action == "임명") {
|
||||
if (2 <= $officerLevel && $officerLevel <= 4) {
|
||||
if (!$destCityID) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'도시가 지정되지 않았습니다.'
|
||||
'result' => false,
|
||||
'reason' => '도시가 지정되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
$result = do도시임명($general, $destCityID, $officerLevel);
|
||||
if($result !== null){
|
||||
if ($result !== null) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
//수뇌의 삭턴 리필
|
||||
$db->update('general', [
|
||||
'killturn' => $db->sqleval('GREATEST(%b, %i)', 'killturn', $gameStor->getValue('killturn')),
|
||||
], 'no=%i', $me['no']);
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
'result' => true,
|
||||
'reason' => 'success'
|
||||
]);
|
||||
}
|
||||
|
||||
if(5 <= $officerLevel && $officerLevel < 12){
|
||||
if (5 <= $officerLevel && $officerLevel < 12) {
|
||||
$result = do수뇌임명($general, $officerLevel);
|
||||
if($result !== null){
|
||||
if ($result !== null) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
//수뇌의 삭턴 리필
|
||||
$db->update('general', [
|
||||
'killturn' => $db->sqleval('GREATEST(%b, %i)', 'killturn', $gameStor->getValue('killturn')),
|
||||
], 'no=%i', $me['no']);
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
'result' => true,
|
||||
'reason' => 'success'
|
||||
]);
|
||||
}
|
||||
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 지정입니다.'
|
||||
'result' => false,
|
||||
'reason' => '올바르지 않은 지정입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($action == "추방") {
|
||||
if ($action == "추방") {
|
||||
$result = do추방($general, $myOfficerLevel);
|
||||
if($result !== null){
|
||||
if ($result !== null) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
//수뇌의 삭턴 리필
|
||||
$db->update('general', [
|
||||
'killturn' => $db->sqleval('GREATEST(%b, %i)', 'killturn', $gameStor->getValue('killturn')),
|
||||
], 'no=%i', $me['no']);
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
'result' => true,
|
||||
'reason' => 'success'
|
||||
]);
|
||||
}
|
||||
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 명령입니다.'
|
||||
]);
|
||||
'result' => false,
|
||||
'reason' => '올바르지 않은 명령입니다.'
|
||||
]);
|
||||
|
||||
+37
-15
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
@@ -24,14 +25,13 @@ if ($defence_train <= 40) {
|
||||
$defence_train = 40;
|
||||
}
|
||||
|
||||
if($defence_train <= 90){
|
||||
if ($defence_train <= 90) {
|
||||
$defence_train = Util::round($defence_train, -1);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$defence_train = 999;
|
||||
}
|
||||
|
||||
if($tnmt < 0 || $tnmt > 1){
|
||||
if ($tnmt < 0 || $tnmt > 1) {
|
||||
$tnmt = 1;
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ $db = DB::db();
|
||||
$me = General::createObjFromDB($generalID);
|
||||
|
||||
|
||||
if($defence_train !== $me->getVar('defence_train')){
|
||||
if($defence_train == 999){
|
||||
if ($defence_train !== $me->getVar('defence_train')) {
|
||||
if ($defence_train == 999) {
|
||||
$me->increaseVar('myset', -1);
|
||||
$me->setVar('defence_train', $defence_train);
|
||||
$affectedTrain = -3;
|
||||
@@ -49,8 +49,7 @@ if($defence_train !== $me->getVar('defence_train')){
|
||||
$affectedAtmos = $me->onCalcDomestic('changeDefenceTrain', "atmos{$defence_train}", $affectedAtmos);
|
||||
$me->increaseVarWithLimit('train', $affectedTrain, 20, GameConst::$maxTrainByWar);
|
||||
$me->increaseVarWithLimit('atmos', $affectedAtmos, 20, GameConst::$maxAtmosByWar);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$me->increaseVar('myset', -1);
|
||||
$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->setVar('tnmt', $tnmt);
|
||||
|
||||
if($me->getNPCType() == 1 && $detachNPC){
|
||||
if ($me->getNPCType() == 1 && $detachNPC) {
|
||||
$turnterm = $gameStor->turnterm;
|
||||
|
||||
if($turnterm < 10){
|
||||
if ($turnterm < 10) {
|
||||
$targetKillTurn = 30 / $turnterm;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$targetKillTurn = 60 / $turnterm;
|
||||
}
|
||||
$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);
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
]);
|
||||
'result' => true,
|
||||
'reason' => 'success'
|
||||
]);
|
||||
|
||||
+10
-7
@@ -718,14 +718,17 @@ function ConquerCity(array $admin, General $general, array $city, array $defende
|
||||
$attackerLogger->pushGlobalHistoryLog("<M><b>【긴급천도】</b></><D><b>{$defenderNationName}</b></>{$josaYi} 수도가 함락되어 <G><b>$minCityName</b></>{$josaRo} 긴급천도하였습니다.");
|
||||
|
||||
$moveLog = "수도가 함락되어 <G><b>$minCityName</b></>{$josaRo} <M>긴급천도</>합니다.";
|
||||
//아국 수뇌부에게 로그 전달
|
||||
foreach ($db->queryFirstColumn(
|
||||
'SELECT no FROM general WHERE nation=%i AND officer_level>=5',
|
||||
foreach ($db->queryAllLists(
|
||||
'SELECT no, officer_level FROM general WHERE nation=%i',
|
||||
$defenderNationID
|
||||
) as $defenderChiefID) {
|
||||
$chiefLogger = new ActionLogger($defenderChiefID, $defenderNationID, $year, $month);
|
||||
$chiefLogger->pushGeneralActionLog($moveLog, ActionLogger::PLAIN);
|
||||
$chiefLogger->flush();
|
||||
) as [$defenderGeneralID, $defenderGeneralChiefLevel]) {
|
||||
$defenderLogger = new ActionLogger($defenderGeneralID, $defenderNationID, $year, $month);
|
||||
$defenderLogger->pushGeneralActionLog($moveLog, ActionLogger::PLAIN);
|
||||
if($defenderGeneralChiefLevel >= 5){
|
||||
$defenderLogger->pushGeneralActionLog("수뇌는 <G><b>{$minCityName}</b></>{$josaRo} 집합되었습니다.");
|
||||
}
|
||||
|
||||
$defenderLogger->flush();
|
||||
}
|
||||
|
||||
//천도
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\InheritAction;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\APIRecoveryType;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
use sammo\LiteHashDRBG;
|
||||
use sammo\RandUtil;
|
||||
use sammo\UniqueConst;
|
||||
use sammo\UserLogger;
|
||||
use sammo\Util;
|
||||
use sammo\Validator;
|
||||
|
||||
class ResetStat extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
$v->rule('required', [
|
||||
'leadership',
|
||||
'strength',
|
||||
'intel',
|
||||
])
|
||||
->rule('int', [
|
||||
'leadership',
|
||||
'strength',
|
||||
'intel',
|
||||
])
|
||||
->rule('min', [
|
||||
'leadership',
|
||||
'strength',
|
||||
'intel'
|
||||
], GameConst::$defaultStatMin)
|
||||
->rule('max', [
|
||||
'leadership',
|
||||
'strength',
|
||||
'intel'
|
||||
], GameConst::$defaultStatMax)
|
||||
->rule('integerArray', 'inheritBonusStat');
|
||||
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
//General.aux 쓰므로 lock;
|
||||
return static::REQ_GAME_LOGIN;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag): null | string | array | APIRecoveryType
|
||||
{
|
||||
$userID = $session->userID;
|
||||
$generalID = $session->generalID;
|
||||
|
||||
|
||||
$leadership = $this->args['leadership'];
|
||||
$strength = $this->args['strength'];
|
||||
$intel = $this->args['intel'];
|
||||
$inheritBonusStat = $this->args['inheritBonusStat'] ?? null;
|
||||
|
||||
if ($leadership + $strength + $intel != GameConst::$defaultStatTotal) {
|
||||
return "능력치 총합이 " . GameConst::$defaultStatTotal . "이 아닙니다. 다시 입력해주세요!";
|
||||
}
|
||||
|
||||
if ($inheritBonusStat) {
|
||||
if (count($inheritBonusStat) != 3) {
|
||||
return "보너스 능력치가 잘못 지정되었습니다. 다시 입력해주세요!";
|
||||
}
|
||||
foreach ($inheritBonusStat as $stat) {
|
||||
if ($stat < 0) {
|
||||
return "보너스 능력치가 음수입니다. 다시 입력해주세요!";
|
||||
}
|
||||
}
|
||||
$sum = array_sum($inheritBonusStat);
|
||||
if ($sum == 0) {
|
||||
$inheritBonusStat = null;
|
||||
} else if ($sum < 3 || $sum > 5) {
|
||||
return "보너스 능력치 합이 잘못 지정되었습니다. 다시 입력해주세요!";
|
||||
}
|
||||
}
|
||||
|
||||
$general = General::createObjFromDB($generalID);
|
||||
if ($userID != $general->getVar('owner')) {
|
||||
return '로그인 상태가 이상합니다. 다시 로그인해 주세요.';
|
||||
}
|
||||
$userLogger = new UserLogger($userID);
|
||||
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$gameStor->cacheValues([
|
||||
'isunited',
|
||||
'season',
|
||||
]);
|
||||
if ($gameStor->isunited) {
|
||||
return '이미 천하가 통일되었습니다.';
|
||||
}
|
||||
$userStor = KVStorage::getStorage($db, "user_{$userID}");
|
||||
|
||||
$lastUserStatReset = $userStor->getValue('last_stat_reset') ?? [];
|
||||
$gameSeason = $gameStor->getValue('season');
|
||||
|
||||
if (array_search($gameSeason, $lastUserStatReset) !== false) {
|
||||
return '이번 시즌에 이미 능력치를 초기화하셨습니다.';
|
||||
}
|
||||
|
||||
|
||||
$inheritStor = KVStorage::getStorage($db, "inheritance_{$userID}");
|
||||
$previousPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0];
|
||||
$reqAmount = 0;
|
||||
if ($inheritBonusStat !== null) {
|
||||
$reqAmount += GameConst::$inheritBornStatPoint;
|
||||
}
|
||||
|
||||
if ($previousPoint < $reqAmount) {
|
||||
return '충분한 유산 포인트를 가지고 있지 않습니다.';
|
||||
}
|
||||
|
||||
$userLogger->push("통솔 {$leadership}, 무력 {$strength}, 지력 {$intel} 스탯 재설정", "inheritPoint");
|
||||
|
||||
if ($inheritBonusStat) {
|
||||
$pleadership = $inheritBonusStat[0] ?? 0;
|
||||
$pstrength = $inheritBonusStat[1] ?? 0;
|
||||
$pintel = $inheritBonusStat[2] ?? 0;
|
||||
$userLogger->push("{$reqAmount}로 통솔 {$pleadership}, 무력 {$pstrength}, 지력 {$pintel} 보너스 능력치 적용", "inheritPoint");
|
||||
} else {
|
||||
$rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||
UniqueConst::$hiddenSeed,
|
||||
'ResetStat',
|
||||
$userID,
|
||||
)));
|
||||
$pleadership = 0;
|
||||
$pstrength = 0;
|
||||
$pintel = 0;
|
||||
foreach (Util::range($rng->nextRangeInt(3, 5)) as $statIdx) {
|
||||
switch ($rng->choiceUsingWeight([$leadership, $strength, $intel])) {
|
||||
case 0:
|
||||
$pleadership++;
|
||||
break;
|
||||
case 1:
|
||||
$pstrength++;
|
||||
break;
|
||||
case 2:
|
||||
$pintel++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$userLogger->push("통솔 {$pleadership}, 무력 {$pstrength}, 지력 {$pintel} 보너스 능력치 적용", "inheritPoint");
|
||||
}
|
||||
|
||||
$leadership += $pleadership;
|
||||
$strength += $pstrength;
|
||||
$intel += $pintel;
|
||||
|
||||
$lastUserStatReset[] = $gameSeason;
|
||||
|
||||
|
||||
$general->setVar('leadership', $leadership);
|
||||
$general->setVar('strength', $strength);
|
||||
$general->setVar('intel', $intel);
|
||||
|
||||
$userLogger->flush();
|
||||
|
||||
$inheritStor->setValue('previous', [$previousPoint - $reqAmount, null]);
|
||||
$userStor->setValue('last_stat_reset', $lastUserStatReset);
|
||||
$general->increaseRankVar(RankColumn::inherit_point_spent_dynamic, $reqAmount);
|
||||
$general->applyDB($db);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\Enums\APIRecoveryType;
|
||||
use sammo\Enums\MessageType;
|
||||
use sammo\Enums\PenaltyKey;
|
||||
use sammo\Json;
|
||||
use sammo\Message;
|
||||
use sammo\MessageTarget;
|
||||
@@ -191,6 +192,9 @@ class SendMessage extends \sammo\BaseAPI
|
||||
|
||||
// 전체 메세지
|
||||
if ($mailbox === Message::MAILBOX_PUBLIC) {
|
||||
if($penalty[PenaltyKey::NoSendPublicMsg->value] ?? 0) {
|
||||
return '공개 메세지를 보낼 수 없습니다.';
|
||||
}
|
||||
$msgID = $this->genPublicMessage($src, $text)->send();
|
||||
return [
|
||||
'msgType' => 'public',
|
||||
@@ -231,7 +235,11 @@ class SendMessage extends \sammo\BaseAPI
|
||||
$lastMsg = new \DateTime($session->lastMsg ?? '0000-00-00');
|
||||
$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) {
|
||||
return "개인메세지는 {$msg_min_interval}초당 1건만 보낼 수 있습니다!";
|
||||
}
|
||||
|
||||
@@ -19,10 +19,14 @@ class che_저지_삼황내문 extends \sammo\BaseItem{
|
||||
if($unit->isAttacker()){
|
||||
return null;
|
||||
}
|
||||
if($unit->getPhase() >= 2){
|
||||
|
||||
if($unit->getPhase() > 0){
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ use function \sammo\getAllNationStaticInfo;
|
||||
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
use sammo\Enums\PenaltyKey;
|
||||
|
||||
use function sammo\buildNationTypeClass;
|
||||
use function sammo\genGenericUniqueRNGFromGeneral;
|
||||
@@ -81,7 +82,8 @@ class che_건국 extends Command\GeneralCommand
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
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::AllowJoinAction(),
|
||||
ConstraintHelper::ConstructableCity(),
|
||||
ConstraintHelper::NoPenalty(PenaltyKey::NoFoundNation),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -199,6 +202,7 @@ class che_건국 extends Command\GeneralCommand
|
||||
refreshNationStaticInfo();
|
||||
|
||||
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
|
||||
$general->increaseInheritancePoint(InheritanceKey::unifier, 250);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general, static::$actionName), $general, '건국');
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
@@ -16,15 +20,18 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
class che_사기진작 extends Command\GeneralCommand{
|
||||
class che_사기진작 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '사기진작';
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
@@ -33,13 +40,13 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
];
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
@@ -48,31 +55,35 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
ConstraintHelper::ReqGeneralAtmosMargin(GameConst::$maxAtmosByCommand),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
//[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
return "{$name}(통솔경험, 자금↓)";
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
return [Util::round($general->getVar('crew')/100), 0];
|
||||
return [Util::round($general->getVar('crew') / 100), 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -81,7 +92,11 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$score = Util::round($general->getLeadership() * 100 / $general->getVar('crew') * GameConst::$atmosDelta);
|
||||
$score = Util::clamp(
|
||||
Util::round($general->getLeadership() * 100 / $general->getVar('crew') * GameConst::$atmosDelta),
|
||||
0,
|
||||
Util::clamp(GameConst::$maxAtmosByCommand - $general->getVar('atmos'), 0),
|
||||
);
|
||||
$scoreText = number_format($score, 0);
|
||||
|
||||
$sideEffect = Util::valueFit(intval($general->getVar('train') * GameConst::$trainSideEffectByAtmosTurn), 0);
|
||||
@@ -93,7 +108,7 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
$exp = 100;
|
||||
$ded = 70;
|
||||
|
||||
$general->increaseVarWithLimit('atmos', $score, 0, GameConst::$maxAtmosByCommand);
|
||||
$general->increaseVar('atmos', $score);
|
||||
$general->setVar('train', $sideEffect);
|
||||
|
||||
$general->addDex($general->getCrewTypeObj(), $score, false);
|
||||
@@ -111,6 +126,4 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use function \sammo\getNationStaticInfo;
|
||||
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
use sammo\Enums\PenaltyKey;
|
||||
|
||||
class che_임관 extends Command\GeneralCommand
|
||||
{
|
||||
@@ -66,7 +67,8 @@ class che_임관 extends Command\GeneralCommand
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
||||
ConstraintHelper::BeNeutral(),
|
||||
ConstraintHelper::AllowJoinAction()
|
||||
ConstraintHelper::AllowJoinAction(),
|
||||
ConstraintHelper::NoPenalty(PenaltyKey::NoChosenAssignment),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -92,7 +94,8 @@ class che_임관 extends Command\GeneralCommand
|
||||
ConstraintHelper::BeNeutral(),
|
||||
ConstraintHelper::ExistsDestNation(),
|
||||
ConstraintHelper::AllowJoinDestNation($relYear),
|
||||
ConstraintHelper::AllowJoinAction()
|
||||
ConstraintHelper::AllowJoinAction(),
|
||||
ConstraintHelper::NoPenalty(PenaltyKey::NoChosenAssignment),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -74,12 +74,15 @@ class che_화계 extends Command\GeneralCommand
|
||||
|
||||
$maxGenScore = 0;
|
||||
$probCorrection = 0;
|
||||
$affectGeneralCount = 0;
|
||||
foreach ($destCityGeneralList as $destGeneral) {
|
||||
/** @var General $destGeneral */
|
||||
if ($destGeneral->getNationID() != $destNationID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$affectGeneralCount++;
|
||||
|
||||
if ($statType === 'leadership') {
|
||||
$genScore = $destGeneral->getLeadership();
|
||||
} else if ($statType === 'strength') {
|
||||
@@ -95,7 +98,7 @@ class che_화계 extends Command\GeneralCommand
|
||||
|
||||
$prob = $maxGenScore / GameConst::$sabotageProbCoefByStat;
|
||||
$prob += $probCorrection;
|
||||
$prob += (log(count($destCityGeneralList) + 1, 2) - 1.25) * GameConst::$sabotageDefenceCoefByGeneralCnt;
|
||||
$prob += (log($affectGeneralCount + 1, 2) - 1.25) * GameConst::$sabotageDefenceCoefByGeneralCnt;
|
||||
|
||||
$prob += $destCity['secu'] / $destCity['secu_max'] / 5; //최대 20%p
|
||||
$prob += $destCity['supply'] ? 0.1 : 0;
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
@@ -17,66 +21,73 @@ use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
|
||||
class che_훈련 extends Command\GeneralCommand{
|
||||
class che_훈련 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '훈련';
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
];
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
ConstraintHelper::ReqGeneralTrainMargin(GameConst::$maxTrainByCommand),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$name = $this->getName();
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$title = "{$name}(통솔경험";
|
||||
if($reqGold > 0){
|
||||
if ($reqGold > 0) {
|
||||
$title .= ", 자금{$reqGold}";
|
||||
}
|
||||
if($reqRice > 0){
|
||||
if ($reqRice > 0) {
|
||||
$title .= ", 군량{$reqRice}";
|
||||
}
|
||||
$title .= ')';
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -85,7 +96,11 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$score = Util::round($general->getLeadership() * 100 / $general->getVar('crew') * GameConst::$trainDelta);
|
||||
$score = Util::clamp(
|
||||
Util::round($general->getLeadership() * 100 / $general->getVar('crew') * GameConst::$trainDelta),
|
||||
0,
|
||||
Util::clamp(GameConst::$maxTrainByCommand - $general->getVar('train'), 0)
|
||||
);
|
||||
$scoreText = number_format($score, 0);
|
||||
|
||||
$sideEffect = Util::valueFit(intval($general->getVar('atmos') * GameConst::$atmosSideEffectByTraining), 0);
|
||||
@@ -97,7 +112,7 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
$exp = 100;
|
||||
$ded = 70;
|
||||
|
||||
$general->increaseVarWithLimit('train', $score, 0, GameConst::$maxTrainByCommand);
|
||||
$general->increaseVar('train', $score);
|
||||
$general->setVar('atmos', $sideEffect);
|
||||
|
||||
$general->addDex($general->getCrewTypeObj(), $score, false);
|
||||
@@ -112,6 +127,4 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
abstract class Constraint{
|
||||
private function __construct(){
|
||||
|
||||
abstract class Constraint
|
||||
{
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
const REQ_GENERAL = 0x10;
|
||||
@@ -18,7 +20,8 @@ abstract class Constraint{
|
||||
const REQ_NUMERIC_ARG = self::REQ_ARG | 0x4000;
|
||||
const REQ_BOOLEAN_ARG = self::REQ_ARG | 0x8000;
|
||||
const REQ_ARRAY_ARG = self::REQ_ARG | 0x10000;
|
||||
|
||||
const REQ_BACKED_ENUM_ARG = self::REQ_ARG | 0x20000;
|
||||
|
||||
const REQ_VALUES = 0;
|
||||
|
||||
protected $general = null;
|
||||
@@ -37,182 +40,241 @@ abstract class Constraint{
|
||||
protected $tested = false;
|
||||
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;
|
||||
}
|
||||
|
||||
public function setGeneral(array $general){
|
||||
public function setGeneral(array $general)
|
||||
{
|
||||
$this->general = $general;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
public function setCity(array $city){
|
||||
public function setCity(array $city)
|
||||
{
|
||||
$this->city = $city;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
public function setNation(array $nation){
|
||||
public function setNation(array $nation)
|
||||
{
|
||||
$this->nation = $nation;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
public function setArg($arg){
|
||||
public function setArg($arg)
|
||||
{
|
||||
$this->arg = $arg;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
public function setEnv($env){
|
||||
public function setEnv($env)
|
||||
{
|
||||
$this->env = $env;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
public function setCmdArg($cmd_arg){
|
||||
public function setCmdArg($cmd_arg)
|
||||
{
|
||||
$this->cmd_arg = $cmd_arg;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
|
||||
public function setDestGeneral(array $general){
|
||||
public function setDestGeneral(array $general)
|
||||
{
|
||||
$this->destGeneral = $general;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
public function setDestCity(array $city){
|
||||
public function setDestCity(array $city)
|
||||
{
|
||||
$this->destCity = $city;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
public function setDestNation(array $nation){
|
||||
public function setDestNation(array $nation)
|
||||
{
|
||||
$this->destNation = $nation;
|
||||
$this->tested = false;
|
||||
$this->reason = null;
|
||||
}
|
||||
|
||||
static public function build(array $input):self{
|
||||
static public function build(array $input): self
|
||||
{
|
||||
$self = new static();
|
||||
foreach($input as $key=>$value){
|
||||
if($value === null){
|
||||
foreach ($input as $key => $value) {
|
||||
if ($value === null) {
|
||||
continue;
|
||||
}
|
||||
switch($key){
|
||||
case 'general': $self->setGeneral($value); break;
|
||||
case 'city': $self->setCity($value); break;
|
||||
case 'nation': $self->setNation($value); break;
|
||||
case 'cmd_arg': $self->setCmdArg($value); break;
|
||||
switch ($key) {
|
||||
case 'general':
|
||||
$self->setGeneral($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 'destCity': $self->setDestCity($value); break;
|
||||
case 'destNation': $self->setDestNation($value); break;
|
||||
case 'destGeneral':
|
||||
$self->setDestGeneral($value);
|
||||
break;
|
||||
case 'destCity':
|
||||
$self->setDestCity($value);
|
||||
break;
|
||||
case 'destNation':
|
||||
$self->setDestNation($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
public function checkInputValues(bool $throwExeception=true):bool{
|
||||
public function checkInputValues(bool $throwExeception = true): bool
|
||||
{
|
||||
$valueType = static::requiredValueType();
|
||||
|
||||
if(($valueType&static::REQ_GENERAL) && $this->general === null){
|
||||
if(!$throwExeception){return false; }
|
||||
if (($valueType & static::REQ_GENERAL) && $this->general === null) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require general');
|
||||
}
|
||||
|
||||
if(($valueType&static::REQ_CITY) && $this->city === null){
|
||||
if(!$throwExeception){return false; }
|
||||
if (($valueType & static::REQ_CITY) && $this->city === null) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require city');
|
||||
}
|
||||
|
||||
if(($valueType&static::REQ_NATION) && $this->nation === null){
|
||||
if(!$throwExeception){return false; }
|
||||
if (($valueType & static::REQ_NATION) && $this->nation === null) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require nation');
|
||||
}
|
||||
|
||||
if(($valueType&static::REQ_DEST_GENERAL) && $this->destGeneral === null){
|
||||
if(!$throwExeception){return false; }
|
||||
if (($valueType & static::REQ_DEST_GENERAL) && $this->destGeneral === null) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require dest general');
|
||||
}
|
||||
|
||||
if(($valueType&static::REQ_DEST_CITY) && $this->destCity === null){
|
||||
if(!$throwExeception){return false; }
|
||||
if (($valueType & static::REQ_DEST_CITY) && $this->destCity === null) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require dest city');
|
||||
}
|
||||
|
||||
if(($valueType&static::REQ_DEST_NATION) && $this->destNation === null){
|
||||
if(!$throwExeception){return false; }
|
||||
if (($valueType & static::REQ_DEST_NATION) && $this->destNation === null) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require dest nation');
|
||||
}
|
||||
|
||||
if (!($valueType&static::REQ_ARG)) {
|
||||
return true;
|
||||
if (!($valueType & static::REQ_ARG)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($valueType === null){
|
||||
if(!$throwExeception){return false; }
|
||||
if ($valueType === null) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require arg');
|
||||
}
|
||||
|
||||
if((($valueType&static::REQ_STRING_ARG)===static::REQ_STRING_ARG) && !is_string($this->arg)){
|
||||
if(!$throwExeception){return false; }
|
||||
if ((($valueType & static::REQ_STRING_ARG) === static::REQ_STRING_ARG) && !is_string($this->arg)) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require string arg');
|
||||
}
|
||||
|
||||
if((($valueType&static::REQ_BOOLEAN_ARG)===static::REQ_BOOLEAN_ARG) && !is_bool($this->arg)){
|
||||
if(!$throwExeception){return false; }
|
||||
if ((($valueType & static::REQ_BOOLEAN_ARG) === static::REQ_BOOLEAN_ARG) && !is_bool($this->arg)) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require bool arg');
|
||||
}
|
||||
|
||||
if((($valueType&static::REQ_INT_ARG)===static::REQ_INT_ARG) && !is_int($this->arg)){
|
||||
if(!$throwExeception){return false; }
|
||||
if ((($valueType & static::REQ_INT_ARG) === static::REQ_INT_ARG) && !is_int($this->arg)) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require int arg');
|
||||
}
|
||||
|
||||
if((($valueType&static::REQ_NUMERIC_ARG)===static::REQ_NUMERIC_ARG) && !is_numeric($this->arg)){
|
||||
if(!$throwExeception){return false; }
|
||||
if ((($valueType & static::REQ_NUMERIC_ARG) === static::REQ_NUMERIC_ARG) && !is_numeric($this->arg)) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
throw new \InvalidArgumentException('require numeric arg');
|
||||
}
|
||||
|
||||
if((($valueType&static::REQ_ARRAY_ARG)===static::REQ_ARRAY_ARG) && !is_array($this->arg)){
|
||||
if(!$throwExeception){return false; }
|
||||
if ((($valueType & static::REQ_ARRAY_ARG) === static::REQ_ARRAY_ARG) && !is_array($this->arg)) {
|
||||
if (!$throwExeception) {
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
public function reason():?string{
|
||||
if($this->tested === false){
|
||||
throw new \RuntimeException(get_class($this).'::test가 실행되지 않음');
|
||||
public function reason(): ?string
|
||||
{
|
||||
if ($this->tested === false) {
|
||||
throw new \RuntimeException(get_class($this) . '::test가 실행되지 않음');
|
||||
}
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public static function testAll(array $constraintPacks, array $input, array $env):?array{
|
||||
foreach($constraintPacks as $constraintArgs){
|
||||
if (!$constraintArgs){
|
||||
public static function testAll(array $constraintPacks, array $input, array $env): ?array
|
||||
{
|
||||
foreach ($constraintPacks as $constraintArgs) {
|
||||
if (!$constraintArgs) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$constraintName = $constraintArgs[0];
|
||||
$method = __NAMESPACE__.'\\'.$constraintName.'::build';
|
||||
$method = __NAMESPACE__ . '\\' . $constraintName . '::build';
|
||||
|
||||
/** @var \sammo\Constraint\Constraint $contraint */
|
||||
$constraint = call_user_func($method,$input);
|
||||
$constraint = call_user_func($method, $input);
|
||||
|
||||
assert($constraint instanceof Constraint);
|
||||
$constraint->setEnv($env);
|
||||
if(count($constraintArgs) == 2){
|
||||
if (count($constraintArgs) == 2) {
|
||||
$arg = $constraintArgs[1];
|
||||
$constraint->setArg($arg);
|
||||
}
|
||||
|
||||
|
||||
if(!$constraint->test()){
|
||||
|
||||
if($constraint->reason() === null){
|
||||
throw new \RuntimeException('Reason is not set:'.$constraintName);
|
||||
if (!$constraint->test()) {
|
||||
|
||||
if ($constraint->reason() === null) {
|
||||
throw new \RuntimeException('Reason is not set:' . $constraintName);
|
||||
}
|
||||
return [$constraintName, $constraint->reason()];
|
||||
}
|
||||
@@ -220,5 +282,4 @@ abstract class Constraint{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
use sammo\Enums\PenaltyKey;
|
||||
|
||||
class ConstraintHelper{
|
||||
|
||||
static function AdhocCallback(callable $callback):array{
|
||||
@@ -176,6 +178,10 @@ class ConstraintHelper{
|
||||
return [__FUNCTION__];
|
||||
}
|
||||
|
||||
static function NoPenalty(PenaltyKey $penaltyKey):array{
|
||||
return [__FUNCTION__, $penaltyKey];
|
||||
}
|
||||
|
||||
static function OccupiedCity(bool $allowNeutral=false):array{
|
||||
return [__FUNCTION__, $allowNeutral];
|
||||
}
|
||||
|
||||
@@ -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,6 +2,7 @@
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use Ds\Map;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
|
||||
class DummyGeneral extends General
|
||||
@@ -31,6 +32,7 @@ class DummyGeneral extends General
|
||||
$this->raw = $raw;
|
||||
|
||||
$this->resultTurn = new LastTurn();
|
||||
$this->penaltyList = new Map();
|
||||
|
||||
if ($initLogger) {
|
||||
$this->initLogger(1, 1);
|
||||
|
||||
@@ -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})",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -224,6 +224,7 @@ class GameConstBase
|
||||
public static $inheritBuffPoints = [0, 200, 600, 1200, 2000, 3000];
|
||||
public static $inheritSpecificSpecialPoint = 4000;
|
||||
public static $inheritResetAttrPointBase = [1000, 1000, 2000, 3000];//필요하면 늘려서 쓰기
|
||||
public static $inheritCheckOwnerPoint = 1000;
|
||||
|
||||
/** @var ?string */
|
||||
public static $scenarioEffect = null;
|
||||
|
||||
+27
-1
@@ -7,6 +7,7 @@ use sammo\Command\GeneralCommand;
|
||||
use sammo\Enums\GeneralAccessLogColumn;
|
||||
use sammo\Enums\GeneralQueryMode;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
use sammo\Enums\PenaltyKey;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\WarUnitTrigger as WarUnitTrigger;
|
||||
|
||||
@@ -28,6 +29,10 @@ class General extends GeneralBase implements iAction
|
||||
protected $logActivatedSkill = [];
|
||||
protected $isFinished = false;
|
||||
|
||||
|
||||
/** @var Map<PenaltyKey,int|float|string> */
|
||||
protected Map $penaltyList;
|
||||
|
||||
/** @var ?iAction */
|
||||
protected $nationType = null;
|
||||
/** @var ?iAction */
|
||||
@@ -86,6 +91,16 @@ class General extends GeneralBase implements iAction
|
||||
$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;
|
||||
|
||||
|
||||
@@ -244,6 +259,17 @@ class General extends GeneralBase implements iAction
|
||||
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
|
||||
{
|
||||
$cacheKey = "recent_war_turn_{$turnTerm}";
|
||||
@@ -372,7 +398,7 @@ class General extends GeneralBase implements iAction
|
||||
}
|
||||
|
||||
$this->calcCache[$cKey] = $statValue;
|
||||
|
||||
|
||||
return $statValue;
|
||||
}
|
||||
|
||||
|
||||
+42
-4
@@ -5,6 +5,7 @@ namespace sammo;
|
||||
use sammo\Command\GeneralCommand;
|
||||
use sammo\Command\NationCommand;
|
||||
use sammo\Enums\MessageType;
|
||||
use sammo\Enums\PenaltyKey;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\Scenario\NPC;
|
||||
|
||||
@@ -3979,9 +3980,10 @@ class GeneralAI
|
||||
continue;
|
||||
}
|
||||
$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;
|
||||
$chief->setVar('permission', 'ambassador');
|
||||
$chief->applyDB($db);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3993,12 +3995,41 @@ class GeneralAI
|
||||
/** @var General[] */
|
||||
$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;
|
||||
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'));
|
||||
});
|
||||
foreach ($userGenerals as $general) {
|
||||
if ($general->hasPenalty(PenaltyKey::NoChief)) {
|
||||
continue;
|
||||
}
|
||||
if ($general->getVar('killturn') < $minUserKillturn) {
|
||||
continue;
|
||||
}
|
||||
@@ -4011,7 +4042,9 @@ class GeneralAI
|
||||
$nextChiefs[11] = $general;
|
||||
$general->setVar('officer_level', 11);
|
||||
$general->setVar('officer_city', 0);
|
||||
$general->setVar('permission', 'ambassador');
|
||||
if(!$general->hasPenalty(PenaltyKey::NoAmbassador)){
|
||||
$general->setVar('permission', 'ambassador');
|
||||
}
|
||||
$nation['chief_set'] |= doOfficerSet(0, 11);
|
||||
$updatedChiefSet |= doOfficerSet(0, 11);
|
||||
$userChiefCnt += 1;
|
||||
@@ -4069,6 +4102,9 @@ class GeneralAI
|
||||
if ($general->getNPCType() >= 2 && $general->getVar('killturn') < $minNPCKillturn) {
|
||||
continue;
|
||||
}
|
||||
if($general->hasPenalty(PenaltyKey::NoChief)){
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($chiefLevel == 11) {
|
||||
} else if ($chiefLevel % 2 == 0 && $general->getStrength(false, false, false, false) < GameConst::$chiefStatMin) {
|
||||
@@ -4091,7 +4127,9 @@ class GeneralAI
|
||||
|
||||
if ($newChief->getNPCType() < 2) {
|
||||
$userChiefCnt += 1;
|
||||
$newChief->setVar('permission', 'ambassador');
|
||||
if(!$newChief->hasPenalty(PenaltyKey::NoAmbassador)){
|
||||
$newChief->setVar('permission', 'ambassador');
|
||||
}
|
||||
}
|
||||
|
||||
$nextChiefs[$chiefLevel] = $newChief;
|
||||
|
||||
@@ -24,6 +24,12 @@ class che_저지발동 extends BaseWarUnitTrigger{
|
||||
}
|
||||
$selfEnv['저지발동'] = true;
|
||||
|
||||
$self->addPhase(-1);
|
||||
$oppose->addPhase(-1);
|
||||
if($self->getPhase() < $self->getMaxPhase()){
|
||||
$oppose->addBonusPhase(-1);
|
||||
}
|
||||
|
||||
$self->getLogger()->pushGeneralBattleDetailLog("상대를 <C>저지</>했다!", ActionLogger::PLAIN);
|
||||
$oppose->getLogger()->pushGeneralBattleDetailLog("저지</>당했다!", ActionLogger::PLAIN);
|
||||
|
||||
|
||||
+196
-73
@@ -1,25 +1,17 @@
|
||||
<template>
|
||||
<TopBackBar :title="title" />
|
||||
<div
|
||||
id="container"
|
||||
class="bg0 px-2"
|
||||
style="max-width: 1000px; margin: auto; border: solid 1px #888888; overflow: hidden"
|
||||
>
|
||||
<div id="container" class="bg0 px-2"
|
||||
style="max-width: 1000px; margin: auto; border: solid 1px #888888; overflow: hidden">
|
||||
<div id="inheritance_list" class="row">
|
||||
<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 class="row">
|
||||
<label :id="`inherit_${key}_head`" class="inherit_head col col-lg-6 col-sm-7 col-6 col-form-label">{{
|
||||
text.title
|
||||
}}</label>
|
||||
text.title
|
||||
}}</label>
|
||||
<div class="col col-lg-6 col-sm-5 col-6">
|
||||
<input
|
||||
:id="`inherit_${key}_value`"
|
||||
type="text"
|
||||
class="form-control inherit_value f_tnum"
|
||||
readonly
|
||||
:value="Math.floor(items[key]).toLocaleString()"
|
||||
/>
|
||||
<input :id="`inherit_${key}_value`" type="text" class="form-control inherit_value f_tnum" readonly
|
||||
:value="Math.floor(items[key]).toLocaleString()" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -53,13 +45,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="a-right">
|
||||
<small class="form-text text-muted"
|
||||
><!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<small class="form-text text-muted"><!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<span style="color: white" v-html="availableSpecialWar[nextSpecialWar].info" /><br />다음에 얻을 전투
|
||||
특기를 정합니다.<br /><span style="color: white"
|
||||
>필요 포인트: {{ inheritActionCost.nextSpecial }}</span
|
||||
></small
|
||||
>
|
||||
특기를 정합니다.<br /><span style="color: white">필요 포인트: {{ inheritActionCost.nextSpecial }}</span></small>
|
||||
</div>
|
||||
<div class="row px-4">
|
||||
<BButton class="col-6 offset-6" variant="primary" @click="setNextSpecialWar"> 구입 </BButton>
|
||||
@@ -79,17 +67,12 @@
|
||||
</div>
|
||||
<div class="row px-4">
|
||||
<div class="col f_tnum">
|
||||
<NumberInputWithInfo
|
||||
v-model="specificUniqueAmount"
|
||||
title="입찰 포인트"
|
||||
:min="inheritActionCost.minSpecificUnique"
|
||||
:max="items.previous"
|
||||
/>
|
||||
<NumberInputWithInfo v-model="specificUniqueAmount" title="입찰 포인트"
|
||||
:min="inheritActionCost.minSpecificUnique" :max="items.previous" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="a-right">
|
||||
<small class="form-text text-muted"
|
||||
>얻고자 하는 유니크 아이템으로 경매를 시작합니다. 24턴 동안 진행됩니다.<br />
|
||||
<small class="form-text text-muted">얻고자 하는 유니크 아이템으로 경매를 시작합니다. 24턴 동안 진행됩니다.<br />
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<span style="color: white" v-html="specificUnique == null ? '' : availableUnique[specificUnique].info" />
|
||||
</small>
|
||||
@@ -110,11 +93,8 @@
|
||||
<BButton class="col-6" variant="primary" @click="tryResestTurnTime()"> 구입 </BButton>
|
||||
</div>
|
||||
<div class="a-right">
|
||||
<small class="form-text text-muted"
|
||||
>다다음턴부터 시간이 랜덤하게 바뀝니다. (필요 포인트가 피보나치식으로 증가합니다)<br /><span style="color: white"
|
||||
>필요 포인트: {{ inheritActionCost.resetTurnTime }}</span
|
||||
></small
|
||||
>
|
||||
<small class="form-text text-muted">다다음턴부터 시간이 랜덤하게 바뀝니다. (필요 포인트가 피보나치식으로 증가합니다)<br /><span
|
||||
style="color: white">필요 포인트: {{ inheritActionCost.resetTurnTime }}</span></small>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
<div class="a-right">
|
||||
<small class="form-text text-muted"
|
||||
>다음 턴에 랜덤 유니크를 얻습니다.<br /><span style="color: white"
|
||||
>필요 포인트: {{ inheritActionCost.randomUnique }}</span
|
||||
></small
|
||||
>
|
||||
<small class="form-text text-muted">다음 턴에 랜덤 유니크를 얻습니다.<br /><span style="color: white">필요 포인트: {{
|
||||
inheritActionCost.randomUnique }}</span></small>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
<div class="a-right">
|
||||
<small class="form-text text-muted"
|
||||
>즉시 전투 특기를 초기화합니다. (필요 포인트가 피보나치식으로 증가합니다)<br /><span style="color: white"
|
||||
>필요 포인트: {{ inheritActionCost.resetSpecialWar }}</span
|
||||
></small
|
||||
>
|
||||
<small class="form-text text-muted">즉시 전투 특기를 초기화합니다. (필요 포인트가 피보나치식으로 증가합니다)<br /><span
|
||||
style="color: white">필요
|
||||
포인트: {{ inheritActionCost.resetSpecialWar }}</span></small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -153,33 +128,98 @@
|
||||
<div class="row">
|
||||
<label class="col col-sm-6 col-form-label" :for="`buff-${buffKey}`">{{ info.title }}</label>
|
||||
<div class="col col-sm-6 f_tnum">
|
||||
<b-form-input
|
||||
:id="`buff-${buffKey}`"
|
||||
v-model.number="inheritBuff[buffKey]"
|
||||
type="number"
|
||||
:min="prevInheritBuff[buffKey] ?? 0"
|
||||
:max="maxInheritBuff"
|
||||
/>
|
||||
<b-form-input :id="`buff-${buffKey}`" v-model.number="inheritBuff[buffKey]" type="number"
|
||||
:min="prevInheritBuff[buffKey] ?? 0" :max="maxInheritBuff" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="text-align: right">
|
||||
<small class="form-text text-muted f_tnum"
|
||||
>{{ info.info }}<br /><span style="color: white"
|
||||
>필요 포인트:
|
||||
<small class="form-text text-muted f_tnum">{{ info.info }}<br /><span style="color: white">필요 포인트:
|
||||
{{
|
||||
inheritActionCost.buff[inheritBuff[buffKey]] - inheritActionCost.buff[prevInheritBuff[buffKey] ?? 0]
|
||||
}}</span
|
||||
></small
|
||||
>
|
||||
inheritActionCost.buff[inheritBuff[buffKey]] - inheritActionCost.buff[prevInheritBuff[buffKey] ?? 0]
|
||||
}}</span></small>
|
||||
</div>
|
||||
<div class="row px-4" style="margin-bottom: 1em">
|
||||
<BButton
|
||||
variant="secondary"
|
||||
class="col col-lg-6 col-4 offset-lg-0 offset-4"
|
||||
@click="inheritBuff[buffKey] = prevInheritBuff[buffKey] ?? 0"
|
||||
>
|
||||
리셋 </BButton
|
||||
><BButton variant="primary" class="col col-lg-6 col-4" @click="buyInheritBuff(buffKey)"> 구입 </BButton>
|
||||
<BButton variant="secondary" class="col col-lg-6 col-4 offset-lg-0 offset-4"
|
||||
@click="inheritBuff[buffKey] = prevInheritBuff[buffKey] ?? 0">
|
||||
리셋 </BButton>
|
||||
<BButton variant="primary" class="col col-lg-6 col-4" @click="buyInheritBuff(buffKey)"> 구입 </BButton>
|
||||
</div>
|
||||
</div>
|
||||
</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 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">
|
||||
<div class="row">기본 능력치</div>
|
||||
<div class="row">
|
||||
<div class="col col-2 center align-self-center">통</div>
|
||||
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.leadership" type="number"
|
||||
:min="currentStat.statMin" :max="currentStat.statMax" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col col-2 center align-self-center">무</div>
|
||||
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.strength" type="number"
|
||||
:min="currentStat.statMin" :max="currentStat.statMax" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col col-2 center align-self-center">지</div>
|
||||
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.intel" type="number"
|
||||
:min="currentStat.statMin" :max="currentStat.statMax" /></div>
|
||||
</div>
|
||||
<div class="row">추가 능력치</div>
|
||||
<div class="row">
|
||||
<div class="col col-2 center align-self-center">통</div>
|
||||
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.inheritBonusStat[0]" type="number"
|
||||
min="0" max="5" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col col-2 center align-self-center">무</div>
|
||||
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.inheritBonusStat[1]" type="number"
|
||||
min="0" max="5" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col col-2 center align-self-center">지</div>
|
||||
<div class="col col-10"><b-form-input v-model.number="resetStatArgs.inheritBonusStat[2]" type="number"
|
||||
min="0" max="5" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="a-right">
|
||||
<small class="form-text text-muted">시즌 당 1회에 한 해 능력치를 초기화합니다. <br />
|
||||
</small>
|
||||
<span style="color: white">필요 포인트: {{ requiredResetStatPoint }}</span>
|
||||
</div>
|
||||
|
||||
<div class="row px-4">
|
||||
<BButton class="col-6 offset-6" variant="primary" @click="resetStat"> 능력치 초기화</BButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -196,7 +236,9 @@
|
||||
{{ log.text }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-grid"><BButton @click="getMoreLog()">더 가져오기</BButton></div>
|
||||
<div class="d-grid">
|
||||
<BButton @click="getMoreLog()">더 가져오기</BButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -231,6 +273,8 @@ declare const staticValues: {
|
||||
randomUnique: number;
|
||||
nextSpecial: number;
|
||||
minSpecificUnique: number;
|
||||
checkOwner: number;
|
||||
bornStatPoint: number;
|
||||
};
|
||||
resetTurnTimeLevel: number;
|
||||
resetSpecialWarLevel: number;
|
||||
@@ -252,16 +296,24 @@ declare const staticValues: {
|
||||
info: string;
|
||||
}
|
||||
>;
|
||||
availableTargetGeneral: Record<number, string>;
|
||||
currentStat: {
|
||||
leadership: number;
|
||||
strength: number;
|
||||
intel: number;
|
||||
statMax: number;
|
||||
statMin: number;
|
||||
};
|
||||
};
|
||||
</script>
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from "vue";
|
||||
import { reactive, ref, watch } from "vue";
|
||||
import "@scss/game_bg.scss";
|
||||
import TopBackBar from "@/components/TopBackBar.vue";
|
||||
import _ from "lodash-es";
|
||||
import NumberInputWithInfo from "@/components/NumberInputWithInfo.vue";
|
||||
import { SammoAPI } from "./SammoAPI";
|
||||
import type { inheritBuffType, InheritPointLogItem } from "./defs/API/InheritAction";
|
||||
import { InheritResetStat, type inheritBuffType, type InheritPointLogItem } from "./defs/API/InheritAction";
|
||||
import * as JosaUtil from "@/util/JosaUtil";
|
||||
import { BButton } from "bootstrap-vue-next";
|
||||
import { unwrap } from "./util/unwrap";
|
||||
@@ -394,12 +446,21 @@ const {
|
||||
currentInheritBuff: prevInheritBuff,
|
||||
availableSpecialWar,
|
||||
availableUnique,
|
||||
availableTargetGeneral,
|
||||
currentStat
|
||||
} = staticValues;
|
||||
|
||||
const nextSpecialWar = ref(Object.keys(availableSpecialWar)[0]);
|
||||
const specificUnique = ref<string | null>(null);
|
||||
const specificUniqueAmount = ref(inheritActionCost.minSpecificUnique);
|
||||
|
||||
const resetStatArgs = reactive<Required<Pick<InheritResetStat, 'inheritBonusStat'>> & InheritResetStat>({
|
||||
leadership: currentStat.leadership,
|
||||
strength: currentStat.strength,
|
||||
intel: currentStat.intel,
|
||||
inheritBonusStat: [0, 0, 0]
|
||||
});
|
||||
|
||||
const lastLogID = ref(Math.min(...staticValues.lastInheritPointLogs.map((v) => v.id)));
|
||||
const inheritPointLogs = ref(
|
||||
(() => {
|
||||
@@ -450,7 +511,7 @@ async function buyInheritBuff(buffKey: inheritBuffType) {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
async function tryResestTurnTime(){
|
||||
async function tryResestTurnTime() {
|
||||
const cost = inheritActionCost.resetTurnTime;
|
||||
|
||||
if (items.value.previous < cost) {
|
||||
@@ -586,16 +647,78 @@ async function openUniqueItemAuction() {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
async function getMoreLog(): Promise<void>{
|
||||
try{
|
||||
const targetOwner = ref<string | null>(null);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const requiredResetStatPoint = ref(0);
|
||||
|
||||
watch(resetStatArgs, (value) => {
|
||||
const bonusStat = value.inheritBonusStat.reduce((acc, v) => acc + v, 0);
|
||||
requiredResetStatPoint.value = bonusStat > 0 ? inheritActionCost.bornStatPoint : 0;
|
||||
})
|
||||
|
||||
|
||||
async function resetStat(): Promise<void> {
|
||||
const statArg: InheritResetStat = {
|
||||
leadership: resetStatArgs.leadership,
|
||||
strength: resetStatArgs.strength,
|
||||
intel: resetStatArgs.intel,
|
||||
};
|
||||
|
||||
if (resetStatArgs.inheritBonusStat.some(v => v > 0)) {
|
||||
statArg.inheritBonusStat = resetStatArgs.inheritBonusStat;
|
||||
}
|
||||
|
||||
if (!confirm(`능력치를 초기화 하시겠습니까? 시즌마다 한번만 가능합니다. 필요 포인트: ${requiredResetStatPoint.value}`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await SammoAPI.InheritAction.ResetStat(statArg);
|
||||
alert('초기화 되었습니다.');
|
||||
location.reload();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert(`실패했습니다: ${e}`);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function getMoreLog(): Promise<void> {
|
||||
try {
|
||||
const result = await SammoAPI.InheritAction.GetMoreLog({
|
||||
lastID: lastLogID.value
|
||||
});
|
||||
for(const log of result.log){
|
||||
for (const log of result.log) {
|
||||
inheritPointLogs.value.set(log.id, log);
|
||||
lastLogID.value = Math.min(lastLogID.value, log.id);
|
||||
}
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert(`실패했습니다: ${e}`);
|
||||
return;
|
||||
@@ -616,4 +739,4 @@ async function getMoreLog(): Promise<void>{
|
||||
.tnum {
|
||||
font-feature-settings: "tnum";
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
+6
-2
@@ -17,7 +17,7 @@ import { APIPathGen, NumVar, StrVar } from "./util/APIPathGen.js";
|
||||
import type { BettingDetailResponse, BettingListResponse } from "./defs/API/Betting";
|
||||
import type { ReserveBulkCommandResponse, ReserveCommandResponse, ReservedCommandResponse } from "./defs/API/Command";
|
||||
import type { ChiefResponse } from "./defs/API/NationCommand";
|
||||
import type { inheritBuffType, InheritLogResponse } from "./defs/API/InheritAction";
|
||||
import type { inheritBuffType, InheritLogResponse, InheritResetStat } from "./defs/API/InheritAction";
|
||||
import type { SetBlockWarResponse, GeneralListResponse as NationGeneralListResponse, NationInfoResponse } from "./defs/API/Nation";
|
||||
import type { UploadImageResponse } from "./defs/API/Misc";
|
||||
import type { GeneralLogType, GetGeneralLogResponse, JoinArgs } from "./defs/API/General";
|
||||
@@ -179,7 +179,11 @@ const apiRealPath = {
|
||||
}>,
|
||||
GetMoreLog: GET as APICallT<{
|
||||
lastID: number
|
||||
}, InheritLogResponse>
|
||||
}, InheritLogResponse>,
|
||||
CheckOwner: PUT as APICallT<{
|
||||
destGeneralID: number;
|
||||
}>,
|
||||
ResetStat: PUT as APICallT<InheritResetStat>,
|
||||
},
|
||||
Message: {
|
||||
DeleteMessage: PATCH as APICallT<{
|
||||
|
||||
@@ -22,3 +22,10 @@ export type InheritPointLogItem = {
|
||||
export type InheritLogResponse = ValidResponse & {
|
||||
log: InheritPointLogItem[];
|
||||
};
|
||||
|
||||
export type InheritResetStat = {
|
||||
leadership: number;
|
||||
strength: number;
|
||||
intel: number;
|
||||
inheritBonusStat?: [number, number, number];
|
||||
};
|
||||
+14
-1
@@ -16,7 +16,10 @@ $gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$me = General::createObjFromDB($generalID);
|
||||
|
||||
|
||||
$availableTargetGeneral = [];
|
||||
foreach ($db->query('SELECT no, name FROM general WHERE npc < 2') as $row) {
|
||||
$availableTargetGeneral[$row['no']] = $row['name'];
|
||||
}
|
||||
|
||||
$currentInheritBuff = [];
|
||||
foreach ($me->getAuxVar('inheritBuff') ?? [] as $buff => $buffLevel) {
|
||||
@@ -95,10 +98,20 @@ $lastInheritPointLogs = $db->query('SELECT id, server_id, year, month, date, tex
|
||||
'randomUnique' => GameConst::$inheritItemRandomPoint,
|
||||
'nextSpecial' => GameConst::$inheritSpecificSpecialPoint,
|
||||
'minSpecificUnique' => GameConst::$inheritItemUniqueMinPoint,
|
||||
'checkOwner' => GameConst::$inheritCheckOwnerPoint,
|
||||
'bornStatPoint' => GameConst::$inheritBornStatPoint,
|
||||
],
|
||||
'availableSpecialWar' => $avilableSpecialWar,
|
||||
'availableUnique' => $availableUnique,
|
||||
'lastInheritPointLogs' => $lastInheritPointLogs,
|
||||
'availableTargetGeneral' => $availableTargetGeneral,
|
||||
'currentStat' => [
|
||||
'leadership' => Util::clamp($me->getVar('leadership'), GameConst::$defaultStatMin, GameConst::$defaultStatMax),
|
||||
'strength' => Util::clamp($me->getVar('strength'), GameConst::$defaultStatMin, GameConst::$defaultStatMax),
|
||||
'intel' => Util::clamp($me->getVar('intel'), GameConst::$defaultStatMin, GameConst::$defaultStatMax),
|
||||
'statMin' => GameConst::$defaultStatMin,
|
||||
'statMax' => GameConst::$defaultStatMax,
|
||||
]
|
||||
]
|
||||
]) ?>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user