Skip to content

Commit

Permalink
Lots of cleanup, fix some rewrite rules, better example
Browse files Browse the repository at this point in the history
  • Loading branch information
vantreeseba committed Apr 27, 2020
1 parent e8304e1 commit 146751b
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 123 deletions.
9 changes: 6 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@
<button id="generate" onClick="generate()">Generate another</button>
<div id="langname"></div>
<div class="row">
<table id="config"/>
<table id="words" />
<table id="phrases" />
<div class="column">
<table id="config"></table>
<table id="ortho"></table>
</div>
<table id="words"></table>
<table id="phrases"></table>
</div>
<script src="./index.js"></script>
</body>
37 changes: 34 additions & 3 deletions docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ function generate(){

let languagename = gen.createWord('language');

document.getElementById('langname').innerHTML =
`The language of ${ languagename }`;

var configtable = document.getElementById('config');
configtable.innerHTML = '<thead><th>Config</th><th></th></thead>';


function addConfigRow(name, data) {
var row = document.createElement('tr');
configtable.append(row);
Expand All @@ -57,8 +59,37 @@ function generate(){
addConfigRow('max syllables in word', gen.config.word_length_max);


document.getElementById('langname').innerHTML =
`The language of ${ languagename }`;
var orthoTable = document.getElementById('ortho');
orthoTable.innerHTML = '<thead><th>Phoneme</th><th>Written</th></thead>';

function addOrthoRow(letter, ortho) {
var row = document.createElement('tr');
orthoTable.append(row);

var configName = document.createElement('td');
configName.innerText = letter;
var configValue = document.createElement('td');
configValue.innerText = ortho;
row.append(configName);
row.append(configValue);
}

var letters = gen.config.vowels
.concat(gen.config.consonants)
.concat(gen.config.sset)
.concat(gen.config.lset)
.concat(gen.config.fset)
.reduce((a, b) => {
if(a.indexOf(b) === -1) {
a.push(b);
}

return a;
}, []);

for(let i = 0; i < letters.length; i++) {
addOrthoRow(letters[i], gen.spell.spell(letters[i]));
}


let wordTable = document.getElementById('words');
Expand Down
146 changes: 91 additions & 55 deletions docs/langgen.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions src/dropecho/langgen/Consts.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package dropecho.langgen;

import seedyrng.Random;

@:expose("Consts")
class Consts {
public static var consonant_sets = [
Expand Down Expand Up @@ -87,37 +89,45 @@ class Consts {
'Doubles' => ['A' => 'aa', 'E' => 'ee', 'I' => 'ii', 'O' => 'oo', 'U' => 'uu']
];

public static function getRandomConsonantSet(random) {
public static function getRandomCorthSet(random:Random) {
return corthsets.get(random.choice([for (k in corthsets.keys()) k]));
}

public static function getRandomVorthSet(random:Random) {
return vorthsets.get(random.choice([for (k in vorthsets.keys()) k]));
}

public static function getRandomConsonantSet(random:Random) {
var keys = [for (x in consonant_sets.keys()) x];

return consonant_sets[random.choice(keys)];
}

public static function getRandomVowelSet(random) {
public static function getRandomVowelSet(random:Random) {
var keys = [for (x in vowel_sets.keys()) x];
return vowel_sets[random.choice(keys)];
}

public static function getRandomSSet(random) {
public static function getRandomSSet(random:Random) {
var keys = [for (x in ssets.keys()) x];
return ssets[random.choice(keys)];
}

public static function getRandomFSet(random) {
public static function getRandomFSet(random:Random) {
var keys = [for (x in fsets.keys()) x];
return fsets[random.choice(keys)];
}

public static function getRandomLSet(random) {
public static function getRandomLSet(random:Random) {
var keys = [for (x in lsets.keys()) x];
return lsets[random.choice(keys)];
}

public static function getRandomSyllableStructure(random) {
public static function getRandomSyllableStructure(random:Random) {
return random.choice(syllable_structures);
}

public static function getRandomPhraseStructure(random) {
public static function getRandomPhraseStructure(random:Random) {
return random.choice(phrase_structures);
}
}
Expand Down
Loading

0 comments on commit 146751b

Please sign in to comment.