This commit is contained in:
neroduckale 2024-03-17 17:53:40 +05:00
parent e9d7dabd6d
commit 3703dc22f7
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 399E73062E1A3667
5 changed files with 300 additions and 210 deletions

View file

@ -1,6 +1,6 @@
@page @page
@model About @model About
@ViewData["Title"] = about @{ ViewData["Title"] = "about"; }
<div> <div>
<h1>neroduckale.</h1> <h1>neroduckale.</h1>
<h2><a href="https://t.me/neroduck" style="color: #00ff9d">telegram</a></h2> <h2><a href="https://t.me/neroduck" style="color: #00ff9d">telegram</a></h2>

View file

@ -1,11 +1,14 @@
@page @page
@model Minecraftia @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"];
}
Статистика игрока Статистика игрока
<span> <span>
<input type="radio" id="nrdk" name="nickname" checked /><label for="huey">neroduckale</label> <input type="radio" id="nrdk" name="nickname" checked/><label for="nrdk">neroduckale</label>
<input type="radio" id="ygolek" name="nickname"/><label for="huey">ygolek</label> <input type="radio" id="ygolek" name="nickname"/><label for="ygolek">ygolek</label>
</span> </span>
<div>Сюда внесены первые десять позиций по количеству, типо какого предмета я скрафтил в больших количествах и так далее</div> <div>Сюда внесены первые десять позиций по количеству, типо какого предмета я скрафтил в больших количествах и так далее</div>
<div class="grid-cards"> <div class="grid-cards">
@ -43,14 +46,27 @@
</div> </div>
</div> </div>
<select name="choose" id="choose">
@{
foreach (var str in custom)
{
if (custom[0] == str)
{
<option selected> @str </option>
}
else
{
<option>@str</option>
}
}
}
</select>
<div class="stats grid-cards"> <div class="stats grid-cards">
<div class="card"> <div class="card">
<canvas id="sravn"> <canvas id="stat"></canvas>
</canvas>
</div> </div>
</div> </div>
<script type="module" src="https://unpkg.com/chart.js@4.2.1/dist/chart.umd.js"></script> <script type="module" src="https://unpkg.com/chart.js@4.2.1/dist/chart.umd.js"></script>
<script type="module" src="~/js/minecraft.js"></script> <script type="module" src="~/js/minecraft.js"></script>
<script type="module" src="~/js/inventory.js"></script>

View file

@ -1,5 +1,5 @@
@page @page
@model Ygolek @model Ygolek
@ViewData["Title"] = ygolek @{ ViewData["Title"] = "ygolek";}
<img src="~/img/ygolek.jpg" style="width: 75%; height: 500px;" alt="YGOLEK'S PHOTO"/> <img src="~/img/ygolek.jpg" style="width: 75%; height: 500px;" alt="YGOLEK'S PHOTO"/>

View file

@ -1,226 +1,300 @@
import {palette} from "./palette.js"; import {palette} from "./palette.js";
let chart = [];
let charts = []; let charts = [];
const keysToSort = [ const keysToSort = [
"minecraft:killed_by", "minecraft:killed_by",
"minecraft:broken", "minecraft:broken",
"minecraft:used", "minecraft:used",
"minecraft:killed", "minecraft:killed",
"minecraft:dropped", "minecraft:dropped",
"minecraft:crafted", "minecraft:crafted",
"minecraft:picked_up", "minecraft:picked_up",
"minecraft:mined", "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 nrdkstats;
let ygolekstats; let ygolekstats;
let locale; let locale;
async function getJson(json) { async function getJson(json) {
let a; let a;
await fetch(`https://neroduck.ru/${json}`, { await fetch(`https://neroduck.ru/${json}`, {
method: "GET", method: "GET",
headers: { Accept: "application/json" }, headers: {Accept: "application/json"},
}) })
.then((response) => { .then((response) => {
return response.json(); return response.json();
}) })
.then((data) => { .then((data) => {
a = data; a = data;
}); });
return a; return a;
} }
async function getJsons() { async function getJsons() {
await getJson("nrdk.json").then((a) => { await getJson("nrdk.json").then((a) => {
nrdkstats = a; nrdkstats = a;
}); });
await getJson("ygolek.json").then((a) => { await getJson("ygolek.json").then((a) => {
ygolekstats = a; ygolekstats = a;
}); });
await getJson("ru_edited.json").then((a) => { await getJson("ru_edited.json").then((a) => {
locale = 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 async function parseStats(stats) {
keysToSort.forEach((key) => { let values = {
let statistic = stats["stats"][key]; valuedropped: [],
statistic = Object.fromEntries(Object.entries(statistic).slice(0, 10)); datasdropped: [],
let keyy = key.replace("minecraft:", ""); valueused: [],
for (let item in statistic) { datasused: [],
values["value" + keyy].push(translate(item, key)); valuecrafted: [],
values["datas" + keyy].push(statistic[item]); datascrafted: [],
} valuekilled_by: [],
createPie(values["value" + keyy], values["datas" + keyy], keyy); 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) { async function createPie(items, datas, idcanvas) {
await charts.forEach((chart) => { await charts.forEach((chart) => {
chart.destroy(); chart.destroy();
}) })
let bgcol = palette("tol-rainbow", items.length); let bgcol = palette("tol-rainbow", items.length);
for (let i = 0; i < bgcol.length; i++) { for (let i = 0; i < bgcol.length; i++) {
bgcol[i] = "#" + bgcol[i]; bgcol[i] = "#" + bgcol[i];
} }
bgcol = bgcol.reverse(); bgcol = bgcol.reverse();
const data = { const data = {
labels: items, labels: items,
datasets: [ datasets: [
{ {
label: "количество", label: "количество",
data: datas, data: datas,
backgroundColor: bgcol, backgroundColor: bgcol,
hoverOffset: 6, hoverOffset: 6,
}, },
], ],
}; };
const config = { const config = {
type: "doughnut", type: "doughnut",
data: data, data: data,
options: { options: {
plugins: { plugins: {
legend: { legend: {
labels: { labels: {
color: "white", color: "white",
}, },
},
},
}, },
}, };
}, let canvas = document.getElementById(idcanvas);
}; charts.push(new Chart(canvas, config))
let canvas = document.getElementById(idcanvas);
charts.push(new Chart(canvas, config))
} }
async function createBar() { async function createBar(value1, value2, stat) {
chart.forEach((a) => {
a.destroy();
});
const data = {
labels: [stat],
datasets: [
{
const data = { label: "neroduckale",
labels: ["Смерти"], data: [value1],
datasets: [ backgroundColor: "#34b8e9",
{ borderColor: "#ffffff",
label: "neroduckale", hoverOffset: 6,
data: [nrdkstats["stats"]["minecraft:custom"]["minecraft:deaths"]], },
backgroundColor: "#34b8e9", {
borderColor: "#ffffff", label: "ygolek",
hoverOffset: 6, data: [value2],
}, backgroundColor: "#e00000",
{ borderColor: "#ffffff",
label: "ygolek", hoverOffset: 6,
data: [ygolekstats["stats"]["minecraft:custom"]["minecraft:deaths"]], },
backgroundColor: "#e00000", ],
borderColor: "#ffffff", };
hoverOffset: 6, const config = {
}, type: "bar",
], data: data,
}; options: {
const config = { plugins: {
type: "bar", legend: {
data: data, labels: {
options: { color: "white",
plugins: { },
legend: { },
labels: { },
color: "white",
},
}, },
}, };
}, let canvas = document.getElementById("stat");
}; chart.push(new Chart(canvas, config));
let canvas = document.getElementById("sravn"); }
let chart = 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) { function translate(item, type) {
if (item.includes("minecraft:") === false) { if (item.includes("minecraft:") === false) {
return item; return item;
} }
let r; let r;
switch (type) { switch (type) {
case "minecraft:killed_by": case "minecraft:killed_by":
r = locale["entity." + item]; r = locale["entity." + item];
return r; return r;
case "minecraft:broken": case "minecraft:broken":
r = locale["item." + item] r = locale["item." + item]
return r return r
case "minecraft:used": case "minecraft:used":
r = locale["item." + item] r = locale["item." + item]
if (r === undefined) { if (r === undefined) {
r = locale["block." + item]; r = locale["block." + item];
} }
return r return r
case "minecraft:killed": case "minecraft:killed":
r = locale["entity." + item] r = locale["entity." + item]
return r return r
case "minecraft:dropped": case "minecraft:dropped":
r = locale["item." + item]; r = locale["item." + item];
if (r === undefined) { if (r === undefined) {
r = locale["block." + item]; r = locale["block." + item];
} }
return r return r
case "minecraft:crafted": case "minecraft:crafted":
r = locale["item." + item] r = locale["item." + item]
if (r === undefined) { if (r === undefined) {
r = locale["block." + item]; r = locale["block." + item];
} }
return r return r
case "minecraft:picked_up": case "minecraft:picked_up":
r = locale["item." + item] r = locale["item." + item]
if (r === undefined) { if (r === undefined) {
r = locale["block." + item]; r = locale["block." + item];
} }
return r return r
case "minecraft:mined": case "minecraft:mined":
r = locale["block." + item] r = locale["block." + item]
return r return r
} }
} }
$('#ygolek').change(async function () { $('#ygolek').change(async function () {
await parseStats(ygolekstats); await parseStats(ygolekstats);
return false; return false;
}); });
$('#nrdk').change(async function () { $('#nrdk').change(async function () {
await parseStats(nrdkstats); await parseStats(nrdkstats);
return false; 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 getJsons();
await parseStats(nrdkstats); await parseStats(nrdkstats);
await createBar(); 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");