js2ts: kingdomList

This commit is contained in:
2021-08-31 02:27:00 +09:00
parent 4f3b39fbfa
commit 67b2dbfe98
4 changed files with 283 additions and 265 deletions
+1 -2
View File
@@ -27,8 +27,7 @@ if($con >= 2) { printLimitMsg($me['turntime']); exit(); }
<title><?=UniqueConst::$serverName?>: 세력일람</title>
<?=WebUtil::printJS('../d_shared/common_path.js')?>
<?=WebUtil::printJS('dist_js/vendors.js')?>
<?=WebUtil::printJS('dist_js/common.js')?>
<?=WebUtil::printJS('js/ext.kingdoms.js')?>
<?=WebUtil::printJS('dist_js/extKingdoms.js')?>
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
<?=WebUtil::printCSS('../d_shared/common.css')?>
<?=WebUtil::printCSS('css/common.css')?>
-263
View File
@@ -1,263 +0,0 @@
$(function(){
var basicPath = document.location.pathname;
basicPath = basicPath.substring(0, basicPath.lastIndexOf('/'))+'/';
var headTbl = $('table:eq(0)');
var $userFrame;
var 국가테이블= $('table:gt(0):lt(-2)');
var getUserType = function(,,){
var = ++;
if( < 40){
if(+ < 40){
return "무능";
}
return "무지";
}
var 최대능력치 = Math.max(, , );
var 능력치2합 = Math.min(+, +, +);
if(최대능력치 >= 70 && 능력치2합 >= 최대능력치 * 1.7){
return "만능";
}
if( >= 60 && < *0.8){
return "무";
}
if( >= 60 && < *0.8){
return "지";
}
if( >= 60 && + < ){
return "통";
}
return "평범";
};
function formatScore(x) {
console.log(x);
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
var runAnalysis = function(){
var $content = $('#on_mover .content');
$.get(basicPath+'a_genList.php',function(rawData){
try{
var $html = $(rawData);
var $장수일람 = {};
var 국가별 = {};
var cnt =0;
$html.each(function(idx){
if(this.tagName == "TABLE"){
cnt+=1;
if(cnt==2){
$장수일람 = $(this);
return false;
}
}
});
$장수일람.find('tr:gt(0)').each(function(){
var 장수 = {};
$this = $(this);
$tds = $this.find('td');
var 장수명 = $.trim($tds.eq(1).text());
var 국가 = $.trim($tds.eq(6).text());
var 부상 = $this.data('general-wounded');
장수.html = $this.clone();
장수.장수명 = 장수명;
장수.국가 = 국가;
장수.벌점 = parseInt($tds.eq(-1).text());
장수. = parseInt($this.data('general-leadership'));
장수. = parseInt($this.data('general-strength'));
장수. = parseInt($this.data('general-intel'));
장수.삭턴 = parseInt($tds.eq(-2).text());
장수.종류 = getUserType(장수., 장수., 장수.);
장수.NPC = $this.data('is-npc');
if(!(국가 in 국가별)){
국가별[국가] = {};
국가별[국가].만능 = [];
국가별[국가]. = [];
국가별[국가]. = [];
국가별[국가]. = [];
국가별[국가].평범 = [];
국가별[국가].무지 = [];
국가별[국가].무능 = [];
//국가별[국가].NPC = [];
}
//if(장수.NPC) 국가별[국가].NPC.push(장수);
국가별[국가][장수.종류].push(장수);
장수.html.hide();
$content.append(장수.html);
});
국가테이블.each(function(idx){
var $this = $(this);
var $tbl = $this;
var $td = $this.find('td:last');
var name = $.trim($this.find('td:first').text());
name = name.substr(2,name.length-4);
var 국가정보 = 국가별[name];
var total = 0;
var 전투유저장수 = 0;
var 통솔합 = 0;
var 삭턴장수 = 0;
var 전투N장수 = 0;
var N장통솔합 = 0;
$td.html('<p class="sum" style="margin:0;font-weight:bold;color:yellow;text-align:center"></p>');
$td.css('text-indent','-5.8em').css('padding-left','5.8em');
for(var 종류명 in 국가정보){
var $p = $("<p></p>").css('margin','0');
var 테이블 = 국가정보[종류명];
if(테이블.length == 0)continue;
테이블.sort(function(, ){
if(.벌점 == .벌점){
return .장수명 > .장수명 ? 1 : 0;
}
return .벌점 - .벌점
});
var text = "  "+종류명;
text = text.substr(text.length-2);
$p.append(text+'장(');
text = ""+테이블.length;
$p.append(text + ')');
if(text.length<3){
$p.append("<span style='display:inline-block;width:"+(3-text.length)/2+"em;'>&nbsp;</span>");
}
$p.append(': ');
total += 테이블.length;
$.each(테이블,function(idx,val){
var 종능 = val. + val. + val.;
console.log(val);
if(종류명 != '무능' && 종류명 != '무지'){
if(val.삭턴 >= 80 && !val.NPC){
전투유저장수 += 1;
통솔합 += val.;
}
if(val.삭턴 > 5 && val.NPC){
전투N장수 += 1;
N장통솔합 += val.;
}
}
var $obj = $('<span></span>');
var $obj2 = $('<span></span>');
$obj.html(val.장수명);
if(!val.NPC && val.삭턴 < 80){
$obj.css('text-decoration','line-through');
삭턴장수+=1;
}
if(val.NPC){
$obj.css('color','cyan');
}
if(val.벌점 >= 1500) $obj.css('color','yellow');
else if(val.벌점 >= 200) $obj.css('color','lightgreen');
$obj2.append($obj);
if(idx < 테이블.length-1){
$obj2.append(', ');
}
$p.append($obj2);
$obj2.hover(function(){
var top = $tbl.offset().top + $tbl.outerHeight() + 3;
$userFrame.css('top',top);
val.html.show();
$userFrame.show();
console.log('올림!'+val.장수명);
},function(){
$userFrame.hide();
val.html.hide();
console.log('내림!'+val.장수명);
});
});
$td.append($p);
}
var result = "* 총("+total+"), 전투장("+전투유저장수+", 약 "+formatScore(통솔합*100)+"명), 전투N장("+전투N장수+", 약 "+formatScore(N장통솔합*100)+"명), 삭턴장("+삭턴장수+") *";
$tbl.find('.sum').html(result);
});
}
catch(err){
console.log(err);
}
});
}
$userFrame = $('<div id="on_mover" style="position:absolute;">'+
'<table class="tb_layout bg0" style="width:100%;"><thead><tr>'+
'<td width="64" align="center" class="bg1">얼 굴</td>'+
'<td width="100" align="center" class="bg1">이 름</td>'+
'<td width="50" align="center" class="bg1">연령</td>'+
'<td width="50" align="center" class="bg1">성격</td>'+
'<td width="90" align="center" class="bg1">특기</td>'+
'<td width="50" align="center" class="bg1">레 벨</td>'+
'<td width="100" align="center" class="bg1">국 가</td>'+
'<td width="60" align="center" class="bg1">명 성</td>'+
'<td width="60" align="center" class="bg1">계 급</td>'+
'<td width="80" align="center" class="bg1">관 직</td>'+
'<td width="45" align="center" class="bg1">통솔</td>'+
'<td width="45" align="center" class="bg1">무력</td>'+
'<td width="45" align="center" class="bg1">지력</td>'+
'<td width="45" align="center" class="bg1">삭턴</td>'+
'<td width="84" align="center" class="bg1">벌점</td>'+
'</tr></thead><tbody class="content"></tbody></table></div>');
$userFrame.find('thead td');
$userFrame.css('width','1000px').css('margin','0').css('padding','0').css('left','50%').css('margin-left','-500px');
$userFrame.css('box-shadow','0px 0px 7px 3px rgba(255,255,255,50)');
$userFrame.hide();
$('body').append($userFrame);
var $frame = $('table:eq(0) td:eq(0)');
$frame.find('br:last').remove();
var $btn = $('<input type="button" value="장수 일람 연동">');
$btn.click(function(){
runAnalysis();
$btn.prop("disabled",true);
var $tr0 = $('table:eq(0) tr:eq(0)');
$tr0.append('<td><strong>*벌점 순 정렬*</strong><br><span style="color:yellow">벌점 1500점 이상</span>, <span style="color:lightgreen">벌점 200점 이상</span>, '+
'<span style="text-decoration:line-through">삭턴장</span>, <span style="color:cyan">ⓝ장</span>'+'<br><strong>전투장 :</strong> 만능장 + 무장 + 지장 + 평범장 - 삭턴자(만능, 무, 지, 평범) </td>');
});
$frame.append($btn);
});
+281
View File
@@ -0,0 +1,281 @@
import $ from 'jquery';
import { unwrap } from './util/unwrap';
import axios from 'axios';
import { setAxiosXMLHttpRequest } from './util/setAxiosXMLHttpRequest';
type KingdomGeneral = {
html: JQuery<HTMLElement>,
장수명: string
국가: string
벌점: number,
: number,
: number,
: number,
삭턴: number,
종류: UserType,
NPC: boolean,
}
type UserType = "통" | "무" | "지" | "만능" | "평범" | "무능" | "무지";
type NationInfo = {
[v in UserType]: KingdomGeneral[]
}
$(function () {
setAxiosXMLHttpRequest();
const $userFrame: JQuery<HTMLElement> = $('<div id="on_mover" style="position:absolute;">' +
'<table class="tb_layout bg0" style="width:100%;"><thead><tr>' +
'<td width="64" align="center" class="bg1">얼 굴</td>' +
'<td width="100" align="center" class="bg1">이 름</td>' +
'<td width="50" align="center" class="bg1">연령</td>' +
'<td width="50" align="center" class="bg1">성격</td>' +
'<td width="90" align="center" class="bg1">특기</td>' +
'<td width="50" align="center" class="bg1">레 벨</td>' +
'<td width="100" align="center" class="bg1">국 가</td>' +
'<td width="60" align="center" class="bg1">명 성</td>' +
'<td width="60" align="center" class="bg1">계 급</td>' +
'<td width="80" align="center" class="bg1">관 직</td>' +
'<td width="45" align="center" class="bg1">통솔</td>' +
'<td width="45" align="center" class="bg1">무력</td>' +
'<td width="45" align="center" class="bg1">지력</td>' +
'<td width="45" align="center" class="bg1">삭턴</td>' +
'<td width="84" align="center" class="bg1">벌점</td>' +
'</tr></thead><tbody class="content"></tbody></table></div>');
$userFrame.find('thead td');
$userFrame.css('width', '1000px').css('margin', '0').css('padding', '0').css('left', '50%').css('margin-left', '-500px');
$userFrame.css('box-shadow', '0px 0px 7px 3px rgba(255,255,255,50)');
$userFrame.hide();
const = $('table:gt(0):lt(-2)');
const getUserType = function (: number, : number, : number): UserType {
//const 총 = 통 + 무 + 지;
if ( < 40) {
if ( + < 40) {
return "무능";
}
return "무지";
}
const = Math.max(, , );
const 2 = Math.min( + , + , + );
if ( >= 70 && 2 >= * 1.7) {
return "만능";
}
if ( >= 60 && < * 0.8) {
return "무";
}
if ( >= 60 && < * 0.8) {
return "지";
}
if ( >= 60 && + < ) {
return "통";
}
return "평범";
};
function formatScore(x: number) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
const runAnalysis = async function () {
const $content = $('#on_mover .content');
try {
const response = await axios({ url: 'a_genList.php', method: 'get', responseType: 'text' });
const rawData = response.data; const $html = $(rawData);
let $장수일람: JQuery<HTMLElement> | undefined;
const 국가별: Record<string, NationInfo> = {};
let cnt = 0;
$html.each(function () {
if (this.tagName == "TABLE") {
cnt += 1;
if (cnt == 2) {
$장수일람 = $(this);
return false;
}
}
});
if ($장수일람 !== undefined) {
$장수일람.find('tr:gt(0)').each(function () {
const = {} as KingdomGeneral;
const $this = $(this);
const $tds = $this.find('td');
const = $.trim($tds.eq(1).text());
const = $.trim($tds.eq(6).text());
//const 부상 = $this.data('general-wounded');
.html = $this.clone();
. = ;
. = ;
. = parseInt($tds.eq(-1).text());
. = parseInt($this.data('general-leadership'));
. = parseInt($this.data('general-strength'));
. = parseInt($this.data('general-intel'));
. = parseInt($tds.eq(-2).text());
. = getUserType(., ., .);
.NPC = $this.data('is-npc');
if (!( in )) {
[] = {
: [],
: [],
: [],
: [],
: [],
: [],
: [],
//NPC:[],
};
}
//if(장수.NPC) 국가별[국가].NPC.push(장수);
[][.].push();
.html.hide();
$content.append(.html);
});
}
.each(function () {
const $this = $(this);
const $tbl = $this;
const $td = $this.find('td:last');
let name = $.trim($this.find('td:first').text());
name = name.substr(2, name.length - 4);
const = [name];
let total = 0;
let = 0;
let = 0;
let = 0;
let N장수 = 0;
let N장통솔합 = 0;
$td.html('<p class="sum" style="margin:0;font-weight:bold;color:yellow;text-align:center"></p>');
$td.css('text-indent', '-5.8em').css('padding-left', '5.8em');
for (const [, ] of Object.entries()) {
const $p = $("<p></p>").css('margin', '0');
if (.length == 0) continue;
.sort(function (, ) {
if (. == .) {
return . > . ? 1 : 0;
}
return . - .
});
let text = "  " + ;
text = text.substr(text.length - 2);
$p.append(text + '장(');
text = "" + .length;
$p.append(text + ')');
if (text.length < 3) {
$p.append("<span style='display:inline-block;width:" + (3 - text.length) / 2 + "em;'>&nbsp;</span>");
}
$p.append(': ');
total += .length;
$.each(, function (idx, val) {
//const 종능 = val.통 + val.무 + val.지;
console.log(val);
if ( != '무능' && != '무지') {
if (val. >= 80 && !val.NPC) {
+= 1;
+= val.;
}
if (val. > 5 && val.NPC) {
N장수 += 1;
N장통솔합 += val.;
}
}
const $obj = $('<span></span>');
const $obj2 = $('<span></span>');
$obj.html(val.);
if (!val.NPC && val. < 80) {
$obj.css('text-decoration', 'line-through');
+= 1;
}
if (val.NPC) {
$obj.css('color', 'cyan');
}
if (val. >= 1500) $obj.css('color', 'yellow');
else if (val. >= 200) $obj.css('color', 'lightgreen');
$obj2.append($obj);
if (idx < .length - 1) {
$obj2.append(', ');
}
$p.append($obj2);
$obj2.hover(function () {
const top = unwrap($tbl.offset()).top + unwrap($tbl.outerHeight()) + 3;
$userFrame.css('top', top);
val.html.show();
$userFrame.show();
console.log('올림!' + val.);
}, function () {
$userFrame.hide();
val.html.hide();
console.log('내림!' + val.);
});
});
$td.append($p);
}
const result = "* 총(" + total + "), 전투장(" + + ", 약 " + formatScore( * 100) + "명), 전투N장(" + N장수 + ", 약 " + formatScore(N장통솔합 * 100) + "명), 삭턴장(" + + ") *";
$tbl.find('.sum').html(result);
});
}
catch (err) {
console.error(err);
}
}
$('body').append($userFrame);
const $frame = $('table:eq(0) td:eq(0)');
$frame.find('br:last').remove();
const $btn = $('<input type="button" value="장수 일람 연동">');
$btn.on('click', function () {
void runAnalysis();
$btn.prop("disabled", true);
const $tr0 = $('table:eq(0) tr:eq(0)');
$tr0.append('<td><strong>*벌점 순 정렬*</strong><br><span style="color:yellow">벌점 1500점 이상</span>, <span style="color:lightgreen">벌점 200점 이상</span>, ' +
'<span style="text-decoration:line-through">삭턴장</span>, <span style="color:cyan">ⓝ장</span>' + '<br><strong>전투장 :</strong> 만능장 + 무장 + 지장 + 평범장 - 삭턴자(만능, 무, 지, 평범) </td>');
});
$frame.append($btn);
});
+1
View File
@@ -41,6 +41,7 @@ module.exports = (env, argv) => {
history: '@/history.ts',
join: '@/join.ts',
select_general_from_pool: '@/select_general_from_pool.ts',
extKingdoms: '@/extKingdoms.ts',
},
output: {
filename: '[name].js',