server.get<{params: { cityId: string }}, string>('/city/:cityId', async req => {
const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
- const yourCity = await cityRepo.FindOne({ owner: account.id });
- const city = await cityRepo.FindOne({ id: req.params.cityId });
+ const yourCity = await cityRepo.getUsersCity(account.id);
+ const city = await cityRepo.findById(req.params.cityId);
const acct = await accountRepo.FindOne({id: city.owner});
server.get<{}, string>('/poll/overview', async req => {
const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
- const city = await cityRepo.FindOne({ owner: account.id });
+ const city = await cityRepo.getUsersCity(account.id);
return renderKingomOverview(city, account);
});
server.get<{}, string>('/poll/construction', async req => {
const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
- const city = await cityRepo.FindOne({ owner: account.id });
+ const city = await cityRepo.getUsersCity(account.id);
const buildings = await cityRepo.buildingRepository.list();
const buildQueues = await cityRepo.getBuildQueues(account.id);
server.get<{}, string>('/poll/unit-training', async req => {
const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
- const city = await cityRepo.FindOne({ owner: account.id });
+ const city = await cityRepo.getUsersCity(account.id);
const unitTrainingQueues = await cityRepo.getUnitTrainingQueues(account.id);
const units = await cityRepo.unitRepository.list();
server.get<{}, string>('/poll/map', async req => {
const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
- const city = await cityRepo.FindOne({ owner: account.id });
+ const city = await cityRepo.getUsersCity(account.id);
- return renderOverworldMap(await cityRepo.FindAll(), city);
+ return renderOverworldMap(await cityRepo.findAllInSector(city.sector_id), city);
});
server.get<{}, string>('/poll/mailroom', async req => {
>('/attack', async req => {
const acct = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
const city = await cityRepo.getUsersCity(acct.id);
- const attackedCity = await cityRepo.FindOne({id: req.body.city});
+ const attackedCity = await cityRepo.findById(req.body.city);
const army = {
soldiers: parseInt(req.body.soldiers),
});
-server.start();
-
-tick.trigger({lastTickAt: 0, lastTick: 0});
\ No newline at end of file
+server.start();
\ No newline at end of file