// lets create the city!
await cityRepo.create(acct.id);
- return `<p>You are all signed up! You can go ahead and log in</p>`;
+ return `<div class="alert success">You are all signed up! You can go ahead and log in</div>`;
});
server.post<{body: {username: string, password: string}}, void>('/login', async (req, raw, res) => {
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 => {
building_type: string
}
}, string>('/cost/construction', async req => {
- const amount = parseInt(req.body.amount, 10);
+ const amount = parseInt(req.body.amount.trim(), 10);
+ console.log('checking amount', amount);
+
+ if(isNaN(amount) || amount < 1) {
+ return '';
+ }
const building = await cityRepo.buildingRepository.findBySlug(req.body.building_type);
if(!building) {
>('/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