가오픈 merge

This commit is contained in:
2019-05-10 01:29:01 +09:00
15 changed files with 97 additions and 38 deletions
+3 -2
View File
@@ -76,7 +76,7 @@ function myCommandList() {
$userID = Session::getUserID();
// 명령 목록
$admin = $gameStor->getValues(['year','month','turnterm','turntime']);
$admin = $gameStor->getValues(['year','month','turnterm','turntime','opentime']);
$me = $db->queryFirstRow("SELECT `no`,name,city,nation,level,turntime,last_turn FROM general WHERE `owner`=%s", $userID);
if(!$me){
@@ -95,9 +95,10 @@ function myCommandList() {
$year = $admin['year'];
$month = $admin['month'];
$date = TimeUtil::now(true);
// 실행된 턴시간이면 +1
$cutTurn = cutTurn($me['turntime'], $admin['turnterm']);
if($admin['turntime'] <= $cutTurn) { $month++; }
if($date <= $cutTurn && $date >= $admin['opentime']) { $month++; }
$totaldate = $me['turntime'];
+19 -5
View File
@@ -2315,16 +2315,30 @@ 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);
}
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
$randFraction = Util::randRangeInt(0, 999999) / 1000000;//6자리 소수
return TimeUtil::nowAddSeconds($randSecond + $randFraction, true);
return $baseDateTime->add(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->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);
}
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
$randFraction = Util::randRangeInt(0, 999999) / 1000000;//6자리 소수
return TimeUtil::nowAddSeconds(- $randSecond - $randFraction, true);
}
return $baseDateTime->sub(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s');
}
+1 -1
View File
@@ -882,7 +882,7 @@ function updateNationState() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$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']);
$assemblerCnts = [];
foreach($db->queryAllLists('SELECT nation,count(no) FROM general WHERE npc = 5 GROUP BY nation') as [$nationID, $assemblerCnt]){
+2 -2
View File
@@ -1403,7 +1403,7 @@ function process_76(&$general) {
$date = substr($general['turntime'],11,5);
$admin = $gameStor->getValues(['startyear','year','month','develcost','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),"");
@@ -1573,7 +1573,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
@@ -284,7 +284,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),"");
@@ -484,7 +484,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 -2
View File
@@ -53,6 +53,7 @@ if(file_exists(__dir__.'/.htaccess')){
'fictionMode'=>($options['fiction']?'가상':'사실'),
'npcMode'=>($options['npcmode']?'가능':'불가'),
'openDatetime'=>$reserved['date'],
'starttime'=>$options['starttime'],
'gameConf'=>$options['gameConf'],
'otherTextInfo'=>$otherTextInfo
],
@@ -63,12 +64,12 @@ if(file_exists(__dir__.'/.htaccess')){
//TODO: 천통시에도 예약 오픈 알림이 필요..?
$admin = $gameStor->getValues(['isunited', 'npcmode', 'year', 'month', 'scenario', 'scenario_text', 'maxgeneral', 'turnterm', 'starttime', 'turntime']);
$admin = $gameStor->getValues(['isunited', 'npcmode', 'year', 'month', 'scenario', 'scenario_text', 'maxgeneral', 'turnterm', 'opentime', 'turntime']);
$admin['maxUserCnt'] = $admin['maxgeneral'];
$admin['npcMode'] = $admin['npcmode'];
$admin['turnTerm'] = $admin['turnterm'];
$admin['isUnited'] = $admin['isunited'];
$admin['starttime'] = substr($admin['starttime'], 5, 11);
$admin['starttime'] = substr($admin['opentime'], 5, 11);
$admin['turntime'] = substr($admin['turntime'], 5, 11);
unset($admin['npcmode']);
unset($admin['maxgeneral']);
+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));
@@ -196,7 +196,7 @@ else{
$experience *= 0.8;
}
$turntime = getRandTurn($admin['turnterm']);
$turntime = getRandTurn($admin['turnterm'], new \DateTimeImmutable($admin['turntime']));
$lastconnect = TimeUtil::now();
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){
+3 -3
View File
@@ -130,7 +130,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){
@@ -188,8 +189,6 @@ class ResetHelper{
true
);
$turntime = TimeUtil::now(true);
if($sync == 0) {
// 현재 시간을 1월로 맞춤
$starttime = cutTurn($turntime, $turnterm);
@@ -230,6 +229,7 @@ class ResetHelper{
'develcost'=>$develcost,
'turntime'=>$turntime,
'starttime'=>$starttime,
'opentime'=>$turntime,
'turnterm'=>$turnterm,
'killturn'=>$killturn,
'genius'=>GameConst::$defaultMaxGenius,
+1 -1
View File
@@ -292,7 +292,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);
+5
View File
@@ -286,6 +286,11 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
$gameStor = KVStorage::getStorage($db, 'game_env');
if(TimeUtil::now(true) < $gameStor->turntime){
//턴 시각 이전이면 아무것도 하지 않음
return true;
}
if(!tryLock()){
return;
}
+2 -1
View File
@@ -46,7 +46,8 @@ var serverLoginTemplate = "\
var serverReservedTemplate = "\
<td colspan='4' class='server_reserved'>\
- 오픈 일시 : <%openDatetime%> - <br>\
<%openDatetime==starttime?'':'- 오픈 일시 : '+openDatetime+ '- <br>'%>\
- 오픈 일시 : <%starttime%> - <br>\
<span style='color:orange;'><%scenarioName%></span> <span style='color:limegreen;'><%turnterm%>분 턴 서버</span><br>\
(상성 설정:<%fictionMode%>), (빙의 여부:<%npcMode%>), (최대 스탯:<%gameConf.defaultStatTotal%>), (기타 설정:<%otherTextInfo%>)</td>\
";