mirror of
https://github.com/MaciejkaG/statki.git
synced 2024-11-30 03:22:54 +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) => {
|
app.get('/game', async (req, res) => {
|
||||||
|
|
||||||
const locale = new Lang(req.acceptsLanguages());
|
|
||||||
|
|
||||||
const game = await redis.json.get(`game:${req.query.id}`);
|
const game = await redis.json.get(`game:${req.query.id}`);
|
||||||
if (req.session.nickname == null) {
|
if (req.session.nickname == null) {
|
||||||
res.redirect('/setup');
|
res.redirect('/setup');
|
||||||
} else if (req.query.id == null || game == null || game.state == 'expired' || req.session.activeGame == null) {
|
} else if (req.query.id == null || game == null || game.state == 'expired' || req.session.activeGame == null) {
|
||||||
res.render("error", {
|
auth.getLanguage(req.session.userId).then(language => {
|
||||||
helpers: {
|
var locale;
|
||||||
error: "Nie znaleziono wskazanej gry",
|
if (language) {
|
||||||
fallback: "/",
|
locale = new Lang([language]);
|
||||||
t: (key) => { return locale.t(key) }
|
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 {
|
} else {
|
||||||
res.render('board', {
|
auth.getLanguage(req.session.userId).then(language => {
|
||||||
helpers: {
|
var locale;
|
||||||
t: (key) => { return locale.t(key) }
|
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 {
|
body {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.secondary {
|
||||||
|
transform: scale(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ $('#board .field').on('click', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function manualPlace(posX, posY) {
|
function manualPlace(posX, posY) {
|
||||||
|
hoveredShip = null;
|
||||||
|
refreshBoardView();
|
||||||
socket.emit("place ship", selectedShip, posX, posY, shipRotation);
|
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 () {
|
$('.field').on('contextmenu', function () {
|
||||||
if ($(this).hasClass('active') && new Date().getTime() / 1000 - lastTimeClick > 0.3) {
|
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;
|
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);
|
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 {
|
try {
|
||||||
await this.mail.sendMail({
|
await this.mail.sendMail({
|
||||||
from: this.mailFrom,
|
from: this.mailFrom,
|
||||||
to: email,
|
to: email,
|
||||||
subject: `${authCode} to twój kod autoryzacji do Statków`,
|
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) {
|
} catch (e) {
|
||||||
reject(e);
|
reject(e);
|
||||||
@ -168,14 +172,19 @@ export class MailAuth {
|
|||||||
|
|
||||||
const lookup = geoip.lookup(ip);
|
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({
|
try {
|
||||||
from: this.mailFrom,
|
await this.mail.sendMail({
|
||||||
to: email,
|
from: this.mailFrom,
|
||||||
subject: `${authCode} to twój kod logowania do Statków`,
|
to: email,
|
||||||
html: html.replace("{{ NICKNAME }}", row.nickname).replace("{{ CODE }}", authCode).replace("{{ LOOKUP }}", lookupData),
|
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 });
|
resolve({ status: 1, uid: row.user_id });
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user