전투 시뮬레이터 장수 불러오기 완성
This commit is contained in:
@@ -8,7 +8,34 @@ $session = Session::requireLogin()->setReadOnly();
|
|||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
$startYear = $gameStor->getValue('startyear');
|
$gameStor->cacheValues(['startyear', 'year']);
|
||||||
|
$startYear = $gameStor->startyear;
|
||||||
|
$year = $gameStor->year;
|
||||||
|
|
||||||
|
$me = $db->queryFirstRow('SELECT no, nation, city FROM general WHERE owner =%i', Session::getUserID());
|
||||||
|
|
||||||
|
if($me){
|
||||||
|
$generalID = $me['no'];
|
||||||
|
$nationID = $me['nation'];
|
||||||
|
$city = $db->queryFirstRow('SELECT city, level, def, wall FROM city WHERE city = %i', $me['city']);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$generalID = 0;
|
||||||
|
$nationID = 0;
|
||||||
|
$city = [
|
||||||
|
'city'=>0,
|
||||||
|
'level'=>5,
|
||||||
|
'def'=>1000,
|
||||||
|
'wall'=>1000,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($nationID){
|
||||||
|
$nation = $db->queryFirstRow('SELECT level, type, tech, capital FROM nation WHERE nation = %i', $nationID);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$nation = null;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -30,6 +57,8 @@ $startYear = $gameStor->getValue('startyear');
|
|||||||
<?=WebUtil::printJS('js/common.js')?>
|
<?=WebUtil::printJS('js/common.js')?>
|
||||||
<script>
|
<script>
|
||||||
var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
||||||
|
var city = <?=Json::encode($city)?>;
|
||||||
|
var nation = <?=Json::encode($nation)?>;
|
||||||
</script>
|
</script>
|
||||||
<?=WebUtil::printJS('js/battle_simulator.js')?>
|
<?=WebUtil::printJS('js/battle_simulator.js')?>
|
||||||
</head>
|
</head>
|
||||||
@@ -47,7 +76,7 @@ var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
|||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">년 시작</span>
|
<span class="input-group-text">년 시작</span>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="form-control" id="year" value="<?=$startYear+3?>" min="<?=$startYear?>">
|
<input type="number" class="form-control" id="year" value="<?=$year?>" min="<?=$startYear?>">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">년</span>
|
<span class="input-group-text">년</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -131,7 +160,7 @@ var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
|||||||
<input type="radio" name="is_attacker_capital" class="form_is_capital" value="1" autocomplete="off">Y
|
<input type="radio" name="is_attacker_capital" class="form_is_capital" value="1" autocomplete="off">Y
|
||||||
</label>
|
</label>
|
||||||
<label class="btn btn-secondary active">
|
<label class="btn btn-secondary active">
|
||||||
<input type="radio" name="is_attacker_capital" class="form_is_capital" value="2" autocomplete="off" checked>N
|
<input type="radio" name="is_attacker_capital" class="form_is_capital" value="0" autocomplete="off">N
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -145,6 +174,9 @@ var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
|||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div class="float-sm-left" style="line-height:25px;">출병자 설정</div>
|
<div class="float-sm-left" style="line-height:25px;">출병자 설정</div>
|
||||||
<div class="float-sm-right btn-toolbar" role="toolbar">
|
<div class="float-sm-right btn-toolbar" role="toolbar">
|
||||||
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
|
<button type="button" class="btn btn-success btn-general-import-server">서버에서 가져오기</button>
|
||||||
|
</div>
|
||||||
<div class="btn-group btn-group-sm mr-2" role="group">
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
<button type="button" class="btn btn-info btn-general-save">저장</button>
|
<button type="button" class="btn btn-info btn-general-save">저장</button>
|
||||||
<input type="file" class="form_load_general_file" accept=".json" style="display: none;" />
|
<input type="file" class="form_load_general_file" accept=".json" style="display: none;" />
|
||||||
@@ -203,7 +235,7 @@ var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
|||||||
<input type="radio" name="is_defender_capital" class="form_is_capital" value="1" autocomplete="off">Y
|
<input type="radio" name="is_defender_capital" class="form_is_capital" value="1" autocomplete="off">Y
|
||||||
</label>
|
</label>
|
||||||
<label class="btn btn-secondary active">
|
<label class="btn btn-secondary active">
|
||||||
<input type="radio" name="is_defender_capital" class="form_is_capital" value="0" autocomplete="off" checked>N
|
<input type="radio" name="is_defender_capital" class="form_is_capital" value="0" autocomplete="off">N
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -236,6 +268,9 @@ var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
|||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div class="float-sm-left" style="line-height:25px;">수비자 설정</div>
|
<div class="float-sm-left" style="line-height:25px;">수비자 설정</div>
|
||||||
<div class="float-sm-right btn-toolbar" role="toolbar">
|
<div class="float-sm-right btn-toolbar" role="toolbar">
|
||||||
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
|
<button type="button" class="btn btn-success btn-general-import-server">서버에서 가져오기</button>
|
||||||
|
</div>
|
||||||
<div class="btn-group btn-group-sm mr-2" role="group">
|
<div class="btn-group btn-group-sm mr-2" role="group">
|
||||||
<button type="button" class="btn btn-info btn-general-save">저장</button>
|
<button type="button" class="btn btn-info btn-general-save">저장</button>
|
||||||
<input type="file" class="form_load_general_file" accept=".json" style="display: none;" />
|
<input type="file" class="form_load_general_file" accept=".json" style="display: none;" />
|
||||||
@@ -477,5 +512,25 @@ var defaultSpecialDomestic = '<?=GameConst::$defaultSpecialDomestic?>';
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="importModal" class="modal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">장수 목록</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<select id="modalSelector"></select>
|
||||||
|
<p>타국 장수을 선택한 경우 숙련과 아이템은 0으로 초기화됩니다.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" id='importFromDB'>가져오기</button>
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">닫기</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
include "lib.php";
|
||||||
|
include "func.php";
|
||||||
|
|
||||||
|
WebUtil::requireAJAX();
|
||||||
|
|
||||||
|
$destGeneralID = Util::getPost('destGeneralID', 'int', 0);
|
||||||
|
|
||||||
|
if(!$destGeneralID || $destGeneralID <= 0){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'올바르지 않은 장수 코드입니다'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$session = Session::requireGameLogin([])->setReadOnly();
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
|
||||||
|
increaseRefresh("시뮬레이터 추출", 1);
|
||||||
|
|
||||||
|
$userID = Session::getUserID();
|
||||||
|
$me = $db->queryFirstRow('SELECT no,nation from general where owner=%i', $userID);
|
||||||
|
$nationID = $me['nation'];
|
||||||
|
|
||||||
|
$reqColumns = [
|
||||||
|
'nation',
|
||||||
|
'name', 'officer_level', 'explevel', 'injury',
|
||||||
|
'leadership', 'horse', 'strength', 'weapon', 'intel', 'book', 'item',
|
||||||
|
'rice', 'personal', 'special2',
|
||||||
|
'crew', 'crewtype',
|
||||||
|
'atmos', 'train', 'dex1', 'dex2', 'dex3', 'dex4', 'dex5', 'defence_train'
|
||||||
|
];
|
||||||
|
|
||||||
|
$dummyItems = [
|
||||||
|
'officer_level'=>1,
|
||||||
|
'weapon'=>'None',
|
||||||
|
'book'=>'None',
|
||||||
|
'item'=>'None',
|
||||||
|
'crew'=>0,
|
||||||
|
'crewtype'=>GameUnitConst::DEFAULT_CREWTYPE,
|
||||||
|
'rice'=>10000,
|
||||||
|
'train'=>GameConst::$maxTrainByCommand,
|
||||||
|
'atmos'=>GameConst::$maxTrainByCommand,
|
||||||
|
'dex1'=>0,
|
||||||
|
'dex2'=>0,
|
||||||
|
'dex3'=>0,
|
||||||
|
'dex4'=>0,
|
||||||
|
'dex5'=>0,
|
||||||
|
'defence_train'=>80
|
||||||
|
];
|
||||||
|
|
||||||
|
$rawDestGeneral = $db->queryFirstRow('SELECT %l FROM general WHERE no=%i', Util::formatListOfBackticks($reqColumns), $destGeneralID);
|
||||||
|
|
||||||
|
if($nationID == 0 || $rawDestGeneral['nation'] != $nationID){
|
||||||
|
foreach($dummyItems as $key=>$val){
|
||||||
|
$rawDestGeneral[$key] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(['dex1', 'dex2', 'dex3', 'dex4', 'dex5'] as $dexKey){
|
||||||
|
$dex = $rawDestGeneral[$dexKey];
|
||||||
|
$rawDestGeneral[$dexKey] = getDexLevelList()[getDexLevel($dex)][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
Json::die([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success',
|
||||||
|
'general'=>$rawDestGeneral,
|
||||||
|
]);
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
include "lib.php";
|
||||||
|
include "func.php";
|
||||||
|
|
||||||
|
//로그인 검사
|
||||||
|
$session = Session::requireGameLogin([]);
|
||||||
|
$generalID = Session::getGeneralID();
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
|
||||||
|
$rawList = Util::convertArrayToDict($db->query('SELECT no, name, npc, nation FROM general'), 'no');
|
||||||
|
$nationID = $rawList[$generalID]['nation'];
|
||||||
|
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success',
|
||||||
|
'nationID'=>$nationID,
|
||||||
|
'generalID'=>$generalID,
|
||||||
|
'column'=>['no', 'name', 'npc']
|
||||||
|
];
|
||||||
|
|
||||||
|
$resultItem = [];
|
||||||
|
foreach(Util::arrayGroupBy($rawList, 'nation') as $subNationID=>$generals){
|
||||||
|
$subNation = [];
|
||||||
|
foreach($generals as $general){
|
||||||
|
$subNation[] = [$general['no'], $general['name'], $general['npc']];
|
||||||
|
}
|
||||||
|
$resultItem[$subNationID] = $subNation;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['list'] = $resultItem;
|
||||||
|
$result['nation'] = Util::convertArrayToDict($db->query('SELECT nation, name, color FROM nation'), 'nation');
|
||||||
|
Json::die($result);
|
||||||
@@ -6,7 +6,7 @@ include "func.php";
|
|||||||
|
|
||||||
|
|
||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireLogin();
|
$session = Session::requireLogin([]);
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|||||||
+351
-229
@@ -1,4 +1,4 @@
|
|||||||
jQuery(function($){
|
jQuery(function($) {
|
||||||
|
|
||||||
|
|
||||||
var $generalForm = $('.form_sample .general_detail');
|
var $generalForm = $('.form_sample .general_detail');
|
||||||
@@ -9,9 +9,28 @@ jQuery(function($){
|
|||||||
|
|
||||||
var $attackerCard = $('.attacker_form');
|
var $attackerCard = $('.attacker_form');
|
||||||
|
|
||||||
var initBasicEvent = function(){
|
var initBasicEvent = function() {
|
||||||
|
|
||||||
$('.form_injury').change(function(){
|
if (window.nation) {
|
||||||
|
$('.form_city_level').val(window.city.level);
|
||||||
|
$('.form_def').val(window.city.def);
|
||||||
|
$('.form_wall').val(window.city.wall);
|
||||||
|
$('.form_nation_type').val(window.nation.type);
|
||||||
|
$('.form_nation_level').val(window.nation.level);
|
||||||
|
$('.form_tech').val(parseInt(window.nation.tech / 1000));
|
||||||
|
if (window.nation.capital == window.city.city) {
|
||||||
|
$('.attacker_nation .form_is_capital:first').click();
|
||||||
|
$('.defender_nation .form_is_capital:first').click();
|
||||||
|
} else {
|
||||||
|
$('.attacker_nation .form_is_capital:second').click();
|
||||||
|
$('.defender_nation .form_is_capital:second').click();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('.attacker_nation .form_is_capital:second').click();
|
||||||
|
$('.defender_nation .form_is_capital:second').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.form_injury').change(function() {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $general = getGeneralDetail($this);
|
var $general = getGeneralDetail($this);
|
||||||
var $helptext = $general.find('.injury_helptext');
|
var $helptext = $general.find('.injury_helptext');
|
||||||
@@ -20,51 +39,48 @@ jQuery(function($){
|
|||||||
//FIXME: PHP 코드와 항상 일치하도록 변경
|
//FIXME: PHP 코드와 항상 일치하도록 변경
|
||||||
var text = '건강';
|
var text = '건강';
|
||||||
var color = 'white';
|
var color = 'white';
|
||||||
if(injury > 60){
|
if (injury > 60) {
|
||||||
text = '위독';
|
text = '위독';
|
||||||
color = 'red';
|
color = 'red';
|
||||||
}
|
} else if (injury > 40) {
|
||||||
else if(injury > 40){
|
|
||||||
text = '심각';
|
text = '심각';
|
||||||
color = 'magenta';
|
color = 'magenta';
|
||||||
}
|
} else if (injury > 20) {
|
||||||
else if(injury > 20){
|
|
||||||
text = '중상';
|
text = '중상';
|
||||||
color = 'orange';
|
color = 'orange';
|
||||||
}
|
} else if (injury > 0) {
|
||||||
else if(injury > 0){
|
|
||||||
text = '경상';
|
text = '경상';
|
||||||
color = 'yellow';
|
color = 'yellow';
|
||||||
}
|
}
|
||||||
$helptext.html(text).css('color', color);
|
$helptext.html(text).css('color', color);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.export_general').click(function(){
|
$('.export_general').click(function() {
|
||||||
var $btn = $(this);
|
var $btn = $(this);
|
||||||
var $general = getGeneralDetail($btn);
|
var $general = getGeneralDetail($btn);
|
||||||
|
|
||||||
var values = exportGeneralInfo($general);
|
var values = exportGeneralInfo($general);
|
||||||
console.log(values);
|
console.log(values);
|
||||||
});
|
});
|
||||||
$('.delete-defender').click(function(){
|
$('.delete-defender').click(function() {
|
||||||
var $card = getGeneralFrame($(this));
|
var $card = getGeneralFrame($(this));
|
||||||
deleteDefender($card);
|
deleteDefender($card);
|
||||||
});
|
});
|
||||||
$('.copy-defender').click(function(){
|
$('.copy-defender').click(function() {
|
||||||
var $card = getGeneralFrame($(this));
|
var $card = getGeneralFrame($(this));
|
||||||
copyDefender($card);
|
copyDefender($card);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.add-defender').click(function(){
|
$('.add-defender').click(function() {
|
||||||
addDefender();
|
addDefender();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn-general-load').click(function(){
|
$('.btn-general-load').click(function() {
|
||||||
var $file = $(this).prev();
|
var $file = $(this).prev();
|
||||||
$file[0].click();
|
$file[0].click();
|
||||||
})
|
})
|
||||||
|
|
||||||
$('.form_load_general_file').on('change', function(e){
|
$('.form_load_general_file').on('change', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $card = getGeneralFrame($this);
|
var $card = getGeneralFrame($this);
|
||||||
@@ -75,26 +91,35 @@ jQuery(function($){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn-general-save').click(function(){
|
$('.btn-general-import-server').click(function() {
|
||||||
|
var $this = $(this);
|
||||||
|
var $card = getGeneralFrame($this);
|
||||||
|
|
||||||
|
var $modal = $('#importModal');
|
||||||
|
$modal.data('target', $card);
|
||||||
|
$modal.modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btn-general-save').click(function() {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $general = getGeneralDetail($this);
|
var $general = getGeneralDetail($this);
|
||||||
var generalData = exportGeneralInfo($general);
|
var generalData = exportGeneralInfo($general);
|
||||||
|
|
||||||
var filename = "general_{0}.json".format(generalData.name);
|
var filename = "general_{0}.json".format(generalData.name);
|
||||||
var saveData = JSON.stringify({
|
var saveData = JSON.stringify({
|
||||||
objType:'general',
|
objType: 'general',
|
||||||
data:generalData
|
data: generalData
|
||||||
}, null, 4);
|
}, null, 4);
|
||||||
|
|
||||||
download(saveData, filename, 'application/json');
|
download(saveData, filename, 'application/json');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn-battle-load').click(function(){
|
$('.btn-battle-load').click(function() {
|
||||||
var $file = $(this).prev();
|
var $file = $(this).prev();
|
||||||
$file[0].click();
|
$file[0].click();
|
||||||
})
|
})
|
||||||
|
|
||||||
$('.form_load_battle_file').on('change', function(e){
|
$('.form_load_battle_file').on('change', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var files = e.target.files;
|
var files = e.target.files;
|
||||||
@@ -103,12 +128,12 @@ jQuery(function($){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn-battle-save').click(function(){
|
$('.btn-battle-save').click(function() {
|
||||||
var battleData = exportAllData();
|
var battleData = exportAllData();
|
||||||
var filename = "battle_{0}.json".format(moment().format('YYYYMMDD_hhmmss'));
|
var filename = "battle_{0}.json".format(moment().format('YYYYMMDD_hhmmss'));
|
||||||
var saveData = JSON.stringify({
|
var saveData = JSON.stringify({
|
||||||
objType:'battle',
|
objType: 'battle',
|
||||||
data:battleData
|
data: battleData
|
||||||
}, null, 4);
|
}, null, 4);
|
||||||
|
|
||||||
download(saveData, filename, 'application/json');
|
download(saveData, filename, 'application/json');
|
||||||
@@ -119,7 +144,7 @@ jQuery(function($){
|
|||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
$generals.bind('drop', function(e){
|
$generals.bind('drop', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $card = getGeneralFrame($this);
|
var $card = getGeneralFrame($this);
|
||||||
@@ -135,7 +160,7 @@ jQuery(function($){
|
|||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
$battlePad.bind('drop', function(e){
|
$battlePad.bind('drop', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var files = e.originalEvent.dataTransfer.files;
|
var files = e.originalEvent.dataTransfer.files;
|
||||||
@@ -145,8 +170,8 @@ jQuery(function($){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var importGeneralInfo = function($general, data){
|
var importGeneralInfo = function($general, data) {
|
||||||
var setVal = function(query, val){
|
var setVal = function(query, val) {
|
||||||
$general.find(query).val(val).change();
|
$general.find(query).val(val).change();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +179,6 @@ jQuery(function($){
|
|||||||
|
|
||||||
setVal('.form_officer_level', data.officer_level);
|
setVal('.form_officer_level', data.officer_level);
|
||||||
setVal('.form_exp_level', data.explevel);
|
setVal('.form_exp_level', data.explevel);
|
||||||
setVal('.form_injury', data.injury);
|
|
||||||
|
|
||||||
setVal('.form_leadership', data.leadership);
|
setVal('.form_leadership', data.leadership);
|
||||||
setVal('.form_general_horse', data.horse);
|
setVal('.form_general_horse', data.horse);
|
||||||
@@ -183,93 +207,93 @@ jQuery(function($){
|
|||||||
setVal('.form_dex5', data.dex5);
|
setVal('.form_dex5', data.dex5);
|
||||||
setVal('.form_defence_train', data.defence_train);
|
setVal('.form_defence_train', data.defence_train);
|
||||||
|
|
||||||
if(!setGeneralNo($general, data.no)){
|
if (!setGeneralNo($general, data.no)) {
|
||||||
setGeneralNo($general, generateNewGeneralNo());
|
setGeneralNo($general, generateNewGeneralNo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var exportGeneralInfo = function($general){
|
var exportGeneralInfo = function($general) {
|
||||||
var getInt = function(query){
|
var getInt = function(query) {
|
||||||
return parseInt($general.find(query).val());
|
return parseInt($general.find(query).val());
|
||||||
}
|
}
|
||||||
|
|
||||||
var getVal = function(query){
|
var getVal = function(query) {
|
||||||
return $general.find(query).val();
|
return $general.find(query).val();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
no:getGeneralNo($general),
|
no: getGeneralNo($general),
|
||||||
name:getVal('.form_general_name'),
|
name: getVal('.form_general_name'),
|
||||||
officer_level:getInt('.form_officer_level'),
|
officer_level: getInt('.form_officer_level'),
|
||||||
explevel:getInt('.form_exp_level'),
|
explevel: getInt('.form_exp_level'),
|
||||||
|
|
||||||
leadership:getInt('.form_leadership'),
|
leadership: getInt('.form_leadership'),
|
||||||
horse:getVal('.form_general_horse'),
|
horse: getVal('.form_general_horse'),
|
||||||
strength:getInt('.form_strength'),
|
strength: getInt('.form_strength'),
|
||||||
weapon:getVal('.form_general_weap'),
|
weapon: getVal('.form_general_weap'),
|
||||||
intel:getInt('.form_intel'),
|
intel: getInt('.form_intel'),
|
||||||
book:getVal('.form_general_book'),
|
book: getVal('.form_general_book'),
|
||||||
item:getVal('.form_general_item'),
|
item: getVal('.form_general_item'),
|
||||||
|
|
||||||
injury:getInt('.form_injury'),
|
injury: getInt('.form_injury'),
|
||||||
|
|
||||||
rice:getInt('.form_rice'),
|
rice: getInt('.form_rice'),
|
||||||
|
|
||||||
personal:getVal('.form_general_character'),
|
personal: getVal('.form_general_character'),
|
||||||
special2:getVal('.form_general_special_war'),
|
special2: getVal('.form_general_special_war'),
|
||||||
|
|
||||||
crew:getInt('.form_crew'),
|
crew: getInt('.form_crew'),
|
||||||
crewtype:getInt('.form_crewtype'),
|
crewtype: getInt('.form_crewtype'),
|
||||||
atmos:getInt('.form_atmos'),
|
atmos: getInt('.form_atmos'),
|
||||||
train:getInt('.form_train'),
|
train: getInt('.form_train'),
|
||||||
|
|
||||||
dex1:getInt('.form_dex1'),
|
dex1: getInt('.form_dex1'),
|
||||||
dex2:getInt('.form_dex2'),
|
dex2: getInt('.form_dex2'),
|
||||||
dex3:getInt('.form_dex3'),
|
dex3: getInt('.form_dex3'),
|
||||||
dex4:getInt('.form_dex4'),
|
dex4: getInt('.form_dex4'),
|
||||||
dex5:getInt('.form_dex5'),
|
dex5: getInt('.form_dex5'),
|
||||||
defence_train:getInt('.form_defence_train'),
|
defence_train: getInt('.form_defence_train'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var importBattleInfoByFile = function(files){
|
var importBattleInfoByFile = function(files) {
|
||||||
if(files === null){
|
if (files === null) {
|
||||||
alert('파일 에러!');
|
alert('파일 에러!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(files.length < 1){
|
if (files.length < 1) {
|
||||||
alert("파일 에러!");
|
alert("파일 에러!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var file = files[0];
|
var file = files[0];
|
||||||
if(file.size > 1024*1024){
|
if (file.size > 1024 * 1024) {
|
||||||
alert('파일이 너무 큽니다!');
|
alert('파일이 너무 큽니다!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(file.type === ''){
|
if (file.type === '') {
|
||||||
alert('폴더를 업로드할 수 없습니다!');
|
alert('폴더를 업로드할 수 없습니다!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function(){
|
reader.onload = function() {
|
||||||
var battleData = {};
|
var battleData = {};
|
||||||
try {
|
try {
|
||||||
battleData = JSON.parse(reader.result);
|
battleData = JSON.parse(reader.result);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
alert('올바르지 않은 파일 형식입니다');
|
alert('올바르지 않은 파일 형식입니다');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!('objType' in battleData)){
|
if (!('objType' in battleData)) {
|
||||||
alert('파일 형식을 확인할 수 없습니다');
|
alert('파일 형식을 확인할 수 없습니다');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(battleData.objType != 'battle'){
|
if (battleData.objType != 'battle') {
|
||||||
alert('전투 데이터가 아닙니다');
|
alert('전투 데이터가 아닙니다');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -281,8 +305,7 @@ jQuery(function($){
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
|
||||||
alert('파일을 읽는데 실패했습니다.');
|
alert('파일을 읽는데 실패했습니다.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -290,52 +313,52 @@ jQuery(function($){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var importGeneralInfoByFile = function(files, $card){
|
var importGeneralInfoByFile = function(files, $card) {
|
||||||
if($card === undefined){
|
if ($card === undefined) {
|
||||||
$card = addDefender();
|
$card = addDefender();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(files === null){
|
if (files === null) {
|
||||||
alert('파일 에러!');
|
alert('파일 에러!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(files.length < 1){
|
if (files.length < 1) {
|
||||||
alert("파일 에러!");
|
alert("파일 에러!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var file = files[0];
|
var file = files[0];
|
||||||
if(file.size > 1024*1024){
|
if (file.size > 1024 * 1024) {
|
||||||
alert('파일이 너무 큽니다!');
|
alert('파일이 너무 큽니다!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(file.type === ''){
|
if (file.type === '') {
|
||||||
alert('폴더를 업로드할 수 없습니다!');
|
alert('폴더를 업로드할 수 없습니다!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function(){
|
reader.onload = function() {
|
||||||
var generalData = {};
|
var generalData = {};
|
||||||
try {
|
try {
|
||||||
generalData = JSON.parse(reader.result);
|
generalData = JSON.parse(reader.result);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
alert('올바르지 않은 파일 형식입니다');
|
alert('올바르지 않은 파일 형식입니다');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!('objType' in generalData)){
|
if (!('objType' in generalData)) {
|
||||||
alert('파일 형식을 확인할 수 없습니다');
|
alert('파일 형식을 확인할 수 없습니다');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(generalData.objType == 'battle'){
|
if (generalData.objType == 'battle') {
|
||||||
importBattleInfo(generalData.data);
|
importBattleInfo(generalData.data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(generalData.objType != 'general'){
|
if (generalData.objType != 'general') {
|
||||||
alert('장수 데이터가 아닙니다');
|
alert('장수 데이터가 아닙니다');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -349,8 +372,7 @@ jQuery(function($){
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
|
||||||
alert('파일을 읽는데 실패했습니다.');
|
alert('파일을 읽는데 실패했습니다.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -358,49 +380,49 @@ jQuery(function($){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var extendGeneralInfoForDB = function(generalData){
|
var extendGeneralInfoForDB = function(generalData) {
|
||||||
|
|
||||||
var dbVal = {
|
var dbVal = {
|
||||||
nation: (generalData.no)<=1 ? 1 : 2,
|
nation: (generalData.no) <= 1 ? 1 : 2,
|
||||||
city: (generalData.no)<=1 ? 1 : 3,
|
city: (generalData.no) <= 1 ? 1 : 3,
|
||||||
turntime:'2018-08-26 12:00',
|
turntime: '2018-08-26 12:00',
|
||||||
special:defaultSpecialDomestic,
|
special: defaultSpecialDomestic,
|
||||||
leadership_exp:0,
|
leadership_exp: 0,
|
||||||
strength_exp:0,
|
strength_exp: 0,
|
||||||
intel_exp:0,
|
intel_exp: 0,
|
||||||
|
|
||||||
gold:10000,
|
gold: 10000,
|
||||||
|
|
||||||
dedication:0,
|
dedication: 0,
|
||||||
|
|
||||||
recent_war:'2018-08-26 12:00',
|
recent_war: '2018-08-26 12:00',
|
||||||
experience:Math.pow(generalData.explevel, 2),
|
experience: Math.pow(generalData.explevel, 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
return $.extend({}, generalData, dbVal);
|
return $.extend({}, generalData, dbVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
var getGeneralFrame = function($btn){
|
var getGeneralFrame = function($btn) {
|
||||||
var $card = $btn.closest('.general_form');
|
var $card = $btn.closest('.general_form');
|
||||||
return $card;
|
return $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
var getGeneralDetail = function($btn){
|
var getGeneralDetail = function($btn) {
|
||||||
var $card = getGeneralFrame($btn);
|
var $card = getGeneralFrame($btn);
|
||||||
var $general = $card.find('.general_detail');
|
var $general = $card.find('.general_detail');
|
||||||
return $general;
|
return $general;
|
||||||
}
|
}
|
||||||
|
|
||||||
var getGeneralNo = function($btn){
|
var getGeneralNo = function($btn) {
|
||||||
return parseInt(getGeneralFrame($btn).data('general_no'));
|
return parseInt(getGeneralFrame($btn).data('general_no'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var setGeneralNo = function($btn, value){
|
var setGeneralNo = function($btn, value) {
|
||||||
if(value == 1){
|
if (value == 1) {
|
||||||
//1번은 무조건 공격자임
|
//1번은 무조건 공격자임
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(value in defenderNoList){
|
if (value in defenderNoList) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var $card = getGeneralFrame($btn);
|
var $card = getGeneralFrame($btn);
|
||||||
@@ -409,35 +431,34 @@ jQuery(function($){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var generateNewGeneralNo = function(){
|
var generateNewGeneralNo = function() {
|
||||||
while(true){
|
while (true) {
|
||||||
var newGeneralNo = parseInt(Math.random()*(1<<24))+2;
|
var newGeneralNo = parseInt(Math.random() * (1 << 24)) + 2;
|
||||||
if(newGeneralNo in defenderNoList){
|
if (newGeneralNo in defenderNoList) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return newGeneralNo;
|
return newGeneralNo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var deleteGeneralNo = function($btn){
|
var deleteGeneralNo = function($btn) {
|
||||||
var $card = getGeneralFrame($btn);
|
var $card = getGeneralFrame($btn);
|
||||||
$card.removeData('general_no');
|
$card.removeData('general_no');
|
||||||
var generalNo = getGeneralNo($card);
|
var generalNo = getGeneralNo($card);
|
||||||
delete defenderNoList[generalNo];
|
delete defenderNoList[generalNo];
|
||||||
}
|
}
|
||||||
|
|
||||||
var addDefender = function($cardAfter){
|
var addDefender = function($cardAfter) {
|
||||||
var $newCard = $('<div class="card mb-2 defender_form general_form"></div>');
|
var $newCard = $('<div class="card mb-2 defender_form general_form"></div>');
|
||||||
|
|
||||||
if($cardAfter === undefined){
|
if ($cardAfter === undefined) {
|
||||||
$defenderColumn.append($newCard);
|
$defenderColumn.append($newCard);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$cardAfter.after($newCard);
|
$cardAfter.after($newCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
$newCard.append($defenderHeaderForm.clone(true,true));
|
$newCard.append($defenderHeaderForm.clone(true, true));
|
||||||
$newCard.append($generalForm.clone(true,true));
|
$newCard.append($generalForm.clone(true, true));
|
||||||
|
|
||||||
$newGeneral = getGeneralDetail($newCard);
|
$newGeneral = getGeneralDetail($newCard);
|
||||||
setGeneralNo($newCard, generateNewGeneralNo());
|
setGeneralNo($newCard, generateNewGeneralNo());
|
||||||
@@ -445,12 +466,12 @@ jQuery(function($){
|
|||||||
return $newCard;
|
return $newCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
var deleteDefender = function($card){
|
var deleteDefender = function($card) {
|
||||||
deleteGeneralNo($card);
|
deleteGeneralNo($card);
|
||||||
$card.detach();
|
$card.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
var copyDefender = function($card){
|
var copyDefender = function($card) {
|
||||||
var $general = getGeneralDetail($card);
|
var $general = getGeneralDetail($card);
|
||||||
|
|
||||||
var generalData = exportGeneralInfo($general);
|
var generalData = exportGeneralInfo($general);
|
||||||
@@ -458,7 +479,7 @@ jQuery(function($){
|
|||||||
importGeneralInfo(getGeneralDetail($newObj), generalData);
|
importGeneralInfo(getGeneralDetail($newObj), generalData);
|
||||||
}
|
}
|
||||||
|
|
||||||
var importBattleInfo = function(battleData){
|
var importBattleInfo = function(battleData) {
|
||||||
|
|
||||||
$('.form_load_battle_file').val('');
|
$('.form_load_battle_file').val('');
|
||||||
console.log(battleData);
|
console.log(battleData);
|
||||||
@@ -481,12 +502,11 @@ jQuery(function($){
|
|||||||
$('.delete-defender').click();
|
$('.delete-defender').click();
|
||||||
|
|
||||||
$attackerNation.find('.form_nation_type').val(attackerNation.type);
|
$attackerNation.find('.form_nation_type').val(attackerNation.type);
|
||||||
$attackerNation.find('.form_tech').val(Math.floor(attackerNation.tech/1000));
|
$attackerNation.find('.form_tech').val(Math.floor(attackerNation.tech / 1000));
|
||||||
$attackerNation.find('.form_nation_level').val(attackerNation.level);
|
$attackerNation.find('.form_nation_level').val(attackerNation.level);
|
||||||
if(attackerNation.capital == 1){
|
if (attackerNation.capital == 1) {
|
||||||
$attackerNation.find('.form_is_capital:first').click();
|
$attackerNation.find('.form_is_capital:first').click();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$attackerNation.find('.form_is_capital:last').click();
|
$attackerNation.find('.form_is_capital:last').click();
|
||||||
}
|
}
|
||||||
$attackerNation.find('.form_city_level').val(attackerCity.level);
|
$attackerNation.find('.form_city_level').val(attackerCity.level);
|
||||||
@@ -494,56 +514,55 @@ jQuery(function($){
|
|||||||
importGeneralInfo($('.attacker_form'), attackerGeneral);
|
importGeneralInfo($('.attacker_form'), attackerGeneral);
|
||||||
|
|
||||||
$defenderNation.find('.form_nation_type').val(defenderNation.type);
|
$defenderNation.find('.form_nation_type').val(defenderNation.type);
|
||||||
$defenderNation.find('.form_tech').val(Math.floor(defenderNation.tech/1000));
|
$defenderNation.find('.form_tech').val(Math.floor(defenderNation.tech / 1000));
|
||||||
$defenderNation.find('.form_nation_level').val(defenderNation.level);
|
$defenderNation.find('.form_nation_level').val(defenderNation.level);
|
||||||
if(defenderNation.capital == 1){
|
if (defenderNation.capital == 1) {
|
||||||
$defenderNation.find('.form_is_capital:first').click();
|
$defenderNation.find('.form_is_capital:first').click();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$defenderNation.find('.form_is_capital:last').click();
|
$defenderNation.find('.form_is_capital:last').click();
|
||||||
}
|
}
|
||||||
$defenderNation.find('.form_city_level').val(defenderCity.level);
|
$defenderNation.find('.form_city_level').val(defenderCity.level);
|
||||||
$('#city_def').val(defenderCity.def);
|
$('#city_def').val(defenderCity.def);
|
||||||
$('#city_wall').val(defenderCity.wall);
|
$('#city_wall').val(defenderCity.wall);
|
||||||
|
|
||||||
$.each(defenderGenerals, function(idx, defenderGeneral){
|
$.each(defenderGenerals, function(idx, defenderGeneral) {
|
||||||
var $card = addDefender();
|
var $card = addDefender();
|
||||||
importGeneralInfo($card, defenderGeneral);
|
importGeneralInfo($card, defenderGeneral);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var exportAllData = function(){
|
var exportAllData = function() {
|
||||||
var $attackerNation = $('.attacker_nation');
|
var $attackerNation = $('.attacker_nation');
|
||||||
var $defenderNation = $('.defender_nation');
|
var $defenderNation = $('.defender_nation');
|
||||||
|
|
||||||
var attackerGeneral = exportGeneralInfo($('.attacker_form'));
|
var attackerGeneral = exportGeneralInfo($('.attacker_form'));
|
||||||
|
|
||||||
var attackerCity = {
|
var attackerCity = {
|
||||||
level:parseInt($attackerNation.find('.form_city_level').val()),
|
level: parseInt($attackerNation.find('.form_city_level').val()),
|
||||||
};
|
};
|
||||||
|
|
||||||
var attackerNation = {
|
var attackerNation = {
|
||||||
type:$attackerNation.find('.form_nation_type').val(),
|
type: $attackerNation.find('.form_nation_type').val(),
|
||||||
tech:parseInt($attackerNation.find('.form_tech').val()) * 1000,
|
tech: parseInt($attackerNation.find('.form_tech').val()) * 1000,
|
||||||
level:parseInt($attackerNation.find('.form_nation_level').val()),
|
level: parseInt($attackerNation.find('.form_nation_level').val()),
|
||||||
capital:$attackerNation.find('.form_is_capital:checked').val()=='1'?1:2,
|
capital: $attackerNation.find('.form_is_capital:checked').val() == '1' ? 1 : 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
var defenderGenerals = $('.defender_form').map(function(){
|
var defenderGenerals = $('.defender_form').map(function() {
|
||||||
return exportGeneralInfo($(this));
|
return exportGeneralInfo($(this));
|
||||||
}).toArray();
|
}).toArray();
|
||||||
|
|
||||||
var defenderCity = {
|
var defenderCity = {
|
||||||
def: parseInt($('#city_def').val()),
|
def: parseInt($('#city_def').val()),
|
||||||
wall: parseInt($('#city_wall').val()),
|
wall: parseInt($('#city_wall').val()),
|
||||||
level:parseInt($defenderNation.find('.form_city_level').val()),
|
level: parseInt($defenderNation.find('.form_city_level').val()),
|
||||||
};
|
};
|
||||||
|
|
||||||
var defenderNation = {
|
var defenderNation = {
|
||||||
type:$defenderNation.find('.form_nation_type').val(),
|
type: $defenderNation.find('.form_nation_type').val(),
|
||||||
tech:parseInt($defenderNation.find('.form_tech').val()) * 1000,
|
tech: parseInt($defenderNation.find('.form_tech').val()) * 1000,
|
||||||
level:parseInt($defenderNation.find('.form_nation_level').val()),
|
level: parseInt($defenderNation.find('.form_nation_level').val()),
|
||||||
capital:$defenderNation.find('.form_is_capital:checked').val()=='1'?3:4,
|
capital: $defenderNation.find('.form_is_capital:checked').val() == '1' ? 3 : 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
var year = parseInt($('#year').val());
|
var year = parseInt($('#year').val());
|
||||||
@@ -551,59 +570,59 @@ jQuery(function($){
|
|||||||
var repeatCnt = parseInt($('#repeat_cnt').val());
|
var repeatCnt = parseInt($('#repeat_cnt').val());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attackerGeneral:attackerGeneral,
|
attackerGeneral: attackerGeneral,
|
||||||
attackerCity:attackerCity,
|
attackerCity: attackerCity,
|
||||||
attackerNation:attackerNation,
|
attackerNation: attackerNation,
|
||||||
|
|
||||||
defenderGenerals:defenderGenerals,
|
defenderGenerals: defenderGenerals,
|
||||||
defenderCity:defenderCity,
|
defenderCity: defenderCity,
|
||||||
defenderNation:defenderNation,
|
defenderNation: defenderNation,
|
||||||
|
|
||||||
year:year,
|
year: year,
|
||||||
month:month,
|
month: month,
|
||||||
repeatCnt:repeatCnt,
|
repeatCnt: repeatCnt,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var extendAllDataForDB = function(allData){
|
var extendAllDataForDB = function(allData) {
|
||||||
var defaultNation = {
|
var defaultNation = {
|
||||||
nation:0,
|
nation: 0,
|
||||||
name:'재야',
|
name: '재야',
|
||||||
capital:0,
|
capital: 0,
|
||||||
level:0,
|
level: 0,
|
||||||
gold:0,
|
gold: 0,
|
||||||
rice:2000,
|
rice: 2000,
|
||||||
type:'None',
|
type: 'None',
|
||||||
tech:0,
|
tech: 0,
|
||||||
gennum:200,
|
gennum: 200,
|
||||||
};
|
};
|
||||||
|
|
||||||
var defaultCity = {
|
var defaultCity = {
|
||||||
nation:0,
|
nation: 0,
|
||||||
supply:1,
|
supply: 1,
|
||||||
name:'도시',
|
name: '도시',
|
||||||
|
|
||||||
pop:500000,
|
pop: 500000,
|
||||||
agri:10000,
|
agri: 10000,
|
||||||
comm:10000,
|
comm: 10000,
|
||||||
secu:10000,
|
secu: 10000,
|
||||||
def:1000,
|
def: 1000,
|
||||||
wall:1000,
|
wall: 1000,
|
||||||
|
|
||||||
trust:100,
|
trust: 100,
|
||||||
|
|
||||||
pop_max:600000,
|
pop_max: 600000,
|
||||||
agri_max:12000,
|
agri_max: 12000,
|
||||||
comm_max:12000,
|
comm_max: 12000,
|
||||||
secu_max:10000,
|
secu_max: 10000,
|
||||||
def_max:12000,
|
def_max: 12000,
|
||||||
wall_max:12000,
|
wall_max: 12000,
|
||||||
|
|
||||||
dead:0,
|
dead: 0,
|
||||||
|
|
||||||
state:0,
|
state: 0,
|
||||||
|
|
||||||
conflict:'{}',
|
conflict: '{}',
|
||||||
};
|
};
|
||||||
|
|
||||||
var attackerNation = $.extend({}, defaultNation, allData.attackerNation);
|
var attackerNation = $.extend({}, defaultNation, allData.attackerNation);
|
||||||
@@ -615,10 +634,9 @@ jQuery(function($){
|
|||||||
attackerCity.city = 1;
|
attackerCity.city = 1;
|
||||||
|
|
||||||
var attackerGeneral = extendGeneralInfoForDB(allData.attackerGeneral);
|
var attackerGeneral = extendGeneralInfoForDB(allData.attackerGeneral);
|
||||||
if(2 <= attackerGeneral.officer_level && attackerGeneral.officer_level <= 4){
|
if (2 <= attackerGeneral.officer_level && attackerGeneral.officer_level <= 4) {
|
||||||
attackerGeneral.officer_city = 1;
|
attackerGeneral.officer_city = 1;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
attackerGeneral.officer_city = 0;
|
attackerGeneral.officer_city = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,16 +647,15 @@ jQuery(function($){
|
|||||||
var defenderCity = $.extend({}, defaultCity, allData.defenderCity);
|
var defenderCity = $.extend({}, defaultCity, allData.defenderCity);
|
||||||
defenderCity.nation = 2;
|
defenderCity.nation = 2;
|
||||||
defenderCity.city = 3;
|
defenderCity.city = 3;
|
||||||
defenderCity.wall_max = defenderCity.wall/5*6;
|
defenderCity.wall_max = defenderCity.wall / 5 * 6;
|
||||||
defenderCity.def_max = defenderCity.def/5*6;
|
defenderCity.def_max = defenderCity.def / 5 * 6;
|
||||||
|
|
||||||
var defenderGenerals = [];
|
var defenderGenerals = [];
|
||||||
$.each(allData.defenderGenerals, function(){
|
$.each(allData.defenderGenerals, function() {
|
||||||
var defenderGeneral = extendGeneralInfoForDB(this);
|
var defenderGeneral = extendGeneralInfoForDB(this);
|
||||||
if(2 <= defenderGeneral.officer_level && defenderGeneral.officer_level <= 4){
|
if (2 <= defenderGeneral.officer_level && defenderGeneral.officer_level <= 4) {
|
||||||
defenderGeneral.officer_city = 3;
|
defenderGeneral.officer_city = 3;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
defenderGeneral.officer_city = 0;
|
defenderGeneral.officer_city = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,58 +664,55 @@ jQuery(function($){
|
|||||||
|
|
||||||
|
|
||||||
return $.extend({}, allData, {
|
return $.extend({}, allData, {
|
||||||
attackerGeneral:attackerGeneral,
|
attackerGeneral: attackerGeneral,
|
||||||
attackerCity:attackerCity,
|
attackerCity: attackerCity,
|
||||||
attackerNation:attackerNation,
|
attackerNation: attackerNation,
|
||||||
|
|
||||||
defenderGenerals:defenderGenerals,
|
defenderGenerals: defenderGenerals,
|
||||||
defenderCity:defenderCity,
|
defenderCity: defenderCity,
|
||||||
defenderNation:defenderNation,
|
defenderNation: defenderNation,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var parseSkillCount = function(skills){
|
var parseSkillCount = function(skills) {
|
||||||
var result = [];
|
var result = [];
|
||||||
$.each(skills, function(key, value){
|
$.each(skills, function(key, value) {
|
||||||
result.push("{0}({1}회)".format(key, toPretty(value)));
|
result.push("{0}({1}회)".format(key, toPretty(value)));
|
||||||
})
|
})
|
||||||
|
|
||||||
if(result.length == 0){
|
if (result.length == 0) {
|
||||||
return '-';
|
return '-';
|
||||||
}
|
}
|
||||||
return result.join(', ');
|
return result.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
var toPretty = function(number){
|
var toPretty = function(number) {
|
||||||
if(isInt(number)){
|
if (isInt(number)) {
|
||||||
number = parseInt(number);
|
number = parseInt(number);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
number = parseFloat(number).toFixed(2);
|
number = parseFloat(number).toFixed(2);
|
||||||
}
|
}
|
||||||
return numberWithCommas(number);
|
return numberWithCommas(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
var showBattleResult = function(result){
|
var showBattleResult = function(result) {
|
||||||
$('#result_datetime').html(result.datetime);
|
$('#result_datetime').html(result.datetime);
|
||||||
$('#result_warcnt').html(toPretty(result.avgWar));
|
$('#result_warcnt').html(toPretty(result.avgWar));
|
||||||
$('#result_phase').html(toPretty(result.phase));
|
$('#result_phase').html(toPretty(result.phase));
|
||||||
$('#result_killed').html(toPretty(result.killed));
|
$('#result_killed').html(toPretty(result.killed));
|
||||||
if(result.minKilled != result.maxKilled){
|
if (result.minKilled != result.maxKilled) {
|
||||||
$('#result_maxKilled').html(toPretty(result.maxKilled));
|
$('#result_maxKilled').html(toPretty(result.maxKilled));
|
||||||
$('#result_minKilled').html(toPretty(result.minKilled));
|
$('#result_minKilled').html(toPretty(result.minKilled));
|
||||||
$('#result_varKilled').show();
|
$('#result_varKilled').show();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$('#result_varKilled').hide();
|
$('#result_varKilled').hide();
|
||||||
}
|
}
|
||||||
$('#result_dead').html(toPretty(result.dead));
|
$('#result_dead').html(toPretty(result.dead));
|
||||||
if(result.minDead != result.maxDead){
|
if (result.minDead != result.maxDead) {
|
||||||
$('#result_maxDead').html(toPretty(result.maxDead));
|
$('#result_maxDead').html(toPretty(result.maxDead));
|
||||||
$('#result_minDead').html(toPretty(result.minDead));
|
$('#result_minDead').html(toPretty(result.minDead));
|
||||||
$('#result_varDead').show();
|
$('#result_varDead').show();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$('#result_varDead').hide();
|
$('#result_varDead').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,7 +724,7 @@ jQuery(function($){
|
|||||||
|
|
||||||
var $summary = $('#battle_result_summary');
|
var $summary = $('#battle_result_summary');
|
||||||
|
|
||||||
$.each(result.defendersSkills, function(idx, defenderSkills){
|
$.each(result.defendersSkills, function(idx, defenderSkills) {
|
||||||
console.log(defenderSkills);
|
console.log(defenderSkills);
|
||||||
var $result = $("<tr class='result_defenderSkills'><th>수비자{0} 스킬</th><td></td></tr>".format(idx + 1));
|
var $result = $("<tr class='result_defenderSkills'><th>수비자{0} 스킬</th><td></td></tr>".format(idx + 1));
|
||||||
$result.find('td').html(parseSkillCount(defenderSkills));
|
$result.find('td').html(parseSkillCount(defenderSkills));
|
||||||
@@ -722,35 +736,35 @@ jQuery(function($){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var beginBattle = function(){
|
var beginBattle = function() {
|
||||||
var data = extendAllDataForDB(exportAllData());
|
var data = extendAllDataForDB(exportAllData());
|
||||||
console.log(data);
|
console.log(data);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:'post',
|
type: 'post',
|
||||||
url:'j_simulate_battle.php',
|
url: 'j_simulate_battle.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
action:'battle',
|
action: 'battle',
|
||||||
query:JSON.stringify(data),
|
query: JSON.stringify(data),
|
||||||
}
|
}
|
||||||
}).then(function(result){
|
}).then(function(result) {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
if(!result.result){
|
if (!result.result) {
|
||||||
alert(result.reason);
|
alert(result.reason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showBattleResult(result);
|
showBattleResult(result);
|
||||||
|
|
||||||
}, function(result){
|
}, function(result) {
|
||||||
alert('전투 개시 실패!');
|
alert('전투 개시 실패!');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var reorderDefender = function(defenderOrder){
|
var reorderDefender = function(defenderOrder) {
|
||||||
$.each(defenderOrder, function(idx, generalNo){
|
$.each(defenderOrder, function(idx, generalNo) {
|
||||||
|
|
||||||
if(!(generalNo in defenderNoList)){
|
if (!(generalNo in defenderNoList)) {
|
||||||
//음..?
|
//음..?
|
||||||
alert("{0}이 수비자 리스트에 없습니다. 버그인 듯 합니다.".format(generalNo));
|
alert("{0}이 수비자 리스트에 없습니다. 버그인 듯 합니다.".format(generalNo));
|
||||||
return true;
|
return true;
|
||||||
@@ -762,39 +776,147 @@ jQuery(function($){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var requestReorderDefender = function(){
|
var requestReorderDefender = function() {
|
||||||
var data = extendAllDataForDB(exportAllData());
|
var data = extendAllDataForDB(exportAllData());
|
||||||
console.log(data);
|
console.log(data);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:'post',
|
type: 'post',
|
||||||
url:'j_simulate_battle.php',
|
url: 'j_simulate_battle.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
action:'reorder',
|
action: 'reorder',
|
||||||
query:JSON.stringify(data),
|
query: JSON.stringify(data),
|
||||||
}
|
}
|
||||||
}).then(function(result){
|
}).then(function(result) {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
if(!result.result){
|
if (!result.result) {
|
||||||
alert(result.reason);
|
alert(result.reason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reorderDefender(result.order);
|
reorderDefender(result.order);
|
||||||
|
|
||||||
}, function(result){
|
}, function(result) {
|
||||||
alert('재정렬 실패!');
|
alert('재정렬 실패!');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var initGeneralList = false;
|
||||||
|
|
||||||
|
$('#importFromDB').click(function() {
|
||||||
|
var generalID = $('#modalSelector').val();
|
||||||
|
console.log(generalID);
|
||||||
|
|
||||||
|
|
||||||
|
$.post({
|
||||||
|
url: 'j_export_simulator_object.php',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
destGeneralID: generalID
|
||||||
|
}
|
||||||
|
}).then(function(data) {
|
||||||
|
|
||||||
|
if (!data.result) {
|
||||||
|
alert(data.reason);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $modal = $('#importModal');
|
||||||
|
var $card = $modal.data('target');
|
||||||
|
importGeneralInfo($card, data.general);
|
||||||
|
|
||||||
|
$modal.modal('hide');
|
||||||
|
}, errUnknown);
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#importModal').on('show.bs.modal', function(e) {
|
||||||
|
if (!initGeneralList) {
|
||||||
|
var $list = $('#modalSelector');
|
||||||
|
|
||||||
|
var addNation = function(generalList, nationName, color) {
|
||||||
|
|
||||||
|
generalList.sort(function(lhs, rhs) {
|
||||||
|
if (lhs.npc != rhs.npc) {
|
||||||
|
return lhs.npc - rhs.npc;
|
||||||
|
}
|
||||||
|
if (lhs.name < rhs.name) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (lhs.name > rhs.name) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
var $optGroup = $('<optgroup label="{0}"></optgroup>'.format(nationName));
|
||||||
|
$optGroup.css('background-color', color);
|
||||||
|
$optGroup.css('color', isBrightColor(color) ? 'black' : 'white');
|
||||||
|
|
||||||
|
$.each(generalList, function(idx, general) {
|
||||||
|
$item = $('<option value="{0}">{1}</option>'.format(general.no, general.name));
|
||||||
|
if (general.npc) {
|
||||||
|
$item.css('color', getNpcColor(general.npc));
|
||||||
|
} else {
|
||||||
|
$item.css('color', 'white');
|
||||||
|
}
|
||||||
|
$item.css('background-color', 'black');
|
||||||
|
$optGroup.append($item);
|
||||||
|
|
||||||
|
});
|
||||||
|
$list.append($optGroup);
|
||||||
|
}
|
||||||
|
$.post({
|
||||||
|
url: 'j_get_basic_general_list.php',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
req: 2,
|
||||||
|
}
|
||||||
|
}).then(function(data) {
|
||||||
|
if (!data.result) {
|
||||||
|
alert(data.reason);
|
||||||
|
$('#importModal').modal('hide');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nations = data.nation;
|
||||||
|
var myNationID = data.nationID;
|
||||||
|
|
||||||
|
$list.empty();
|
||||||
|
//자국 먼저
|
||||||
|
|
||||||
|
if (0 in data.list) {
|
||||||
|
nations[0] = {
|
||||||
|
nation: 0,
|
||||||
|
name: '재야',
|
||||||
|
color: '#000000'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
addNation(combineArray(data.list[myNationID], data.column), nations[myNationID].name, nations[myNationID].color);
|
||||||
|
|
||||||
|
for (var nationID in data.list) {
|
||||||
|
if (nationID == myNationID) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
addNation(combineArray(data.list[nationID], data.column), nations[nationID].name, nations[nationID].color);
|
||||||
|
}
|
||||||
|
initGeneralList = true;
|
||||||
|
}, errUnknown);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
initBasicEvent();
|
initBasicEvent();
|
||||||
$attackerCard.append($generalForm.clone(true,true));
|
$attackerCard.append($generalForm.clone(true, true));
|
||||||
addDefender();
|
addDefender();
|
||||||
|
|
||||||
$('.btn-begin_battle').click(function(){
|
$('.btn-begin_battle').click(function() {
|
||||||
beginBattle();
|
beginBattle();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btn-reorder_defender').click(function(){
|
$('.btn-reorder_defender').click(function() {
|
||||||
requestReorderDefender();
|
requestReorderDefender();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
+125
-99
@@ -3,8 +3,8 @@
|
|||||||
* @see https://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
* @see https://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
||||||
* @param {string} string escape하고자 하는 문자열
|
* @param {string} string escape하고자 하는 문자열
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
var escapeHtml = (function (string) {
|
var escapeHtml = (function(string) {
|
||||||
var entityMap = {
|
var entityMap = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
'<': '<',
|
'<': '<',
|
||||||
@@ -32,58 +32,70 @@ function isInt(n) {
|
|||||||
return +n === n && !(n % 1);
|
return +n === n && !(n % 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
;(function(ns){
|
;
|
||||||
|
(function(ns) {
|
||||||
//https://gist.github.com/demouth/3217440
|
//https://gist.github.com/demouth/3217440
|
||||||
/**
|
/**
|
||||||
* mb_strwidth
|
* mb_strwidth
|
||||||
* @param String
|
* @param String
|
||||||
* @return int
|
* @return int
|
||||||
* @see http://php.net/manual/ja/function.mb-strwidth.php
|
* @see http://php.net/manual/ja/function.mb-strwidth.php
|
||||||
*/
|
*/
|
||||||
var mb_strwidth = function(str){
|
var mb_strwidth = function(str) {
|
||||||
var i=0,l=str.length,c='',length=0;
|
var i = 0,
|
||||||
for(;i<l;i++){
|
l = str.length,
|
||||||
c=str.charCodeAt(i);
|
c = '',
|
||||||
if(0x0000<=c&&c<=0x0019){
|
length = 0;
|
||||||
length += 0;
|
for (; i < l; i++) {
|
||||||
}else if(0x0020<=c&&c<=0x1FFF){
|
c = str.charCodeAt(i);
|
||||||
length += 1;
|
if (0x0000 <= c && c <= 0x0019) {
|
||||||
}else if(0x2000<=c&&c<=0xFF60){
|
length += 0;
|
||||||
length += 2;
|
} else if (0x0020 <= c && c <= 0x1FFF) {
|
||||||
}else if(0xFF61<=c&&c<=0xFF9F){
|
length += 1;
|
||||||
length += 1;
|
} else if (0x2000 <= c && c <= 0xFF60) {
|
||||||
}else if(0xFFA0<=c){
|
length += 2;
|
||||||
length += 2;
|
} else if (0xFF61 <= c && c <= 0xFF9F) {
|
||||||
}
|
length += 1;
|
||||||
}
|
} else if (0xFFA0 <= c) {
|
||||||
return length;
|
length += 2;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mb_strimwidth
|
* mb_strimwidth
|
||||||
* @param String
|
* @param String
|
||||||
* @param int
|
* @param int
|
||||||
* @param int
|
* @param int
|
||||||
* @param String
|
* @param String
|
||||||
* @return String
|
* @return String
|
||||||
* @see http://www.php.net/manual/ja/function.mb-strimwidth.php
|
* @see http://www.php.net/manual/ja/function.mb-strimwidth.php
|
||||||
*/
|
*/
|
||||||
var mb_strimwidth = function(str,start,width,trimmarker){
|
var mb_strimwidth = function(str, start, width, trimmarker) {
|
||||||
if(typeof trimmarker === 'undefined') trimmarker='';
|
if (typeof trimmarker === 'undefined') trimmarker = '';
|
||||||
var trimmakerWidth = mb_strwidth(trimmarker),i=start,l=str.length,trimmedLength=0,trimmedStr='';
|
var trimmakerWidth = mb_strwidth(trimmarker),
|
||||||
for(;i<l;i++){
|
i = start,
|
||||||
var charCode=str.charCodeAt(i),c=str.charAt(i),charWidth=mb_strwidth(c),next=str.charAt(i+1),nextWidth=mb_strwidth(next);
|
l = str.length,
|
||||||
trimmedLength += charWidth;
|
trimmedLength = 0,
|
||||||
trimmedStr += c;
|
trimmedStr = '';
|
||||||
if(trimmedLength+trimmakerWidth+nextWidth>width){
|
for (; i < l; i++) {
|
||||||
trimmedStr += trimmarker;
|
var charCode = str.charCodeAt(i),
|
||||||
break;
|
c = str.charAt(i),
|
||||||
}
|
charWidth = mb_strwidth(c),
|
||||||
}
|
next = str.charAt(i + 1),
|
||||||
return trimmedStr;
|
nextWidth = mb_strwidth(next);
|
||||||
};
|
trimmedLength += charWidth;
|
||||||
ns.mb_strwidth = mb_strwidth;
|
trimmedStr += c;
|
||||||
ns.mb_strimwidth = mb_strimwidth;
|
if (trimmedLength + trimmakerWidth + nextWidth > width) {
|
||||||
|
trimmedStr += trimmarker;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return trimmedStr;
|
||||||
|
};
|
||||||
|
ns.mb_strwidth = mb_strwidth;
|
||||||
|
ns.mb_strimwidth = mb_strimwidth;
|
||||||
})(window);
|
})(window);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +105,7 @@ function isInt(n) {
|
|||||||
*/
|
*/
|
||||||
function convertDictById(arr) {
|
function convertDictById(arr) {
|
||||||
var result = {};
|
var result = {};
|
||||||
arr.forEach(function (v, i) {
|
arr.forEach(function(v, i) {
|
||||||
result[v.id] = v;
|
result[v.id] = v;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
@@ -106,7 +118,7 @@ function convertDictById(arr) {
|
|||||||
*/
|
*/
|
||||||
function convertSet(arr) {
|
function convertSet(arr) {
|
||||||
var result = {};
|
var result = {};
|
||||||
arr.forEach(function (v) {
|
arr.forEach(function(v) {
|
||||||
result[v] = true;
|
result[v] = true;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
@@ -115,7 +127,7 @@ function convertSet(arr) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {0}, {1}, {2}형태로 포맷해주는 함수
|
* {0}, {1}, {2}형태로 포맷해주는 함수
|
||||||
*/
|
*/
|
||||||
String.prototype.format = function() {
|
String.prototype.format = function() {
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
return this.replace(/{(\d+)}/g, function(match, number) {
|
return this.replace(/{(\d+)}/g, function(match, number) {
|
||||||
@@ -134,12 +146,11 @@ function hexToRgb(hex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isBrightColor(color){
|
function isBrightColor(color) {
|
||||||
color = hexToRgb(color);
|
color = hexToRgb(color);
|
||||||
if ((color.r*0.299 + color.g*0.587 + color.b*0.114) > 140){
|
if ((color.r * 0.299 + color.g * 0.587 + color.b * 0.114) > 140) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,7 +188,7 @@ function numberWithCommas(x) {
|
|||||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
function linkifyStrWithOpt(text){
|
function linkifyStrWithOpt(text) {
|
||||||
return linkifyStr(text, {});
|
return linkifyStr(text, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +199,14 @@ function linkifyStrWithOpt(text){
|
|||||||
* @param {object} options
|
* @param {object} options
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
var TemplateEngine = function (html, options) {
|
var TemplateEngine = function(html, options) {
|
||||||
var re = /<%(.+?)%>/g,
|
var re = /<%(.+?)%>/g,
|
||||||
reExp = /(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,
|
reExp = /(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,
|
||||||
code = 'with(obj) { var r=[];\n',
|
code = 'with(obj) { var r=[];\n',
|
||||||
cursor = 0,
|
cursor = 0,
|
||||||
result,
|
result,
|
||||||
match;
|
match;
|
||||||
var add = function (line, js) {
|
var add = function(line, js) {
|
||||||
js ? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
|
js ? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
|
||||||
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
|
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
|
||||||
return add;
|
return add;
|
||||||
@@ -208,82 +219,97 @@ var TemplateEngine = function (html, options) {
|
|||||||
}
|
}
|
||||||
add(html.substr(cursor, html.length - cursor));
|
add(html.substr(cursor, html.length - cursor));
|
||||||
code = (code + 'return r.join(""); }').replace(/[\r\t\n]/g, ' ');
|
code = (code + 'return r.join(""); }').replace(/[\r\t\n]/g, ' ');
|
||||||
try { result = new Function('obj', code).apply(options, [options]); }
|
try { result = new Function('obj', code).apply(options, [options]); } catch (err) { console.error("'" + err.message + "'", " in \n\nCode:\n", code, "\n"); }
|
||||||
catch (err) { console.error("'" + err.message + "'", " in \n\nCode:\n", code, "\n"); }
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIconPath(imgsvr, picture){
|
function getIconPath(imgsvr, picture) {
|
||||||
// ../d_shared/common_path.js 필요
|
// ../d_shared/common_path.js 필요
|
||||||
if(!imgsvr){
|
if (!imgsvr) {
|
||||||
return pathConfig.sharedIcon+'/'+picture;
|
return pathConfig.sharedIcon + '/' + picture;
|
||||||
}
|
} else {
|
||||||
else{
|
return pathConfig.root + '/d_pic/' + picture;
|
||||||
return pathConfig.root+'/d_pic/'+picture;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function activeFlip($obj){
|
function activeFlip($obj) {
|
||||||
var $result;
|
var $result;
|
||||||
if($obj === undefined){
|
if ($obj === undefined) {
|
||||||
$result = $('img[data-flip]');
|
$result = $('img[data-flip]');
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$result = $obj.find('img[data-flip]');
|
$result = $obj.find('img[data-flip]');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result.each(function(){
|
$result.each(function() {
|
||||||
activeFlipItem($(this));
|
activeFlipItem($(this));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function activeFlipItem($img){
|
function combineObject(item, columnList) {
|
||||||
|
var newItem = {};
|
||||||
|
for (var columnIdx in columnList) {
|
||||||
|
var columnName = columnList[columnIdx];
|
||||||
|
newItem[columnName] = item[columnIdx];
|
||||||
|
}
|
||||||
|
return newItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
function combineArray(array, columnList) {
|
||||||
|
var result = [];
|
||||||
|
for (var key in array) {
|
||||||
|
var item = array[key];
|
||||||
|
result[key] = combineObject(item, columnList);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function activeFlipItem($img) {
|
||||||
var imageList = [];
|
var imageList = [];
|
||||||
imageList.push($img.attr('src'));
|
imageList.push($img.attr('src'));
|
||||||
$.each($img.data('flip').split(','), function(idx, value){
|
$.each($img.data('flip').split(','), function(idx, value) {
|
||||||
var value = $.trim(value);
|
var value = $.trim(value);
|
||||||
if(!value){
|
if (!value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
imageList.push(value);
|
imageList.push(value);
|
||||||
});
|
});
|
||||||
if(imageList.length <= 1){
|
if (imageList.length <= 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$img.data('computed_flip_array', imageList);
|
$img.data('computed_flip_array', imageList);
|
||||||
$img.data('computed_flip_idx', 0);
|
$img.data('computed_flip_idx', 0);
|
||||||
|
|
||||||
$img.click(function(){
|
$img.click(function() {
|
||||||
var arr = $img.data('computed_flip_array');
|
var arr = $img.data('computed_flip_array');
|
||||||
var idx = $img.data('computed_flip_idx');
|
var idx = $img.data('computed_flip_idx');
|
||||||
idx = (idx + 1)%(arr.length);
|
idx = (idx + 1) % (arr.length);
|
||||||
$img.attr('src', arr[idx]);
|
$img.attr('src', arr[idx]);
|
||||||
$img.data('computed_flip_idx', idx);
|
$img.data('computed_flip_idx', idx);
|
||||||
});
|
});
|
||||||
$img.css('cursor','pointer');
|
$img.css('cursor', 'pointer');
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery(function($){
|
jQuery(function($) {
|
||||||
$('.obj_tooltip').mouseover(function(){
|
$('.obj_tooltip').mouseover(function() {
|
||||||
var $objTooltip = $(this);
|
var $objTooltip = $(this);
|
||||||
if($objTooltip.data('setObjTooltip')){
|
if ($objTooltip.data('setObjTooltip')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tooltipClassText = $objTooltip.data('tooltip-class');
|
var tooltipClassText = $objTooltip.data('tooltip-class');
|
||||||
if(!tooltipClassText){
|
if (!tooltipClassText) {
|
||||||
tooltipClassText = '';
|
tooltipClassText = '';
|
||||||
}
|
}
|
||||||
var template = '<div class="tooltip {0}" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>'
|
var template = '<div class="tooltip {0}" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>'
|
||||||
.format(tooltipClassText);
|
.format(tooltipClassText);
|
||||||
|
|
||||||
$objTooltip.tooltip({
|
$objTooltip.tooltip({
|
||||||
title:function(){
|
title: function() {
|
||||||
return $.trim($(this).find('.tooltiptext').html());
|
return $.trim($(this).find('.tooltiptext').html());
|
||||||
},
|
},
|
||||||
template:template,
|
template: template,
|
||||||
html:true
|
html: true
|
||||||
}).tooltip('show');
|
}).tooltip('show');
|
||||||
|
|
||||||
$objTooltip.data('setObjTooltip', true);
|
$objTooltip.data('setObjTooltip', true);
|
||||||
@@ -297,7 +323,7 @@ jQuery(function($){
|
|||||||
activeFlip();
|
activeFlip();
|
||||||
|
|
||||||
var customCSS = localStorage.getItem('sam_customCSS');
|
var customCSS = localStorage.getItem('sam_customCSS');
|
||||||
if(customCSS){
|
if (customCSS) {
|
||||||
var $style = $('<style type="text/css"></style>');
|
var $style = $('<style type="text/css"></style>');
|
||||||
$style.text(customCSS);
|
$style.text(customCSS);
|
||||||
$style.appendTo($('head'));
|
$style.appendTo($('head'));
|
||||||
@@ -307,11 +333,11 @@ jQuery(function($){
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function errUnknown(){
|
function errUnknown() {
|
||||||
alert('작업을 실패했습니다.');
|
alert('작업을 실패했습니다.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function errUnknownToast(){
|
function errUnknownToast() {
|
||||||
$.toast({
|
$.toast({
|
||||||
title: '에러!',
|
title: '에러!',
|
||||||
content: '작업을 실패했습니다.',
|
content: '작업을 실패했습니다.',
|
||||||
@@ -320,8 +346,8 @@ function errUnknownToast(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function quickReject(errMsg){
|
function quickReject(errMsg) {
|
||||||
if(errMsg === undefined){
|
if (errMsg === undefined) {
|
||||||
errMsg = '작업을 실패했습니다.';
|
errMsg = '작업을 실패했습니다.';
|
||||||
}
|
}
|
||||||
var deferred = $.Deferred();
|
var deferred = $.Deferred();
|
||||||
@@ -329,8 +355,8 @@ function quickReject(errMsg){
|
|||||||
return deferred.promise();
|
return deferred.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
function nl2br(text){
|
function nl2br(text) {
|
||||||
return text.replace(/\n/g,"<br>");
|
return text.replace(/\n/g, "<br>");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
function br2nl (text) {
|
function br2nl (text) {
|
||||||
@@ -338,11 +364,11 @@ function br2nl (text) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getNpcColor(npcType){
|
function getNpcColor(npcType) {
|
||||||
if(npcType >= 2){
|
if (npcType >= 2) {
|
||||||
return 'cyan';
|
return 'cyan';
|
||||||
}
|
}
|
||||||
if(npcType == 1){
|
if (npcType == 1) {
|
||||||
return 'skyblue';
|
return 'skyblue';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+138
-145
@@ -1,5 +1,5 @@
|
|||||||
var templateGeneralCard =
|
var templateGeneralCard =
|
||||||
'<div class="general_card">\
|
'<div class="general_card">\
|
||||||
<h4 class="bg1 with_border"><%name%></h4>\
|
<h4 class="bg1 with_border"><%name%></h4>\
|
||||||
<h4><img src="<%iconPath%>" height=64 width=64></h4>\
|
<h4><img src="<%iconPath%>" height=64 width=64></h4>\
|
||||||
<p><%leadership%> / <%strength%> / <%intel%><br>\
|
<p><%leadership%> / <%strength%> / <%intel%><br>\
|
||||||
@@ -11,7 +11,7 @@ var templateGeneralCard =
|
|||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
var templateSpecial =
|
var templateSpecial =
|
||||||
'<span class="obj_tooltip" data-toggle="tooltip" data-placement="top"><%text%>\
|
'<span class="obj_tooltip" data-toggle="tooltip" data-placement="top"><%text%>\
|
||||||
<span class="tooltiptext">\
|
<span class="tooltiptext">\
|
||||||
<%info%>\
|
<%info%>\
|
||||||
</span>\
|
</span>\
|
||||||
@@ -19,7 +19,7 @@ var templateSpecial =
|
|||||||
';
|
';
|
||||||
|
|
||||||
var templateGeneralRow =
|
var templateGeneralRow =
|
||||||
'<tr>\
|
'<tr>\
|
||||||
<td><img class="generalIcon" width="64" height="64" src="<%iconPath%>"></td>\
|
<td><img class="generalIcon" width="64" height="64" src="<%iconPath%>"></td>\
|
||||||
<td style="<%userCSS%>"><%name%><%nameAux%></td>\
|
<td style="<%userCSS%>"><%name%><%nameAux%></td>\
|
||||||
<td><%age%>세</td>\
|
<td><%age%>세</td>\
|
||||||
@@ -37,7 +37,7 @@ var templateGeneralRow =
|
|||||||
<td><%killturn%></td>\
|
<td><%killturn%></td>\
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
function pickGeneral(){
|
function pickGeneral() {
|
||||||
$btn = $(this);
|
$btn = $(this);
|
||||||
|
|
||||||
if (!confirm('빙의할까요? : {0}'.format($btn.data('name')))) {
|
if (!confirm('빙의할까요? : {0}'.format($btn.data('name')))) {
|
||||||
@@ -45,13 +45,13 @@ function pickGeneral(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_select_npc.php',
|
url: 'j_select_npc.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
pick:$btn.val()
|
pick: $btn.val()
|
||||||
}
|
}
|
||||||
}).then(function(result){
|
}).then(function(result) {
|
||||||
if(!result.result){
|
if (!result.result) {
|
||||||
alert(result.reason);
|
alert(result.reason);
|
||||||
location.refresh();
|
location.refresh();
|
||||||
}
|
}
|
||||||
@@ -62,32 +62,30 @@ function pickGeneral(){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateOutdateTimer(){
|
function updateOutdateTimer() {
|
||||||
var $validUntilText = $('#valid_until_text');
|
var $validUntilText = $('#valid_until_text');
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
var validUntil = $validUntilText.data('until');
|
var validUntil = $validUntilText.data('until');
|
||||||
if(validUntil <= 0){
|
if (validUntil <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (validUntil < now) {
|
||||||
else if(validUntil < now){
|
$validUntilText.data('until', 0);
|
||||||
$validUntilText.data('until',0);
|
|
||||||
$('#valid_until').hide();
|
$('#valid_until').hide();
|
||||||
$('#outdate_token').show();
|
$('#outdate_token').show();
|
||||||
return;
|
return;
|
||||||
}
|
} else if (validUntil - now <= 30000) {
|
||||||
else if(validUntil - now <= 30000){
|
$validUntilText.css('color', "rgb(255, {0}, {0})".format(255 * (validUntil - now) / 30000));
|
||||||
$validUntilText.css('color', "rgb(255, {0}, {0})".format(255*(validUntil - now)/30000));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(updateOutdateTimer, 1000);
|
setTimeout(updateOutdateTimer, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePickMoreTimer(){
|
function updatePickMoreTimer() {
|
||||||
var $btn = $('#btn_pick_more');
|
var $btn = $('#btn_pick_more');
|
||||||
|
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
var remain = ($btn.data('available') - now) / 1000;
|
var remain = ($btn.data('available') - now) / 1000;
|
||||||
if(remain <= 0){
|
if (remain <= 0) {
|
||||||
$btn.prop('disabled', false)
|
$btn.prop('disabled', false)
|
||||||
$btn.html('다른 장수 보기');
|
$btn.html('다른 장수 보기');
|
||||||
return;
|
return;
|
||||||
@@ -98,53 +96,50 @@ function updatePickMoreTimer(){
|
|||||||
setTimeout(updatePickMoreTimer, 250);
|
setTimeout(updatePickMoreTimer, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
function printGenerals(value){
|
function printGenerals(value) {
|
||||||
$('.card_holder').empty();
|
$('.card_holder').empty();
|
||||||
$('#valid_until').show();
|
$('#valid_until').show();
|
||||||
$('#valid_until_text').html(value.validUntil).data('until', (new Date(value.validUntil)).getTime()).css('color','white');
|
$('#valid_until_text').html(value.validUntil).data('until', (new Date(value.validUntil)).getTime()).css('color', 'white');
|
||||||
$('#outdate_token').hide();
|
$('#outdate_token').hide();
|
||||||
var time = Date.now() + value.pickMoreSeconds*1000;
|
var time = Date.now() + value.pickMoreSeconds * 1000;
|
||||||
$('#btn_pick_more').data('available', time).prop('disabled',true);
|
$('#btn_pick_more').data('available', time).prop('disabled', true);
|
||||||
|
|
||||||
var pick = $.map(value.pick, function(value, key) {
|
var pick = $.map(value.pick, function(value, key) {
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
|
|
||||||
pick.sort(function(lhs, rhs){
|
pick.sort(function(lhs, rhs) {
|
||||||
var lsum = lhs.leadership+lhs.strength+lhs.intel;
|
var lsum = lhs.leadership + lhs.strength + lhs.intel;
|
||||||
var rsum = rhs.leadership+rhs.strength+rhs.intel;
|
var rsum = rhs.leadership + rhs.strength + rhs.intel;
|
||||||
return lsum - rsum;
|
return lsum - rsum;
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each(pick, function(idx, cardData){
|
$.each(pick, function(idx, cardData) {
|
||||||
cardData.iconPath = getIconPath(cardData.imgsvr, cardData.picture);
|
cardData.iconPath = getIconPath(cardData.imgsvr, cardData.picture);
|
||||||
if(cardData.special in specialInfo){
|
if (cardData.special in specialInfo) {
|
||||||
cardData.specialText = TemplateEngine(templateSpecial, {
|
cardData.specialText = TemplateEngine(templateSpecial, {
|
||||||
text:cardData.special,
|
text: cardData.special,
|
||||||
info:specialInfo[cardData.special]
|
info: specialInfo[cardData.special]
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
cardData.specialText = cardData.special;
|
cardData.specialText = cardData.special;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cardData.special2 in specialInfo){
|
if (cardData.special2 in specialInfo) {
|
||||||
cardData.special2Text = TemplateEngine(templateSpecial, {
|
cardData.special2Text = TemplateEngine(templateSpecial, {
|
||||||
text:cardData.special2,
|
text: cardData.special2,
|
||||||
info:specialInfo[cardData.special2]
|
info: specialInfo[cardData.special2]
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
cardData.special2Text = cardData.special2;
|
cardData.special2Text = cardData.special2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cardData.personal in characterInfo){
|
if (cardData.personal in characterInfo) {
|
||||||
cardData.personalText = TemplateEngine(templateSpecial, {
|
cardData.personalText = TemplateEngine(templateSpecial, {
|
||||||
text:cardData.personal,
|
text: cardData.personal,
|
||||||
info:characterInfo[cardData.personal]
|
info: characterInfo[cardData.personal]
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
cardData.personalText = cardData.personal;
|
cardData.personalText = cardData.personal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,10 +149,10 @@ function printGenerals(value){
|
|||||||
$('.card_holder').append($card);
|
$('.card_holder').append($card);
|
||||||
$card.find('.select_btn').click(pickGeneral);
|
$card.find('.select_btn').click(pickGeneral);
|
||||||
$card.find('.obj_tooltip').tooltip({
|
$card.find('.obj_tooltip').tooltip({
|
||||||
title:function(){
|
title: function() {
|
||||||
return $.trim($(this).find('.tooltiptext').html());
|
return $.trim($(this).find('.tooltiptext').html());
|
||||||
},
|
},
|
||||||
html:true
|
html: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -165,59 +160,57 @@ function printGenerals(value){
|
|||||||
updateOutdateTimer();
|
updateOutdateTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function printGeneralList(value){
|
function printGeneralList(value) {
|
||||||
var tokenList = value.token;
|
var tokenList = value.token;
|
||||||
var generalList = $.map(value.list, function(general){
|
var generalList = $.map(value.list, function(general) {
|
||||||
general = {
|
general = {
|
||||||
no:general[0],
|
no: general[0],
|
||||||
picture:general[1],
|
picture: general[1],
|
||||||
imgsvr:general[2],
|
imgsvr: general[2],
|
||||||
npc:general[3],
|
npc: general[3],
|
||||||
age:general[4],
|
age: general[4],
|
||||||
nation:general[5],
|
nation: general[5],
|
||||||
special:general[6],
|
special: general[6],
|
||||||
special2:general[7],
|
special2: general[7],
|
||||||
personal:general[8],
|
personal: general[8],
|
||||||
name:general[9],
|
name: general[9],
|
||||||
ownerName:general[10],
|
ownerName: general[10],
|
||||||
injury:general[11],
|
injury: general[11],
|
||||||
leadership:general[12],
|
leadership: general[12],
|
||||||
lbonus:general[13],
|
lbonus: general[13],
|
||||||
strength:general[14],
|
strength: general[14],
|
||||||
intel:general[15],
|
intel: general[15],
|
||||||
explevel:general[16],
|
explevel: general[16],
|
||||||
experience:general[17],
|
experience: general[17],
|
||||||
dedication:general[18],
|
dedication: general[18],
|
||||||
officerLevel:general[19],
|
officerLevel: general[19],
|
||||||
killturn:general[20],
|
killturn: general[20],
|
||||||
connect:general[21],
|
connect: general[21],
|
||||||
reserved:0
|
reserved: 0
|
||||||
};
|
};
|
||||||
if(general.npc < 2){
|
if (general.npc < 2) {
|
||||||
general.reserved = 2;
|
general.reserved = 2;
|
||||||
}
|
}
|
||||||
if(general.no in tokenList){
|
if (general.no in tokenList) {
|
||||||
general.reserved = 1;
|
general.reserved = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
general.userCSS = "";
|
general.userCSS = "";
|
||||||
general.nameAux = "";
|
general.nameAux = "";
|
||||||
|
|
||||||
if(general.reserved == 1){
|
if (general.reserved == 1) {
|
||||||
general.userCSS = 'color:violet';
|
general.userCSS = 'color:violet';
|
||||||
}
|
} else if (general.npc >= 2) {
|
||||||
else if(general.npc >= 2){
|
|
||||||
general.userCSS = 'color:cyan';
|
general.userCSS = 'color:cyan';
|
||||||
}
|
} else if (general.npc == 1) {
|
||||||
else if(general.npc == 1){
|
|
||||||
general.userCSS = 'color:skyblue';
|
general.userCSS = 'color:skyblue';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(general.ownerName){
|
if (general.ownerName) {
|
||||||
general.nameAux += '<br><small>({0})</small>'.format(general.ownerName);
|
general.nameAux += '<br><small>({0})</small>'.format(general.ownerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(general.reserved == 1){
|
if (general.reserved == 1) {
|
||||||
general.nameAux += '<br><small>({0}회)</small>'.format(tokenList[general.no]);
|
general.nameAux += '<br><small>({0}회)</small>'.format(tokenList[general.no]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,41 +219,41 @@ function printGeneralList(value){
|
|||||||
general.iconPath = getIconPath(general.imgsvr, general.picture);
|
general.iconPath = getIconPath(general.imgsvr, general.picture);
|
||||||
|
|
||||||
general.specialDomesticWithTooltip = TemplateEngine(templateSpecial, {
|
general.specialDomesticWithTooltip = TemplateEngine(templateSpecial, {
|
||||||
text:general.special,
|
text: general.special,
|
||||||
info:specialInfo[general.special]
|
info: specialInfo[general.special]
|
||||||
});
|
});
|
||||||
|
|
||||||
general.speicalWarWithTooltip = TemplateEngine(templateSpecial, {
|
general.speicalWarWithTooltip = TemplateEngine(templateSpecial, {
|
||||||
text:general.special2,
|
text: general.special2,
|
||||||
info:specialInfo[general.special2]
|
info: specialInfo[general.special2]
|
||||||
});
|
});
|
||||||
|
|
||||||
general.personalWithTooltip = TemplateEngine(templateSpecial, {
|
general.personalWithTooltip = TemplateEngine(templateSpecial, {
|
||||||
text:general.personal,
|
text: general.personal,
|
||||||
info:characterInfo[general.personal]
|
info: characterInfo[general.personal]
|
||||||
});
|
});
|
||||||
|
|
||||||
return general;
|
return general;
|
||||||
});
|
});
|
||||||
|
|
||||||
generalList.sort(function(lhs, rhs){
|
generalList.sort(function(lhs, rhs) {
|
||||||
if(lhs.reserved > rhs.reserved){
|
if (lhs.reserved > rhs.reserved) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(lhs.reserved < rhs.reserved){
|
if (lhs.reserved < rhs.reserved) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(lhs.total != rhs.total){
|
if (lhs.total != rhs.total) {
|
||||||
return rhs.total - lhs.total;
|
return rhs.total - lhs.total;
|
||||||
}
|
}
|
||||||
if(lhs.leadership != rhs.leadership){
|
if (lhs.leadership != rhs.leadership) {
|
||||||
return rhs.leadership - lhs.total;
|
return rhs.leadership - lhs.total;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lhs.name < rhs.name){
|
if (lhs.name < rhs.name) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(lhs.name > rhs.name){
|
if (lhs.name > rhs.name) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -270,9 +263,9 @@ function printGeneralList(value){
|
|||||||
_printGeneralList(true);
|
_printGeneralList(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _printGeneralList(clear){
|
function _printGeneralList(clear) {
|
||||||
var $generalTable = $('#general_list');
|
var $generalTable = $('#general_list');
|
||||||
if(clear){
|
if (clear) {
|
||||||
$generalTable.empty();
|
$generalTable.empty();
|
||||||
$generalTable.data('lastIdx', 0);
|
$generalTable.data('lastIdx', 0);
|
||||||
$('#row_print_more').show();
|
$('#row_print_more').show();
|
||||||
@@ -284,77 +277,77 @@ function _printGeneralList(clear){
|
|||||||
var idxTo = Math.min(idxFrom + 50, generalList.length);
|
var idxTo = Math.min(idxFrom + 50, generalList.length);
|
||||||
$generalTable.data('lastIdx', idxTo);
|
$generalTable.data('lastIdx', idxTo);
|
||||||
|
|
||||||
for(var idx = idxFrom; idx < idxFrom + 50; idx++){
|
for (var idx = idxFrom; idx < idxFrom + 50; idx++) {
|
||||||
var general = generalList[idx];
|
var general = generalList[idx];
|
||||||
$generalTable.append(TemplateEngine(templateGeneralRow, general));
|
$generalTable.append(TemplateEngine(templateGeneralRow, general));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(idxTo == generalList.length){
|
if (idxTo == generalList.length) {
|
||||||
$('#row_print_more').hide();
|
$('#row_print_more').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$generalTable.find('.obj_tooltip').tooltip({
|
$generalTable.find('.obj_tooltip').tooltip({
|
||||||
title:function(){
|
title: function() {
|
||||||
return $.trim($(this).find('.tooltiptext').html());
|
return $.trim($(this).find('.tooltiptext').html());
|
||||||
},
|
},
|
||||||
html:true
|
html: true
|
||||||
});
|
});
|
||||||
$('#tb_general_list').show();
|
$('#tb_general_list').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function($){
|
$(function($) {
|
||||||
window.generalList = [];
|
window.generalList = [];
|
||||||
|
|
||||||
$.post('j_get_select_npc_token.php').then(function(value){
|
$.post('j_get_select_npc_token.php').then(function(value) {
|
||||||
if(!value.result){
|
if (!value.result) {
|
||||||
alert(value.reason);
|
alert(value.reason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(value);
|
console.log(value);
|
||||||
printGenerals(value);
|
printGenerals(value);
|
||||||
});
|
|
||||||
|
|
||||||
$('#btn_pick_more').click(function(){
|
|
||||||
var generals = $.map($('.keep_select:checked'), function(value){
|
|
||||||
return $(value).val();
|
|
||||||
});
|
});
|
||||||
console.log(generals);
|
|
||||||
$.post({
|
$('#btn_pick_more').click(function() {
|
||||||
url:'j_get_select_npc_token.php',
|
var generals = $.map($('.keep_select:checked'), function(value) {
|
||||||
dataType:'json',
|
return $(value).val();
|
||||||
data:{
|
});
|
||||||
refresh:true,
|
console.log(generals);
|
||||||
keep:generals
|
$.post({
|
||||||
}
|
url: 'j_get_select_npc_token.php',
|
||||||
}).then(function(result){
|
dataType: 'json',
|
||||||
if(!result.result){
|
data: {
|
||||||
alert(result.reason);
|
refresh: true,
|
||||||
location.refresh();
|
keep: generals
|
||||||
}
|
}
|
||||||
console.log(result);
|
}).then(function(result) {
|
||||||
printGenerals(result);
|
if (!result.result) {
|
||||||
|
alert(result.reason);
|
||||||
|
location.refresh();
|
||||||
|
}
|
||||||
|
console.log(result);
|
||||||
|
printGenerals(result);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$('#btn_load_general_list').click(function(){
|
$('#btn_load_general_list').click(function() {
|
||||||
$.post({
|
$.post({
|
||||||
url:'j_get_general_list.php',
|
url: 'j_get_general_list.php',
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:{
|
data: {
|
||||||
with_token:true
|
with_token: true
|
||||||
}
|
}
|
||||||
}).then(function(result){
|
}).then(function(result) {
|
||||||
if(!result.result){
|
if (!result.result) {
|
||||||
alert(result.reason);
|
alert(result.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
printGeneralList(result);
|
printGeneralList(result);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$('#btn_print_more').click(function(){
|
$('#btn_print_more').click(function() {
|
||||||
_printGeneralList();
|
_printGeneralList();
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user