Compare commits
No commits in common. "9a7ef61d93990b737201fe6da81d3c3e3c86c481" and "d510caa123be6b7e82f202882dca69bfc2b5db5e" have entirely different histories.
9a7ef61d93
...
d510caa123
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.28.4",
|
"version": "1.28.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.28.4",
|
"version": "1.28.3",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"better-sqlite3": "^8.3.0",
|
"better-sqlite3": "^8.3.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.28.4",
|
"version": "1.28.3",
|
||||||
"description": "Game host for SChat 2-powered chat sites",
|
"description": "Game host for SChat 2-powered chat sites",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
const path = require('path');
|
|
||||||
const args = require('yargs').argv;
|
|
||||||
const fs = require('fs').promises;
|
|
||||||
|
|
||||||
async function init() {
|
|
||||||
await fs.copyFile(args.file, `${path.basename(args.file, path.extname(args.file))}_backup_${Date.now()}.json`);
|
|
||||||
|
|
||||||
const filepath = path.join(process.cwd(), args.file);
|
|
||||||
const points = require(filepath); // eslint-disable-line
|
|
||||||
|
|
||||||
Object.entries(points).forEach(([game, scores]) => {
|
|
||||||
const originKey = Object.keys(scores).find((userKey) => userKey.includes(`:${args.origin}`));
|
|
||||||
const originScore = scores[originKey];
|
|
||||||
|
|
||||||
const targetKey = Object.keys(scores).find((userKey) => userKey.includes(`:${args.target}`));
|
|
||||||
const targetScore = scores[targetKey];
|
|
||||||
|
|
||||||
if (typeof originScore === 'undefined' || typeof targetScore === 'undefined') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const totalScore = targetScore + originScore;
|
|
||||||
|
|
||||||
points[game][targetKey] = targetScore + originScore;
|
|
||||||
delete points[game][originKey];
|
|
||||||
|
|
||||||
console.log(`${game} ${targetScore} (${args.target}) + ${originScore} (${args.origin}) = ${totalScore}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
await fs.writeFile(filepath, JSON.stringify(points, null, 4));
|
|
||||||
|
|
||||||
console.log(`Saved ${filepath}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
|
Loading…
Reference in New Issue