You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

66 lines
2.5 KiB

use rand::Rng;
use crate::lipu_nimi;
pub fn pali(nimi_sin: &str) -> String {
pali_lili(nimi_sin, true, false) //ilo li pali e toki la nimi "la" li ken lon la nimi sin li lon ala
}
fn pali_lili(nimi_sin: &str, la_li_ken: bool, nimi_sin_li_lon_a: bool) -> String {
let mut toki_sin = String::new();
let mut mi_anu_sina = false;
let mut la_anu_seme = rand::thread_rng().gen_range(0_u8..10) == 0;
if la_li_ken == false {
la_anu_seme = false;
}
let mut nimi_sin_li_lon = nimi_sin_li_lon_a;
let mut x = 0;
let suli = rand::thread_rng().gen_range(1_u8..4); // toki la, kipisi tu tu li ken lon.
while x < suli {
if x == 1 {
if rand::thread_rng().gen_range(0_u8..10) == 0 {
toki_sin.push_str("o "); //o li ken lon
} else if !mi_anu_sina {
toki_sin.push_str("li "); //nimi "mi" anu nimi "sina" li lon ala la nimi "li" li ken lon
}
}
if x == 2 {
toki_sin.push_str("e "); //nimi "e"
}
if x == 3 {
toki_sin.push_str(lipu_nimi::pana(&[1]).as_str()); //nimi sama nimi "kepeken"
toki_sin.push_str(" ");
}
let mut y = 0;
let suli_kipisi;
if suli == 1 { suli_kipisi = rand::thread_rng().gen_range(2_u8..4);
} else {
suli_kipisi = rand::thread_rng().gen_range(1_u8..4); //kipisi la nimi tu tu li ken lon
}
while y < suli_kipisi {
let nimi_ni = lipu_nimi::pana(&[0,1]);
if (nimi_ni == "mi" || nimi_ni == "sina") && suli_kipisi == 1 {
mi_anu_sina = true; //nimi li nimi "mi" taso anu nimi "sina" taso
}
if (rand::thread_rng().gen_range(0_u8..4) == 0 || (x == suli-1 && y == suli_kipisi-1)) && !nimi_sin_li_lon {
toki_sin.push_str(nimi_sin); //ilo li pana e nimi sin.
nimi_sin_li_lon = true; //ni la, nimi sin li lon!
} else {
toki_sin.push_str(nimi_ni.as_str());
}
toki_sin.push_str(" ");
y += 1;
if suli_kipisi-y > 1 && rand::random() { //nimi "pi" li ken lon la, ona li ken lon!
toki_sin.push_str("pi ");
}
}
x += 1;
}
if la_anu_seme {
toki_sin.push_str("la ");
toki_sin.push_str(pali_lili(nimi_sin, false, nimi_sin_li_lon).as_str()); //nimi "la" li lon la, ilo li pali e toki sin li pana e toki ni
}
toki_sin //ilo li pana e toki
}