Skip to content

Commit

Permalink
fixed predictions
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Aug 17, 2021
1 parent 7ef5688 commit 31e7ef2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 51 deletions.
5 changes: 2 additions & 3 deletions public/obs/scores.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
<script type="text/javascript" src="obs.js"></script>
<script>
recievedData.registerListener((newVal) => {
const { genset, teams, settings } = newVal
const { genset, teams, settings, boAmount } = newVal
const finalTeam = settings.reversed
? [teams[1], teams[0]]
: [teams[0], teams[1]]
document.documentElement.style.setProperty(
"--colour-scheme",
genset.useVOTColours ? "#fd4453" : genset.customColour
)
document.getElementById("bestOf").innerHTML =
"BO" + teams[0].score.length
document.getElementById("bestOf").innerHTML = "BO" + boAmount
document.getElementById("rightTeam").innerHTML =
finalTeam[1].short.toUpperCase()
document.getElementById("leftTeam").innerHTML =
Expand Down
2 changes: 1 addition & 1 deletion src/apis/twitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const submitPrediction = (selected, predLength) => {
.toArray((arr) => {
return (map = arr[selected.map])
})
.then(() => db.teams.bulkGet([0, 1]))
.then(() => db.teams.bulkGet([0, 1, 2]))
.then((arr) => (teams = arr))
.then(() => db.userSessions.get("twitch"))
.then((obj) => (twitch = obj))
Expand Down
63 changes: 16 additions & 47 deletions src/webrtc/send.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import urlExist from "url-exist"
import db from "../db/db"
import { connections } from "./connect"

Expand All @@ -19,50 +18,16 @@ export function sendScores(protocol = "") {
}

async function logoURL(name, tinx) {
const fName = name.replace(/\s+/g, "-").toLowerCase()
const logoDBs = [
`https://raw.githubusercontent.com/lootmarket/esport-team-logos/master/valorant/${fName}/${fName}-logo.png?raw=true`,
`https://raw.githubusercontent.com/TateB/esportslogos/main/oceania/${fName}/${fName}.square.png?raw=true`,
]

return db.teams
.get(tinx)
.then((sTeam) => {
const link = sTeam.iconLink.split("/")
const linkName = link[link.length - 2]
return linkName === fName ? sTeam.iconLink : false
})
.then((isSame) => {
if (isSame) {
return [isSame]
}
return Promise.all(
logoDBs.map(async (val) => ((await urlExist(val)) ? val : null))
)
})
.then((nulls) => nulls.filter((x) => x !== null))
.then((urlChqd) => {
global.log(urlChqd)
return urlChqd[0]
? db.teams
.update(tinx, { iconLink: urlChqd[0] })
.then(() => urlChqd[0])
: "icons/default.png"
})
.then((url) => {
return db.settings.get("general").then((genset) => {
if (tinx === 0 && genset.settings.useTeamOneCustomIcon)
return readFile(genset.settings.teamOneCustomIcon[0])
if (tinx === 1 && genset.settings.useTeamTwoCustomIcon)
return readFile(genset.settings.teamTwoCustomIcon[0])
if (url === "icons/default.png") {
return genset.settings.useCustomIcon
? readFile(genset.settings.customIcon[0])
: "icons/default.png"
}
return url
})
})
return db.settings.get("general").then((genset) => {
if (tinx === 0 && genset.settings.useTeamOneCustomIcon)
return readFile(genset.settings.teamOneCustomIcon[0])
if (tinx === 1 && genset.settings.useTeamTwoCustomIcon)
return readFile(genset.settings.teamTwoCustomIcon[0])

return genset.settings.useCustomIcon
? readFile(genset.settings.customIcon[0])
: "icons/default.png"
})
}

var teams, settings, genset
Expand Down Expand Up @@ -97,7 +62,9 @@ export function sendScores(protocol = "") {
.then((newlink) => (teams[0].iconLink = newlink))
.then(() => logoURL(teams[1].name, 1))
.then((newlink) => (teams[1].iconLink = newlink))
.then(() =>
.then(() => db.mapbans.where("isBan").equals(0).toArray())
.then((mbArr) => mbArr.length)
.then((boAmount) =>
connections
.filter((x) =>
protocol === ""
Expand All @@ -107,7 +74,9 @@ export function sendScores(protocol = "") {
.map((x) => {
global.log("mapping for send")
global.log(x)
return x.peer.send(JSON.stringify({ teams, genset, settings }))
return x.peer.send(
JSON.stringify({ teams, genset, settings, boAmount })
)
})
)
})
Expand Down

0 comments on commit 31e7ef2

Please sign in to comment.