diff --git a/hwe/css/select_npc.css b/hwe/css/select_npc.css index d6935563..8d345056 100644 --- a/hwe/css/select_npc.css +++ b/hwe/css/select_npc.css @@ -39,5 +39,10 @@ position: relative; top: -1px; *overflow: hidden; - } - \ No newline at end of file +} + + +#outdate_token{ + color:red; + display:none; +} \ No newline at end of file diff --git a/hwe/j_get_select_npc_token.php b/hwe/j_get_select_npc_token.php index 53863ade..613eff5d 100644 --- a/hwe/j_get_select_npc_token.php +++ b/hwe/j_get_select_npc_token.php @@ -4,7 +4,7 @@ namespace sammo; include "lib.php"; include "func.php"; -const VALID_SECOND = 25; +const VALID_SECOND = 90; const PICK_MORE_SECOND = 10; const KEEP_CNT = 3; @@ -74,10 +74,14 @@ if($token && $refresh){ } if($token && !$refresh){ + $pickMoreFrom = (new \DateTime($token['pick_more_from']))->getTimestamp(); + $nowT = $oNow->getTimestamp(); + Json::die([ 'result'=>true, 'pick'=>Json::decode($token['pick_result']), 'pickMoreFrom'=>$token['pick_more_from'], + 'pickMoreSeconds'=>$pickMoreFrom-$nowT, 'validUntil'=>$token['valid_until'] ]); } @@ -114,7 +118,7 @@ while(count($pickResult) < $pickLimit){ $newNonce = mt_rand(0, 0xfffffff); -$validSecond = max(VALID_SECOND, $turnterm*25); +$validSecond = max(VALID_SECOND, $turnterm*40); $pickMoreSecond = max(PICK_MORE_SECOND, $turnterm*10); $validUntil = $oNow->add(new \DateInterval(sprintf('PT%dS', $validSecond))); @@ -160,5 +164,6 @@ Json::die([ 'result'=>true, 'pick'=>$pickResult, 'pickMoreFrom'=>($inserted===-1)?$pickMoreFrom->format('Y-m-d H:i:s'):'2000-01-01 01:00:00', + 'pickMoreSeconds'=>($inserted===-1)?$pickMoreSecond:0, 'validUntil'=>$validUntil->format('Y-m-d H:i:s') ]); \ No newline at end of file diff --git a/hwe/js/select_npc.js b/hwe/js/select_npc.js index 5170d58d..eae34bc7 100644 --- a/hwe/js/select_npc.js +++ b/hwe/js/select_npc.js @@ -29,8 +29,29 @@ function pickGeneral(){ return false; } +function updateOutdateTimer(){ + var $validUntilText = $('#valid_until_text'); + var now = Date.now(); + var validUntil = $validUntilText.data('until'); + if(validUntil <= 0){ + return; + } + else if(validUntil < now){ + $validUntilText.data('until',0); + $('#valid_until').hide(); + $('#outdate_token').show(); + return; + } + else if(validUntil - now <= 30000){ + $validUntilText.css('color', "rgb(255, {0}, {0})".format(255*(validUntil - now)/30000)); + } + + setTimeout(updateOutdateTimer, 1000); +} + function updatePickMoreTimer(){ var $btn = $('#btn_pick_more'); + var now = Date.now(); var remain = ($btn.data('available') - now) / 1000; if(remain <= 0){ @@ -46,8 +67,10 @@ function updatePickMoreTimer(){ function printGenerals(value){ $('.card_holder').empty(); - $('#valid_until_text').html(value.validUntil); - $('#btn_pick_more').data('available', new Date(value.pickMoreFrom).getTime()).prop('disabled',true); + $('#valid_until_text').html(value.validUntil).data('until', (new Date(value.validUntil)).getTime()).show().css('color','white'); + $('#outdate_token').hide(); + var time = Date.now() + value.pickMoreSeconds*1000; + $('#btn_pick_more').data('available', time).prop('disabled',true); $.each(value.pick, function(idx, cardData){ cardData.iconPath = getIconPath(cardData.imgsvr, cardData.picture); @@ -59,6 +82,7 @@ function printGenerals(value){ }); updatePickMoreTimer(); + updateOutdateTimer(); } $(function($){ @@ -90,6 +114,7 @@ $('#btn_pick_more').click(function(){ alert(result.reason); location.refresh(); } + console.log(result); printGenerals(result); }); }); diff --git a/hwe/select_npc.php b/hwe/select_npc.php index 99e4890d..ee13d4f8 100644 --- a/hwe/select_npc.php +++ b/hwe/select_npc.php @@ -24,15 +24,15 @@ $nations = $db->queryAllLists('SELECT `name`, scoutmsg, color FROM nation'); <?=UniqueConst::$serverName?>: NPC빙의 - - - - - + + + + + - - + + @@ -78,7 +78,7 @@ history.go(-1);
장수 빙의
-( 까지 유효)
+( 까지 유효)- 만료 -