Skip to content

Commit

Permalink
1.2.19
Browse files Browse the repository at this point in the history
  • Loading branch information
Razviar committed Sep 9, 2023
1 parent b93fc70 commit 4bec31b
Show file tree
Hide file tree
Showing 20 changed files with 715 additions and 565 deletions.
1,080 changes: 570 additions & 510 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 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.18",
"version": "1.2.20",
"description": "Marvel Snap Tracker",
"main": "./.webpack/main",
"scripts": {
Expand Down Expand Up @@ -42,24 +42,24 @@
"update-electron-app": "2.0.1"
},
"devDependencies": {
"@electron-forge/cli": "6.4.1",
"@electron-forge/maker-deb": "6.4.1",
"@electron-forge/maker-dmg": "6.4.1",
"@electron-forge/maker-rpm": "6.4.1",
"@electron-forge/maker-squirrel": "6.4.1",
"@electron-forge/maker-zip": "6.4.1",
"@electron-forge/plugin-webpack": "6.4.1",
"@electron-forge/publisher-github": "6.4.1",
"@electron-forge/cli": "6.4.2",
"@electron-forge/maker-deb": "6.4.2",
"@electron-forge/maker-dmg": "6.4.2",
"@electron-forge/maker-rpm": "6.4.2",
"@electron-forge/maker-squirrel": "6.4.2",
"@electron-forge/maker-zip": "6.4.2",
"@electron-forge/plugin-webpack": "6.4.2",
"@electron-forge/publisher-github": "6.4.2",
"@marshallofsound/webpack-asset-relocator-loader": "0.5.0",
"@types/auto-launch": "5.0.2",
"@types/lodash": "4.14.197",
"copy-webpack-plugin": "10.2.4",
"@types/lodash": "4.14.198",
"copy-webpack-plugin": "11.0.0",
"csp-html-webpack-plugin": "5.1.0",
"css-loader": "6.8.1",
"dotenv-webpack": "8.0.1",
"electron": "26.1.0",
"electron": "26.2.0",
"file-loader": "6.2.0",
"fork-ts-checker-webpack-plugin": "7.3.0",
"fork-ts-checker-webpack-plugin": "8.0.0",
"node-loader": "2.0.0",
"prettier": "3.0.3",
"style-loader": "3.3.3",
Expand Down
10 changes: 10 additions & 0 deletions src/api/bots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Request} from 'root/app/request';
import {Bots} from 'root/models/bots';

export async function getBots(): Promise<Bots> {
const res = await Request.get('/snap/do.php?cmd=getbots', {
url: 'https://static2.marvelsnap.pro/snap/do.php?cmd=getbots',
});

return res;
}
8 changes: 6 additions & 2 deletions src/app/game_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {exec, execFile} from 'child_process';
import {BrowserWindow} from 'electron';
import electronIsDev from 'electron-is-dev';
import psList from 'ps-list';
import {getBots} from 'root/api/bots';

import {getCards} from 'root/api/cards';
import {registerHotkeys, unRegisterHotkeys} from 'root/app/hotkeys';
Expand All @@ -24,7 +25,7 @@ class GameState {
private psListInterval: NodeJS.Timeout | undefined;
private processId: number | undefined;
private badErrorHappening: boolean = false;
private refreshMillis = 1000;
private readonly refreshMillis = 1000;
private readonly processName = 'SNAP.exe';
private processPath: string | undefined = '';
private readonly movementSensitivity = 1;
Expand All @@ -33,7 +34,7 @@ class GameState {
public isFullscreen: boolean = false;
private decks: UserDeck[] = [];
private selectedDeck: string = '';
private deckStats: Record<string, {win: number; loss: number; cube_win: number; cube_loss: number}> = {};
private readonly deckStats: Record<string, {win: number; loss: number; cube_win: number; cube_loss: number}> = {};
public isDoingBattle: Boolean = false;
public battleScores: [number, number] = [10, 10];

Expand Down Expand Up @@ -186,6 +187,9 @@ class GameState {
getCards().then((cards) => {
sendMessageToOverlayWindow('cards-message', cards);
});
getBots().then((bots) => {
sendMessageToOverlayWindow('bots-message', bots);
});
}

public overlayPositionSetter(onlySetPosition?: boolean): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/ipc_main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {App, dialog, nativeImage, shell} from 'electron';
import {join} from 'path';
import {getSuggestions} from 'root/api/getsuggestions';

import {getSuggestions} from 'root/api/getsuggestions';
import {setuserdata, tokencheck, tokenrequest, userbytokenid, UserData} from 'root/api/userbytokenid';
import {loadAppIcon} from 'root/app/app_icon';
import {sendSettingsToRenderer} from 'root/app/auth';
Expand Down
1 change: 1 addition & 0 deletions src/app/locatewindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ 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],
uid: userID,
selectedDeckId,
isBattle:
Expand Down
2 changes: 1 addition & 1 deletion src/lib/func.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function getObject(o: any, prop: any, val: any): any {
}
}
} else {
for (let p in o) {
for (const p in o) {
if (p == prop) {
if (o[p] == val) {
return o;
Expand Down
5 changes: 4 additions & 1 deletion src/lib/messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {TokenCheckRes, TokenRequestRes} from 'root/api/userbytokenid';
import {Account, LatestSettings, OverlaySettings} from 'root/app/settings-store/settings_store';
import {HotkeysSettingsV1} from 'root/app/settings-store/v8';
import {Bots} from 'root/models/bots';
import {Cards} from 'root/models/cards';
import {UserMetadata} from 'root/models/metadata';
import {UserDeck} from 'root/models/snap_deck';
Expand Down Expand Up @@ -46,7 +47,8 @@ export interface Messages {
'match-started': {
matchId: string;
uid: string;
players: string[];
players: [string, string];
playerNicks: [string, string];
selectedDeckId: string;
isBattle: boolean;
isNewBattle: boolean;
Expand Down Expand Up @@ -82,6 +84,7 @@ export interface Messages {
'deck-message': string;
'decks-message': UserDeck[];
'cards-message': Cards;
'bots-message': Bots;
'set-userdata': UserMetadata;
mulligan: boolean;
'set-version': string;
Expand Down
7 changes: 7 additions & 0 deletions src/models/bots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface Bots {
HiddenAiHumanNames: string[];
HiddenAiLSTMNames: string[];
HiddenAiMarvelNames: string[];
HiddenAiNamePostfixes: string[];
HiddenAiRealPlayerNames: string[];
}
2 changes: 2 additions & 0 deletions src/models/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class Match {
public totalCards: number = 0;
public oppEntityId: number = 0;
public oppDeckStable: SnapCard[] = [];
public opponentNick: string = '';

public over(purgeOpp?: boolean): void {
this.matchId = '';
Expand All @@ -49,6 +50,7 @@ export class Match {
this.GameNumber = 0;
this.DecisionPlayer = 0;
this.totalCards = 0;
this.opponentNick = '';
this.timers = {me: 0, opponent: 0};
if (purgeOpp) {
this.oppDeckStable = [];
Expand Down
2 changes: 2 additions & 0 deletions src/models/overlay.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {OverlaySettings} from 'root/app/settings-store/settings_store';
import {Bots} from 'root/models/bots';
import {Cards} from 'root/models/cards';

export interface OverlayConfig {
ovlSettings: OverlaySettings | undefined;
allCards: Cards;
allBots: Bots;
selectedDeck: string;
currentScale: number;
currentOpacity: number;
Expand Down
6 changes: 3 additions & 3 deletions src/windows/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import 'root/windows/fa-brands-400.woff2';
import 'root/windows/fa-regular-400.woff2';
import 'root/windows/fa-solid-900.woff2';
import 'root/windows/fontawesome.css';
import 'root/windows/rP2Hp2ywxg089UriCZ2IHSeH.woff2';
import 'root/windows/rP2Hp2ywxg089UriCZOIHQ.woff2';
import {controlClick} from 'root/windows/home/functions/controlclick';
import {installHomeMessages} from 'root/windows/home/functions/messages';
import {setHkClick} from 'root/windows/home/functions/setHkClick';
import {settingsChecker} from 'root/windows/home/functions/settingsChecker';
import {tabclick} from 'root/windows/home/functions/tabclick';
import 'root/windows/home/home.css';
import 'root/windows/home/icons.css';
import {onMessageFromIpcMain, sendMessageToIpcMain} from 'root/windows/messages';
import {setHkClick} from 'root/windows/home/functions/setHkClick';
import 'root/windows/rP2Hp2ywxg089UriCZ2IHSeH.woff2';
import 'root/windows/rP2Hp2ywxg089UriCZOIHQ.woff2';

export const HomePageElements = {
header: document.getElementById('header') as HTMLElement,
Expand Down
38 changes: 38 additions & 0 deletions src/windows/overlay/functions/checkbot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {currentMatch, overlayConfig} from 'root/windows/overlay/overlay';

export function CheckBottiness(): string {
let nick = currentMatch.opponentNick;
let botLikness = 0;

overlayConfig.allBots.HiddenAiHumanNames.forEach((nameToTest) => {
if (nick === nameToTest) {
botLikness += 5;
}
});

overlayConfig.allBots.HiddenAiLSTMNames.forEach((nameToTest) => {
if (nick.includes(nameToTest) && nameToTest.length > 3) {
botLikness++;
}
});

overlayConfig.allBots.HiddenAiMarvelNames.forEach((nameToTest) => {
if (nick === nameToTest) {
botLikness += 5;
}
});

overlayConfig.allBots.HiddenAiNamePostfixes.forEach((nameToTest) => {
if (nick.includes(nameToTest) && nameToTest.length > 3) {
botLikness++;
}
});

overlayConfig.allBots.HiddenAiRealPlayerNames.forEach((nameToTest) => {
if (nick.includes(nameToTest) && nameToTest.length > 3) {
botLikness++;
}
});

return `${nick} (${botLikness === 0 ? 'Human' : botLikness > 1 ? 'Most Likely A Bot' : 'Could Be a Bot'})`;
}
2 changes: 1 addition & 1 deletion src/windows/overlay/functions/drawdeck.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {makeCard} from 'root/windows/overlay/functions/makecard';
import {sortDeck} from 'root/windows/overlay/functions/sortdeck';
import {currentMatch, overlayConfig, overlayElements, toggleButtonClass} from 'root/windows/overlay/overlay';
import {currentMatch, overlayConfig, overlayElements} from 'root/windows/overlay/overlay';

export function drawDeck(): void {
let output = '';
Expand Down
9 changes: 9 additions & 0 deletions src/windows/overlay/functions/messages_ipcmain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,21 @@ export function SetMessages(setInteractiveHandler: (overlaySettings: OverlaySett
//console.log(overlayConfig.allCards);
});

onMessageFromIpcMain('bots-message', (bots) => {
overlayConfig.allBots = bots;
//console.log(overlayConfig.allBots);
});

onMessageFromIpcMain('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];

if (currentMatch.matchId !== '') {
currentMatch.over(!newMatch.isBattle || newMatch.isNewBattle);
updateOppDeck([]);
}

overlayConfig.selectedDeck = newMatch.selectedDeckId;
overlayElements.MainDeckFrame.classList.add('hidden');
//(overlayElements.ToggleMe, overlayElements.MainDeckFrame.classList.contains('hidden'));
Expand Down
42 changes: 24 additions & 18 deletions src/windows/overlay/functions/updatedeck.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
import {SnapCard} from 'root/models/snap_deck';
import {drawDeck} from 'root/windows/overlay/functions/drawdeck';
import {makeCard} from 'root/windows/overlay/functions/makecard';
import {sortDeck} from 'root/windows/overlay/functions/sortdeck';
import {currentMatch, overlayConfig, overlayElements} from 'root/windows/overlay/overlay';

export function updateDeck(highlight: string[]): void {
let graveyard: SnapCard[] = [];
let output = '';
const output = '';
let graveyardString = '';

Object.keys(currentMatch.cardEntityIDs).forEach((cardEntityID) => {
const TheEntity = currentMatch.cardEntityIDs[+cardEntityID];
if (
+TheEntity.ownerEntityId === +currentMatch.myEntityId &&
TheEntity.cardDefId !== '' &&
currentMatch.zones?.[TheEntity.zoneId]?.type === 'graveyardEntity'
) {
graveyard.push({
CardDefId: TheEntity.cardDefId,
RarityDefId: TheEntity.rarityDefId,
ArtVariantDefId: TheEntity.artVariantDefId,
});
}
});
try {
Object.keys(currentMatch.cardEntityIDs).forEach((cardEntityID) => {
const TheEntity = currentMatch.cardEntityIDs[+cardEntityID];
if (
+TheEntity.ownerEntityId === +currentMatch.myEntityId &&
TheEntity.cardDefId !== '' &&
currentMatch.zones?.[TheEntity.zoneId]?.type === 'graveyardEntity'
) {
graveyard.push({
CardDefId: TheEntity.cardDefId,
RarityDefId: TheEntity.rarityDefId,
ArtVariantDefId: TheEntity.artVariantDefId,
});
}
});
} catch (e) {
console.log(e);
}

graveyard = sortDeck(graveyard, true);

if (graveyard.length > 0) {
drawDeck();

graveyard.forEach((card) => {
graveyardString += makeCard(card.CardDefId, true, card.RarityDefId, card.ArtVariantDefId);
});

overlayElements.MainOut.innerHTML =
output + '<div style="flex-basis:100%; text-align:center; padding:5px">Graveyard</div>' + graveyardString;
overlayElements.MainOut.innerHTML +=
'<div style="flex-basis:100%; text-align:center; padding:5px">Graveyard</div>' + graveyardString;
}

highlight.forEach((cardDefId) => {
Expand Down
11 changes: 9 additions & 2 deletions src/windows/overlay/functions/updateoppdeck.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import {SnapCard} from 'root/models/snap_deck';
import {CheckBottiness} from 'root/windows/overlay/functions/checkbot';
import {makeCard} from 'root/windows/overlay/functions/makecard';
import {sortDeck} from 'root/windows/overlay/functions/sortdeck';
import {currentMatch, overlayConfig, overlayElements, toggleButtonClass} from 'root/windows/overlay/overlay';
import {currentMatch, overlayConfig, overlayElements} from 'root/windows/overlay/overlay';

export function updateOppDeck(highlight: string[]): void {
overlayElements.DeckNameOpp.innerHTML = CheckBottiness();

let oppGraveyard: SnapCard[] = [];
if (currentMatch.oppDeckStable.length > 12) {
currentMatch.oppDeckStable.length = 0;
}
Object.keys(currentMatch.cardEntityIDs).forEach((cardEntityID) => {
const TheEntity = currentMatch.cardEntityIDs[+cardEntityID];
if (
+TheEntity.ownerEntityId === +currentMatch.oppEntityId &&
TheEntity.cardDefId !== '' &&
currentMatch.oppDeckStable.findIndex((el) => el.CardDefId === TheEntity.cardDefId) === -1
currentMatch.oppDeckStable.findIndex((el) => el.CardDefId === TheEntity.cardDefId) === -1 &&
currentMatch.oppDeckStable.length <= 12
) {
currentMatch.oppDeckStable.push({
CardDefId: TheEntity.cardDefId,
Expand Down
9 changes: 1 addition & 8 deletions src/windows/overlay/overlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,10 @@ a[href^="ftp://"]
background-color: #20252b;
}

#deckName {
.deckNameBattle {
max-width: 180px;
overflow: hidden;
text-overflow: ellipsis;
/* color: #fff; */
font-weight: bold;
display: flex;
align-items: center;
Expand All @@ -342,12 +341,6 @@ a[href^="ftp://"]
font-weight: bold;
}

#deckName {
max-width: 180px;
overflow: hidden;
text-overflow: ellipsis;
}

.CardMainWrapper {
display: flex;
flex-flow: column nowrap;
Expand Down
Loading

0 comments on commit 4bec31b

Please sign in to comment.