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
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))
} }
async function createBar() { async function parseStats(stats) {
let values = {
valuedropped: [],
datasdropped: [],
valueused: [],
datasused: [],
const data = { valuecrafted: [],
labels: ["Смерти"], datascrafted: [],
datasets: [ valuekilled_by: [],
{ dataskilled_by: [],
label: "neroduckale", valuebroken: [],
data: [nrdkstats["stats"]["minecraft:custom"]["minecraft:deaths"]], datasbroken: [],
backgroundColor: "#34b8e9", valuepicked_up: [],
borderColor: "#ffffff", dataspicked_up: [],
hoverOffset: 6, valuemined: [],
}, datasmined: [],
{ valuekilled: [],
label: "ygolek", dataskilled: [],
data: [ygolekstats["stats"]["minecraft:custom"]["minecraft:deaths"]], };
backgroundColor: "#e00000", // SORTING
borderColor: "#ffffff", keysToSort.forEach((key) => {
hoverOffset: 6, 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])
}; );
const config = { }
type: "bar", });
data: data,
options: { //parsing
plugins: { keysToSort.forEach((key) => {
legend: { let statistic = stats["stats"][key];
labels: { statistic = Object.fromEntries(Object.entries(statistic).slice(0, 10));
color: "white", 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);
let canvas = document.getElementById("sravn"); });
let chart = new Chart(canvas, config)
} }
function translate(item, type) {
if (item.includes("minecraft:") === false) { async function createPie(items, datas, idcanvas) {
return item;
} await charts.forEach((chart) => {
let r; chart.destroy();
switch (type) { })
case "minecraft:killed_by": let bgcol = palette("tol-rainbow", items.length);
r = locale["entity." + item]; for (let i = 0; i < bgcol.length; i++) {
return r; bgcol[i] = "#" + bgcol[i];
case "minecraft:broken": }
r = locale["item." + item] bgcol = bgcol.reverse();
return r
case "minecraft:used": const data = {
r = locale["item." + item] labels: items,
if (r === undefined) { datasets: [
r = locale["block." + item]; {
} label: "количество",
return r data: datas,
case "minecraft:killed": backgroundColor: bgcol,
r = locale["entity." + item] hoverOffset: 6,
return r },
case "minecraft:dropped": ],
r = locale["item." + item]; };
if (r === undefined) { const config = {
r = locale["block." + item]; type: "doughnut",
} data: data,
return r options: {
case "minecraft:crafted": plugins: {
r = locale["item." + item] legend: {
if (r === undefined) { labels: {
r = locale["block." + item]; color: "white",
} },
return r },
case "minecraft:picked_up": },
r = locale["item." + item] },
if (r === undefined) { };
r = locale["block." + item]; let canvas = document.getElementById(idcanvas);
} charts.push(new Chart(canvas, config))
return r }
case "minecraft:mined":
r = locale["block." + item] async function createBar(value1, value2, stat) {
return r 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 () { $('#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");