Skip to content

Commit

Permalink
1.2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
Razviar committed Sep 2, 2023
1 parent 5dab09d commit 870df1f
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 161 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 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.15",
"version": "1.2.17",
"description": "Marvel Snap Tracker",
"main": "./.webpack/main",
"scripts": {
Expand All @@ -26,7 +26,7 @@
"dependencies": {
"@types/find": "0.2.1",
"auto-launch": "5.0.6",
"axios": "1.4.0",
"axios": "1.5.0",
"date-fns": "2.30.0",
"electron-is-dev": "2.0.0",
"error-stack-parser": "2.1.4",
Expand Down Expand Up @@ -61,13 +61,13 @@
"file-loader": "6.2.0",
"fork-ts-checker-webpack-plugin": "7.3.0",
"node-loader": "2.0.0",
"prettier": "3.0.2",
"prettier": "3.0.3",
"style-loader": "3.3.3",
"ts-loader": "9.4.4",
"tslint": "6.1.3",
"tslint-loader": "3.5.4",
"tslint-plugin-prettier": "2.3.0",
"typescript": "5.1.6",
"typescript": "5.2.2",
"webpack-hook-plugin": "1.0.7"
},
"optionalDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions src/api/cards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Cards} from 'root/models/cards';
import {Request} from 'root/app/request';

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

return res;
}
4 changes: 4 additions & 0 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 {getCards} from 'root/api/cards';
import {registerHotkeys, unRegisterHotkeys} from 'root/app/hotkeys';
import {WindowLocator} from 'root/app/locatewindow';
import {withLogParser} from 'root/app/log_parser_manager';
Expand Down Expand Up @@ -181,6 +182,9 @@ class GameState {
sendMessageToOverlayWindow('set-ovlsettings', ovlSettings);
sendMessageToOverlayWindow('deck-message', this.selectedDeck);
sendMessageToOverlayWindow('decks-message', this.decks);
getCards().then((cards) => {
sendMessageToOverlayWindow('cards-message', cards);
});
}

public overlayPositionSetter(onlySetPosition?: boolean): void {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/messages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +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 {CardPlayed} from 'root/models/cards';
import {Cards} from 'root/models/cards';
import {UserMetadata} from 'root/models/metadata';
import {UserDeck} from 'root/models/snap_deck';
import {UserResult} from 'root/models/userbytokenid';
Expand Down Expand Up @@ -81,6 +81,7 @@ export interface Messages {
'disable-clicks': undefined;
'deck-message': string;
'decks-message': Array<UserDeck>;
'cards-message': Cards;
'set-userdata': UserMetadata;
mulligan: boolean;
'set-version': string;
Expand All @@ -92,7 +93,6 @@ export interface Messages {
'set-setting-icon': string;
'set-setting-do-uploads': boolean;
'set-setting-disable-hotkeys': boolean;
'card-played': CardPlayed;
'set-setting-o-hidezero': boolean;
'set-setting-o-hidemy': boolean;
'set-setting-o-hideopp': boolean;
Expand Down
188 changes: 74 additions & 114 deletions src/models/cards.ts
Original file line number Diff line number Diff line change
@@ -1,127 +1,87 @@
export interface Card {
id: number;
doublelink: number;
cardid: string;
multiverseid: number;
CardDefId: string;
name: string;
slug: string;
kw: string;
flavor: string;
power: number;
market: number;
toughness: number;
expansion: number;
rarity: number;
mana: string;
convmana: number;
text: string;
loyalty: number;
type: number;
subtype: number;
txttype: string;
pict: string;
date_in: number;
colorindicator: string;
mtga_id: number;
is_collectible: number;
reprint: number;
draftrate: number;
drafteval: number;
is_land: number;
colorarr: string;
currentstandard: number;
currenthistoric: number;
art: string;
has_hiresimg: number;
willbeoutsoon: number;
drafteval2: number;
wleval: number;
battleusage: number;
wleval_draft: number;
battleusage_draft: number;
is_boostable: number;
is_craftable: number;
TraditionalStandardBan: number;
TraditionalHistoricBan: number;
StandardBan: number;
HistoricBan: number;
wleval_1sthand: number;
description: string;
abilities: string;
cost: string;
power: string;
category: string;
source: string;
variants: Variant[];
use_count: string;
connected_cards: string;
is_Token: string;
share_cube_earned: number;
share_cube_lost: number;
share_cube_won: number;
share_loss: number;
share_total: number;
share_win: number;
stats_cuberate: number;
stats_winrate: number;
collectible: string;
stats_cube_lost: string;
stats_cube_won: string;
stats_loss: string;
stats_win: string;
stats_position: string;
PrimaryColor: string;
RingColor: string;
SecondaryColor: string;
stats_winrate_played: string;
stats_cuberate_played: string;
CardSeriesDefId: string;
SeriesStartDates: string;
}

export interface Cardnfo {
battleusage: number;
battleusage_draft: number;
drafteval2: number;
id: number;
market: number;
mtga_id: number;
reprints: number[];
wleval: number;
wleval_draft: number;
export interface Variant {
id: string;
source: string;
category: string;
credits?: string;
released?: string;
possession?: string | null;
usage_count?: string | null;
ReleaseDate?: string;
wasAddedIn?: string;
}

export interface Expcount {
cardcount: number;
rar_1: number;
rar_2: number;
rar_3: number;
rar_4: number;
}

export interface CardFilterResult {
data: Cardnfo[];
maxdrafteval2: number;
maxprice: number;
maxusage: number;
minusage: number;
maxusagedraft: number;
minusagedraft: number;
maxwleval: number;
maxwleval_draft: number;
mindrafteval2: number;
minwleval: number;
minwleval_draft: number;
}
export type Cards = Record<string, Card>;

export interface CardRequestFilters {
color: string[];
expansion: string;
mana: string;
type: string;
subtype: string;
export interface Location {
CardDefId: string;
abilities: string;
description: string;
difficulty: string;
name: string;
rarity: string;
rulings: string;
srt: string;
direct: string;
smrtsrhc: string;
collection?: string;
booster: string;
TraditionalStandardBan: string;
TraditionalHistoricBan: string;
StandardBan: string;
HistoricBan: string;
tip: string;
released: string;
}

export interface CardFilterReq {
direct: number;
filter: {[index: string]: string[] | number[]};
lib: number;
limit: number;
page: number;
srt: number;
}
export type Locations = Record<string, Location>;

export interface CardPriceData {
date: string;
bid: number;
ask: number;
market: number;
}
export type VariantFiltersStrings = 'status' | 'srt' | 'direct' | 'rarity' | 'category' | 'smrtsrhc' | 'clearfilters';

export type CardFiltersStrings =
| 'cost'
| 'power'
| 'pool'
| 'srt'
| 'direct'
| 'smrtsrhc'
| 'clearfilters'
| 'usecount'
| 'collection'
| 'dataToShow'
| 'releaseStatus'
| 'tokenStatus';

export type LocationFiltersStrings = 'smrtsrhc' | 'released' | 'rarity' | 'difficulty' | 'clearfilters';

export interface CardPlayed {
grpId: number;
instanceId: number;
ownerSeatId: number;
visibility: string;
zoneId: number;
export interface CardBack {
CardBackDefId: string;
Name: string;
Enabled: string;
source: string;
}
8 changes: 4 additions & 4 deletions src/models/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class Match {
public DecisionPlayer: number = 0;
public totalCards: number = 0;
public oppEntityId: number = 0;
public oppDeckStable: Array<{cardDefId: string; rarity: string; artVariantDefId: string}> = [];
public oppDeckStable: SnapCard[] = [];

public over(purgeOpp?:boolean): void {
public over(purgeOpp?: boolean): void {
this.matchId = '';
this.ourUid = '';
this.zones = {};
Expand All @@ -50,8 +50,8 @@ export class Match {
this.DecisionPlayer = 0;
this.totalCards = 0;
this.timers = {me: 0, opponent: 0};
if(purgeOpp){
this.oppDeckStable=[];
if (purgeOpp) {
this.oppDeckStable = [];
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/models/overlay.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {OverlaySettings} from 'root/app/settings-store/settings_store';
import {Card} from 'root/models/cards';
import {Cards} from 'root/models/cards';

export interface OverlayConfig {
ovlSettings: OverlaySettings | undefined;
allCards: Map<string, Card>;
allCards: Cards;
selectedDeck: string;
currentScale: number;
currentOpacity: number;
Expand Down
2 changes: 2 additions & 0 deletions src/windows/overlay/functions/drawdeck.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
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';

export function drawDeck(): void {
let output = '';
currentMatch.totalCards = 0;
currentMatch.myFullDeck = sortDeck(currentMatch.myFullDeck, true);
currentMatch.myFullDeck.forEach((card) => {
output += makeCard(card.CardDefId, true, card.RarityDefId, card.ArtVariantDefId);
});
Expand Down
15 changes: 10 additions & 5 deletions src/windows/overlay/functions/makecard.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import {currentMatch, overlayConfig} from 'root/windows/overlay/overlay';

export function makeCard(cardDefId: string, side: boolean, rarity?: string, variant?: string): string {
const today = new Date();
const yyyy = today.getFullYear();
const mm = today.getMonth() + 1; // Months start at 0!
const dd = today.getDate();
const formattedToday = dd + '-' + mm + '-' + yyyy;
return `
<div class="DcDrow CardMainWrapper" data-cid="${cardDefId}" data-side="${
side ? 'me' : 'opp'
}" id="card${cardDefId}${side ? 'me' : 'opp'}" style="width: 80px; height:104px;">
side ? 'me' : 'opp'
}" id="card${cardDefId}${side ? 'me' : 'opp'}" style="width: 80px; height:104px;">
<div class="CardPicRenderer" style="width: 80px; height:104px; background-image: url('https://static.marvelsnap.pro/cards/${
variant !== undefined && variant !== '' ? variant : cardDefId
}${rarity && rarity != '' && rarity !== 'Common' ? `-${rarity.toLowerCase()}` : ''}.webp')"></div>
}${
rarity && rarity != '' && rarity !== 'Common' ? `-${rarity.toLowerCase()}` : ''
}.webp?anticache=${formattedToday}')"></div>
</div>
`;
}
9 changes: 4 additions & 5 deletions src/windows/overlay/functions/messages_ipcmain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ export function SetMessages(setInteractiveHandler: (overlaySettings: OverlaySett
sendMessageToIpcMain('set-scale', zoom);
});

/*onMessageFromIpcMain('set-metadata', (meta) => {
overlayConfig.metaData = meta;
overlayConfig.allCards = new Map(meta.allcards);
overlayConfig.metaData.allcards = [];
});*/
onMessageFromIpcMain('cards-message', (cards) => {
overlayConfig.allCards = cards;
//console.log(overlayConfig.allCards);
});

onMessageFromIpcMain('match-started', (newMatch) => {
//console.log('match-started', newMatch);
Expand Down
Loading

0 comments on commit 870df1f

Please sign in to comment.