1
0
Fork 0

[node] Added agent class, and fixed contract updates

This commit is contained in:
Julien Dessaux 2024-05-15 23:49:33 +02:00
parent 9d48b58d7f
commit 6504e44ffa
Signed by: adyxax
GPG key ID: F92E51B86E07177E
6 changed files with 61 additions and 44 deletions

View file

@ -1,12 +1,9 @@
import * as dbAgents from '../database/agents.ts';
import * as db from '../database/db.ts';
import * as dbTokens from '../database/tokens.ts';
import {
Response,
} from '../lib/api.ts';
import {
Agent,
} from '../lib/types.ts';
import { Agent, initAgent, setAgent } from '../lib/agent.ts';
import { Contract } from '../lib/contracts.ts';
import { Ship } from '../lib/ships.ts';
import * as libContracts from '../lib/contracts.ts';
@ -30,6 +27,7 @@ export async function init(): Promise<void> {
switch(json.error?.code) {
case 4111: // 4111 means the agent symbol has already been claimed so no server reset happened
// TODO await agents.agents();
await initAgent();
return;
default:
throw json;
@ -37,5 +35,5 @@ export async function init(): Promise<void> {
}
db.reset();
dbTokens.addToken(json.data.token);
dbAgents.addAgent(json.data.agent);
setAgent(json.data.agent);
}