Compare commits

..
10 Commits
Author SHA1 Message Date
Hide_D 84b0b69b67 j_install_db 초기화 코드 정리 2024-05-17 18:11:56 +00:00
Hide_D 47a4144757 사소하게 수정 2024-05-17 18:03:20 +00:00
Hide_D 625cf81f1f clearDB에 $db 전달 2024-05-17 17:59:27 +00:00
Hide_D 0b8e91efe8 설치 메시지 수정 2024-05-17 17:50:07 +00:00
Hide_D 8db7aa3528 종료 처리 2024-05-17 17:42:34 +00:00
Hide_D 726679c933 db unset 2024-05-17 17:36:39 +00:00
Hide_D ec9e7be5d8 install_db 2024-05-17 17:32:39 +00:00
Hide_D 43ee0015ea 인스톨 코드 수정 2024-05-17 17:12:58 +00:00
Hide_D a146735007 APIHelper에 MeekroDBExceptionr에러시 logError 2024-05-17 17:10:43 +00:00
Hide_D 46bf5531d9 dep 2024-05-17 17:02:25 +00:00
28 changed files with 276 additions and 882 deletions
BIN
View File
Binary file not shown.
+3 -11
View File
@@ -136,21 +136,13 @@ $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>
+4 -5
View File
@@ -9,7 +9,6 @@ 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';
@@ -377,11 +376,11 @@ function myNationInfo(General $generalObj)
function checkSecretMaxPermission($penalty)
{
$secretMax = 4;
if ($penalty[PenaltyKey::NoTopSecret->value] ?? false) {
if ($penalty['noTopSecret'] ?? false) {
$secretMax = 1;
} else if ($penalty[PenaltyKey::NoChief->value] ?? false) {
} else if ($penalty['noChief'] ?? false) {
$secretMax = 1;
} else if ($penalty[PenaltyKey::NoAmbassador->value] ?? false) {
} else if ($penalty['noAmbassador'] ?? false) {
$secretMax = 2;
}
return $secretMax;
@@ -404,7 +403,7 @@ function checkSecretPermission(array $me, $checkSecretLimit = true)
}
if ($penalty[PenaltyKey::NoChief->value] ?? false) {
if ($penalty['noSecret'] ?? false) {
return 0;
}
-8
View File
@@ -3,7 +3,6 @@ namespace sammo;
use sammo\Command\GeneralCommand;
use sammo\Command\NationCommand;
use sammo\Enums\PenaltyKey;
function getGeneralTurnBrief(General $generalObj, array $turnList) {
$result = [];
@@ -435,13 +434,6 @@ 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);
}
+2 -2
View File
@@ -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,
+1 -9
View File
@@ -19,15 +19,7 @@ if(!prepareDir('data/file_cache')){
]);
}
$absolutePath = realpath('data/file_cache');
if(!$absolutePath){
Json::die([
'result'=>false,
'reason'=>'cache 불가'
]);
}
$storage = new \Nette\Caching\Storages\FileStorage($absolutePath);
$storage = new \Nette\Caching\Storages\FileStorage('data/file_cache');
$cache = new Cache($storage);
$serverID = UniqueConst::$serverID;
+98 -117
View File
@@ -1,12 +1,9 @@
<?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";
@@ -24,99 +21,92 @@ $userID = Session::getUserID();
$db = DB::db();
$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,penalty from general where owner=%i', $userID);
$me = $db->queryFirstRow('SELECT no,nation,officer_level 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
{
global $myPenalty;
if ($myPenalty[PenaltyKey::NoChiefChange->value] ?? false) {
return '수뇌를 임명할 수 없는 상태입니다.';
}
function do수뇌임명(General $general, int $targetOfficerLevel):?string{
$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 '지력이 부족합니다.';
}
}
@@ -125,59 +115,52 @@ 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
{
global $myPenalty;
function do도시임명(General $general, int $cityID, int $targetOfficerLevel):?string{
$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);
@@ -186,25 +169,22 @@ 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'];
@@ -212,17 +192,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);
}
@@ -240,26 +220,27 @@ 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',
@@ -298,24 +279,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);
}
@@ -327,62 +308,62 @@ 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
]);
}
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
]);
}
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
]);
}
Json::die([
'result' => true,
'reason' => 'success'
'result'=>true,
'reason'=>'success'
]);
}
Json::die([
'result' => false,
'reason' => '올바르지 않은 명령입니다.'
]);
'result'=>false,
'reason'=>'올바르지 않은 명령입니다.'
]);
+15 -37
View File
@@ -1,5 +1,4 @@
<?php
namespace sammo;
include "lib.php";
@@ -25,13 +24,14 @@ 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,7 +49,8 @@ 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);
}
@@ -59,44 +60,21 @@ $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'
]);
+1 -5
View File
@@ -55,11 +55,7 @@ class GetCachedMap extends \sammo\BaseAPI
return 'cache 불가';
}
$absolutePath = realpath('data/file_cache');
if (!$absolutePath) {
return 'cache 불가';
}
$storage = new \Nette\Caching\Storages\FileStorage($absolutePath);
$storage = new \Nette\Caching\Storages\FileStorage('data/file_cache');
$cache = new Cache($storage);
$now = TimeUtil::nowDateTimeImmutable();
-4
View File
@@ -288,10 +288,6 @@ class GetConst extends \sammo\BaseAPI
if (!prepareDir($cacheDir)) {
throw new RuntimeException('cache 폴더 없음');
}
$absolutePath = realpath($cacheDir);
if (!$absolutePath) {
throw new RuntimeException('cache 폴더 없음');
}
$storage = new \Nette\Caching\Storages\FileStorage($cacheDir);
$cache = new Cache($storage);
-154
View File
@@ -1,154 +0,0 @@
<?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;
}
}
+1 -9
View File
@@ -7,7 +7,6 @@ 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;
@@ -192,9 +191,6 @@ 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',
@@ -235,11 +231,7 @@ class SendMessage extends \sammo\BaseAPI
$lastMsg = new \DateTime($session->lastMsg ?? '0000-00-00');
$msg_interval = $now->getTimestamp() - $lastMsg->getTimestamp();
if($penalty[PenaltyKey::NoSendPrivateMsg->value] ?? 0) {
return '개인 메세지를 보낼 수 없습니다.';
}
$msg_min_interval = $penalty[PenaltyKey::SendPrivateMsgDelay->value] ?? 2;
$msg_min_interval = $penalty['sendPrivateMsgDelay'] ?? 2;
if ($msg_interval < $msg_min_interval) {
return "개인메세지는 {$msg_min_interval}초당 1건만 보낼 수 있습니다!";
}
+1 -4
View File
@@ -18,7 +18,6 @@ use function \sammo\getAllNationStaticInfo;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Enums\PenaltyKey;
use function sammo\buildNationTypeClass;
use function sammo\genGenericUniqueRNGFromGeneral;
@@ -82,8 +81,7 @@ class che_건국 extends Command\GeneralCommand
$this->minConditionConstraints = [
ConstraintHelper::BeOpeningPart($relYear + 1),
ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.'),
ConstraintHelper::NoPenalty(PenaltyKey::NoFoundNation),
ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.')
];
}
@@ -104,7 +102,6 @@ class che_건국 extends Command\GeneralCommand
ConstraintHelper::CheckNationNameDuplicate($nationName),
ConstraintHelper::AllowJoinAction(),
ConstraintHelper::ConstructableCity(),
ConstraintHelper::NoPenalty(PenaltyKey::NoFoundNation),
];
}
+2 -5
View File
@@ -17,7 +17,6 @@ use function \sammo\getNationStaticInfo;
use \sammo\Constraint\ConstraintHelper;
use sammo\Enums\InheritanceKey;
use sammo\Enums\PenaltyKey;
class che_임관 extends Command\GeneralCommand
{
@@ -67,8 +66,7 @@ class che_임관 extends Command\GeneralCommand
$this->minConditionConstraints = [
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
ConstraintHelper::BeNeutral(),
ConstraintHelper::AllowJoinAction(),
ConstraintHelper::NoPenalty(PenaltyKey::NoChosenAssignment),
ConstraintHelper::AllowJoinAction()
];
}
@@ -94,8 +92,7 @@ class che_임관 extends Command\GeneralCommand
ConstraintHelper::BeNeutral(),
ConstraintHelper::ExistsDestNation(),
ConstraintHelper::AllowJoinDestNation($relYear),
ConstraintHelper::AllowJoinAction(),
ConstraintHelper::NoPenalty(PenaltyKey::NoChosenAssignment),
ConstraintHelper::AllowJoinAction()
];
}
+69 -130
View File
@@ -1,11 +1,9 @@
<?php
namespace sammo\Constraint;
abstract class Constraint
{
private function __construct()
{
abstract class Constraint{
private function __construct(){
}
const REQ_GENERAL = 0x10;
@@ -20,8 +18,7 @@ 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;
@@ -40,241 +37,182 @@ 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->test()) {
if ($constraint->reason() === null) {
throw new \RuntimeException('Reason is not set:' . $constraintName);
if($constraint->reason() === null){
throw new \RuntimeException('Reason is not set:'.$constraintName);
}
return [$constraintName, $constraint->reason()];
}
@@ -282,4 +220,5 @@ abstract class Constraint
return null;
}
}
}
@@ -2,8 +2,6 @@
namespace sammo\Constraint;
use sammo\Enums\PenaltyKey;
class ConstraintHelper{
static function AdhocCallback(callable $callback):array{
@@ -178,10 +176,6 @@ class ConstraintHelper{
return [__FUNCTION__];
}
static function NoPenalty(PenaltyKey $penaltyKey):array{
return [__FUNCTION__, $penaltyKey];
}
static function OccupiedCity(bool $allowNeutral=false):array{
return [__FUNCTION__, $allowNeutral];
}
-44
View File
@@ -1,44 +0,0 @@
<?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,7 +2,6 @@
namespace sammo;
use Ds\Map;
use sammo\Enums\InheritanceKey;
class DummyGeneral extends General
@@ -32,7 +31,6 @@ class DummyGeneral extends General
$this->raw = $raw;
$this->resultTurn = new LastTurn();
$this->penaltyList = new Map();
if ($initLogger) {
$this->initLogger(1, 1);
-40
View File
@@ -1,40 +0,0 @@
<?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,7 +224,6 @@ 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;
+1 -27
View File
@@ -7,7 +7,6 @@ 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;
@@ -29,10 +28,6 @@ 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 */
@@ -91,16 +86,6 @@ 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;
@@ -259,17 +244,6 @@ 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}";
@@ -398,7 +372,7 @@ class General extends GeneralBase implements iAction
}
$this->calcCache[$cKey] = $statValue;
return $statValue;
}
+4 -42
View File
@@ -5,7 +5,6 @@ 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;
@@ -3980,10 +3979,9 @@ class GeneralAI
continue;
}
$chief = $this->chiefGenerals[$chiefLevel];
if ($chief->getNPCType() < 2 && $chief->getVar('killturn') >= $minUserKillturn && !$chief->hasPenalty(PenaltyKey::NoAmbassador)) {
if ($chief->getNPCType() < 2 && $chief->getVar('killturn') >= $minUserKillturn) {
$userChiefCnt += 1;
$chief->setVar('permission', 'ambassador');
$chief->applyDB($db);
}
}
@@ -3995,41 +3993,12 @@ class GeneralAI
/** @var General[] */
$nextChiefs = [];
$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)) {
if ($userChiefCnt == 0 && $this->userGenerals && !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;
}
@@ -4042,9 +4011,7 @@ class GeneralAI
$nextChiefs[11] = $general;
$general->setVar('officer_level', 11);
$general->setVar('officer_city', 0);
if(!$general->hasPenalty(PenaltyKey::NoAmbassador)){
$general->setVar('permission', 'ambassador');
}
$general->setVar('permission', 'ambassador');
$nation['chief_set'] |= doOfficerSet(0, 11);
$updatedChiefSet |= doOfficerSet(0, 11);
$userChiefCnt += 1;
@@ -4102,9 +4069,6 @@ 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) {
@@ -4127,9 +4091,7 @@ class GeneralAI
if ($newChief->getNPCType() < 2) {
$userChiefCnt += 1;
if(!$newChief->hasPenalty(PenaltyKey::NoAmbassador)){
$newChief->setVar('permission', 'ambassador');
}
$newChief->setVar('permission', 'ambassador');
}
$nextChiefs[$chiefLevel] = $newChief;
+1 -1
View File
@@ -77,6 +77,7 @@ class ResetHelper{
ServConfig::getServerList()[$prefix]->closeServer();
$db = DB::db();
$mysqli_obj = $db->get();
$serverID = $prefix.'_'.date("ymd").'_'.Util::randomStr(4);
@@ -110,7 +111,6 @@ class ResetHelper{
$servRoot.'/d_setting/GameConst.php',
);
$mysqli_obj = $db->get();
if($mysqli_obj->multi_query(file_get_contents($servRoot.'/sql/reset.sql'))){
while(true){
if (!$mysqli_obj->more_results()) {
@@ -24,12 +24,6 @@ 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);
-110
View File
@@ -1,110 +0,0 @@
{
"title":"【공백지】 이벤트 클래식",
"startYear":180,
"history": [
"<C>●</>180년 1월:<L><b>【공백지】</b></>예전 지도에서 장비를 많이 가지고 즐겨보는 이벤트 깃수"
],
"const": {
"joinRuinedNPCProp":0,
"npcBanMessageProb":1,
"uniqueTrialCoef": 2,
"maxUniqueTrialProb": 0.5,
"defaultMaxGenius": 9999,
"defaultMaxGeneral": 700,
"allItems": {
"horse" : {
"che_명마_01_노기" : 0, "che_명마_02_조랑" : 0, "che_명마_03_노새" : 0,
"che_명마_04_나귀" : 0, "che_명마_05_갈색마" : 0, "che_명마_06_흑색마" : 0,
"che_명마_07_백마" : 8, "che_명마_07_기주마" : 8, "che_명마_07_오환마" : 8, "che_명마_07_백상" : 8,
"che_명마_08_양주마" : 8, "che_명마_08_흉노마" : 8, "che_명마_09_과하마" : 8, "che_명마_09_의남백마" : 8,
"che_명마_10_대완마" : 8, "che_명마_10_옥추마" : 8, "che_명마_11_서량마" : 8, "che_명마_11_화종마" : 8,
"che_명마_12_사륜거" : 8, "che_명마_12_옥란백용구": 8, "che_명마_13_절영" : 8, "che_명마_13_적로" : 8,
"che_명마_14_적란마" : 8, "che_명마_14_조황비전" : 8, "che_명마_15_한혈마" : 8, "che_명마_15_적토마" : 8
},
"weapon" : {
"che_무기_01_단도" : 0, "che_무기_02_단궁" : 0, "che_무기_03_단극" : 0,
"che_무기_04_목검" : 0, "che_무기_05_죽창" : 0, "che_무기_06_소부" : 0,
"che_무기_07_동추" : 8, "che_무기_07_철편" : 8, "che_무기_07_철쇄" : 8, "che_무기_07_맥궁" : 8,
"che_무기_08_유성추" : 8, "che_무기_08_철질여골" : 8, "che_무기_09_쌍철극" : 8, "che_무기_09_동호비궁" : 8,
"che_무기_10_삼첨도" : 8, "che_무기_10_대부" : 8, "che_무기_11_고정도" : 8, "che_무기_11_이광궁" : 8,
"che_무기_12_철척사모" : 8, "che_무기_12_칠성검" : 8, "che_무기_13_사모" : 8, "che_무기_13_양유기궁" : 8,
"che_무기_14_언월도" : 8, "che_무기_14_방천화극" : 8, "che_무기_15_청홍검" : 8, "che_무기_15_의천검" : 8
},
"book" : {
"che_서적_01_효경전" : 0, "che_서적_02_회남자" : 0, "che_서적_03_변도론" : 0,
"che_서적_04_건상역주" : 0, "che_서적_05_여씨춘추" : 0, "che_서적_06_사민월령" : 0,
"che_서적_07_위료자" : 8, "che_서적_07_사마법" : 8, "che_서적_07_한서" : 8, "che_서적_07_논어" : 8,
"che_서적_08_전론" : 8, "che_서적_08_사기" : 8, "che_서적_09_장자" : 8, "che_서적_09_역경" : 8,
"che_서적_10_시경" : 8, "che_서적_10_구국론" : 8, "che_서적_11_상군서" : 8, "che_서적_11_춘추전" : 8,
"che_서적_12_산해경" : 8, "che_서적_12_맹덕신서" : 8, "che_서적_13_관자" : 8, "che_서적_13_병법24편" : 8,
"che_서적_14_한비자" : 8, "che_서적_14_오자병법" : 8, "che_서적_15_노자" : 8, "che_서적_15_손자병법" : 8
},
"item" : {
"che_치료_환약" : 0, "che_저격_수극" : 0, "che_사기_탁주" : 0,
"che_훈련_청주" : 0, "che_계략_이추" : 0, "che_계략_향낭" : 0,
"che_의술_정력견혈산" : 4, "che_의술_청낭서" : 4, "che_의술_태평청령" : 4, "che_의술_상한잡병론" : 4,
"che_보물_도기" : 4, "che_조달_주판" : 4,
"che_내정_납금박산로" : 4, "che_전략_평만지장도" : 4, "che_숙련_동작" : 4, "che_명성_구석" : 4,
"che_척사_오악진형도" : 4, "che_격노_구정신단경" : 4, "che_징병_낙주" : 4,
"che_저격_매화수전" : 4, "che_저격_비도":4, "che_위압_조목삭" : 4, "che_공성_묵자" : 4,
"che_집중_전국책" : 4, "che_환술_논어집해" : 4,
"che_진압_박혁론" : 4, "che_부적_태현청생부" : 4, "che_저지_삼황내문" : 4,
"che_행동_서촉지형도" : 4, "che_간파_노군입산부" : 4, "che_불굴_상편" : 4,
"che_약탈_옥벽" : 4,
"che_농성_주서음부" : 4, "che_농성_위공자병법" : 4,
"che_계략_육도" : 4, "che_계략_삼략" : 4,
"che_상성보정_과실주" : 4,
"che_능력치_지력_이강주" : 4, "che_능력치_무력_두강주" : 4, "che_능력치_통솔_보령압주" : 4,
"che_훈련_철벽서" : 4, "che_훈련_단결도" : 4, "che_사기_춘화첩" : 4, "che_사기_초선화" : 4,
"che_회피_태평요술" : 4, "che_필살_둔갑천서" : 4
}
}
},
"events":[
[
"month", 1000,
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
["CreateManyNPC", 10, 10],
["DeleteEvent"]
],
[
"month", 1000,
["Date", "==", 181, 1],
["RaiseNPCNation"],
["DeleteEvent"]
],
[
"month", 999,
["Date", "==", 181, 1],
["OpenNationBetting", 4, 5000],
["OpenNationBetting", 1, 2000],
["DeleteEvent"]
],
[
"month", 999,
["and",
["Date", ">=", 183, 1],
["RemainNation", "<=", 8]
],
["OpenNationBetting", 1, 1000],
["DeleteEvent"]
],
[
"destroy_nation", 1000,
["and",
["Date", ">=", 183, 1],
["RemainNation", "==", 1]
],
["BlockScoutAction"],
["DeleteEvent"]
]
]
}
+71 -93
View File
@@ -1,17 +1,25 @@
<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>
@@ -45,9 +53,13 @@
</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>
@@ -67,12 +79,17 @@
</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>
@@ -93,8 +110,11 @@
<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">
@@ -103,8 +123,11 @@
<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">
@@ -113,9 +136,11 @@
<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>
@@ -128,48 +153,33 @@
<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>
</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>
<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>
@@ -186,9 +196,7 @@
{{ log.text }}
</div>
</div>
<div class="d-grid">
<BButton @click="getMoreLog()"> 가져오기</BButton>
</div>
<div class="d-grid"><BButton @click="getMoreLog()"> 가져오기</BButton></div>
</div>
</template>
@@ -223,7 +231,6 @@ declare const staticValues: {
randomUnique: number;
nextSpecial: number;
minSpecificUnique: number;
checkOwner: number;
};
resetTurnTimeLevel: number;
resetSpecialWarLevel: number;
@@ -245,7 +252,6 @@ declare const staticValues: {
info: string;
}
>;
availableTargetGeneral: Record<number, string>;
};
</script>
<script lang="ts" setup>
@@ -388,7 +394,6 @@ const {
currentInheritBuff: prevInheritBuff,
availableSpecialWar,
availableUnique,
availableTargetGeneral,
} = staticValues;
const nextSpecialWar = ref(Object.keys(availableSpecialWar)[0]);
@@ -445,7 +450,7 @@ async function buyInheritBuff(buffKey: inheritBuffType) {
location.reload();
}
async function tryResestTurnTime() {
async function tryResestTurnTime(){
const cost = inheritActionCost.resetTurnTime;
if (items.value.previous < cost) {
@@ -581,43 +586,16 @@ async function openUniqueItemAuction() {
location.reload();
}
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;
}
}
async function getMoreLog(): Promise<void> {
try {
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;
@@ -638,4 +616,4 @@ async function getMoreLog(): Promise<void> {
.tnum {
font-feature-settings: "tnum";
}
</style>
</style>
+1 -4
View File
@@ -179,10 +179,7 @@ const apiRealPath = {
}>,
GetMoreLog: GET as APICallT<{
lastID: number
}, InheritLogResponse>,
CheckOwner: PUT as APICallT<{
destGeneralID: number;
}>,
}, InheritLogResponse>
},
Message: {
DeleteMessage: PATCH as APICallT<{
+1 -6
View File
@@ -16,10 +16,7 @@ $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) {
@@ -98,12 +95,10 @@ $lastInheritPointLogs = $db->query('SELECT id, server_id, year, month, date, tex
'randomUnique' => GameConst::$inheritItemRandomPoint,
'nextSpecial' => GameConst::$inheritSpecificSpecialPoint,
'minSpecificUnique' => GameConst::$inheritItemUniqueMinPoint,
'checkOwner' => GameConst::$inheritCheckOwnerPoint,
],
'availableSpecialWar' => $avilableSpecialWar,
'availableUnique' => $availableUnique,
'lastInheritPointLogs' => $lastInheritPointLogs,
'availableTargetGeneral' => $availableTargetGeneral,
]
]) ?>
</head>