전투 시뮬레이터 장수 불러오기 완성
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();
|
||||||
|
|||||||
+149
-27
@@ -11,6 +11,25 @@ jQuery(function($){
|
|||||||
|
|
||||||
var initBasicEvent = function() {
|
var initBasicEvent = 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() {
|
$('.form_injury').change(function() {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $general = getGeneralDetail($this);
|
var $general = getGeneralDetail($this);
|
||||||
@@ -23,16 +42,13 @@ jQuery(function($){
|
|||||||
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';
|
||||||
}
|
}
|
||||||
@@ -75,6 +91,15 @@ jQuery(function($){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.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() {
|
$('.btn-general-save').click(function() {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $general = getGeneralDetail($this);
|
var $general = getGeneralDetail($this);
|
||||||
@@ -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);
|
||||||
@@ -281,8 +305,7 @@ jQuery(function($){
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -431,8 +453,7 @@ jQuery(function($){
|
|||||||
|
|
||||||
if ($cardAfter === undefined) {
|
if ($cardAfter === undefined) {
|
||||||
$defenderColumn.append($newCard);
|
$defenderColumn.append($newCard);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$cardAfter.after($newCard);
|
$cardAfter.after($newCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,8 +506,7 @@ jQuery(function($){
|
|||||||
$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);
|
||||||
@@ -498,8 +518,7 @@ jQuery(function($){
|
|||||||
$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);
|
||||||
@@ -617,8 +636,7 @@ jQuery(function($){
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,8 +655,7 @@ jQuery(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,8 +689,7 @@ jQuery(function($){
|
|||||||
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);
|
||||||
@@ -688,8 +704,7 @@ jQuery(function($){
|
|||||||
$('#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));
|
||||||
@@ -697,8 +712,7 @@ jQuery(function($){
|
|||||||
$('#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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,6 +800,114 @@ jQuery(function($){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|||||||
+38
-12
@@ -32,7 +32,8 @@ 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
|
||||||
@@ -41,7 +42,10 @@ function isInt(n) {
|
|||||||
* @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,
|
||||||
|
l = str.length,
|
||||||
|
c = '',
|
||||||
|
length = 0;
|
||||||
for (; i < l; i++) {
|
for (; i < l; i++) {
|
||||||
c = str.charCodeAt(i);
|
c = str.charCodeAt(i);
|
||||||
if (0x0000 <= c && c <= 0x0019) {
|
if (0x0000 <= c && c <= 0x0019) {
|
||||||
@@ -70,9 +74,17 @@ function isInt(n) {
|
|||||||
*/
|
*/
|
||||||
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),
|
||||||
|
i = start,
|
||||||
|
l = str.length,
|
||||||
|
trimmedLength = 0,
|
||||||
|
trimmedStr = '';
|
||||||
for (; i < l; i++) {
|
for (; i < l; i++) {
|
||||||
var charCode=str.charCodeAt(i),c=str.charAt(i),charWidth=mb_strwidth(c),next=str.charAt(i+1),nextWidth=mb_strwidth(next);
|
var charCode = str.charCodeAt(i),
|
||||||
|
c = str.charAt(i),
|
||||||
|
charWidth = mb_strwidth(c),
|
||||||
|
next = str.charAt(i + 1),
|
||||||
|
nextWidth = mb_strwidth(next);
|
||||||
trimmedLength += charWidth;
|
trimmedLength += charWidth;
|
||||||
trimmedStr += c;
|
trimmedStr += c;
|
||||||
if (trimmedLength + trimmakerWidth + nextWidth > width) {
|
if (trimmedLength + trimmakerWidth + nextWidth > width) {
|
||||||
@@ -138,8 +150,7 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,8 +219,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,8 +227,7 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,8 +236,7 @@ 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]');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +246,24 @@ function activeFlip($obj){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function activeFlipItem($img) {
|
||||||
var imageList = [];
|
var imageList = [];
|
||||||
imageList.push($img.attr('src'));
|
imageList.push($img.attr('src'));
|
||||||
|
|||||||
+7
-14
@@ -68,14 +68,12 @@ function updateOutdateTimer(){
|
|||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +121,7 @@ function printGenerals(value){
|
|||||||
text: cardData.special,
|
text: cardData.special,
|
||||||
info: specialInfo[cardData.special]
|
info: specialInfo[cardData.special]
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
cardData.specialText = cardData.special;
|
cardData.specialText = cardData.special;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,8 +130,7 @@ function printGenerals(value){
|
|||||||
text: cardData.special2,
|
text: cardData.special2,
|
||||||
info: specialInfo[cardData.special2]
|
info: specialInfo[cardData.special2]
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
cardData.special2Text = cardData.special2;
|
cardData.special2Text = cardData.special2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,8 +139,7 @@ function printGenerals(value){
|
|||||||
text: cardData.personal,
|
text: cardData.personal,
|
||||||
info: characterInfo[cardData.personal]
|
info: characterInfo[cardData.personal]
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
cardData.personalText = cardData.personal;
|
cardData.personalText = cardData.personal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,11 +200,9 @@ function printGeneralList(value){
|
|||||||
|
|
||||||
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';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user