예약턴 초기 릴리즈

This commit is contained in:
2019-05-09 01:28:49 +09:00
parent f20e4bd572
commit 445e445e49
12 changed files with 99 additions and 40 deletions
+2 -2
View File
@@ -78,7 +78,7 @@ function myCommandList() {
$date = date('Y-m-d H:i:s');
// 명령 목록
$admin = $gameStor->getValues(['year','month','turnterm']);
$admin = $gameStor->getValues(['year','month','turnterm','turntime']);
$me = $db->queryFirstRow("SELECT `no`,turntime,term,turn0,turn1,turn2,turn3,turn4,turn5,turn6,turn7,turn8,turn9,turn10,turn11,turn12,turn13,turn14,turn15,turn16,turn17,turn18,turn19,turn20,turn21,turn22,turn23 FROM general WHERE `owner`=%s", $userID);
if(!$me){
@@ -97,7 +97,7 @@ function myCommandList() {
$month = $admin['month'];
// 실행된 턴시간이면 +1
$cutTurn = cutTurn($me['turntime'], $admin['turnterm']);
if($date <= $cutTurn) { $month++; }
if($date <= $cutTurn && $date < $admin['tuntime']) { $month++; }
$totaldate = $me['turntime'];
+33 -10
View File
@@ -1523,6 +1523,11 @@ function checkTurn() {
$alllog = [];
if(date('Y-m-d H:i:s') < $gameStor->turntime){
//턴 시각 이전이면 아무것도 하지 않음
return true;
}
// 잦은 갱신 금지 현재 5초당 1회
if(!timeover()) { return; }
// 현재 처리중이면 접근 불가
@@ -1557,7 +1562,12 @@ function checkTurn() {
$db->update('plock', ['plock'=>1], true);
return;
}
$date = date('Y-m-d H:i:s');
$gameStor->cacheAll();
// 1턴이상 갱신 없었으면 서버 지연
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', checkDelay');
checkDelay();
@@ -1569,10 +1579,11 @@ function checkTurn() {
CheckOverhead();
//서버정보
$date = date('Y-m-d H:i:s');
// 최종 처리 월턴의 다음 월턴시간 구함
$prevTurn = cutTurn($gameStor->turntime, $gameStor->turnterm);
$nextTurn = addTurn($prevTurn, $gameStor->turnterm);
$computedPrevTurn = false;
// 현재 턴 이전 월턴까지 모두처리.
//최종 처리 이후 다음 월턴이 현재 시간보다 전이라면
while($nextTurn <= $date) {
@@ -1678,12 +1689,16 @@ function checkTurn() {
// 다음달로 넘김
$prevTurn = $nextTurn;
$nextTurn = addTurn($prevTurn, $gameStor->turnterm);
$computedPrevTurn = true;
}
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', '.__LINE__);
// 이시각 정각 시까지 업데이트 완료했음
$gameStor->turntime = $prevTurn;
if($computedPrevTurn){
$gameStor->turntime = $prevTurn;
}
// 그 시각 년도,월 저장
list($gameStor->year, $gameStor->month) = turnDate($prevTurn);
@@ -2915,16 +2930,24 @@ function SabotageInjury($city, $type=0) {
return $injuryCount;
}
function getRandTurn($term) {
function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null) {
if($baseDateTime === null){
$baseDateTime = new \DateTimeImmutable();
}
else if($baseDateTime instanceof \DateTime){
$baseDateTime = DateTimeImmutable::createFromMutable($baseDateTime);
}
$randtime = rand(0, 60 * $term - 1);
$turntime = date('Y-m-d H:i:s', strtotime('now') + $randtime);
return $turntime;
return $baseDateTime->add(new \DateInterval('PT'.$randtime.'S'))->format('Y-m-d H:i:s');
}
function getRandTurn2($term) {
function getRandTurn2($term, ?\DateTimeInterface $baseDateTime = null) {
if($baseDateTime === null){
$baseDateTime = new \DateTimeImmutable();
}
else if($baseDateTime instanceof \DateTime){
$baseDateTime = DateTimeImmutable::createFromMutable($baseDateTime);
}
$randtime = rand(0, 60 * $term - 1);
$turntime = date('Y-m-d H:i:s', strtotime('now') - $randtime);
return $turntime;
return $baseDateTime->sub(new \DateInterval('PT'.$randtime.'S'))->format('Y-m-d H:i:s');
}
+1 -1
View File
@@ -973,7 +973,7 @@ function updateNationState() {
$connect=$db->get();
$history = array();
$admin = $gameStor->getValues(['year', 'month', 'fiction', 'startyear', 'show_img_level', 'turnterm']);
$admin = $gameStor->getValues(['year', 'month', 'fiction', 'startyear', 'show_img_level', 'turnterm', 'turntime']);
$query = "select nation,name,level,gennum,tech from nation";
$nationresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+2 -2
View File
@@ -1894,7 +1894,7 @@ function process_76(&$general) {
$date = substr($general['turntime'],11,5);
$admin = $gameStor->getValues(['startyear','year','month','develcost','npccount','turnterm']);
$admin = $gameStor->getValues(['startyear','year','month','develcost','npccount','turnterm','turntime']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2070,7 +2070,7 @@ function process_76(&$general) {
$affinity = rand() % 150 + 1;
$name = "ⓖ의병장{$npcid}";
$picture = 'default.jpg';
$turntime = getRandTurn($admin['turnterm']);
$turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
$personal = rand() % 10;
$bornyear = $admin['year'];
$deadyear = $admin['year'] + 3;
+2 -2
View File
@@ -290,7 +290,7 @@ function process_29(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$admin = $gameStor->getValues(['startyear','year','month','develcost','npccount','turnterm','scenario','maxgeneral']);
$admin = $gameStor->getValues(['startyear','year','month','develcost','npccount','turnterm','scenario','maxgeneral', 'turntime']);
$query = "select nation,name,level,gennum,scout from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -490,7 +490,7 @@ function process_29(&$general) {
$npccount = 10000 + $npcid;
$affinity = rand() % 150 + 1;
$picture = 'default.jpg';
$turntime = getRandTurn($admin['turnterm']);
$turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
$personal = rand() % 10;
$bornyear = $admin['year'];
$deadyear = $admin['year'] + 3;
+7
View File
@@ -225,6 +225,13 @@ if($session->userGrade < 5 && !$allowReset){
</div>
</div>
<div class="form-group row">
<label for="pre_reserve_open" class="col-sm-3 col-form-label">가오픈 예약</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="pre_reserve_open" id="pre_reserve_open" placeholder="YYYY-MM-DD hh:mm" value="" />
</div>
</div>
<div class="form-group row">
<div class="col-sm-3"></div>
<div class="col-sm-9">
+2 -1
View File
@@ -88,7 +88,8 @@ $result = ResetHelper::buildScenario(
$options['npcmode'],
$options['show_img_level'],
$options['tournament_trig'],
$options['join_mode']
$options['join_mode'],
$options['starttime']
);
$result['affected']=1;
+43 -15
View File
@@ -27,6 +27,20 @@ if($reserve_open && $reserve_open < date('Y-m-d H:i')){
]);
}
$pre_reserve_open = Util::getReq('pre_reserve_open');
if($pre_reserve_open && !$reserve_open){
Json::die([
'result'=>false,
'reason'=>'가오픈 예약을 위해선 오픈 예약을 지정해야합니다.'
]);
}
if($pre_reserve_open && $pre_reserve_open >= $reserve_open){
Json::die([
'result'=>false,
'reason'=>'가오픈 시간이 오픈 예약 시점보다 이전이어야 합니다.'
]);
}
if($session->userGrade < 5 && !$allowReset){
Json::die([
'result'=>false,
@@ -114,22 +128,35 @@ if($reserve_open){
}
$scenarioObj = new Scenario($scenario, true);
$open_date = $reserve_open->format('Y-m-d H:i:s');
$reserveInfo = [
'turnterm'=>$turnterm,
'sync'=>$sync,
'scenario'=>$scenario,
'scenarioName'=>$scenarioObj->getTitle(),
'fiction'=>$fiction,
'extend'=>$extend,
'npcmode'=>$npcmode,
'show_img_level'=>$show_img_level,
'tournament_trig'=>$tournament_trig,
'gameConf'=>$scenarioObj->getGameConf(),
'join_mode'=>$join_mode,
'starttime'=>$open_date,
];
if($pre_reserve_open){
$pre_reserve_open = new \DateTime($pre_reserve_open);
$open_date = $pre_reserve_open->format('Y-m-d H:i:s');
}
$db->delete('reserved_open', true);
$db->insert('reserved_open', [
'options'=>Json::encode([
'turnterm'=>$turnterm,
'sync'=>$sync,
'scenario'=>$scenario,
'scenarioName'=>$scenarioObj->getTitle(),
'fiction'=>$fiction,
'extend'=>$extend,
'npcmode'=>$npcmode,
'show_img_level'=>$show_img_level,
'tournament_trig'=>$tournament_trig,
'gameConf'=>$scenarioObj->getGameConf(),
'join_mode'=>$join_mode,
]),
'date'=>$reserve_open->format('Y-m-d H:i:s')
'options'=>Json::encode($reserveInfo),
'date'=>$open_date
]);
AppConf::getList()[DB::prefix()]->closeServer();
Json::die([
@@ -147,5 +174,6 @@ Json::die(ResetHelper::buildScenario(
$npcmode,
$show_img_level,
$tournament_trig,
$join_mode
$join_mode,
TimeUtil::DatetimeNow()
));
+3 -3
View File
@@ -68,7 +68,7 @@ if (!$member) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$gameStor->cacheValues(['year','month','maxgeneral','scenario','show_img_level','turnterm','genius','npcmode']);
$gameStor->cacheValues(['year','month','maxgeneral','scenario','show_img_level','turnterm','turntime','genius','npcmode']);
########## 동일 정보 존재여부 확인. ##########
$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2');
@@ -153,7 +153,7 @@ $leader = $leader + $pleader;
$power = $power + $ppower;
$intel = $intel + $pintel;
$admin = $gameStor->getValues(['scenario', 'turnterm', 'show_img_level', 'startyear', 'year']);
$admin = $gameStor->getValues(['scenario', 'turnterm', 'turntime', 'show_img_level', 'startyear', 'year']);
$relYear = Util::valueFit($admin['year'] - $admin['startyear'], 0);
$age = 20 + ($pleader + $ppower + $pintel) * 2 - (mt_rand(0, 1));
@@ -187,7 +187,7 @@ else{
$experience *= 0.8;
}
$turntime = getRandTurn($admin['turnterm']);
$turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
$lastconnect = date('Y-m-d H:i:s');
if ($lastconnect >= $turntime) {
+1
View File
@@ -155,6 +155,7 @@ function formSetup(){
show_img_level:$('#show_img_level input:radio:checked').val(),
tournament_trig:$('#tournament_trig input:radio:checked').val(),
reserve_open:$('#reserve_open').val(),
pre_reserve_open:$('#pre_reserve_open').val(),
join_mode:$('#join_mode input:radio:checked').val(),
}
}).then(function(result){
+2 -3
View File
@@ -129,7 +129,8 @@ class ResetHelper{
int $npcmode,
int $show_img_level,
int $tournament_trig,
string $join_mode
string $join_mode,
string $turntime
):array{
//FIXME: 분리할 것
if(120 % $turnterm != 0){
@@ -186,8 +187,6 @@ class ResetHelper{
true
);
$turntime = date('Y-m-d H:i:s');
$time = substr($turntime, 11, 2);
if($sync == 0) {
// 현재 시간을 1월로 맞춤
+1 -1
View File
@@ -227,7 +227,7 @@ class NPC{
$level = $nationID?1:0;
}
$turntime = \sammo\getRandTurn($env['turnterm']);
$turntime = \sammo\getRandTurn($env['turnterm'], new \DateTimeImmutable($env['turntime']));
$killturn = ($this->death - $year) * 12 + mt_rand(0, 11);