Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Dwarf() {
- any([ DwarfLineage, DwarfLineage, DwarfAlone ])();
- }
- function DwarfLineage() {
- PrepareDwarfName();
- DwarfHeritage();
- }
- function DwarfHeritage() {
- Dwarf();
- tokens.push(",");
- tokens.push(any([ "heir to the throne of", "son of", "daughter of" ]));
- DwarfSelf();
- }
- function DwarfAlone() {
- PrepareDwarfName();
- DwarfSelf();
- }
- function DwarfSelf() {
- DwarfName();
- DwarfTitle();
- }
- function DwarfTitle() {
- any([ Nothing, SomeDwarfTitle ])();
- }
- function SomeDwarfTitle() {
- tokens.push(",");
- tokens.push(any(DwarfTitles));
- tokens.push("of");
- tokens.push(any(of([ Territories, Nations, Peoples ])));
- }
- function DwarfName() {
- SomeDwarfName();
- any([ Nothing, Nothing, WhichOfHisName ])();
- names.pop();
- }
- function WhichOfHisName() {
- SomeOrdinalNumber();
- }
- function SomeOrdinalNumber() {
- var number = names[names.length - 1].number;
- var ordinal = "";
- switch(number) {
- case 1: ordinal = "1st"; break;
- case 2: ordinal = "2nd"; break;
- case 3: ordinal = "3rd"; break;
- default: ordinal = number + "th";
- }
- tokens.push(ordinal);
- }
- function SomeDwarfName() {
- tokens.push(names[names.length - 1].name);
- }
- function PrepareDwarfName() {
- var name = any(DwarfNames);
- if(memory[name])
- memory[name]++;
- else
- memory[name] = 1;
- names.push({ name: name, number: memory[name] });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement