Coins in Level Analysis (#140)

This commit is contained in:
Justin Pridgen 2021-04-02 10:32:10 -04:00 committed by GitHub
parent 28daa03c50
commit e1f81b1f5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View file

@ -78,6 +78,7 @@ function analyze_level(level, rawData) {
const header = data.shift();
let level_portals = [];
let level_coins = [];
let level_text = [];
let orb_array = {};
@ -94,6 +95,9 @@ function analyze_level(level, rawData) {
if (id in ids.portals) {
obj.portal = ids.portals[id];
level_portals.push(obj);
} else if (id in ids.coins) {
obj.coin = ids.coins[id];
level_coins.push(obj);
} else if (id in ids.orbs) {
obj.orb = ids.orbs[id];
@ -153,6 +157,8 @@ function analyze_level(level, rawData) {
response.settings = {}
response.portals = level_portals.sort(function (a, b) {return parseInt(a.x) - parseInt(b.x)}).map(x => x.portal + " " + Math.floor(x.x / (Math.max(last, 529.0) + 340.0) * 100) + "%").join(", ")
response.coins = level_coins.sort(function (a, b) {return parseInt(a.x) - parseInt(b.x)}).map(x => x.coin + " " + Math.floor(x.x / (Math.max(last, 529.0) + 340.0) * 100) + "%").join(", ")
response.coinsVerified = level.verifiedCoins
response.orbs = orb_array
response.orbs.total = Object.values(orb_array).reduce((a, x) => a + x, 0); // we already have an array of objects, use it

View file

@ -6,7 +6,7 @@
<meta id="meta-desc" property="og:description" content="Analyze a Geometry Dash level and view it's objects, portals, color channels, code, and more!">
<meta id="meta-image" name="og:image" itemprop="image" content="https://gdbrowser.com/assets/cp.png">
<meta name="twitter:card" content="summary">
<link href="../assets/css/browser.css?v=2" type="text/css" rel="stylesheet">
<link href="../assets/css/browser.css" type="text/css" rel="stylesheet">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-135255146-3"></script><script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-135255146-3');</script>
<link rel="icon" href="../assets/cp.png">
</head>
@ -44,6 +44,9 @@
<h3 style="margin-top: -0.25%" id="hdText"></h3>
</div>
<h1 class="topMargin" id="coinText">Coin order</h1>
<div class="transparentBox analysis" id="coins"></div>
<h1 class="topMargin">Portal order</h1>
<div class="transparentBox analysis" id="portals" style="height: 23%"></div>
<div>
@ -144,6 +147,7 @@ let blockList = Object.keys(res.blocks)
let colorList = Object.keys(res.colors)
let portals = res.portals.split(", ").map(x => x.split(" "))
let coins = res.coins.split(", ").map(x => x.split(" "))
function commafy(num) { return (+num || 0).toString().replace(/(\d)(?=(\d\d\d)+$)/g, "$1,") }
@ -169,6 +173,14 @@ function appendPortals() {
appendPortals()
coins.forEach(x => {
if (!x || x[0] == "") {
$('#coinText').remove()
$('#coins').remove()
}
else $('#coins').append(`<div class="inline coinDiv"><img height="40%" src='../assets/${res.coinsVerified ? "silvercoin" : "browncoin"}.png'><h3>${x[1]}</h3></div>`)
})
triggerList.forEach(x => {
if (x == "total") $('#triggerText').text(`Triggers (${commafy(res.triggers[x])})`)
else $('#triggers').append(`<div class="inline triggerDiv"><img height="50%" src='../assets/objects/triggers/${x}.png'><h3 style="padding-top: 7%">x${commafy(res.triggers[x])}</h3></div>`)
@ -311,4 +323,4 @@ appendPortals()
});
</script>
</script>

View file

@ -20,6 +20,10 @@
"1334": "4x"
},
"coins": {
"1329": "coin"
},
"orbs": {
"36": "yellow",
"84": "blue",
@ -109,4 +113,4 @@
"monsters": ["Monsters", 918, 1327, 1328, 1584],
"fires": ["Fire", 920, 923, 924, 921]
}
}
}