@ing.jorgeu/wargaming-overlay 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -14
- package/announcements.js +130 -0
- package/battle_reader.py +9 -0
- package/data/faction-facts.json +6118 -0
- package/factions.js +20 -0
- package/game-store.js +4 -1
- package/listhammer.js +106 -0
- package/package.json +10 -3
- package/public/announcements-control.js +57 -0
- package/public/control.html +10 -1
- package/public/control.js +40 -20
- package/public/factions.json +39 -0
- package/public/live-score.js +2 -4
- package/public/match-view.js +26 -0
- package/public/overlay-art.html +1 -1
- package/public/style.css +9 -0
- package/public/toast.css +14 -0
- package/public/toast.js +21 -0
- package/scripts/fact-coverage.js +9 -0
- package/server.js +49 -4
- package/turn-tracker.js +37 -0
package/turn-tracker.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Accessibility snapshots can be partial. Only increases of previously seen
|
|
2
|
+
// values are activity; discovering a mission while scrolling is not activity.
|
|
3
|
+
function inferTurn(previous, incoming, samePlayers) {
|
|
4
|
+
const fresh={firstPlayer:null,activePlayer:null,half:null,highestRound:incoming.round,eligible:incoming.round===1 && incoming.players.every(p=>p.score===0),seen:{},reason:'Esperando actividad para detectar el turno'};
|
|
5
|
+
let t=samePlayers && previous.turn ? structuredClone(previous.turn) : fresh;
|
|
6
|
+
if(incoming.round<t.highestRound) return {...t,reason:'Ronda histórica: turno sin determinar'};
|
|
7
|
+
if(incoming.round>t.highestRound){t={...t,highestRound:incoming.round,eligible:true,seen:{},activePlayer:null,half:null};}
|
|
8
|
+
const events=[];
|
|
9
|
+
for(const p of incoming.players){
|
|
10
|
+
const old=t.seen[p.name]||{},next={...old};let activity=false;
|
|
11
|
+
const values={};
|
|
12
|
+
for(const key of ['primary','secondary']) if(Number.isFinite(p[key]?.score))values[key]=p[key].score;
|
|
13
|
+
if(Number.isFinite(p.score))values.score=p.score;
|
|
14
|
+
for(const m of p.secondaries||[])if(Number.isFinite(m.score))values[`mission:${m.name}`]=m.score;
|
|
15
|
+
for(const m of p.primaryObjectives||[]){
|
|
16
|
+
if(m.checked!=null)values[`checked:${m.name}`]=Number(m.checked);
|
|
17
|
+
if(Number.isFinite(m.counter))values[`counter:${m.name}`]=m.counter;
|
|
18
|
+
}
|
|
19
|
+
for(const [key,value] of Object.entries(values)){
|
|
20
|
+
if(Number.isFinite(old[key]) && value>old[key])activity=true;
|
|
21
|
+
next[key]=value;
|
|
22
|
+
}
|
|
23
|
+
t.seen[p.name]=next;
|
|
24
|
+
if(activity)events.push(p.name);
|
|
25
|
+
}
|
|
26
|
+
if(events.length===1){
|
|
27
|
+
const name=events[0];
|
|
28
|
+
if(!t.firstPlayer && t.eligible)t.firstPlayer=name;
|
|
29
|
+
t.activePlayer=name;
|
|
30
|
+
// Bottom is terminal for this round: delayed scoring cannot rewind it.
|
|
31
|
+
if(t.firstPlayer && t.half!=='bottom')t.half=name===t.firstPlayer?'top':'bottom';
|
|
32
|
+
t.reason=t.half?'Turno inferido por actividad de puntuación':`Actividad de ${name}; esperando conocer el orden de juego`;
|
|
33
|
+
}
|
|
34
|
+
if(events.length>1)t.reason='Cambios en ambos jugadores; se conserva el último turno detectado';
|
|
35
|
+
return t;
|
|
36
|
+
}
|
|
37
|
+
module.exports={inferTurn};
|