Skip to content

Commit

Permalink
show island count in sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanBlumLevine committed Feb 5, 2023
1 parent f267e78 commit ea9ef95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/visualizer/src/main/looper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class Looper {
teamNames.push(meta.teams[team].name)
teamIDs.push(meta.teams[team].teamID)
}
this.stats.initializeGame(teamNames, teamIDs)
this.stats.initializeGame(teamNames, teamIDs, match.current.mapStats.island_stats.size)
const extraInfo = (this.mapinfo ? this.mapinfo + "\n" : "") + (this.conf.doingRotate ? " (Map rotated and flipped! Disable for new matches with 'Z'.)" : "")
this.stats.setExtraInfo(extraInfo)
if (!showTourneyUpload) this.stats.hideTourneyUpload()
Expand Down
15 changes: 12 additions & 3 deletions client/visualizer/src/sidebar/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class Stats {

let teamNames: Array<string> = ["?????", "?????"];
let teamIDs: Array<number> = [1, 2];
this.initializeGame(teamNames, teamIDs);
this.initializeGame(teamNames, teamIDs, 0);
}

/**
Expand Down Expand Up @@ -179,6 +179,12 @@ export default class Stats {
return table;
}

private initIslandCount(islands: number){
let wrapper = document.createElement("div");
wrapper.innerHTML = `<b>${islands} islands</b> (${Math.ceil(islands * .75)} to win)`
return wrapper;
}

private initRelativeBars(teamIDs: Array<number>) {
let metalIDs = [0, 1, 2];
let colors = ["#963749", "#25b5bc", "#f413b1"];
Expand Down Expand Up @@ -448,7 +454,7 @@ export default class Stats {
/**
* Clear the current stats bar and reinitialize it with the given teams.
*/
initializeGame(teamNames: Array<string>, teamIDs: Array<number>) {
initializeGame(teamNames: Array<string>, teamIDs: Array<number>, islands: number) {
// Remove the previous match info
while (this.div.firstChild) {
this.div.removeChild(this.div.firstChild);
Expand Down Expand Up @@ -510,6 +516,9 @@ export default class Stats {
this.div.appendChild(teamDiv);
}


this.div.appendChild(document.createElement("hr"));
this.div.append(this.initIslandCount(islands))
this.div.appendChild(document.createElement("hr"));

// Add stats table
Expand Down Expand Up @@ -541,7 +550,7 @@ export default class Stats {
const relativeBarsParent = document.createElement("tbody");
relativeBarsParent.style.width = "100%";
relativeBarsTable.appendChild(relativeBarsParent);
this.div.appendChild(relativeBarsTable);
this.div.appendChild(relativeBarsTable);

this.relativeBars = this.initRelativeBars(teamIDs);
const relativeBarsElements = [
Expand Down

0 comments on commit ea9ef95

Please sign in to comment.