Add common name roots and implement a uniform random generation

This commit is contained in:
Tissevert 2020-08-13 18:30:29 +02:00
parent d44b8258f5
commit d1383c5dc0
2 changed files with 66 additions and 1 deletions

View file

@ -1,8 +1,17 @@
import Roots;
var generate = document.getElementById('generate'); var generate = document.getElementById('generate');
var result = document.getElementById('result'); var result = document.getElementById('result');
function random(roots) {
var i = Math.floor(roots.length * Math.random());
return roots[i];
}
function name() { function name() {
return "machin"; var prefix = random(Roots.prefixes);
var suffix = random(Roots.suffixes);
return prefix + suffix;
} }
generate.addEventListener('click', function() { generate.addEventListener('click', function() {

56
src/Roots.js Normal file
View file

@ -0,0 +1,56 @@
var prefixes = [
"Adal",
"Aethel",
"Agil",
"Anse",
"Berthe",
"Chagn",
"Chil",
"Childe",
"Chro",
"Clo",
"Dago",
"Ermen",
"Fré",
"Frédé",
"Gonde",
"Hil",
"Hilde",
"Huc",
"Liud",
"Rad",
"Ro",
"Sig",
"Théo",
"Theut",
"Wil"
];
var suffixes = [
"ald",
"bald",
"baud",
"berge",
"béron",
"bert",
"fried",
"garde",
"gaire",
"gisèle",
"gonde",
"haut",
"hilde",
"mar",
"mir",
"ric",
"taire",
"trude",
"vis",
"vald",
"wulf"
];
return {
prefixes: prefixes,
suffixes: suffixes
};