cutDay가 변경된 월을 반환하도록 수정

설치 도구를 구현.
This commit is contained in:
2018-03-31 05:44:16 +09:00
parent d9e5d5b2cd
commit 81a439439b
2 changed files with 57 additions and 11 deletions
+9 -3
View File
@@ -1549,13 +1549,19 @@ function cutDay($date, int $turnterm) {
$baseGap = 60*24 / $turnterm;
$diffMin = intdiv($date->getTimeStamp() - $baseDate->getTimeStamp(), 60);
if($diffMin % $baseGap != 0){
$timeAdjust = $diffMin % $baseGap;
$newMonth = intdiv($timeAdjust, $turnterm) + 1;
$yearPulled = false;
if($newMonth > 3){//3월 이후일때는
$yearPulled = true;
$diffMin += $baseGap;
}
$diffMin -= $diffMin % $baseGap;
$diffMin -= $timeAdjust;
$baseDate->add(new \DateInterval("PT{$diffMin}M"));
return $baseDate->format('Y-m-d H:i:s');
return [$baseDate->format('Y-m-d H:i:s'), $yearPulled, $newMonth];
}
function increaseRefresh($type="", $cnt=1) {
+48 -8
View File
@@ -69,21 +69,61 @@ if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/schema.sql'))){
while (@$mysqli_obj->next_result()) {;}
}
CityConst::build();
$db->insert('plock', [
'plock'=>0
]);
/*
$db->insert('game', [
]);
*/
//TODO:script
$turntime = date('Y-m-d H:i:s');
$time = substr($turntime, 11, 2);
if($sync == 0) {
// 현재 시간을 1월로 맞춤
$starttime = cutTurn($turntime, $turnterm);
$month = 1;
$year = $startyear;
} else {
// 현재 시간과 동기화
list($starttime, $yearPulled, $month) = cutDay($turntime, $turnterm);
if($yearPulled){
$year = $startyear-1;
}
else{
$year = $startyear;
}
}
$killturn = 4800 / $turnterm;
if($npcmode == 1) { $killturn = floor($killturn / 3); }
$env = [
'year'=> $year,
'month'=> $month,
'msg'=>'공지사항',//TODO:공지사항
'maxgeneral'=>500,
'normgeneral'=>300,
'maxnation'=>55,
'conlimit'=>300,
'gold_rate'=>100,
'rice_rate'=>100,
'turntime'=>$turntime,
'starttime'=>$starttime,
'turnterm'=>$turnterm,
'killturn'=>$killturn,
'genius'=>5,
'startyear'=>$startyear,
'scenario'=>$scenario,
'show_img_level'=>$show_img_level,
'npcmode'=>$npcmode,
'extend'=>$extend,
'fiction'=>$fiction
];
$db->insert('game', $env);
$scenario->build($env);
Json::die([
'result'=>false,
'reason'=>'NYI'
'result'=>true
]);