Pages affected by Ethics enum renaming

This commit is contained in:
Neshura 2023-08-15 22:51:28 +02:00
parent 716fc71282
commit 84301ecd0a
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
2 changed files with 24 additions and 24 deletions

View file

@ -1,6 +1,6 @@
<script lang="ts">
import { Bar } from 'svelte-chartjs';
import { Ethics, EthicsDataLegacy } from '$lib/types/stellaris';
import { LegacyEthics, EthicsDataLegacy } from '$lib/types/stellaris';
import { Chart as ChartJS, registerables } from 'chart.js';
@ -14,7 +14,7 @@
const parseEthicsData = (data: Array<Array<number>>) => {
let parsedEthicsData: Array<EthicsDataLegacy> = new Array<EthicsDataLegacy>();
Object.keys(Ethics).forEach((ethic: number | string) => {
Object.keys(LegacyEthics).forEach((ethic: number | string) => {
if (Number.isInteger(Number(ethic))) {
parsedEthicsData[Number(ethic)] = new EthicsDataLegacy(data[Number(ethic)]);
}
@ -29,12 +29,12 @@
ethicsData.forEach((ethicsData, index) => {
sumArray[index] = ethicsData.sum(false);
labelArray[index] = Ethics[index];
labelArray[index] = LegacyEthics[index];
});
let zipped: Array<{ sums: number; labels: string }> = [];
for (let i = 0; i < ethicsData.length; i++) {
zipped.push({ sums: ethicsData[i].sum(false), labels: Ethics[i] });
zipped.push({ sums: ethicsData[i].sum(false), labels: LegacyEthics[i] });
}
zipped.sort((a: { sums: number; labels: string }, b: { sums: number; labels: string }) =>
a.sums > b.sums ? -1 : 1

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { writable, type Writable } from "svelte/store";
import { Radar } from 'svelte-chartjs';
import { Ethics, EthicsDataLegacy } from '$lib/types/stellaris';
import { LegacyEthics, EthicsDataLegacy } from '$lib/types/stellaris';
import { Chart as ChartJS, registerables } from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
@ -16,7 +16,7 @@
const parseEthicsData = (data: Array<Array<number>>) => {
let parsedEthicsData: Array<EthicsDataLegacy> = new Array<EthicsDataLegacy>();
Object.keys(Ethics).forEach((ethic: number | string) => {
Object.keys(LegacyEthics).forEach((ethic: number | string) => {
if (Number.isInteger(Number(ethic))) {
parsedEthicsData[Number(ethic)] = new EthicsDataLegacy(data[Number(ethic)]);
}
@ -44,23 +44,23 @@
let sumRegularArray = new Array<number>();
const labelsArray = [
Ethics.Egalitarian,
Ethics.Militarist,
Ethics.Xenophobe,
Ethics.Competitive,
Ethics.Elitist,
Ethics.Materialist,
Ethics.Ecologist,
Ethics.Authoritarian,
Ethics.Pacifist,
Ethics.Xenophile,
Ethics.Cooperative,
Ethics.Pluralist,
Ethics.Spiritualist,
Ethics.Industrialist
LegacyEthics.Egalitarian,
LegacyEthics.Militarist,
LegacyEthics.Xenophobe,
LegacyEthics.Competitive,
LegacyEthics.Elitist,
LegacyEthics.Materialist,
LegacyEthics.Ecologist,
LegacyEthics.Authoritarian,
LegacyEthics.Pacifist,
LegacyEthics.Xenophile,
LegacyEthics.Cooperative,
LegacyEthics.Pluralist,
LegacyEthics.Spiritualist,
LegacyEthics.Industrialist
];
labelsArray.forEach((ethic: Ethics, index: number) => {
labelsArray.forEach((ethic: LegacyEthics, index: number) => {
sumTotalArray[index] = ethicsData[ethic].sum(weighted);
sumRegularArray[index] = ethicsData[ethic].sumRegular();
});
@ -74,7 +74,7 @@
scaleLimit % 2 == 0 ? (scaleLimit = scaleLimit) : (scaleLimit = scaleLimit + 1);
const chart_data = {
labels: labelsArray.map((ethic) => Ethics[ethic]),
labels: labelsArray.map((ethic) => LegacyEthics[ethic]),
datasets: [
{
label: 'Total Ethics',
@ -133,7 +133,7 @@
};
function updateChartData() {
labelsArray.forEach((ethic: Ethics, index: number) => {
labelsArray.forEach((ethic: LegacyEthics, index: number) => {
sumTotalArray[index] = ethicsData[ethic].sum(weighted);
});
@ -158,7 +158,7 @@
<Radar data={chart_data} {options} />
<label>
<input type="checkbox" bind:checked={weighted} on:change={updateChartData} />
Use weighted Ethics
Use weighted LegacyEthics
</label>
</div>