added the ability to customise Settlements

This commit is contained in:
Daniel Stirba 2023-02-06 22:53:52 +11:00
parent e31cac12df
commit e89bfc976a
4 changed files with 152 additions and 14 deletions

View file

@ -1,6 +1,8 @@
export function generateCityName() {
const prefixes = ["camp", "castle", "east", "edge", "ever", "great", "mount", "new", "north", "red", "rose", "south", "west"];
const suffixes = ["wood","avon","bank", "bark", "barrow", "bay", "beach", "bell", "borough","berg", "bourne", "broad", "bridge", "brook", "brough", "burgh", "burn", "bury", "by", "canyon", "caster", "chester", "cliffe", "combe", "cot, cott", "cote", "cove", "creek", "croft", "crook", "dale", "den", "din", "dine", "don", "downs", "falls", "field", "fin", "flats", "ford", "fork", "gate", "grove", "gum", "ham", "harbour", "heights", "hill", "holm", "hurst", "ing", "kirk", "land", "lake", "latch", "lea", "leigh", "ley", "marsh", "mere", "minster", "mond", "mont", "more", "ness", "park", "pilly", "pine", "point", "pond", "ridge", "river", "rock", "sett", "side", "son", "stead", "stoke", "stone", "stow", "terrace", "thorpe", "ton", "tor", "town", "vale", "valley", "view", "village", "ville", "water", "well", "wharf", "wick", "wood", "worth"];
import { cityGeneratorSetting } from "main";
export function generateCityName(settings : cityGeneratorSetting) {
const prefixes = settings.prefixArray;
const suffixes = settings.suffixArray;
const syllables = ["ab", "ac", "al", "am", "an", "ap", "apo", "ar", "arr", "as", "ast", "at", "ate", "au", "av", "ay", "aye", "ba", "be", "ben", "bo", "br", "bri", "bu", "bur", "ca", "cal", "car", "ce", "chi", "ci", "ck", "co", "com", "con", "cor", "cy", "d", "da", "dan", "dar", "de", "den", "di", "do", "dor", "du", "dur", "ed", "el", "en", "eon", "er", "es", "ey", "fa", "far", "fe", "fi", "fin", "fo", "for", "foy", "fr", "fu", "ga", "gal", "ge", "gi", "gil", "gin", "go", "gor", "gr", "gu", "ha", "han", "har", "he", "hi", "hin", "ho", "hoe", "hos", "hu", "ic", "il", "ill", "in", "ing", "ion", "ir", "irk", "is", "ja", "je", "jen", "jo", "ju", "ka", "ke", "ker", "ki", "kir", "ko", "la", "lan", "las", "le", "ler", "li", "lin", "lis", "lo", "lor", "loy", "lu", "ma", "mac", "mal", "man", "mas", "me", "mi", "mo", "mon", "mu", "mul", "mur", "na", "nal", "ne", "ni", "no", "nor", "nov", "nu", "och", "ode", "oka", "ol", "ome", "on", "op", "or", "ore", "os", "ou", "ous", "pa", "par", "pe", "pen", "pi", "po", "pol", "pon", "por", "pu", "qu", "ra", "re", "ri", "ro", "ru", "sa", "se", "si", "so", "su", "ta", "te", "ti", "to", "tu", "ul", "un", "ur", "us", "va", "ve", "vi", "vo", "vu", "wa", "we", "wi", "wo", "wu", "y", "ya", "ye", "yi", "yo", "yu", "za", "ze", "zi", "zo"];

126
main.ts
View file

@ -8,14 +8,26 @@ export type currency = {
rarity: string
}
export type cityGeneratorSetting = {
prefixArray: string[],
suffixArray: string[]
}
interface MyPluginSettings {
enableCurrency: boolean;
enableSettlementSettings: boolean;
citySettings: cityGeneratorSetting;
currencyTypes: currency[];
currencyFrequency: number;
}
const DEFAULT_SETTINGS: MyPluginSettings = {
enableCurrency: false,
enableSettlementSettings:false,
citySettings: {
prefixArray: ["camp", "castle", "east", "edge", "ever", "great", "mount", "new", "north", "red", "rose", "south", "west"],
suffixArray: ["wood","avon","bank", "bark", "barrow", "bay", "beach", "bell", "borough","berg", "bourne", "broad", "bridge", "brook", "brough", "burgh", "burn", "bury", "by", "canyon", "caster", "chester", "cliffe", "combe", "cot", "cott", "cote", "cove", "creek", "croft", "crook", "dale", "den", "din", "dine", "don", "downs", "falls", "field", "fin", "flats", "ford", "fork", "gate", "grove", "gum", "ham", "harbour", "heights", "hill", "holm", "hurst", "ing", "kirk", "land", "lake", "latch", "lea", "leigh", "ley", "marsh", "mere", "minster", "mond", "mont", "more", "ness", "park", "pilly", "pine", "point", "pond", "ridge", "river", "rock", "sett", "side", "son", "stead", "stoke", "stone", "stow", "terrace", "thorpe", "ton", "tor", "town", "vale", "valley", "view", "village", "ville", "water", "well", "wharf", "wick", "wood", "worth"],
},
currencyTypes: [{
"name": "GP",
"rarity": "rare"
@ -96,12 +108,21 @@ class SampleSettingTab extends PluginSettingTab {
this.plugin = plugin;
}
convertStringToArray(string:string, arr:string[]): void {
const newString = string.replace(/\s/g, '');
const array = newString.split(',');
array.forEach((el) => {
arr.push(el);
})
}
display(): void {
const {containerEl} = this;
containerEl.empty();
containerEl.createEl('h2', {text: 'Fantasy Content Generator'});
containerEl.createEl('h2', { text: 'Fantasy Content Generator' });
containerEl.createEl("h3", { text: "Currency Settings" });
new Setting(containerEl)
.setName('Enable Currency for Loot Generation.')
@ -157,11 +178,14 @@ class SampleSettingTab extends PluginSettingTab {
})
})
containerEl.createEl("h3", { text: "Added Currency" });
containerEl.createEl("h4", { text: "Added Currency" });
containerEl.createEl("p", { text: "Click remove on a currency you would like to removed" });
const foldDiv = containerEl.createEl('details',{cls: "OFCGDetails"});
foldDiv.createEl("summary", { text: "Currency", cls: "OFCGSummary" });
for (let index = 0; index < this.plugin.settings.currencyTypes.length; index++) {
new Setting(containerEl)
new Setting(foldDiv)
.setName(this.plugin.settings.currencyTypes[index].name)
.addButton((btn) => btn
.setCta()
@ -176,5 +200,101 @@ class SampleSettingTab extends PluginSettingTab {
}
}
containerEl.createEl("h3", { text: "Settlement Settings" });
new Setting(containerEl)
.setName('Enable Custom Data for Settlement Generation.')
.setDesc('Want to give your own Custom settlement prefixes or suffixes this is the option for you')
.addToggle((toggle) => {
toggle.setValue(this.plugin.settings.enableSettlementSettings);
toggle.onChange(async (value) => {
this.plugin.settings.enableSettlementSettings = value;
this.display();
await this.plugin.saveSettings();
})
})
if (this.plugin.settings.enableSettlementSettings) {
let preText = "";
let sufText = "";
containerEl.createEl("h4", { text: "Prefixes being used" });
new Setting(containerEl)
.setName("New Prefix:")
.addTextArea((text) => {
text.onChange((value) => {
preText = value;
})
})
.addButton((btn) => {
btn.setCta().setButtonText("Add")
.onClick(async () => {
this.convertStringToArray(preText, this.plugin.settings.citySettings.prefixArray);
this.display();
await this.plugin.saveSettings();
})
})
containerEl.createEl("p", { text: "Click 'remove' on a prefix you would like to removed" });
const foldDiv = containerEl.createEl('details',{cls: "OFCGDetails"});
foldDiv.createEl("summary", { text: "Prefixes", cls: "OFCGSummary" });
for (let index = 0; index < this.plugin.settings.citySettings.prefixArray.length; index++) {
new Setting(foldDiv)
.setName(this.plugin.settings.citySettings.prefixArray[index])
.addButton((btn) => btn
.setCta()
.setButtonText("Remove")
.onClick(async() => {
this.plugin.settings.citySettings.prefixArray.splice(index, 1);
this.display();
await this.plugin.saveSettings();
})
)
}
containerEl.createEl('hr');
containerEl.createEl("h4", { text: "Suffixes being used" });
new Setting(containerEl)
.setName("New Suffix:")
.addTextArea((text) => {
text.onChange((value) => {
sufText = value;
})
})
.addButton((btn) => {
btn.setCta().setButtonText("Add")
.onClick(async () => {
this.convertStringToArray(sufText, this.plugin.settings.citySettings.suffixArray);
this.display();
await this.plugin.saveSettings();
})
})
containerEl.createEl("p", { text: "Click 'remove' on a suffix you would like to removed" });
const foldDiv2 = containerEl.createEl('details',{cls: "OFCGDetails"});
foldDiv2.createEl("summary", { text: "Suffixes", cls: "OFCGSummary" });
for (let index = 0; index < this.plugin.settings.citySettings.suffixArray.length; index++) {
new Setting(foldDiv2)
.setName(this.plugin.settings.citySettings.suffixArray[index])
.addButton((btn) => btn
.setCta()
.setButtonText("Remove")
.onClick(async() => {
this.plugin.settings.citySettings.suffixArray.splice(index, 1);
this.display();
await this.plugin.saveSettings();
})
)
}
}
}
}

View file

@ -18,9 +18,10 @@ import MyPlugin from "main";
import { generateInn } from "generators/inn";
import { generatePathfinderName } from "generators/Pathfinder/pathfinderName";
import { ISettlementDomainObject } from "fantasy-content-generator/dist/interfaces";
import { generateMiscellaneousArtifacts } from "generators/artifact";
const races: string[] = ["none","none", "inn", "settlement", "none", "airships", "drinks", "loot", "metals", "magicaltrees", "ship", "none", "animalgroups", "groups", "religion", "none", "aasimars", "catfolk", "fetchlings","halfelf","halforc","hobgoblin","ifrits","kobalds","oreads","ratfolk","sylphs","tengu","tians","tiefling","undines","angel", "cavePerson", "darkelf", "demon", "dragon", "drow", "dwarf", "elf", "fairy", "gnome", "goblin", "halfdemon", "halfling", "highelf", "highfairy", "human", "ogre", "orc"];
const racesDisplayName: string[] = ["Select a Generator to Start","--[Settlements and Buildings]--", "Inn's & Taverns", "Settlement", "--[Objects and Vehicles]--", "Airships", "Drinks", "Loot And Treasure", "Metals", "Magical Trees", "Ship", "--[Groups and Religions]--", "Animal Groups", "Groups", "Religion", "--[Races]--", "Aasimars", "Catfolk", "Fetchlings","Half-Elf","Half-Orc","Hobgoblin","Ifrits","Kobalds","Oreads","Ratfolk","Sylphs","Tengu","Tians","Tiefling","Undines","Angel", "Cave Person", "Dark Elf", "Demon", "Dragon", "Drow", "Dwarf", "Elf", "Fairy", "Gnome", "Goblin", "Half Demon", "Halfling", "High Elf", "High Fairy", "Human", "Ogre", "Orc"];
const races: string[] = ["none","none", "inn", "settlement", "none", "airships", "drinks","artifacts", "loot", "metals", "magicaltrees", "ship", "none", "animalgroups", "groups", "religion", "none", "aasimars", "catfolk", "fetchlings","halfelf","halforc","hobgoblin","ifrits","kobalds","oreads","ratfolk","sylphs","tengu","tians","tiefling","undines","angel", "cavePerson", "darkelf", "demon", "dragon", "drow", "dwarf", "elf", "fairy", "gnome", "goblin", "halfdemon", "halfling", "highelf", "highfairy", "human", "ogre", "orc"];
const racesDisplayName: string[] = ["Select a Generator to Start","--[Settlements and Buildings]--", "Inn's & Taverns", "Settlement", "--[Objects and Vehicles]--", "Airships", "Drinks","Artifacts", "Loot And Treasure", "Metals", "Magical Trees", "Ship", "--[Groups and Religions]--", "Animal Groups", "Groups", "Religion", "--[Races]--", "Aasimars", "Catfolk", "Fetchlings","Half-Elf","Half-Orc","Hobgoblin","Ifrits","Kobalds","Oreads","Ratfolk","Sylphs","Tengu","Tians","Tiefling","Undines","Angel", "Cave Person", "Dark Elf", "Demon", "Dragon", "Drow", "Dwarf", "Elf", "Fairy", "Gnome", "Goblin", "Half Demon", "Halfling", "High Elf", "High Fairy", "Human", "Ogre", "Orc"];
const pathfinderFilter = ["aasimars", "catfolk", "fetchlings","halfelf","halforc","hobgoblin","ifrits","kobalds","oreads","ratfolk","sylphs","tengu","tians","tiefling","undines"];
let genSettings = {
@ -91,6 +92,9 @@ export class GeneratorModal extends Modal {
case "loot":
this.generatorLootSettings(optionsDiv, amountToGen, generateLoot, this.plugin.settings.enableCurrency, this.plugin.settings.currencyFrequency, this.plugin.settings.currencyTypes);
break;
case "artifacts":
this.generatorCustomSettings(optionsDiv, amountToGen, generateMiscellaneousArtifacts);
break;
case "none":
optionsDiv.innerHTML = "";
break;
@ -251,7 +255,7 @@ export class GeneratorModal extends Modal {
const shipName = generatorFunction();
console.log(shipName);
const name = generateCityName();
const name = generateCityName(this.plugin.settings.citySettings);
new Setting(settingsdiv)
.addButton((btn) => {

View file

@ -1,8 +1,20 @@
/*
.OFCGDetails {
border: 1px solid #aaa;
border-radius: 4px;
padding: 0.5em 0.5em 0.5em;
}
This CSS file will be included with your plugin, and
available in the app when your plugin is enabled.
.OFCGSSummary {
font-weight: bold;
margin: -0.5em -0.5em 0.5em;
padding: 0.5em;
}
If your plugin does not need CSS, delete this file.
.OFCGDetails[open] {
padding: 0.5em;
}
*/
.OFCGDetails[open] summary {
border-bottom: 1px solid #aaa;
margin-bottom: 0.5em;
}