Skip to content
Permalink
Browse files

Merge pull request #297 from lusbenjamin/label-practice-event

Label Handler for Practice Matches
  • Loading branch information...
Manuel-777 committed Apr 30, 2019
2 parents aefd1bb + 830c83d commit 2807bb1488c7b3aeaf8cdc404ee7df0781f74860
Showing with 22 additions and 5 deletions.
  1. +10 −3 window_background/background.js
  2. +10 −0 window_background/labels.js
  3. +2 −2 window_overlay/overlay.js
@@ -32,6 +32,7 @@ global
onLabelInEventGetActiveEvents,
onLabelEventMatchCreated,
onLabelOutDirectGameChallenge,
onLabelOutEventAIPractice,
onLabelInDraftDraftStatus,
onLabelInDraftMakePick,
onLabelOutDraftMakePick,
@@ -1141,6 +1142,13 @@ function onLogEntryFound(entry) {
onLabelEventMatchCreated(entry, json);
break;

case "Event.AIPractice":
if (entry.arrow == "==>") {
json = entry.json();
onLabelOutEventAIPractice(entry, json);
}
break;

case "DirectGame.Challenge":
if (entry.arrow == "==>") {
json = entry.json();
@@ -1483,8 +1491,6 @@ function createMatch(arg) {
ipc_send("overlay_set_bounds", obj);
}

let str = JSON.stringify(currentDeck.getSave());

currentMatch.player.originalDeck = originalDeck;
currentMatch.player.deck = originalDeck.clone();
currentMatch.playerCardsLeft = originalDeck.clone();
@@ -1517,7 +1523,8 @@ function createMatch(arg) {
windowOverlay
);

if (currentMatch.eventId == "DirectGame") {
if (currentMatch.eventId == "DirectGame" && currentDeck) {
let str = JSON.stringify(currentDeck.getSave());
httpApi.httpTournamentCheck(str, currentMatch.opponent.name, true);
}

@@ -528,6 +528,16 @@ function onLabelOutDirectGameChallenge(entry, json) {
httpApi.httpTournamentCheck(deck, json.params.opponentDisplayName, false, json.params.playFirst, json.params.bo3);
}

function onLabelOutEventAIPractice(entry, json) {
if (!json) return;
var deck = json.params.deck;

deck = replaceAll(deck, '"Id"', '"id"');
deck = replaceAll(deck, '"Quantity"', '"quantity"');
deck = JSON.parse(deck);
select_deck(deck);
}

function onLabelInDraftDraftStatus(entry, json) {
if (!json) return;

@@ -801,7 +801,7 @@ $(document).ready(function() {
//
$(".draft_prev").click(function() {
pickN -= 1;
let packSize = packSizes[currentDraft.set] || 14;
let packSize = (currentDraft && packSizes[currentDraft.set]) || 14;

if (pickN < 0) {
pickN = packSize;
@@ -817,7 +817,7 @@ $(document).ready(function() {
//
$(".draft_next").click(function() {
pickN += 1;
let packSize = packSizes[currentDraft.set] || 14;
let packSize = (currentDraft && packSizes[currentDraft.set]) || 14;

if (pickN > packSize) {
pickN = 0;

0 comments on commit 2807bb1

Please sign in to comment.
You can’t perform that action at this time.