diff --git a/hwe/css/common.css b/hwe/css/common.css index 488dad05..eecb5928 100644 --- a/hwe/css/common.css +++ b/hwe/css/common.css @@ -3,11 +3,12 @@ html, body{ background-color:black; color:white; + line-height:1.3; } table { font-family:'맑은 고딕'; } font { font-family:'맑은 고딕'; } -input { font-family:'맑은 고딕'; height:20px } +input { font-family:'맑은 고딕'; font-size:13px; } select { font-family:'굴림'; line-height:100%; } /* */ diff --git a/hwe/css/select_npc.css b/hwe/css/select_npc.css index d86b3365..d6935563 100644 --- a/hwe/css/select_npc.css +++ b/hwe/css/select_npc.css @@ -1,3 +1,8 @@ +.container{ + width:1000px; + margin:0 auto; +} + .card_holder{ text-align:center; } @@ -6,6 +11,18 @@ display:inline-block; } +.general_card h4 { + margin:0; +} + +.general_card p { + margin:0; +} + + +.general_card .select_btn { + width:100%; +} .general_card label { display: block; diff --git a/hwe/j_get_select_npc_token.php b/hwe/j_get_select_npc_token.php index e924cb8f..915b2f30 100644 --- a/hwe/j_get_select_npc_token.php +++ b/hwe/j_get_select_npc_token.php @@ -31,13 +31,10 @@ if($oldGeneral !== null){ } list( - $year, - $month, $maxgeneral, $turnterm, - $genius, $npcmode -) = $db->queryFirstList('SELECT year,month,maxgeneral,turnterm,genius,npcmode from game limit 1'); +) = $db->queryFirstList('SELECT maxgeneral,turnterm,npcmode from game limit 1'); if(!$npcmode){ Json::die([ @@ -46,7 +43,6 @@ if(!$npcmode){ ]); } - $token = $db->queryFirstRow('SELECT * FROM select_npc_token WHERE `owner`=%i AND `valid_until`>=%s', $userID, $now); $pickResult = []; @@ -94,7 +90,7 @@ foreach($db->query('SELECT `no`, `name`, leader, power, intel, imgsvr, picture, $general['special2'] = \sammo\SpecialityConst::WAR[$general['special2']][0]??'-'; $candidates[$general['no']] = $general + ['keepCnt'=>KEEP_CNT]; $allStat = $general['leader'] + $general['power'] + $general['intel']; - $weight[$general['no']] = pow($allStat, 1.7); + $weight[$general['no']] = pow($allStat, 1.5); } foreach($db->queryFirstColumn('SELECT pick_result FROM select_npc_token WHERE `owner`!=%i AND valid_until >=%s', $userID, $now) as $reserved){ @@ -124,8 +120,6 @@ $pickMoreMinute = max(PICK_MORE_MINUTE, intdiv($turnterm, 5)); $validUntil = $oNow->add(new \DateInterval(sprintf('PT%dM', $validMinute))); $pickMoreFrom = $oNow->add(new \DateInterval(sprintf('PT%dM', $pickMoreMinute))); -$db->query('LOCK TABLES select_npc_token WRITE'); - $db->delete('select_npc_token', 'valid_until < %s', $now); $inserted = 0; @@ -155,8 +149,6 @@ else{ } } -$db->query('UNLOCK TABLES'); - if($inserted === 0){ Json::die([ 'result'=>false, diff --git a/hwe/j_select_npc.php b/hwe/j_select_npc.php new file mode 100644 index 00000000..51fb91e9 --- /dev/null +++ b/hwe/j_select_npc.php @@ -0,0 +1,109 @@ +false, + 'reason'=>'장수를 선택하지 않았습니다' + ]); +} + +$session = Session::requireLogin()->setReadOnly(); +$userID = Session::getUserID(); +$db = DB::db(); +$rootDB = RootDB::db(); + +$oNow = new \DateTimeImmutable(); +$now = $oNow->format('Y-m-d H:i:s'); + +$userNick = RootDB::db()->queryFirstField('SELECT `NAME` FROM member WHERE `NO`=%i',$userID); +if(!$userNick){ + Json::die([ + 'result'=>false, + 'reason'=>'멤버 정보를 가져오지 못했습니다.' + ]); +} + +$pickResult = $db->queryFirstField('SELECT pick_result FROM select_npc_token WHERE `owner`=%i AND `valid_until`>=%s', $userID, $now); +if(!$pickResult){ + Json::die([ + 'result'=>false, + 'reason'=>'유효한 장수 목록이 없습니다.' + ]); +} + + +$pickResult = Json::decode($pickResult); +if(!key_exists($pick, $pickResult)){ + Json::die([ + 'result'=>false, + 'reason'=>'선택한 장수가 목록에 없습니다.' + ]); +} +$pickedNPC = $pickResult[$pick]; + + +$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2'); +list( + $year, + $month, + $maxgeneral, + $npcmode +) = $db->queryFirstList('SELECT year,month,maxgeneral,npcmode from game limit 1'); + +if(!$npcmode){ + Json::die([ + 'result'=>false, + 'reason'=>'빙의 가능한 서버가 아닙니다' + ]); +} + +if ($gencount >= $maxgeneral) { + Json::die([ + 'result'=>false, + 'reason'=>'더 이상 등록 할 수 없습니다.' + ]); +} + +//등록 시작 +$db->update('general', [ + 'owner'=>$userID, + 'npc'=>1 +], 'owner <= 0 AND npc = 2 AND no = %i', $pick); + +if(!$db->affectedRows()){ + Json::die([ + 'result'=>false, + 'reason'=>'장수 등록에 실패했습니다.' + ]); +} + +$db->delete('select_npc_token', 'owner=%i', $userID); + +pushGeneralHistory($pickedNPC, "●{$year}년 {$month}월:{$pickedNPC['name']}의 육체에 {$userNick}(이)가 빙의되다."); +//pushGenLog($me, $mylog); +pushGeneralPublicRecord(["●{$month}월:{$pickedNPC['name']}의 육체에 {$userNick}(이)가 빙의됩니다!"], $year, $month); + +pushAdminLog(["가입 : {$userID} // {$session->userName} // {$pick} // ".getenv("REMOTE_ADDR")]); + +$rootDB->insert('member_log', [ + 'member_no' => $userID, + 'date'=>date('Y-m-d H:i:s'), + 'action_type'=>'make_general', + 'action'=>Json::encode([ + 'server'=>DB::prefix(), + 'type'=>'npc', + 'generalID'=>$npc['no'], + 'generalName'=>$npc['name'] + ]) +]); + +Json::die([ + 'result'=>true, + 'reason'=>'success' +]); \ No newline at end of file diff --git a/hwe/js/select_npc.js b/hwe/js/select_npc.js index 8229d686..5170d58d 100644 --- a/hwe/js/select_npc.js +++ b/hwe/js/select_npc.js @@ -8,6 +8,27 @@ var templateGeneralCard = \ '; +function pickGeneral(){ + $btn = $(this); + + $.post({ + url:'j_select_npc.php', + dataType:'json', + data:{ + pick:$btn.val() + } + }).then(function(result){ + if(!result.result){ + alert(result.reason); + location.refresh(); + } + + alert('빙의에 성공했습니다.'); + location.href = './'; + }); + return false; +} + function updatePickMoreTimer(){ var $btn = $('#btn_pick_more'); var now = Date.now(); @@ -29,18 +50,18 @@ function printGenerals(value){ $('#btn_pick_more').data('available', new Date(value.pickMoreFrom).getTime()).prop('disabled',true); $.each(value.pick, function(idx, cardData){ cardData.iconPath = getIconPath(cardData.imgsvr, cardData.picture); - console.log(cardData); var $card = $(TemplateEngine(templateGeneralCard, cardData)); console.log($card); $('.card_holder').append($card); + $card.find('.select_btn').click(pickGeneral); }); updatePickMoreTimer(); } -jQuery(function($){ +$(function($){ $.post('j_get_select_npc_token.php').then(function(value){ if(!value.result){ diff --git a/hwe/new_select_npc.php b/hwe/new_select_npc.php deleted file mode 100644 index d5e18c35..00000000 --- a/hwe/new_select_npc.php +++ /dev/null @@ -1,103 +0,0 @@ -setReadOnly(); -$userID = Session::getUserID(); -$rootDB = RootDB::db(); -$db = DB::db(); - -//회원 테이블에서 정보확인 -$member = $rootDB->queryFirstRow('select no,name,picture,grade from member where no=%i', $userID); - -if(!$member) { - $session->logout(); - header('location:..'); - die(); -} - -list($npcmode, $maxgeneral) = $db->queryFirstList('SELECT npcmode,maxgeneral FROM game LIMIT 1'); - -if(!$npcmode) { - header('location:..'); - die(); -} - -$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2'); - -$nations = $db->queryAllLists('SELECT `name`, scoutmsg, color FROM nation'); -?> - - - -<?=UniqueConst::$serverName?>: NPC빙의 - - - - - - - - - - - - - - -= $maxgeneral) { -?> - - - - - - - -
-
장 수 선 택
- - -
- - - - - - - - - - - - - - - -
임관 권유 메세지
- -
-
장수 빙의
-
-( 까지 유효)
-
-
-
-
-
-
-
-
-
-
- - diff --git a/hwe/select_npc.php b/hwe/select_npc.php index 868318b9..99e4890d 100644 --- a/hwe/select_npc.php +++ b/hwe/select_npc.php @@ -6,141 +6,88 @@ include "func.php"; $session = Session::requireLogin()->setReadOnly(); $userID = Session::getUserID(); -$rootDB = RootDB::db(); $db = DB::db(); -//회원 테이블에서 정보확인 -$member = $rootDB->queryFirstRow('select no,name,picture,grade from member where no=%i', $userID); +list($npcmode, $maxgeneral) = $db->queryFirstList('SELECT npcmode,maxgeneral FROM game LIMIT 1'); -if(!$member) { - MessageBox("잘못된 접근입니다!!!"); - echo ""; - exit(1); -} - -$admin = $db->queryFirstRow('select npcmode,maxgeneral,show_img_level from game limit 1'); - -if($admin['npcmode'] != 1) { - header('Location:join.php'); +if(!$npcmode) { + header('location:..'); die(); } +$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2'); -$connect=$db->get(); - +$nations = $db->queryAllLists('SELECT `name`, scoutmsg, color FROM nation'); ?> -<?=UniqueConst::$serverName?>: NPC선택 +<?=UniqueConst::$serverName?>: NPC빙의 + + + + + + + - - - -
장 수 선 택
- - -
-= $admin['maxgeneral']) { - echo ""; - echo ""; - exit(); -} += $maxgeneral) { ?> - - -"; - } else { - echo " - "; - } -} -?> -
임관 권유 메세지
{$nation['name']}-
{$nation['name']}{$nation['scoutmsg']}
- -
- - - - -= 3) { -?> - - - - - - - - - - - - - - -
장수 선택
장수/1001.jpg border=0 name=picture width=64 height=64>
- -
- 컴퓨터가 조작중이던 NPC장수를 조종하게 됩니다.
- 80시간동안 휴식을 취하면 다시 컴퓨터가 조종하게 되고 장수의 소유권을 잃습니다. -
-
- - - -
- - + + + + +
+
장 수 선 택
+ + +
+ + + + + + + + + + + + + + + +
임관 권유 메세지
+ +
+
장수 빙의
+
+( 까지 유효)
+
+
+
+
+
+
+
+
+
+
+ diff --git a/hwe/select_npc_post.php b/hwe/select_npc_post.php deleted file mode 100644 index 4387baf7..00000000 --- a/hwe/select_npc_post.php +++ /dev/null @@ -1,144 +0,0 @@ -rule('required', 'face') -->rule('integer', 'face'); -if(!$v->validate()){ - MessageBox($v->errorStr()); - echo ""; - exit(1); -} - -$session = Session::requireLogin()->setReadOnly(); -$userID = Session::getUserID(); - -$face = (int)$_POST['face']; -$rootDB = RootDB::db(); - -//회원 테이블에서 정보확인 -$member = $rootDB->queryFirstRow('SELECT `no`, id, picture, grade, `name` FROM member WHERE no=%i', $userID); - -if(!$member) { - MessageBox("잘못된 접근입니다!!!"); - echo ""; - exit(1); -} - -$db = DB::db(); - -$npc = $db->queryFirstRow('SELECT `no`, `name`, `npc`, `level` FROM general WHERE `no`=%i', $face); -if(!$npc){ - echo ""; - echo ""; - exit(); -} - - -########## 동일 정보 존재여부 확인. ########## - -list( - $year, - $month, - $maxgeneral, - $turnterm, - $genius, - $npcmode -) = $db->queryFirstList('SELECT year,month,maxgeneral,turnterm,genius,npcmode from game limit 1'); - -$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2'); -$oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i', $userID); - -if($npcmode != 1) { - echo ""; - echo ""; - exit(); -} -if($oldGeneral) { - echo(""); - exit; -} -if($maxgeneral <= $gencount) { - echo(""); - exit; -} -if($npc['npc'] < 2) { - echo(""); - exit; -} -if($npc['npc'] != 2) { - echo(""); - exit; -} -/*if($npc['level'] >= 5) { - echo(""); - exit; - -} */ - -$userNick = RootDB::db()->queryFirstField('SELECT `NAME` FROM member WHERE `NO`=%i',Session::getUserID()); - -$npcID = $npc['no']; -$db->update('general', [ - 'name2'=>$userNick, - 'npc'=>1, - 'killturn'=>6, - 'mode'=>2, - 'owner'=>$userID -], 'no=%i and npc=2', $npcID); -$affected = $db->affectedRows(); -if(!$affected){ - echo(""); - exit; -} - -$me = [ - 'no'=>$npcID -]; - -pushGeneralHistory($me, "●{$year}년 {$month}월:{$npc['name']}의 육체에 {$userNick}(이)가 빙의되다."); -//pushGenLog($me, $mylog); -pushGeneralPublicRecord(["●{$month}월:{$npc['name']}의 육체에 {$userNick}(이)가 빙의됩니다!"], $year, $month); - -pushAdminLog(["가입 : {$userID} // {$session->userName} // {$npcID} // ".getenv("REMOTE_ADDR")]); - -$rootDB->insert('member_log', [ - 'member_no' => $userID, - 'date'=>date('Y-m-d H:i:s'), - 'action_type'=>'make_general', - 'action'=>Json::encode([ - 'server'=>DB::prefix(), - 'type'=>'npc', - 'generalID'=>$npc['no'], - 'generalName'=>$npc['name'] - ]) -]); - -?> - diff --git a/js/common.js b/js/common.js index 142575e0..0ac528d6 100644 --- a/js/common.js +++ b/js/common.js @@ -118,4 +118,14 @@ var TemplateEngine = function (html, options) { try { result = new Function('obj', code).apply(options, [options]); } catch (err) { console.error("'" + err.message + "'", " in \n\nCode:\n", code, "\n"); } return result; +} + +function getIconPath(imgsvr, picture){ + // ../d_shared/common_path.js 필요 + if(!imgsvr){ + return pathConfig.sharedIcon+'/'+picture; + } + else{ + return pathConfig.root+'/d_pic/'+picture; + } } \ No newline at end of file