mirror of
https://github.com/MaciejkaG/statki.git
synced 2024-11-30 01:32:55 +01:00
Mobile version improvements
- Most of the game should work on mobile now - It's not yet perfect and needs finishes/improvements
This commit is contained in:
parent
e7b0470653
commit
c0ae701507
40
index.js
40
index.js
@ -283,24 +283,44 @@ app.post('/api/nickname', (req, res) => {
|
||||
|
||||
app.get('/game', async (req, res) => {
|
||||
|
||||
const locale = new Lang(req.acceptsLanguages());
|
||||
|
||||
const game = await redis.json.get(`game:${req.query.id}`);
|
||||
if (req.session.nickname == null) {
|
||||
res.redirect('/setup');
|
||||
} else if (req.query.id == null || game == null || game.state == 'expired' || req.session.activeGame == null) {
|
||||
res.render("error", {
|
||||
helpers: {
|
||||
error: "Nie znaleziono wskazanej gry",
|
||||
fallback: "/",
|
||||
t: (key) => { return locale.t(key) }
|
||||
auth.getLanguage(req.session.userId).then(language => {
|
||||
var locale;
|
||||
if (language) {
|
||||
locale = new Lang([language]);
|
||||
req.session.langs = [language];
|
||||
} else {
|
||||
locale = new Lang(req.acceptsLanguages());
|
||||
req.session.langs = req.acceptsLanguages();
|
||||
}
|
||||
|
||||
res.render("error", {
|
||||
helpers: {
|
||||
error: "Nie znaleziono wskazanej gry",
|
||||
fallback: "/",
|
||||
t: (key) => { return locale.t(key) }
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
res.render('board', {
|
||||
helpers: {
|
||||
t: (key) => { return locale.t(key) }
|
||||
auth.getLanguage(req.session.userId).then(language => {
|
||||
var locale;
|
||||
if (language) {
|
||||
locale = new Lang([language]);
|
||||
req.session.langs = [language];
|
||||
} else {
|
||||
locale = new Lang(req.acceptsLanguages());
|
||||
req.session.langs = req.acceptsLanguages();
|
||||
}
|
||||
|
||||
res.render('board', {
|
||||
helpers: {
|
||||
t: (key) => { return locale.t(key) }
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -36,5 +36,9 @@
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.secondary {
|
||||
transform: scale(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ $('#board .field').on('click', function () {
|
||||
});
|
||||
|
||||
function manualPlace(posX, posY) {
|
||||
hoveredShip = null;
|
||||
refreshBoardView();
|
||||
socket.emit("place ship", selectedShip, posX, posY, shipRotation);
|
||||
}
|
||||
|
||||
@ -57,6 +59,10 @@ $('#secondaryBoard .field').on('click', function () {
|
||||
}
|
||||
});
|
||||
|
||||
function manualShoot(posX, posY) {
|
||||
socket.emit("shoot", posX, posY);
|
||||
}
|
||||
|
||||
$('.field').on('contextmenu', function () {
|
||||
if ($(this).hasClass('active') && new Date().getTime() / 1000 - lastTimeClick > 0.3) {
|
||||
let originPos = occupiedFields.find((elem) => elem.pos[0] == $(this).data('pos-x') && elem.pos[1] == $(this).data('pos-y')).origin;
|
||||
|
@ -136,12 +136,16 @@ export class MailAuth {
|
||||
|
||||
authCode = authCode.slice(0, 4) + " " + authCode.slice(4);
|
||||
|
||||
const lookup = geoip.lookup(ip);
|
||||
|
||||
const lookupData = `User-Agent: ${agent}\nAdres IP: ${ip}\nKraj: ${lookup.country}\nRegion: ${lookup.region}\nMiasto: ${lookup.city}`;
|
||||
|
||||
try {
|
||||
await this.mail.sendMail({
|
||||
from: this.mailFrom,
|
||||
to: email,
|
||||
subject: `${authCode} to twój kod autoryzacji do Statków`,
|
||||
html: html.replace("{{ CODE }}", authCode),
|
||||
html: html.replace("{{ CODE }}", authCode).replace("{{ LOOKUP }}", lookupData),
|
||||
});
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
@ -168,14 +172,19 @@ export class MailAuth {
|
||||
|
||||
const lookup = geoip.lookup(ip);
|
||||
|
||||
const lookupData = `User-Agent: ${agent}\nAdres IP: ${ip}\nKraj: ${lookup.country}\nRegion: ${lookup.region}\nMiasto: ${lookup.city}`
|
||||
const lookupData = `User-Agent: ${agent}\nAdres IP: ${ip}\nKraj: ${lookup.country}\nRegion: ${lookup.region}\nMiasto: ${lookup.city}`;
|
||||
|
||||
await this.mail.sendMail({
|
||||
from: this.mailFrom,
|
||||
to: email,
|
||||
subject: `${authCode} to twój kod logowania do Statków`,
|
||||
html: html.replace("{{ NICKNAME }}", row.nickname).replace("{{ CODE }}", authCode).replace("{{ LOOKUP }}", lookupData),
|
||||
});
|
||||
try {
|
||||
await this.mail.sendMail({
|
||||
from: this.mailFrom,
|
||||
to: email,
|
||||
subject: `${authCode} to twój kod logowania do Statków`,
|
||||
html: html.replace("{{ NICKNAME }}", row.nickname).replace("{{ CODE }}", authCode).replace("{{ LOOKUP }}", lookupData),
|
||||
});
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
|
||||
|
||||
resolve({ status: 1, uid: row.user_id });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user