Ver Fonte

planet_bases: get usernames and corp codes

raylu há 3 semanas atrás
pai
commit
a1fca9c0cb
2 ficheiros alterados com 16 adições e 4 exclusões
  1. 15 4
      planet_bases.py
  2. 1 0
      ts/production.ts

+ 15 - 4
planet_bases.py

@@ -48,10 +48,12 @@ def main() -> None:
 	with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
 		for planet, bases in zip(args.planets, executor.map(get_bases, args.planets)):
 			print(planet)
-			for base in bases:
-				if base['OwnerCode'] is None:
-					continue
-				print(f'\t{base["OwnerCode"]}\t{base["OwnerName"]}')
+			companies = executor.map(get_company, (base['OwnerCode'] for base in bases if base['OwnerCode'] is not None))
+			for co in sorted(companies, key=lambda co: co['CorporationCode'] or '\uffff'):
+				print('\t', end='')
+				if co['CorporationCode'] is not None:
+					print(f'[{co["CorporationCode"]}]', end=' ')
+				print(f'{co["UserName"]}\t{co["CompanyCode"]}\t{co["CompanyName"]}')
 
 def get_sectors() -> tuple[typing.Mapping[str, typing.Collection[str]], typing.Mapping[str, typing.Sequence[System]]]:
 	systems: typing.Sequence[System] = cache.get('https://rest.fnar.net/systemstars')
@@ -66,6 +68,9 @@ def get_sectors() -> tuple[typing.Mapping[str, typing.Collection[str]], typing.M
 def get_bases(planet: str) -> typing.Sequence[Site]:
 	return cache.get('https://rest.fnar.net/planet/sites/' + planet, expiry=cache.ONE_DAY)
 
+def get_company(code: str) -> typing.Mapping[str, typing.Any]:
+	return cache.get('https://rest.fnar.net/company/code/' + code, expiry=cache.ONE_DAY)
+
 class System(typing.TypedDict):
 	SystemId: str
 	NaturalId: str
@@ -82,5 +87,11 @@ class Site(typing.TypedDict):
 	OwnerName: str
 	OwnerCode: str | None
 
+class Company(typing.TypedDict):
+	UserName: str
+	CompanyCode: str
+	CompanyName: str
+	CorporationCode: str
+
 if __name__ == '__main__':
 	main()

+ 1 - 0
ts/production.ts

@@ -111,6 +111,7 @@ async function recipeForMats(): Promise<{recipes: Record<string, Recipe>, extrac
 	const chosenRecipes: Record<string, string> = {
 		'AL': '6xALO 1xO 1xC 1xFLX=>4xAL',
 		'C': '4xHCP=>4xC',
+		'DRF': '50xNFI 1xDCS=>1xDRF',
 		'FE': '6xFEO 1xC 1xO 1xFLX=>4xFE',
 		'GL': '2xSIO 1xNA 1xSEN=>10xGL',
 		'HCP': '14xH2O 1xNS=>8xHCP',