+
@@ -78,8 +77,19 @@
{{ index + 1 }} |
- {{ namePair[0].english_name }} {{ namePair[1].english_name }} |
- {{ namePair[0].anglish_name }} {{ namePair[1].anglish_name }} |
+
+ {{ namePair[0].english_name }} {{ namePair[1].english_name }}
+ |
+
+ {{ namePair[0].english_name }}
+ |
+
+
+ {{ namePair[0].anglish_name }} {{ namePair[1].anglish_name }}
+ |
+
+ {{ namePair[0].anglish_name }}
+ |
@@ -91,6 +101,7 @@ import { ref, type Ref } from 'vue';
let names: Ref
= ref({});
let generatedNamesTable: Ref = ref([]);
+let filteredNamesTable: Ref = ref([]);
interface NameEntry {
"english_name": string,
@@ -108,7 +119,7 @@ interface NamesDict {
}
async function getNames() {
- const res = await fetch("../../anglish_given_names.json");
+ const res = await fetch("/anglish_given_names.json");
await res.json().then((data: NamesDict) => {
names.value = data;
console.log("Loaded names!");
@@ -131,47 +142,78 @@ let namesToGenerate: Ref = ref(1);
function generateFirstName(num: number) {
let namesPool: Array = [];
- if (livingNamesUsed) {
+ if (livingNamesUsed.value) {
+ console.log("Living names used!");
namesPool = [
...names.value["Living"],
...namesPool,
]
}
- if (quickenedNamesUsed) {
+ if (quickenedNamesUsed.value) {
+ console.log("Quickened names used!");
namesPool = [
...names.value["Quickened"],
...namesPool,
]
}
- if (frozenNamesUsed) {
+ if (frozenNamesUsed.value) {
+ console.log("Frozen names used!");
namesPool = [
...names.value["Frozen"],
...namesPool,
]
}
- if (unfoundedNamesUsed) {
+ if (unfoundedNamesUsed.value) {
+ console.log("Unfounded names used!");
namesPool = [
...names.value["Unfounded"],
...namesPool,
]
}
+ // Filter them by sex
+ namesPool = namesPool.filter((name) => {
+ if (sex.value == 0) {
+ return name;
+ } else if ((name.kind == "Male" || name.kind == "Unisex") && sex.value == 1) {
+ return name;
+ } else if ((name.kind == "Female" || name.kind == "Unisex") && sex.value == 2) {
+ return name;
+ }
+ // else {
+ // console.log(`Name did not match: ${name.english_name}\nkind: ${name.kind}\nsex value: ${sex.value}`);
+ // }
+ });
+
let generatedNames: Array = [];
for (let i = 0; i < num; i++) {
- generatedNames.push(
- namesPool[(Math.floor(Math.random() * namesPool.length))]
- );
+ let name = namesPool[(Math.floor(Math.random() * namesPool.length))];
+
+ // do {
+ // if (name.kind == "Unisex" && sex.value == 0) {
+ // break;
+ // } else if (name.kind == "Male" && sex.value == 1) {
+ // break;
+ // } else if (name.kind == "Female" && sex.value == 2) {
+ // break;
+ // } else {
+ // console.log(`Name did not match: ${name.english_name}\nkind: ${name.kind}\nsex value: ${sex.value}`);
+ // name = namesPool[(Math.floor(Math.random() * namesPool.length))];
+ // }
+ // } while (true);
+
+ generatedNames.push(name);
}
return generatedNames;
}
function generateLastName(num: number) {
- if (!lastNamesUsed) {
+ if (!lastNamesUsed.value) {
return [];
}
@@ -195,6 +237,8 @@ function generateNames() {
const firstNames = generateFirstName(numberOfNames);
const lastNames = generateLastName(numberOfNames);
+ // If male or female or unisex etc
+
const zippedNames = firstNames.map((left, idx) => [left, lastNames[idx]]);
// console.log(zippedNames);