mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-09 19:23:08 +02:00
Clean up
This commit is contained in:
parent
427b3dcd73
commit
886510d721
3 changed files with 28 additions and 28 deletions
|
@ -19,9 +19,9 @@ const langs = {
|
||||||
'es': loadLang('es')
|
'es': loadLang('es')
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.entries(langs).map(([, locale]) => {
|
Object.values(langs).forEach(locale => {
|
||||||
// Extend native language (Japanese)
|
// Extend native language (Japanese)
|
||||||
locale = Object.assign({}, native, locale);
|
Object.assign(locale, native);
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = langs;
|
module.exports = langs;
|
||||||
|
|
|
@ -112,7 +112,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
mapCategories(): string[] {
|
mapCategories(): string[] {
|
||||||
const categories = Object.entries(maps).map(x => x[1].category);
|
const categories = Object.values(maps).map(x => x.category);
|
||||||
return categories.filter((item, pos) => categories.indexOf(item) == pos);
|
return categories.filter((item, pos) => categories.indexOf(item) == pos);
|
||||||
},
|
},
|
||||||
isAccepted(): boolean {
|
isAccepted(): boolean {
|
||||||
|
@ -179,8 +179,8 @@ export default Vue.extend({
|
||||||
if (this.game.settings.map == null) {
|
if (this.game.settings.map == null) {
|
||||||
this.mapName = null;
|
this.mapName = null;
|
||||||
} else {
|
} else {
|
||||||
const foundMap = Object.entries(maps).find(x => x[1].data.join('') == this.game.settings.map.join(''));
|
const found = Object.values(maps).find(x => x.data.join('') == this.game.settings.map.join(''));
|
||||||
this.mapName = foundMap ? foundMap[1].name : '-Custom-';
|
this.mapName = found ? found.name : '-Custom-';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ export default Vue.extend({
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
this.game.settings.map = null;
|
this.game.settings.map = null;
|
||||||
} else {
|
} else {
|
||||||
this.game.settings.map = Object.entries(maps).find(x => x[1].name == v)[1].data;
|
this.game.settings.map = Object.values(maps).find(x => x.name == v).data;
|
||||||
}
|
}
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
this.updateSettings();
|
this.updateSettings();
|
||||||
|
@ -217,9 +217,9 @@ export default Vue.extend({
|
||||||
const y = Math.floor(pos / this.game.settings.map[0].length);
|
const y = Math.floor(pos / this.game.settings.map[0].length);
|
||||||
const newPixel =
|
const newPixel =
|
||||||
pixel == ' ' ? '-' :
|
pixel == ' ' ? '-' :
|
||||||
pixel == '-' ? 'b' :
|
pixel == '-' ? 'b' :
|
||||||
pixel == 'b' ? 'w' :
|
pixel == 'b' ? 'w' :
|
||||||
' ';
|
' ';
|
||||||
const line = this.game.settings.map[y].split('');
|
const line = this.game.settings.map[y].split('');
|
||||||
line[x] = newPixel;
|
line[x] = newPixel;
|
||||||
this.$set(this.game.settings.map, y, line.join(''));
|
this.$set(this.game.settings.map, y, line.join(''));
|
||||||
|
|
|
@ -87,8 +87,8 @@ export default function(request: websocket.request, connection: websocket.connec
|
||||||
const set = game.user1Id.equals(user._id) ? {
|
const set = game.user1Id.equals(user._id) ? {
|
||||||
form1: form
|
form1: form
|
||||||
} : {
|
} : {
|
||||||
form2: form
|
form2: form
|
||||||
};
|
};
|
||||||
|
|
||||||
await ReversiGame.update({ _id: gameId }, {
|
await ReversiGame.update({ _id: gameId }, {
|
||||||
$set: set
|
$set: set
|
||||||
|
@ -117,8 +117,8 @@ export default function(request: websocket.request, connection: websocket.connec
|
||||||
const set = game.user1Id.equals(user._id) ? {
|
const set = game.user1Id.equals(user._id) ? {
|
||||||
form2: form
|
form2: form
|
||||||
} : {
|
} : {
|
||||||
form1: form
|
form1: form
|
||||||
};
|
};
|
||||||
|
|
||||||
await ReversiGame.update({ _id: gameId }, {
|
await ReversiGame.update({ _id: gameId }, {
|
||||||
$set: set
|
$set: set
|
||||||
|
@ -193,7 +193,7 @@ export default function(request: websocket.request, connection: websocket.connec
|
||||||
function getRandomMap() {
|
function getRandomMap() {
|
||||||
const mapCount = Object.entries(maps).length;
|
const mapCount = Object.entries(maps).length;
|
||||||
const rnd = Math.floor(Math.random() * mapCount);
|
const rnd = Math.floor(Math.random() * mapCount);
|
||||||
return Object.entries(maps).find((x, i) => i == rnd)[1].data;
|
return Object.values(maps)[rnd].data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const map = freshGame.settings.map != null ? freshGame.settings.map : getRandomMap();
|
const map = freshGame.settings.map != null ? freshGame.settings.map : getRandomMap();
|
||||||
|
@ -227,11 +227,11 @@ export default function(request: websocket.request, connection: websocket.connec
|
||||||
await ReversiGame.update({
|
await ReversiGame.update({
|
||||||
_id: gameId
|
_id: gameId
|
||||||
}, {
|
}, {
|
||||||
$set: {
|
$set: {
|
||||||
isEnded: true,
|
isEnded: true,
|
||||||
winnerId: winner
|
winnerId: winner
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
publishReversiGameStream(gameId, 'ended', {
|
publishReversiGameStream(gameId, 'ended', {
|
||||||
winnerId: winner,
|
winnerId: winner,
|
||||||
|
@ -293,15 +293,15 @@ export default function(request: websocket.request, connection: websocket.connec
|
||||||
await ReversiGame.update({
|
await ReversiGame.update({
|
||||||
_id: gameId
|
_id: gameId
|
||||||
}, {
|
}, {
|
||||||
$set: {
|
$set: {
|
||||||
crc32,
|
crc32,
|
||||||
isEnded: o.isEnded,
|
isEnded: o.isEnded,
|
||||||
winnerId: winner
|
winnerId: winner
|
||||||
},
|
},
|
||||||
$push: {
|
$push: {
|
||||||
logs: log
|
logs: log
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
publishReversiGameStream(gameId, 'set', Object.assign(log, {
|
publishReversiGameStream(gameId, 'set', Object.assign(log, {
|
||||||
next: o.turn
|
next: o.turn
|
||||||
|
|
Loading…
Reference in a new issue