Permalink
Browse files

save priority timers

  • Loading branch information...
Manuel-777 committed Dec 26, 2018
1 parent fb50013 commit d97fa71755c1deb665be2ebdea5077d7d7e15dd4
Showing with 21 additions and 1 deletion.
  1. +16 −1 window_background/background.js
  2. +5 −0 window_background/labels.js
@@ -766,7 +766,7 @@ function onLogEntryFound(entry) {
ipc_send("set_username", playerName);
}
else {
console.log("Entry:", entry.label, entry, entry.json());
//console.log("Entry:", entry.label, entry, entry.json());
if (firstPass) {
updateLoading(entry);
}
@@ -1154,6 +1154,19 @@ function tryZoneTransfers() {
}
}

let priorityTimers = [0,0,0,0,0];
let lastPriorityChangeTime = 0;
//
function changePriority(previous, current, time) {
priorityTimers[previous] += time - lastPriorityChangeTime;

lastPriorityChangeTime = time;
priorityTimers[0] = lastPriorityChangeTime;
console.log(priorityTimers);
console.log("since match begin:", time - matchBeginTime);
ipc_send('set_priority_timer', priorityTimers, windowOverlay);
}

// Get player name by seat in the game
function getNameBySeat(seat) {
try {
@@ -1216,6 +1229,8 @@ function createMatch(arg) {
currentMatchTime = 0;
playerWin = 0;
oppWin = 0;
priorityTimers = [0,0,0,0,0];
lastPriorityChangeTime = matchBeginTime;

ipc_send("ipc_log", "vs "+oppName);
ipc_send("set_timer", matchBeginTime, windowOverlay);
@@ -14,6 +14,8 @@ function onLabelOutLogInfo(entry, json) {

function onLabelGreToClient(entry, json) {
if (!json) return;
logTime = parseWotcTime(entry.timestamp);

json = json.greToClientEvent.greToClientMessages;
json.forEach(function(msg) {
//console.log("Message: "+msg.msgId, msg);
@@ -81,6 +83,9 @@ function onLabelGreToClient(entry, json) {
// - reference objects that may be deleted

if (msg.gameStateMessage.turnInfo != undefined) {
if (msg.gameStateMessage.turnInfo.priorityPlayer !== turnPriority) {
changePriority(msg.gameStateMessage.turnInfo.priorityPlayer, turnPriority, logTime);
}
prevTurn = turnNumber;
turnPhase = msg.gameStateMessage.turnInfo.phase;
turnStep = msg.gameStateMessage.turnInfo.step;

0 comments on commit d97fa71

Please sign in to comment.