From 81a439439ba8f7aa39ec9d84eecde9bce01a1292 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 31 Mar 2018 05:44:16 +0900 Subject: [PATCH] =?UTF-8?q?cutDay=EA=B0=80=20=EB=B3=80=EA=B2=BD=EB=90=9C?= =?UTF-8?q?=20=EC=9B=94=EC=9D=84=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 설치 도구를 구현. --- twe/func.php | 12 +++++++--- twe/j_install.php | 56 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/twe/func.php b/twe/func.php index b88a09be..ed58d86e 100644 --- a/twe/func.php +++ b/twe/func.php @@ -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) { diff --git a/twe/j_install.php b/twe/j_install.php index c0c3660f..e116cc39 100644 --- a/twe/j_install.php +++ b/twe/j_install.php @@ -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 ]); \ No newline at end of file