@@ -64,6 +64,7 @@ const NATIONALITY: { [s: string]: string } = {
64
64
106 : "Venus Vacation" ,
65
65
107 : "The Idolmaster" ,
66
66
108 : "SSSS" ,
67
+ 109 : "Atelier Ryza" ,
67
68
} ;
68
69
const kuroshiro = new Kuroshiro ( ) ;
69
70
const UNRELEASED = [ "Tone" , "Chikuma" , "Pola" , "Vittorio Veneto" , "Kirov" , "Sovetsky Soyuz" ] ;
@@ -74,7 +75,10 @@ function findShip(id: string, name: string, nationality: string) {
74
75
for ( let ship of Object . values ( reference ) ) {
75
76
if ( ! ship . name ) continue ;
76
77
if (
77
- ( ship . name . en === name || ship . name . cn === name || ship . name . code === name || ship . code === id ) &&
78
+ ( ship . name . en === name ||
79
+ ship . name . cn === name ||
80
+ ship . name . code === name ||
81
+ ship . code === id ) &&
78
82
NATIONALITY [ ship . nationality ] === nationality
79
83
) {
80
84
id_map [ id ] = ship . id ;
@@ -127,7 +131,9 @@ export async function parseShip(
127
131
url : string
128
132
) : Promise < Ship > {
129
133
const doc = new JSDOM ( body ) . window . document ;
130
- let tableInfo = parseTable ( doc . querySelector ( ".mw-parser-output>.nomobile>div>div>.ship-card tbody" ) ) ;
134
+ let tableInfo = parseTable (
135
+ doc . querySelector ( ".mw-parser-output>.nomobile>div>div>.ship-card tbody" )
136
+ ) ;
131
137
let nationality = tableInfo . Faction ;
132
138
let referenceShip = findShip ( id , name , nationality ) ;
133
139
let ship = new Ship ( ) ;
@@ -176,10 +182,16 @@ export async function parseShip(
176
182
ship . slots = [ null , null , null ] ;
177
183
for ( let i = 0 ; i < 3 ; i ++ )
178
184
ship . slots [ i ] = parseShipEQSlot (
179
- doc . querySelector ( `.mw-parser-output .nomobile>div>div>.wikitable.ship-equipment tr:nth-child(${ i + 3 } )` )
185
+ doc . querySelector (
186
+ `.mw-parser-output .nomobile>div>div>.wikitable.ship-equipment tr:nth-child(${ i + 3 } )`
187
+ )
180
188
) ;
181
- ship . enhanceValue = nodeParse ( doc . querySelector ( ".ship-enhance.wikitable td:nth-child(1)" ) . childNodes )
182
- ship . scrapValue = nodeParse ( doc . querySelector ( ".ship-enhance.wikitable td:nth-child(2)" ) . childNodes )
189
+ ship . enhanceValue = nodeParse (
190
+ doc . querySelector ( ".ship-enhance.wikitable td:nth-child(1)" ) . childNodes
191
+ ) ;
192
+ ship . scrapValue = nodeParse (
193
+ doc . querySelector ( ".ship-enhance.wikitable td:nth-child(2)" ) . childNodes
194
+ ) ;
183
195
ship . skills = parseSkills ( doc . getElementById ( "Skills" ) ) ;
184
196
if ( ship . rarity === "Priority" || ship . rarity === "Decisive" )
185
197
ship . devLevels = parseDevelopmentLevels ( doc . querySelector ( "#Development_levels tbody" ) ) ;
@@ -189,16 +201,22 @@ export async function parseShip(
189
201
// This ship can be retrofited
190
202
ship . retrofit = true ;
191
203
ship . retrofitId = 3000 + parseInt ( ship . id ) + "" ;
192
- let retroTable = doc . getElementById ( "Retrofit" ) . parentElement . nextElementSibling . nextElementSibling
193
- retroTable = 'TABLE' === retroTable . nextElementSibling . tagName ?
194
- retroTable . nextElementSibling : retroTable
204
+ let retroTable =
205
+ doc . getElementById ( "Retrofit" ) . parentElement . nextElementSibling . nextElementSibling ;
206
+ retroTable =
207
+ "TABLE" === retroTable . nextElementSibling . tagName
208
+ ? retroTable . nextElementSibling
209
+ : retroTable ;
195
210
ship . retrofitProjects = parseRetrofit ( retroTable . lastElementChild ) ;
196
211
ship . retrofitHullType =
197
212
doc . querySelector ( ".ship-card-content .card-info tr:nth-child(3)>:last-child>:last-child" )
198
213
?. textContent || ship . hullType ;
199
214
if ( ship . retrofitHullType === "Light Aircraft Carrier" ) ship . retrofitHullType = "Light Carrier" ;
200
215
}
201
- let obtainedFrom = parseShipObtainedFrom ( doc . querySelector ( ".nomobile .ship-construction.wikitable tbody" ) , ship ) ;
216
+ let obtainedFrom = parseShipObtainedFrom (
217
+ doc . querySelector ( ".nomobile .ship-construction.wikitable tbody" ) ,
218
+ ship
219
+ ) ;
202
220
ship . construction = obtainedFrom . construction ;
203
221
ship . obtainedFrom = obtainedFrom . obtainedFrom ;
204
222
ship . misc = {
@@ -214,9 +232,13 @@ function parseTable(table: Element) {
214
232
for ( let i = 0 ; i < child . children . length ; i += 2 ) {
215
233
let title = child . children [ i ] . textContent . replace ( / \s / g, " " ) . trim ( ) ;
216
234
if ( title === "Voice Actor" ) {
217
-
218
235
final [ title ] = {
219
- name : ( child . children [ i + 1 ] . querySelector ( "a.text, a.extiw" ) ?. textContent . trim ( ) ?? ( Array . from ( child . children [ i + 1 ] . childNodes ) . filter ( n => n . nodeType === 3 && n . textContent . trim ( ) ) [ 0 ] ?. textContent . trim ( ) ) ) ?? "Unknown" ,
236
+ name :
237
+ child . children [ i + 1 ] . querySelector ( "a.text, a.extiw" ) ?. textContent . trim ( ) ??
238
+ Array . from ( child . children [ i + 1 ] . childNodes )
239
+ . filter ( ( n ) => n . nodeType === 3 && n . textContent . trim ( ) ) [ 0 ]
240
+ ?. textContent . trim ( ) ??
241
+ "Unknown" ,
220
242
url : child . children [ i + 1 ] . querySelector ( "a.text, a.extiw" ) ?. getAttribute ( "href" ) ,
221
243
} ;
222
244
} else if ( title === "Illustrator" )
@@ -259,7 +281,8 @@ function parseShipLimits(skill_table: Element) {
259
281
function parseLimitBreak ( row : Element ) {
260
282
let buffs = [ ] ;
261
283
let rows = row . children [ 1 ] . children ;
262
- for ( let i = 0 ; i < rows . length ; i ++ ) if ( rows [ i ] . textContent . trim ( ) ) buffs . push ( rows [ i ] . textContent . trim ( ) ) ;
284
+ for ( let i = 0 ; i < rows . length ; i ++ )
285
+ if ( rows [ i ] . textContent . trim ( ) ) buffs . push ( rows [ i ] . textContent . trim ( ) ) ;
263
286
return buffs ;
264
287
}
265
288
@@ -417,24 +440,27 @@ function parseShipEQSlot(slot: Element): Slot {
417
440
return eqslot ;
418
441
}
419
442
420
- function nodeParseKey ( input : string ) {
421
- return {
422
- "medalOfHonor" : "medal" ,
423
- "specializedCore" : "core"
424
- } [ input ] ?? input
443
+ function nodeParseKey ( input : string ) {
444
+ return (
445
+ {
446
+ medalOfHonor : "medal" ,
447
+ specializedCore : "core" ,
448
+ } [ input ] ?? input
449
+ ) ;
425
450
}
426
451
427
452
function nodeParse ( nodes : NodeListOf < ChildNode > ) {
428
- let obj : { [ key :string ] : number } = { } ;
453
+ let obj : { [ key : string ] : number } = { } ;
429
454
let value = 0 ;
430
455
for ( let node of nodes ) {
431
- if ( node . nodeType === 3 && node . textContent . trim ( ) ) value = parseInt ( node . textContent )
432
- else if ( node . nodeType === 1 ) {
433
- let el = node as Element
434
- if ( el . getAttribute ( "title" ) ) obj [ nodeParseKey ( camelize ( el . getAttribute ( "title" ) . trim ( ) ) ) ] = value
435
- }
456
+ if ( node . nodeType === 3 && node . textContent . trim ( ) ) value = parseInt ( node . textContent ) ;
457
+ else if ( node . nodeType === 1 ) {
458
+ let el = node as Element ;
459
+ if ( el . getAttribute ( "title" ) )
460
+ obj [ nodeParseKey ( camelize ( el . getAttribute ( "title" ) . trim ( ) ) ) ] = value ;
461
+ }
436
462
}
437
- return obj
463
+ return obj ;
438
464
}
439
465
440
466
function parseStats ( doc : Document ) : ShipStats {
@@ -474,7 +500,7 @@ function parseStats(doc: Document): ShipStats {
474
500
} ;
475
501
for ( let j = 1 ; j < titles . length ; j ++ ) {
476
502
if ( ! titles [ j ] || titles [ j ] . trim ( ) . length === 0 ) continue ;
477
- if ( titles [ j ] === "antisubmarineWarfareASW" ) titles [ j ] = ' huntingRange'
503
+ if ( titles [ j ] === "antisubmarineWarfareASW" ) titles [ j ] = " huntingRange" ;
478
504
if ( ! isStat ( titles [ j ] ) ) {
479
505
console . log ( "Irregular stat" + doc . location . href ) ;
480
506
throw "parseStat " + titles [ j ] ;
0 commit comments