Skip to content

Commit

Permalink
fix: scyther and scizor data
Browse files Browse the repository at this point in the history
  • Loading branch information
bitomic committed Oct 9, 2022
1 parent a71f867 commit 6f4f377
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/tasks/wiki/Licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class UserTask extends Task {
}

protected getBasicData( parsed: HTMLElement ): IBasicData[] {
return parsed.querySelector( '.tab' )?.querySelectorAll( '.fooinfo' ) // the main table where the image is
const result = parsed.querySelector( '.tab' )?.querySelectorAll( '.fooinfo' ) // the main table where the image is
.map( ( i, idx ) => {
const lastColumn: Array<string | undefined> = i.nextElementSibling.nextElementSibling.querySelectorAll( 'tr' ).map( i => i.querySelectorAll( 'td' ).pop() )
.map( i => i?.innerText )
Expand All @@ -96,6 +96,15 @@ export class UserTask extends Task {
style: this.normalizeStyle( style )
}
} ) as IBasicData[]

if ( result[ 0 ]?.name === 'Scizor' ) {
result.push( {
...result[ 0 ],
name: 'Scyther'
} )
}

return result
}

protected async getStats( name: string | undefined ): Promise<IAllStats[]> {
Expand All @@ -115,6 +124,7 @@ export class UserTask extends Task {
if ( !trs ) return []
else if ( name === 'Aegislash' ) return this.getAegislashStats( trs )
else if ( name === 'Hoopa' ) return this.getHoopaStats( trs )
else if ( name === 'Scizor' ) return this.getScizorStats( trs )

const allStats: IAllStats = { stats: {} }
for ( const tr of trs ) {
Expand Down Expand Up @@ -208,6 +218,35 @@ export class UserTask extends Task {
return allStats
}

protected getScizorStats( trs: HTMLElement[] ): IAllStats[] {
const allStats: IAllStats[] = []

const baseStats: IAllStats[ 'stats' ] = {}
this.getMultipleRowsStats( trs, 0, 3 ).reduce( ( list, item, index ) => {
list[ `${ index + 1 }` ] = item
return list
}, baseStats )

const boundStats: IAllStats[ 'stats' ] = {}
this.getMultipleRowsStats( trs, 5, 15 ).reduce( ( list, item, index ) => {
list[ `${ index + 5 }` ] = item
return list
}, boundStats )

const unboundStats: IAllStats[ 'stats' ] = {}
this.getMultipleRowsStats( trs, 17, 27 ).reduce( ( list, item, index ) => {
list[ `${ index + 5 }` ] = item
return list
}, unboundStats )

allStats.push(
{ stats: { ...baseStats, ...boundStats } },
{ stats: { ...baseStats, ...unboundStats } }
)

return allStats
}

protected async getLinks(): Promise<Set<string> | null> {
const { body } = await request( 'https://www.serebii.net/pokemonunite/pokemon.shtml' )
const links = parse( await body.text() ).querySelector( '.dextable' )
Expand Down

0 comments on commit 6f4f377

Please sign in to comment.