Skip to content

Commit

Permalink
v.2.2.19
Browse files Browse the repository at this point in the history
  • Loading branch information
Razviar committed Jul 17, 2022
1 parent 98c56bb commit 5c421bf
Show file tree
Hide file tree
Showing 11 changed files with 1,564 additions and 2,014 deletions.
3,408 changes: 1,443 additions & 1,965 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mtgaprotracker",
"productName": "mtgaprotracker",
"version": "2.2.15",
"version": "2.2.19",
"description": "MTG Arena Pro Tracker",
"main": "./.webpack/main",
"scripts": {
Expand All @@ -26,47 +26,47 @@
"dependencies": {
"@types/find": "0.2.1",
"auto-launch": "5.0.5",
"axios": "0.26.0",
"axios": "0.27.2",
"date-fns": "2.28.0",
"electron-is-dev": "2.0.0",
"error-stack-parser": "2.0.7",
"error-stack-parser": "2.1.4",
"find-process": "1.4.7",
"lodash": "4.17.21",
"moment": "2.29.1",
"node-abi": "3.8.0",
"node-mac-permissions": "2.2.0",
"moment": "2.29.4",
"node-abi": "3.22.0",
"node-mac-permissions": "2.2.1",
"pretty-checkbox": "3.0.3",
"ps-list": "7.2.0",
"source-map-support": "0.5.21",
"update-electron-app": "2.0.1"
},
"devDependencies": {
"@electron-forge/cli": "6.0.0-beta.63",
"@electron-forge/maker-deb": "6.0.0-beta.63",
"@electron-forge/maker-dmg": "6.0.0-beta.63",
"@electron-forge/maker-rpm": "6.0.0-beta.63",
"@electron-forge/maker-squirrel": "6.0.0-beta.63",
"@electron-forge/maker-zip": "6.0.0-beta.63",
"@electron-forge/plugin-webpack": "6.0.0-beta.63",
"@electron-forge/publisher-github": "6.0.0-beta.63",
"@electron-forge/cli": "6.0.0-beta.64",
"@electron-forge/maker-deb": "6.0.0-beta.64",
"@electron-forge/maker-dmg": "6.0.0-beta.64",
"@electron-forge/maker-rpm": "6.0.0-beta.64",
"@electron-forge/maker-squirrel": "6.0.0-beta.64",
"@electron-forge/maker-zip": "6.0.0-beta.64",
"@electron-forge/plugin-webpack": "6.0.0-beta.64",
"@electron-forge/publisher-github": "6.0.0-beta.64",
"@marshallofsound/webpack-asset-relocator-loader": "0.5.0",
"@types/auto-launch": "5.0.2",
"@types/lodash": "4.14.178",
"@types/lodash": "4.14.182",
"copy-webpack-plugin": "10.2.4",
"csp-html-webpack-plugin": "5.1.0",
"css-loader": "5.2.6",
"dotenv-webpack": "7.1.0",
"electron": "17.0.1",
"css-loader": "5.2.7",
"dotenv-webpack": "7.1.1",
"electron": "19.0.8",
"file-loader": "6.2.0",
"fork-ts-checker-webpack-plugin": "7.2.1",
"fork-ts-checker-webpack-plugin": "7.2.12",
"node-loader": "2.0.0",
"prettier": "2.5.1",
"prettier": "2.7.1",
"style-loader": "3.3.1",
"ts-loader": "9.2.6",
"ts-loader": "9.3.1",
"tslint": "6.1.3",
"tslint-loader": "3.5.4",
"tslint-plugin-prettier": "2.3.0",
"typescript": "4.5.5",
"typescript": "4.7.4",
"webpack-hook-plugin": "1.0.7"
},
"optionalDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions src/GetData2/GetData2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<PreserveCompilationContext>false</PreserveCompilationContext>
<GenerateDependencyFile>false</GenerateDependencyFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>

<ItemGroup>
Expand Down
90 changes: 74 additions & 16 deletions src/GetData2/MTGAProGetData.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using UnityEngine;
using Wizards.Mtga.FrontDoorModels;

Expand All @@ -15,14 +15,31 @@ public class LogElement
public object Payload;
}

public class DeckForLog
public class EntryFeeForLog
{
public string Name;
public Wizards.Mtga.Decks.Client_DeckContents Deck;
public string CurrencyType;
public int Quantity;
}

public class EventForLog
{
public string InternalEventName;
public string PublicEventName;
public string TitleLocKey;
public DateTime StartTime;
public DateTime LockedTime;
public DateTime ClosedTime;
public bool IsRanked;
public List<EntryFeeForLog> EntryFees;
public string DeckSelectFormat;
public int MaxWins;
public int MaxLoss;
public bool isLimited;
}
public class MTGAProGetData : MonoBehaviour
{
private static bool gotInventoryData = false;
private static bool gotEventsData = false;
private static bool gotLoginData = false;
private static bool gotRankInfo = false;
private static bool gotUniqueID = false;
Expand Down Expand Up @@ -84,9 +101,13 @@ private void GetHoldOnPapa()
{
GetInventoryData();
}


if (gotUniqueID && gotInventoryData && gotLoginData && gotRankInfo)

if (!gotEventsData && WrapperController.Instance != null && WrapperController.Instance.EventManager != null && WrapperController.Instance.EventManager.EventsByInternalName != null && WrapperController.Instance.EventManager.EventsByInternalName.Count > 0)
{
GetEventsData();
}

if (gotUniqueID && gotInventoryData && gotLoginData && gotRankInfo && gotEventsData)
{
return;
}
Expand Down Expand Up @@ -138,6 +159,46 @@ private void PrintAccountInfo()
}
}

private void GetEventsData()
{
try
{
gotEventsData = true;
Dictionary<string, Wizards.MDN.EventContext> gameEvents = WrapperController.Instance.EventManager.EventsByInternalName;
Dictionary<string, EventForLog> gameEventsOutput = new Dictionary<string, EventForLog>();
foreach (KeyValuePair<string, Wizards.MDN.EventContext> gameEvent in gameEvents)
{
List<EntryFeeForLog> EntryFeeList = new List<EntryFeeForLog>();

foreach (Wotc.Mtga.Events.EventEntryFeeInfo entryFee in gameEvent.Value.PlayerEvent.EventInfo.EntryFees)
{
EntryFeeList.Add(new EntryFeeForLog { CurrencyType = entryFee.CurrencyType.ToString(), Quantity = entryFee.Quantity });
}

gameEventsOutput.Add(gameEvent.Key, new EventForLog
{
InternalEventName = gameEvent.Value.PlayerEvent.EventInfo.InternalEventName,
PublicEventName = gameEvent.Value.PlayerEvent.EventUXInfo.PublicEventName,
TitleLocKey = gameEvent.Value.PlayerEvent.EventUXInfo.TitleLocKey,
StartTime = gameEvent.Value.PlayerEvent.EventInfo.StartTime,
LockedTime = gameEvent.Value.PlayerEvent.EventInfo.LockedTime,
ClosedTime = gameEvent.Value.PlayerEvent.EventInfo.ClosedTime,
IsRanked = gameEvent.Value.PlayerEvent.EventInfo.IsRanked,
EntryFees = EntryFeeList,
DeckSelectFormat = gameEvent.Value.PlayerEvent.EventUXInfo.DeckSelectFormat,
MaxWins = gameEvent.Value.PlayerEvent.EventUXInfo.EventComponentData.ByCourseObjectiveTrack != null ? gameEvent.Value.PlayerEvent.EventUXInfo.EventComponentData.ByCourseObjectiveTrack.ChestDescriptions.Count : 0,
MaxLoss = gameEvent.Value.PlayerEvent.EventUXInfo.EventComponentData.LossDetailsDisplay != null ? gameEvent.Value.PlayerEvent.EventUXInfo.EventComponentData.LossDetailsDisplay.Games : 0,
isLimited = gameEvent.Value.PlayerEvent.DefaultTemplateName.IndexOf("Limited") != -1,
});
}
WriteToLog("Events", gameEventsOutput);
}
catch (Exception e)
{
WriteToLog("ErrorGetInitialData", e);
}
}

private void GetInventoryData()
{
try
Expand All @@ -146,11 +207,8 @@ private void GetInventoryData()
WrapperController.Instance.InventoryManager.UnsubscribeFromAll(InventoryChangeHandler);
WrapperController.Instance.InventoryManager.SubscribeToAll(InventoryChangeHandler);

/*PAPA.SceneLoading.OnWrapperSceneLoaded += onWrapperSceneLoaded;
PAPA.SceneLoading.OnDuelSceneLoaded += onDuelSceneLoaded;*/

WriteToLog("Collection", WrapperController.Instance.InventoryManager.Cards);
WriteToLog("InventoryContent", WrapperController.Instance.InventoryManager.Inventory);
WriteToLog("InventoryContent", WrapperController.Instance.InventoryManager.Inventory);

Task task = new Task(() => PeriodicCollectionPrinter());
task.Start();
Expand Down Expand Up @@ -185,10 +243,10 @@ private void PeriodicCollectionPrinter()
{
try
{
Thread.Sleep(600000);
WriteToLog("Collection", WrapperController.Instance.InventoryManager.Cards);
WriteToLog("InventoryContent", WrapperController.Instance.InventoryManager.Inventory);
PeriodicCollectionPrinter();
Thread.Sleep(600000);
WriteToLog("Collection", WrapperController.Instance.InventoryManager.Cards);
WriteToLog("InventoryContent", WrapperController.Instance.InventoryManager.Inventory);
PeriodicCollectionPrinter();
}
catch (Exception e)
{
Expand Down
4 changes: 2 additions & 2 deletions src/api/checkFileBeforeUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export async function checkFileBeforeUpload(checkmd5: string): Promise<boolean>
return resMap === 'UPDATE';
}

export async function doFileUpload(file: string, name: string): Promise<boolean> {
const res = await Request.gzip('/mtg/uploadcards.php?version=1', {file, name});
export async function doFileUpload(file: Buffer, name: string): Promise<boolean> {
const res = await Request.gzip('/mtg/uploadcards.php?version=1', {file: file.toString('base64'), name});
const resMap = asString(res);
return resMap === 'UPDATE';
}
8 changes: 2 additions & 6 deletions src/app/cards_uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import fs from 'fs';
import {join} from 'path';

import {checkFileBeforeUpload, doFileUpload} from 'root/api/checkFileBeforeUpload';
import {settingsStore} from 'root/app/settings-store/settings_store';
import {error} from 'root/lib/logger';

export function uploadCardData(FilesOfInterest: string[], pathElements: string[]): void {
const pth = join(...pathElements);
fs.readdir(pth, (err, dirToScan) => {
if (err !== null) {
const settings = settingsStore.get();
settings.mtgaPath = undefined;
settingsStore.save();
return;
}

Expand All @@ -26,14 +22,14 @@ export function uploadCardData(FilesOfInterest: string[], pathElements: string[]
return pass;
})
.forEach((interestingFile) => {
fs.readFile(join(pth, interestingFile), 'utf8', (errr: NodeJS.ErrnoException | null, data: string) => {
fs.readFile(join(pth, interestingFile), null, (errr: NodeJS.ErrnoException | null, data: Buffer) => {
fileUploader(errr, data, interestingFile);
});
});
});
}

const fileUploader = (err: NodeJS.ErrnoException | null, data: string, filename: string) => {
const fileUploader = (err: NodeJS.ErrnoException | null, data: Buffer, filename: string) => {
if (err !== null) {
error('Failure to read MTGA resources files', err);
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/do-path-ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {settingsStore} from 'root/app/settings-store/settings_store';
export function doMtgaPathOps(): void {
//console.log('doMtgaPathOps');
let mtgaPath = settingsStore.get().mtgaPath;
//console.log('mtgaPath1', mtgaPath);
if (mtgaPath === undefined && locateMtgaDir(mtgaPath)) {
mtgaPath = settingsStore.get().mtgaPath;
//console.log('mtgaPath2', mtgaPath);
}
if (mtgaPath === undefined) {
sendMessageToHomeWindow('show-prompt', {
Expand All @@ -27,7 +29,6 @@ export function doMtgaPathOps(): void {
}
if (settingsStore.get().uploads && mtgaPath !== undefined) {
//console.log('uploadCardData');
uploadCardData(['Data_loc_', 'Data_cards_'], [mtgaPath, 'Downloads', 'Data']);
uploadCardData(['Loc_Events_', 'Loc_Decks_', 'Loc_Internal_'], [mtgaPath, 'Downloads', 'Loc']);
uploadCardData(['Raw_CardDatabase', 'Raw_cards', 'Raw_ClientLocalization'], [mtgaPath, 'Downloads', 'Raw']);
}
}
7 changes: 6 additions & 1 deletion src/app/mtga_dir_ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export function locateMtgaDir(checkPath: string | undefined): boolean {
return;
}
const testPth = join(...possiblePathElements);
//console.log(testPth);
if (fs.existsSync(testPth)) {
//console.log('exists!');
pth = testPth;
pathFound = true;
}
Expand All @@ -57,7 +59,7 @@ export function locateMtgaDir(checkPath: string | undefined): boolean {
result = false;
settings.mtgaPath = undefined;
}

//console.log('settingsStore', settingsStore.get().mtgaPath);
settingsStore.save();

return result;
Expand All @@ -71,16 +73,19 @@ interface MostRecentDate {

export function locateMostRecentDate(): MostRecentDate {
const mtgaPath = settingsStore.get().mtgaPath;
//console.log('locateMostRecentDate', mtgaPath);
if (mtgaPath === undefined) {
return {date: undefined, fileId: undefined, logPath: undefined};
}
let logDate: Date | undefined;
let fileId: string | undefined;
let logPath: string | undefined;
const pth = join(mtgaPath, ...['Logs', 'Logs']);
//console.log(pth);
try {
const files = fs.readdirSync(pth);
files.forEach((file) => {
//console.log(file);
logPath = join(pth, file);
const ctime = fs.statSync(logPath).ctime;
if (logDate === undefined || logDate < ctime) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ async function makeAxios(
...config,
withCredentials: false,
url: `${baseURL}${path.startsWith('/') ? '' : '/'}${path}`,
maxContentLength: Infinity,
maxBodyLength: Infinity,
method,
});
const sendingEvents = path.indexOf('cm_uploadpackfile') > -1;
Expand Down
Binary file modified src/our-active-win/GetData2.dll
Binary file not shown.
Binary file added src/our-active-win/SharpMonoInjector.pdb
Binary file not shown.

0 comments on commit 5c421bf

Please sign in to comment.