mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-08-13 01:01:59 +00:00
Initial Database
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
31
interfaces/Ability.ts
Normal file
31
interfaces/Ability.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import AbilityType from "./AbilityType";
|
||||
import LangList from "./LangList";
|
||||
import { promises } from "fs";
|
||||
|
||||
interface Ability {
|
||||
id?: number
|
||||
type: AbilityType
|
||||
name: LangList<string>
|
||||
text: LangList<string>
|
||||
}
|
||||
|
||||
const file = "./generated/abilities.json"
|
||||
|
||||
let abilities: Array<string> = []
|
||||
|
||||
namespace Ability {
|
||||
export async function fetch(): Promise<void> {
|
||||
const els = await promises.readFile(file)
|
||||
abilities = JSON.parse(els.toString())
|
||||
}
|
||||
|
||||
export function process(str: string): number | undefined {
|
||||
return abilities.indexOf(str)
|
||||
}
|
||||
|
||||
export async function save(): Promise<void> {
|
||||
return promises.writeFile(file, JSON.stringify(abilities))
|
||||
}
|
||||
}
|
||||
|
||||
export default Ability
|
Reference in New Issue
Block a user