diff --git a/src/api/squaremap/parser.ts b/src/api/squaremap/parser.ts index fa86655..07a9a67 100644 --- a/src/api/squaremap/parser.ts +++ b/src/api/squaremap/parser.ts @@ -244,7 +244,6 @@ export const parseNations = async(towns: SquaremapTown[]) => { councillors: [], towns: [], area: 0, - wealth: 0, king: undefined, capital: undefined } @@ -257,7 +256,9 @@ export const parseNations = async(towns: SquaremapTown[]) => { raw[nationName].councillors = fastMergeUnique(raw[nationName].councillors, town.councillors) raw[nationName].area += town.area - raw[nationName].wealth += town.wealth + + if (town.wealth) + raw[nationName].wealth += town.wealth // Current town is in existing nation if (raw[nationName].name == nationName) diff --git a/src/types/nation.ts b/src/types/nation.ts index bfc1da7..192d69e 100644 --- a/src/types/nation.ts +++ b/src/types/nation.ts @@ -18,7 +18,7 @@ export type BaseNation = { export type Nation = Prettify> export type SquaremapNation = Prettify diff --git a/tests/squaremap/nations.test.ts b/tests/squaremap/nations.test.ts index 1fb782e..067515e 100644 --- a/tests/squaremap/nations.test.ts +++ b/tests/squaremap/nations.test.ts @@ -2,7 +2,7 @@ import { describe, it, expect, expectTypeOf, assertType } from 'vitest' import type { SquaremapNation } from '../../src/types' -import { Aurora } from '../../src/main' +import { Aurora, NotFoundError } from '../../src/main' describe('[Squaremap/Aurora] Nations', () => { let nations: SquaremapNation[] = null @@ -29,11 +29,14 @@ describe('[Squaremap/Aurora] Nations', () => { expect(nation.name).toBe('R.O.C') }) - it('can get multiple nation', async () => { - const nations = await Aurora.Nations.get('SiBeRia', 'veNICE', 'verMOnt', 'vAult_citY') as SquaremapNation[] + it('can get multiple nations', async () => { + const nations = await Aurora.Nations.get('SiBeRia', 'veNICE', 'verMOnt', 'fAroe_ISlanDs') as SquaremapNation[] + + console.log(nations) expect(nations).toBeTruthy() - expect(nations.length).toBe(3) + expect(nations.length).toBe(4) + expect(nations.some(n => n instanceof NotFoundError)).toBe(false) assertType(nations) })