From 76257b74832c12eca60e18d3f5ae351e4b23cc87 Mon Sep 17 00:00:00 2001 From: deadvey <deadvey@nixos> Date: Tue, 24 Dec 2024 17:42:11 +0000 Subject: [PATCH] prophecy generator --- prophecies/.gitignore | 1 + prophecies/Cargo.toml | 7 ++ prophecies/prophecies | 148 +++++++++++++++++++++++++++++++++++++++++ prophecies/src/main.rs | 28 ++++++++ 4 files changed, 184 insertions(+) create mode 100644 prophecies/.gitignore create mode 100644 prophecies/Cargo.toml create mode 100644 prophecies/prophecies create mode 100644 prophecies/src/main.rs diff --git a/prophecies/.gitignore b/prophecies/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/prophecies/.gitignore @@ -0,0 +1 @@ +/target diff --git a/prophecies/Cargo.toml b/prophecies/Cargo.toml new file mode 100644 index 0000000..5ab5437 --- /dev/null +++ b/prophecies/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "prophecies" +version = "0.1.0" +edition = "2024" + +[dependencies] +rand = "0.8.5" diff --git a/prophecies/prophecies b/prophecies/prophecies new file mode 100644 index 0000000..ab86412 --- /dev/null +++ b/prophecies/prophecies @@ -0,0 +1,148 @@ +If Under fell, if Over leaped, +If life was death, if death life reaped, +Something rises from the gloom +To make the Underland a tomb. +Hear it scratching down below, +Rat of long forgotten snow, +Evil cloaked in coat of white, +Will the warrior drain your light? +What will turn the warrior weak? +What do burning Gnawers seek? +Just a barely speaking pup +Who holds the land of Under up. +Die the baby die his heart, +Die his most essential part. +Die the peace that rules the hour. +Gnawers have their key to power. +Warmblood now a bloodborne death +Will rob your body of its breath, +Mark your skin, and seal your fate. +The Underland becomes a plate. +Turn and turn and turn again. +You see the what but not the when. +Remedy and wrong entwine, +And so they form a single vine. +Bring the warrior from above +If yet his heart is swayed by love. +Bring the princess or despair, +No crawlers care without her there. +Turn and turn and turn again. +You see the what but not the when. +Remedy and wrong entwine, +And so they form a single vine. +Those whose blood runs red and hot +Must join to seek the healing spot. +In the cradle find the cure +For that which makes the blood impure. +Turn and turn and turn again. +You see the what but not the when. +Remedy and wrong entwine, +And so they form a single vine. +Gnawer, human, set aside +The hatreds that reside inside. +If the flames of war are fanned, +All warmbloods lose the Underland. +Turn and turn and turn again. +You see the what but not the when. +Remedy and wrong entwine, +And so they form a single vine. +Beware, Underlanders, time hangs by a thread. +The hunters are hunted, white water runs red. +The gnawers will strike to extinguish the rest. +The hope of the hopeless resides in a quest. +An Overland warrior, a son of the sun, +May bring us back light, he may bring us back none. +But gather your neighbors and follow his call +Or rats will most surely devour us all. +Two over, two under, of royal descent, +Two flyers, two crawlers, two spinners assent. +One gnawer beside and one lost up ahead. +And eight will be left when we count up the dead. +The last who will die must decide where he stands. +The fate of the eight is contained in his hands. +So bid him take care, bid him look where he leaps, +As life may be death and death life again reaps. +On soft feet, by none detected, +Dealing death, by most rejected, +Killed by claw, since resurrected, +Marked by X, two lines connected. +Finally, they intersected, +Two lines met, one unexpected. +Dancing in the firelight, +See the queen that conquers night. +Gold flows from her, hot and bright. +Father, mother, sister, brother, +Off they go. I do not know +If we will see another. +Catch the nibblers in a trap. +Watch the nibblers spin and snap. +Quiet while they take a nap. +Father, mother, sister, brother, +Off they go. I do not know +If we will see another. +Now the guests are at our door +Greet them as we have before. +Some will slice and some will pour. +Father, mother, sister, brother, +Off they go. I do not know +If we will see another. +The war has been declared, +Your ally been ensnared. +It is now or it is never. +Break the code or die forever. +Time is running out +Running out +Running out. +To the warrior give my blade. +By his hand your fate is made. +But do not forget the ticking +Or the clicking, clicking, clicking. +While a rat's tongue may be flicking, +With its feet it does the tricking. +For the paw and not the jaw +Makes the Code of Claw. +Time is standing still +Standing still +Standing still. +Since the princess is the key +To unlock the treachery, +She cannot avoid the matching +Or the scratching, scratching, scratching. +When a secret plot is hatching, +In the naming is the catching. +What she saw, it is the flaw +Of the Code of Claw. +Time is turning back +Turning back +Turning back. +When the monster's blood is spilled, +When the warrior has been killed, +You must not ignore the rapping, +Or the tapping, tapping, tapping. +If the gnawers find you napping, +You will rot while they are mapping +Out the law of those who gnaw +In the Code of Claw. + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prophecies/src/main.rs b/prophecies/src/main.rs new file mode 100644 index 0000000..df18af0 --- /dev/null +++ b/prophecies/src/main.rs @@ -0,0 +1,28 @@ +use std::fs; +use std::io; +use rand::Rng; + +fn main() -> io::Result<()> { + // Read the file that contains every prophecy line in the series + let file_contents: String = fs::read_to_string("prophecies")?; + + // Determine the name of the prophecy by picking a random word in file + let split_into_words = file_contents.split_whitespace().collect::<Vec<_>>(); + let name = split_into_words[rand::thread_rng().gen_range(0..split_into_words.len())]; + println!("THE PROPHECY OF {}:\n", name.to_uppercase()); + + // Randomly decide how long the prophecy will be, range of 4 to 30 + let number_of_lines = rand::thread_rng().gen_range(4..30); + + // Split file into lines + let split_string = file_contents.split("\n").collect::<Vec<_>>(); + let lines_in_string = split_string.len(); + + // Iterate for "number_of_lines" and each time pick a random line in the file + for _i in 0..number_of_lines { + let line_index = rand::thread_rng().gen_range(0..lines_in_string); // Pick random line + println!("{}",split_string[line_index]); // Print the random line + } + + Ok(()) +}