import { Injectable } from '@angular/core' ; import { TranslateService } from '@ngx-translate/core' ; import { formatClass } from '../../../../services/hs-utils' ; import { ImageLocalizationOptions } from '../../../../services/localization.service' ; import { capitalizeEachWord } from '../../../../services/utils' ; import { CardsFacadeStandaloneService } from './cards-facade-standalone.service' ; @ Injectable ( ) export class LocalizationStandaloneService { private locale = 'enUS' ; private useHighResImages = true ; constructor ( private readonly allCards , private readonly translate ) { } public async setLocale ( locale ) { this . locale = locale ; await this . translate . use ( locale ) . toPromise ( ) ; await this . allCards . setLocale ( locale ) ; } public getCardImage ( cardId , options ? ) { if ( ! cardId ) { return null ; } const bgs = options ?. isBgs ? 'bgs/' : '' ; const heroSkin = options ?. isHeroSkin ? 'heroSkins/' : '' ; const highRes = this . useHighResImages || options ?. isHighRes ? '512' : '256' ; const base = `https://static.firestoneapp.com/cards/${ bgs }${ heroSkin }${ this . locale }/${ highRes }` ; const suffix = `${ cardId }${ options ?. isPremium ? '_golden' : '' }.png` ; return `${ base }/${ suffix }?v=2` ; } public getNonLocalizedCardImage ( cardId , options ? ) { if ( ! cardId ) { return null ; } const base = `https://static.firestoneapp.com/cards` ; const suffix = `${ cardId }${ options ?. isPremium ? '_golden' : '' }.png` ; return `${ base }/${ suffix }?v=2` ; } public getCardName ( cardId , defaultName = null ) { const card = this . allCards . getCard ( cardId ) ; return card ?. name ?? defaultName ; } public getCreatedByCardName ( creatorCardId ) { return `Created by ${ this . getCardName ( creatorCardId ) ?? 'unknown' }` ; } public getUnknownCardName ( playerClass = null ) { return playerClass ? `Unknown ${ formatClass ( playerClass , this ) } card` : 'Unknown Card' ; } public getUnknownManaSpellName ( manaCost ) { return `Unknown ${ manaCost } mana spell` ; } public getUnknownRaceName ( race ) { return `Unknown ${ capitalizeEachWord ( race ) }` ; } public translateString ( key ) { return this . translate . instant ( key ) ; } }