diff --git a/nrdkwebsite/Pages/about.cshtml b/nrdkwebsite/Pages/about.cshtml index a6de110..ba7b54d 100644 --- a/nrdkwebsite/Pages/about.cshtml +++ b/nrdkwebsite/Pages/about.cshtml @@ -1,6 +1,6 @@ @page @model About -@ViewData["Title"] = about +@{ ViewData["Title"] = "about"; }

neroduckale.

telegram

diff --git a/nrdkwebsite/Pages/minecraftia.cshtml b/nrdkwebsite/Pages/minecraftia.cshtml index 5dcd7b3..b3fd93f 100644 --- a/nrdkwebsite/Pages/minecraftia.cshtml +++ b/nrdkwebsite/Pages/minecraftia.cshtml @@ -1,11 +1,14 @@ @page @model Minecraftia -@{ViewData["Title"] = "minecraft";} +@{ + ViewData["Title"] = "minecraft"; + string[] custom = ["interact_with_crafting_table", "leave_game", "time_since_death", "damage_resisted", "sprint_one_cm","damage_blocked_by_shield","drop","talked_to_villager","play_time","deaths","jump","walk_on_water_one_cm","enchant_item","interact_with_furnace","sleep_in_bed","waystone_activated","damage_dealt","player_kills","crouch_one_cm","interact_with_smoker","interact_with_smithing_table","interact_with_anvil","mob_kills","damage_dealt_resisted","climb_one_cm","walk_one_cm","sneak_time","walk_under_water_one_cm","boat_one_cm","total_world_time","interact_with_stonecutter","interact_with_grindstone","time_since_rest","damage_absorbed","damage_taken","trigger_trapped_chest","swim_one_cm","fly_one_cm","pig_one_cm","open_chest","fall_one_cm"]; +} -Статистика игрока +Статистика игрока - - + +
Сюда внесены первые десять позиций по количеству, типо какого предмета я скрафтил в больших количествах и так далее
@@ -43,14 +46,27 @@
+ +
- - - +
- - \ No newline at end of file + \ No newline at end of file diff --git a/nrdkwebsite/Pages/ygolek.cshtml b/nrdkwebsite/Pages/ygolek.cshtml index 03f0927..874b4bd 100644 --- a/nrdkwebsite/Pages/ygolek.cshtml +++ b/nrdkwebsite/Pages/ygolek.cshtml @@ -1,5 +1,5 @@ @page @model Ygolek -@ViewData["Title"] = ygolek +@{ ViewData["Title"] = "ygolek";} YGOLEK'S PHOTO \ No newline at end of file diff --git a/nrdkwebsite/wwwroot/js/inventory.js b/nrdkwebsite/wwwroot/js/inventory.js deleted file mode 100644 index e69de29..0000000 diff --git a/nrdkwebsite/wwwroot/js/minecraft.js b/nrdkwebsite/wwwroot/js/minecraft.js index 403b83a..af65dc8 100644 --- a/nrdkwebsite/wwwroot/js/minecraft.js +++ b/nrdkwebsite/wwwroot/js/minecraft.js @@ -1,226 +1,300 @@ import {palette} from "./palette.js"; + +let chart = []; let charts = []; const keysToSort = [ - "minecraft:killed_by", - "minecraft:broken", - "minecraft:used", - "minecraft:killed", - "minecraft:dropped", - "minecraft:crafted", - "minecraft:picked_up", - "minecraft:mined", + "minecraft:killed_by", + "minecraft:broken", + "minecraft:used", + "minecraft:killed", + "minecraft:dropped", + "minecraft:crafted", + "minecraft:picked_up", + "minecraft:mined", ]; - +const custom = [ + "minecraft:interact_with_crafting_table", + "minecraft:leave_game", + "minecraft:time_since_death", + "minecraft:damage_resisted", + "minecraft:sprint_one_cm", + "minecraft:damage_blocked_by_shield", + "minecraft:drop", + "minecraft:talked_to_villager", + "minecraft:play_time", + "minecraft:deaths", + "minecraft:jump", + "minecraft:walk_on_water_one_cm", + "minecraft:enchant_item", + "minecraft:interact_with_furnace", + "minecraft:sleep_in_bed", + "minecraft:waystone_activated", + "minecraft:damage_dealt", + "minecraft:player_kills", + "minecraft:crouch_one_cm", + "minecraft:interact_with_smoker", + "minecraft:interact_with_smithing_table", + "minecraft:interact_with_anvil", + "minecraft:mob_kills", + "minecraft:damage_dealt_resisted", + "minecraft:climb_one_cm", + "minecraft:walk_one_cm", + "minecraft:sneak_time", + "minecraft:walk_under_water_one_cm", + "minecraft:boat_one_cm", + "minecraft:total_world_time", + "minecraft:interact_with_stonecutter", + "minecraft:interact_with_grindstone", + "minecraft:time_since_rest", + "minecraft:damage_absorbed", + "minecraft:damage_taken", + "minecraft:trigger_trapped_chest", + "minecraft:swim_one_cm", + "minecraft:fly_one_cm", + "minecraft:pig_one_cm", + "minecraft:open_chest", + "minecraft:fall_one_cm" +] let nrdkstats; let ygolekstats; let locale; - async function getJson(json) { - let a; - await fetch(`https://neroduck.ru/${json}`, { - method: "GET", - headers: { Accept: "application/json" }, - }) - .then((response) => { - return response.json(); - }) - .then((data) => { - a = data; - }); - return a; + let a; + await fetch(`https://neroduck.ru/${json}`, { + method: "GET", + headers: {Accept: "application/json"}, + }) + .then((response) => { + return response.json(); + }) + .then((data) => { + a = data; + }); + return a; } async function getJsons() { - await getJson("nrdk.json").then((a) => { - nrdkstats = a; - }); - await getJson("ygolek.json").then((a) => { - ygolekstats = a; - }); - await getJson("ru_edited.json").then((a) => { - locale = a; - }); -} -async function parseStats(stats) { - let values = { - valuedropped: [], - datasdropped: [], - valueused: [], - datasused: [], - valuecrafted: [], - datascrafted: [], - valuekilled_by: [], - dataskilled_by: [], - valuebroken: [], - datasbroken: [], - valuepicked_up: [], - dataspicked_up: [], - valuemined: [], - datasmined: [], - valuekilled: [], - dataskilled: [], - }; - // SORTING - keysToSort.forEach((key) => { - if (stats["stats"][key] && typeof stats["stats"][key] === "object") { - stats["stats"][key] = Object.fromEntries( - Object.entries(stats["stats"][key]).sort((a, b) => b[1] - a[1]) - ); - } - }); - - //parsing - keysToSort.forEach((key) => { - let statistic = stats["stats"][key]; - statistic = Object.fromEntries(Object.entries(statistic).slice(0, 10)); - let keyy = key.replace("minecraft:", ""); - for (let item in statistic) { - values["value" + keyy].push(translate(item, key)); - values["datas" + keyy].push(statistic[item]); - } - createPie(values["value" + keyy], values["datas" + keyy], keyy); - }); -} -async function createPie(items, datas, idcanvas) { - - await charts.forEach((chart) => { - chart.destroy(); - }) - - let bgcol = palette("tol-rainbow", items.length); - for (let i = 0; i < bgcol.length; i++) { - bgcol[i] = "#" + bgcol[i]; - } - bgcol = bgcol.reverse(); - - const data = { - labels: items, - datasets: [ - { - label: "количество", - data: datas, - backgroundColor: bgcol, - hoverOffset: 6, - }, - ], - }; - const config = { - type: "doughnut", - data: data, - options: { - plugins: { - legend: { - labels: { - color: "white", - }, - }, - }, - }, - }; - let canvas = document.getElementById(idcanvas); - charts.push(new Chart(canvas, config)) + await getJson("nrdk.json").then((a) => { + nrdkstats = a; + }); + await getJson("ygolek.json").then((a) => { + ygolekstats = a; + }); + await getJson("ru_edited.json").then((a) => { + locale = a; + }); } -async function createBar() { - - - - - - const data = { - labels: ["Смерти"], - datasets: [ - { - label: "neroduckale", - data: [nrdkstats["stats"]["minecraft:custom"]["minecraft:deaths"]], - backgroundColor: "#34b8e9", - borderColor: "#ffffff", - hoverOffset: 6, - }, - { - label: "ygolek", - data: [ygolekstats["stats"]["minecraft:custom"]["minecraft:deaths"]], - backgroundColor: "#e00000", - borderColor: "#ffffff", - hoverOffset: 6, - }, - ], - }; - const config = { - type: "bar", - data: data, - options: { - plugins: { - legend: { - labels: { - color: "white", - }, - }, - }, - }, - }; - let canvas = document.getElementById("sravn"); - let chart = new Chart(canvas, config) +async function parseStats(stats) { + let values = { + valuedropped: [], + datasdropped: [], + valueused: [], + datasused: [], + valuecrafted: [], + datascrafted: [], + valuekilled_by: [], + dataskilled_by: [], + valuebroken: [], + datasbroken: [], + valuepicked_up: [], + dataspicked_up: [], + valuemined: [], + datasmined: [], + valuekilled: [], + dataskilled: [], + }; + // SORTING + keysToSort.forEach((key) => { + if (stats["stats"][key] && typeof stats["stats"][key] === "object") { + stats["stats"][key] = Object.fromEntries( + Object.entries(stats["stats"][key]).sort((a, b) => b[1] - a[1]) + ); + } + }); + + //parsing + keysToSort.forEach((key) => { + let statistic = stats["stats"][key]; + statistic = Object.fromEntries(Object.entries(statistic).slice(0, 10)); + let keyy = key.replace("minecraft:", ""); + for (let item in statistic) { + values["value" + keyy].push(translate(item, key)); + values["datas" + keyy].push(statistic[item]); + } + createPie(values["value" + keyy], values["datas" + keyy], keyy); + }); } -function translate(item, type) { - if (item.includes("minecraft:") === false) { - return item; - } - let r; - switch (type) { - - case "minecraft:killed_by": - r = locale["entity." + item]; - return r; - case "minecraft:broken": - r = locale["item." + item] - return r - case "minecraft:used": - r = locale["item." + item] - if (r === undefined) { - r = locale["block." + item]; - } - return r - case "minecraft:killed": - r = locale["entity." + item] - return r - case "minecraft:dropped": - r = locale["item." + item]; - if (r === undefined) { - r = locale["block." + item]; - } - return r - case "minecraft:crafted": - r = locale["item." + item] - if (r === undefined) { - r = locale["block." + item]; - } - return r - case "minecraft:picked_up": - r = locale["item." + item] - if (r === undefined) { - r = locale["block." + item]; - } - return r - case "minecraft:mined": - r = locale["block." + item] - return r - } + +async function createPie(items, datas, idcanvas) { + + await charts.forEach((chart) => { + chart.destroy(); + }) + + let bgcol = palette("tol-rainbow", items.length); + for (let i = 0; i < bgcol.length; i++) { + bgcol[i] = "#" + bgcol[i]; + } + bgcol = bgcol.reverse(); + + const data = { + labels: items, + datasets: [ + { + label: "количество", + data: datas, + backgroundColor: bgcol, + hoverOffset: 6, + }, + ], + }; + const config = { + type: "doughnut", + data: data, + options: { + plugins: { + legend: { + labels: { + color: "white", + }, + }, + }, + }, + }; + let canvas = document.getElementById(idcanvas); + charts.push(new Chart(canvas, config)) +} + +async function createBar(value1, value2, stat) { + chart.forEach((a) => { + a.destroy(); + }); + + const data = { + labels: [stat], + datasets: [ + { + label: "neroduckale", + data: [value1], + backgroundColor: "#34b8e9", + borderColor: "#ffffff", + hoverOffset: 6, + }, + { + label: "ygolek", + data: [value2], + backgroundColor: "#e00000", + borderColor: "#ffffff", + hoverOffset: 6, + }, + ], + }; + const config = { + type: "bar", + data: data, + options: { + plugins: { + legend: { + labels: { + color: "white", + }, + }, + }, + }, + }; + let canvas = document.getElementById("stat"); + chart.push(new Chart(canvas, config)); +} + +async function changeBar(value1, value2, stat) { + chart[0].data = { + labels: [stat], + datasets: [ + { + label: "neroduckale", + data: [value1], + backgroundColor: "#34b8e9", + borderColor: "#ffffff", + hoverOffset: 6, + }, + { + label: "ygolek", + data: [value2], + backgroundColor: "#e00000", + borderColor: "#ffffff", + hoverOffset: 6, + }, + ], + }; + chart[0].update(); + //перевод, cm -> blocks +} +function translate(item, type) { + if (item.includes("minecraft:") === false) { + return item; + } + let r; + switch (type) { + + case "minecraft:killed_by": + r = locale["entity." + item]; + return r; + case "minecraft:broken": + r = locale["item." + item] + return r + case "minecraft:used": + r = locale["item." + item] + if (r === undefined) { + r = locale["block." + item]; + } + return r + case "minecraft:killed": + r = locale["entity." + item] + return r + case "minecraft:dropped": + r = locale["item." + item]; + if (r === undefined) { + r = locale["block." + item]; + } + return r + case "minecraft:crafted": + r = locale["item." + item] + if (r === undefined) { + r = locale["block." + item]; + } + return r + case "minecraft:picked_up": + r = locale["item." + item] + if (r === undefined) { + r = locale["block." + item]; + } + return r + case "minecraft:mined": + r = locale["block." + item] + return r + } } $('#ygolek').change(async function () { - await parseStats(ygolekstats); - return false; + await parseStats(ygolekstats); + return false; }); $('#nrdk').change(async function () { - await parseStats(nrdkstats); - return false; + await parseStats(nrdkstats); + return false; +}); + +$('#choose').change(async function (event) { + let a = event.target.value; + await changeBar(nrdkstats["stats"]["minecraft:custom"]["minecraft:" + a], ygolekstats["stats"]["minecraft:custom"]["minecraft:" + a], a) + return false; }); await getJsons(); await parseStats(nrdkstats); -await createBar(); \ No newline at end of file +await createBar(nrdkstats["stats"]["minecraft:custom"]["minecraft:interact_with_crafting_table"], ygolekstats["stats"]["minecraft:custom"]["minecraft:interact_with_crafting_table"], "minecraft:interact_with_crafting_table");