164 lines
3.4 KiB
PHP
164 lines
3.4 KiB
PHP
<?php
|
|
namespace sammo;
|
|
|
|
include "lib.php";
|
|
include "func.php";
|
|
|
|
$session = Session::Instance()->setReadOnly();
|
|
if($session->userGrade < 5){
|
|
Json::die([
|
|
'result'=>false,
|
|
'reason'=>'관리자 아님'
|
|
]);
|
|
}
|
|
|
|
$v = new Validator($_POST);
|
|
$v->rule('required', [
|
|
'turnterm',
|
|
'sync',
|
|
'scenario',
|
|
'fiction',
|
|
'extend',
|
|
'npcmode',
|
|
'show_img_level'
|
|
])->rule('integer', [
|
|
'turnterm',
|
|
'sync',
|
|
'scenario',
|
|
'fiction',
|
|
'extend',
|
|
'npcmode',
|
|
'show_img_level'
|
|
]);
|
|
if(!$v->validate()){
|
|
$errors = array_values((array)$v->errors());
|
|
$errors = array_map(function($value){return join(', ', $value);}, $errors);
|
|
$errors = join(', ', $errors);
|
|
Json::die([
|
|
'result'=>false,
|
|
'reason'=>$errors
|
|
]);
|
|
}
|
|
|
|
$turnterm = (int)$_POST['turnterm'];
|
|
$sync = (int)$_POST['sync'];
|
|
$scenario = (int)$_POST['scenario'];
|
|
$fiction = (int)$_POST['fiction'];
|
|
$extend = (int)$_POST['extend'];
|
|
$npcmode = (int)$_POST['npcmode'];
|
|
$show_img_level = (int)$_POST['show_img_level'];
|
|
|
|
if(120 % $turnterm != 0){
|
|
Json::die([
|
|
'result'=>false,
|
|
'turnterm은 120의 약수여야 합니다.'
|
|
]);
|
|
}
|
|
|
|
$db = DB::db();
|
|
$mysqli_obj = $db->get();
|
|
|
|
|
|
$scenarioObj = new Scenario($scenario, false);
|
|
$startyear = $scenarioObj->getYear();
|
|
|
|
if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){
|
|
while(true){
|
|
if (!$mysqli_obj->more_results()) {
|
|
break;
|
|
}
|
|
if(!$mysqli_obj->next_result()){
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/schema.sql'))){
|
|
while(true){
|
|
if (!$mysqli_obj->more_results()) {
|
|
break;
|
|
}
|
|
if(!$mysqli_obj->next_result()){
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$db->insert('plock', [
|
|
'plock'=>1
|
|
]);
|
|
|
|
CityConst::build();
|
|
|
|
|
|
|
|
|
|
$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 = [
|
|
'scenario'=>$scenario,
|
|
'scenario_text'=>$scenarioObj->getTitle(),
|
|
'startyear'=>$startyear,
|
|
'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,
|
|
'show_img_level'=>$show_img_level,
|
|
'npcmode'=>$npcmode,
|
|
'extended_general'=>$extend,
|
|
'fiction'=>$fiction
|
|
];
|
|
|
|
foreach(RootDB::db()->query('SELECT `no`, `name`, `picture`, `imgsvr` FROM member WHERE grade >= 5') as $admin){
|
|
$db->insert('general', [
|
|
'owner'=>$admin['no'],
|
|
'name'=>$admin['name'],
|
|
'picture'=>$admin['picture'],
|
|
'imgsvr'=>$admin['imgsvr'],
|
|
'turntime'=>$turntime,
|
|
'killturn'=>null
|
|
]);
|
|
}
|
|
|
|
$db->insert('game', $env);
|
|
|
|
$scenarioObj->build($env);
|
|
|
|
$db->update('plock', [
|
|
'plock'=>0
|
|
], true);
|
|
|
|
Json::die([
|
|
'result'=>true
|
|
]); |