Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SigmaTheFox committed Jun 8, 2024
2 parents e2085f3 + d368aef commit d785773
Show file tree
Hide file tree
Showing 13 changed files with 1,412 additions and 1,086 deletions.
2 changes: 1 addition & 1 deletion forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
config: {
name: 'marvelsnaptracker',
iconUrl: 'https://marvelsnap.pro/snap/icon.ico',
signWithParams: '/sha1 13f0485857babe3350c094db5d424bea8307c0af /t http://timestamp.sectigo.com /fd SHA256',
signWithParams: '/sha1 a2ed9c1235299de7e8178c13fad6d2bdde08ad67 /t http://timestamp.sectigo.com /fd SHA256',
},
},
{
Expand Down
2,365 changes: 1,339 additions & 1,026 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "marvelsnaptracker",
"productName": "Marvel Snap Tracker",
"version": "1.2.27",
"version": "1.2.30",
"description": "Marvel Snap Tracker",
"main": "./.webpack/main",
"scripts": {
Expand All @@ -24,50 +24,50 @@
"forge": "./forge.config.js"
},
"dependencies": {
"@types/find": "0.2.2",
"@types/find": "0.2.4",
"auto-launch": "5.0.6",
"axios": "1.6.2",
"axios": "1.7.2",
"date-fns": "2.30.0",
"electron-is-dev": "2.0.0",
"electron-is-dev": "3.0.1",
"error-stack-parser": "2.1.4",
"find-process": "1.4.7",
"form-data": "4.0.0",
"jsonrepair": "3.5.0",
"jsonrepair": "3.8.0",
"lodash": "4.17.21",
"moment": "2.29.4",
"node-abi": "3.52.0",
"moment": "2.30.1",
"node-abi": "3.63.0",
"pretty-checkbox": "3.0.3",
"ps-list": "7.2.0",
"source-map-support": "0.5.21",
"update-electron-app": "3.0.0"
},
"devDependencies": {
"@electron-forge/cli": "7.2.0",
"@electron-forge/maker-deb": "7.2.0",
"@electron-forge/maker-dmg": "7.2.0",
"@electron-forge/maker-rpm": "7.2.0",
"@electron-forge/maker-squirrel": "7.2.0",
"@electron-forge/maker-zip": "7.2.0",
"@electron-forge/plugin-webpack": "7.2.0",
"@electron-forge/publisher-github": "7.2.0",
"@electron-forge/cli": "7.4.0",
"@electron-forge/maker-deb": "7.4.0",
"@electron-forge/maker-dmg": "7.4.0",
"@electron-forge/maker-rpm": "7.4.0",
"@electron-forge/maker-squirrel": "7.4.0",
"@electron-forge/maker-zip": "7.4.0",
"@electron-forge/plugin-webpack": "7.4.0",
"@electron-forge/publisher-github": "7.4.0",
"@marshallofsound/webpack-asset-relocator-loader": "0.5.0",
"@types/auto-launch": "5.0.5",
"@types/lodash": "4.14.202",
"@types/lodash": "4.17.4",
"copy-webpack-plugin": "11.0.0",
"csp-html-webpack-plugin": "5.1.0",
"css-loader": "6.8.1",
"dotenv-webpack": "8.0.1",
"electron": "28.1.0",
"css-loader": "7.1.2",
"dotenv-webpack": "8.1.0",
"electron": "30.1.0",
"file-loader": "6.2.0",
"fork-ts-checker-webpack-plugin": "9.0.2",
"node-loader": "2.0.0",
"prettier": "3.1.1",
"style-loader": "3.3.3",
"style-loader": "4.0.0",
"ts-loader": "9.5.1",
"tslint": "6.1.3",
"tslint-loader": "3.5.4",
"tslint-plugin-prettier": "2.3.0",
"typescript": "5.3.3",
"typescript": "5.4.5",
"webpack-hook-plugin": "1.0.7"
},
"optionalDependencies": {
Expand Down
10 changes: 8 additions & 2 deletions src/api/logsender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {app} from 'electron';
import electronIsDev from 'electron-is-dev';

import {LogFileParsingState, LogSenderParsingMetadata} from 'root/app/log-parser/model';
import {sendMessageToHomeWindow} from 'root/app/messages';
Expand Down Expand Up @@ -68,13 +69,14 @@ export function sendEventsToServer(
// API call to server
async function uploadpackfile(results: ParseResults[], version: string): Promise<string | boolean> {
try {
console.log(`/snap/donew2.php?cmd=cm_uploadpackfile&version=${version}${isMac() ? 'm' : 'w'}`);
const res = await Request.gzip<ParseResults[]>(
`/snap/donew2.php?cmd=cm_uploadpackfile&version=${version}${isMac() ? 'm' : 'w'}`,
results
);
const resMap = asMap(res);
/*console.log('!!!');
console.log(res);

/*console.log(res);
console.log('!!!');*/
if (resMap === undefined) {
return false;
Expand Down Expand Up @@ -118,9 +120,13 @@ async function sendNextBatch(): Promise<void> {
if (events.length === 0 || events.length + part.events.length <= logSenderParsingMetadata.batchSize) {
for (const event of part.events) {
let sendingRate = logSenderParsingMetadata.sendingRates[event.indicator] as number | undefined;

if (sendingRate === undefined) {
sendingRate = 1;
}
/* if (electronIsDev) {
console.log(event.indicator, sendingRate);
}*/
if (Math.random() <= sendingRate) {
events.push(event);
}
Expand Down
5 changes: 1 addition & 4 deletions src/api/overlay.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {app} from 'electron';

import {parseMetadata} from 'root/api/parseMetadata';
import {parseUserMetadata} from 'root/api/parseUserMetadata';
import {AxiosResponse, Request} from 'root/app/request';
import {error} from 'root/lib/logger';
import {asArray, asMap, asNumber, asString, removeUndefined} from 'root/lib/type_utils';
import {Request} from 'root/app/request';
import {isMac} from 'root/lib/utils';
import {UserMetadata} from 'root/models/metadata';

Expand Down
15 changes: 10 additions & 5 deletions src/app/locatewindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ export class WindowLocator {

sendMessageToOverlayWindow('match-started', {
matchId: change.Id,
players: [change.Players[0].AccountId as string, change.Players[1].AccountId as string],
playerNicks: [change.Players[0].Name as string, change.Players[1].Name as string],
players: [
change.Players[0].PlayerInfo.AccountId as string,
change.Players[1].PlayerInfo.AccountId as string,
],
playerNicks: [change.Players[0].PlayerInfo.Name as string, change.Players[1].PlayerInfo.Name as string],
uid: userID,
selectedDeckId,
isBattle:
Expand All @@ -159,13 +162,15 @@ export class WindowLocator {
break;
case 'CubeGame.GameCreatePlayerChange':
sendMessageToOverlayWindow('match-set-player', {
accountId: change.AccountId,
name: change.Name,
accountId: change.PlayerInfo.AccountId,
name: change.PlayerInfo.Name,
entityId: +change.EntityId,
deckEntityId: +change.DeckEntityId,
graveyardEntityId: +change.GraveyardEntityId,
handEntityId: +change.HandEntityId,
CardBackDefId: change.CardBack.CardBackDefId ? change.CardBack.CardBackDefId : 'Snap_01',
CardBackDefId: change.PlayerInfo.CardBack.CardBackDefId
? change.PlayerInfo.CardBack.CardBackDefId
: 'Snap_01',
});
case 'CubeGame.GameCreateLocationChange':
sendMessageToOverlayWindow('match-set-location', {
Expand Down
53 changes: 29 additions & 24 deletions src/app/log-parser/log_parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import format from 'date-fns/format';
import {format} from 'date-fns';
import {app} from 'electron';
import {Stats, statSync} from 'fs';
import {join} from 'path';
Expand Down Expand Up @@ -158,29 +158,34 @@ export class LogParser {
const data = await getJSONData(path);
const dataParsed = parseAsJSONIfNeeded(data);

//console.log(parsingMetadata.Variables);
Object.keys(parsingMetadata.Variables).forEach((Variable) => {
if (parsingMetadata.Variables[Variable][0] !== fileToParse) {
return;
}
const pathToVariableToExtract = parsingMetadata.Variables[Variable].slice(1);
const extractedElementToProcess = extractValue(dataParsed, pathToVariableToExtract) as any[];
//console.log('extractedElementToProcess', extractedElementToProcess);
switch (Variable) {
case 'PLAYER_ID':
extractedElementToProcess.forEach((extractedElement, i) => {
const extractedAccountId = extractValue(dataParsed, [...pathToVariableToExtract, i, 'AccountId']);
if (extractedAccountId && extractedAccountId === this.currentState.state.userId) {
variables[Variable] = i;
variables['OPPONENT_ID'] = i == 0 ? 1 : 0;
variables['PLAYER_NUM'] = i == 0 ? 1 : 2;
variables['OPPONENT_NUM'] = i == 0 ? 2 : 1;
}
});
break;
}
//variables[Variable] = extractedElementToProcess;
});
//console.log(parsingMetadata.Variables);
Object.keys(parsingMetadata.Variables).forEach((Variable) => {
if (parsingMetadata.Variables[Variable][0] !== fileToParse) {
return;
}
const pathToVariableToExtract = parsingMetadata.Variables[Variable].slice(1);
const extractedElementToProcess = extractValue(dataParsed, pathToVariableToExtract) as any[];
//console.log('extractedElementToProcess', extractedElementToProcess);
switch (Variable) {
case 'PLAYER_ID':
extractedElementToProcess.forEach((extractedElement, i) => {
const extractedAccountId = extractValue(dataParsed, [
...pathToVariableToExtract,
i,
'PlayerInfo',
'AccountId',
]);
if (extractedAccountId && extractedAccountId === this.currentState.state.userId) {
variables[Variable] = i;
variables['OPPONENT_ID'] = i == 0 ? 1 : 0;
variables['PLAYER_NUM'] = i == 0 ? 1 : 2;
variables['OPPONENT_NUM'] = i == 0 ? 2 : 1;
}
});
break;
}
//variables[Variable] = extractedElementToProcess;
});

//console.log('variables', variables);

Expand Down
2 changes: 1 addition & 1 deletion src/app/log_parser_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import electronIsDev from 'electron-is-dev';
import {sendEventsToServer} from 'root/api/logsender';
import {gameState} from 'root/app/game_state';
import {LogParser} from 'root/app/log-parser/log_parser';
import {sendMessageToHomeWindow, sendMessageToOverlayWindow} from 'root/app/messages';
import {sendMessageToHomeWindow} from 'root/app/messages';
import {settingsStore} from 'root/app/settings-store/settings_store';
import {error} from 'root/lib/logger';

Expand Down
Binary file not shown.
Binary file not shown.
Empty file.
2 changes: 1 addition & 1 deletion src/windows/overlay/functions/messages_ipcmain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function SetMessages(setInteractiveHandler: (overlaySettings: OverlaySett
});

onMessageFromIpcMain('match-started', (newMatch) => {
//console.log('match-started', newMatch);
console.log('match-started', newMatch);
const ourPlayerPosition: 0 | 1 = newMatch.players[0] === newMatch.uid ? 0 : 1;
currentMatch.opponentNick = newMatch.playerNicks[ourPlayerPosition === 0 ? 1 : 0];

Expand Down
2 changes: 1 addition & 1 deletion src/windows/overlay/overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>
</div>
<div id="MainOut" class="DeckOut"></div>
<div id="CardHint" class="CardHint">Hover over the card to see it's details</div>
<div id="CardHint" class="CardHint">Hover over the card to see its details</div>
<div class="MoreDecks link Interactive" data-link="https://marvelsnap.pro/decks/">
<img class="imgico Linkico" width="15" /> Get More Decks From MarvelSnap.pro
</div>
Expand Down

0 comments on commit d785773

Please sign in to comment.