Text Size
Text Size
Exit Full Screen
Python Mini
Show
Source Code
View Source Code in Full Screen
Open in New Tab
import time import random def block(x): print "" time.sleep(2) print x res = str("quest") while res != "yes" or "no": res = raw_input(x).lower() time.sleep(1) if res == "yes": print "You > Yes" break elif res == "no": print "You > No" break else: continue print "" return res def chanceChoice(x, y, z): choices = [x, y, z] chanceCh = random.choice(choices) return chanceCh def chanceRand(x, y, a, b): guess = random.randint(x, y) chance = random.randint(x, y) if guess == chance: return b elif guess != chance: return a print "Your Adventure begins." time.sleep(1) print "You find yourself in a dark forest at dawn. You don't know how you got there, and you have no memory of what happened immediately last night. You have no food and only 100 mL of drinking water. The early morning air is chilly." time.sleep(1) print "Your adventure will present itself in decisions. Answer 'yes' or 'no'!" time.sleep(2) Q1 = block("Do you stay where you are and hope help arrives?") if Q1 == "yes": time.sleep(1) print "And so, you decide to remain. Without food, you are hungry, but you don't know where to find food." Q2y = block("Then, you hear a shrill noise in a clearing not far away. Do you investigate?") if Q2y == "yes": time.sleep(1) print "You carefully approach the source of the noise. As you do so, you begin to hear rustling noises. When you reach the bushes, you find a horse stuck in the brambles. It is equipped with a bridle and a saddle. Feeling compassion, you gingerly begin to free the horse. Just as you finish, you hear approaching hoofbeats in the distance." Q3y = block("Do you flee from the approaching horsemen?") if Q3y == "yes": time.sleep(1) print "You immediately begin running away. As you try to cross a rocky stream, you slip, fall and hit your head on a rock. You pass out." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END elif Q3y == "no": time.sleep(1) print "You stay where you are as a dozen horsemen enter the clearing. You instantly can tell that they are soldiers; they wear metal helmets, are dressed in light armor, and each carries a sword and shield on his back." print "The leader of the group, a man wearing a blue plume on his helmet, dismounts from one of his comrade's horses. He introduces himself as Sergeant Joseph C. of the 78th Regiment of the 3rd Division of the Dragonclaw Republic Cavalry, and that they were out on patrol when his horse ran off. He kindly thanks you for finding his horse, and after listening to your story, offers to take you to safety in the army garrison of the City of Dobbins." time.sleep(1) print "You agree to come, and Sergeant Joseph helps you onto his horse. Sitting behind the Sergeant, you ride off with the cavalrymen to Dobbins." time.sleep(4) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END elif Q2y == "no": time.sleep(1) print "You duck behind a nearby tree in fear. From there, you hear nothing more. You continue waiting for several hours. Then suddenly, you hear rustling in some nearby bushes, and before you can react, black-clad men have surrounded you. Bandits! You try to flee, but one punches you hard in the head, knocking you unconscious." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END elif Q1 == "no": time.sleep(1) print "You set off into the woods. After about an hour of walking, you spot a skeleton lying in a small clearing. It is dressed in leather clothing. Nearby is a bronze shortsword and some iron-tipped arrows." Q2n = block("Do you take the sword and arrows from the skeleton?") if Q2n == "yes": time.sleep(1) print "You approach and take first the arrows, then the sword, daring not touch the skeleton. The moment you pick up the sword..." event = chanceChoice("trap", "necro", "nada") if event == "trap": time.sleep(1) print "You hear a dull click, and suddenly a net springs up from the forest floor and pulls you into the trees. You are knocked out in the process." time.sleep(1) print "Some hours later, you awake tied up in the camp of some bandits. As you become aware of your surroundings, you realize that it is dusk, and all of the bandits are busy eating at a nearby fire. You are situated next to a pile of sacks and crates." time.sleep(1) print "Suddenly, a short cloaked figure sneaks out of the nearby forest and carefully approaches you. Motioning for you to stay quiet, it slowly starts to untie you." time.sleep(1) print "Suddenly, you hear murmuring from the bandits. One bandit has sensed something is wrong. They all gather their weapons and stand alert. The one bandit approaches your location to investigate." Q3 = block("Do you stay to help your liberator?") if Q3 == "yes": time.sleep(1) print "Standing in front of you, the cloaked being draws out his sword and confronts the the bandit. Weaponless, you take a wooden pole from the supplies pile and manage to knock the bandit to the ground." time.sleep(1) print "Both you and your liberator then flee into the woods, with the bandits in hot pursuit, well armed and in full force. You hide in a deep gully together with your liberator, as the bandits unknowingly run past." time.sleep(1) event2 = chanceRand(1, 10, "help", "capture") if event2 == "help": time.sleep(1) print "The cloaked being removes his hood. He is a goblin. He introduces himself as Cephalith, and explains that he was sent as a scout to track the bandit's movements." print "He then explains that he lives in the nearby goblin town of Tor-Litha and asks you to accompany him back, where he says you will be safe." time.sleep(4) Q4a = block("Do you trust Cephalith and go with him?") if Q4a == "yes": time.sleep(1) print "You are led by Cephalith through the woods. After about an hour of walking, Cephalith meets up with a goblin farm cart on a road. After greeting his comrades, he takes you onto the cart, at which point you fall asleep." time.sleep(2) print "You wake up the next morning in a house. Noticing that you are awake, Cephalith and his friends gives you a delicious breakfast and water to drink. They are very kind. Afterwards, they give you a tour of Tor-Litha, a peaceful farming village populated by goblins." time.sleep(3) Q5a = block("Do you wish to leave the town of Tor-Litha now?") if Q5a == "yes": time.sleep(1) print "You tell Cephalith that you ought to be on your way. He asks if you are sure you wish to leave. You say yes. Before you leave, he takes you back home, where he gives you a bag of food and water, some coins, an iron sword and a small shield. As you walk out of Tor-Litha, he bids you farewell and good luck." time.sleep(4) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END elif Q5a == "no": time.sleep(1) print "When you are returning to Cephalith's house, you tell him that it would be nice to stay for a couple more days. He says that he enjoys the company and can accomodate you during that time." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END END END END elif Q4a == "no": time.sleep(1) print "You initially begin walking with Cephalith, but you later sneak off and take shelter in an abandoned bear's den. Here, you sleep until the next morning." time.sleep(1) print "The next morning, you continue through the woods. Before long, you happen upon a road. You decide to follow the road. After two hours of walking, you find yourself at a fork in the road. The left road is wide and worn from traffic, while the right seems less frequently traveled." time.sleep(2) Q5b = block("Do you take the road that is more frequently traveled?") if Q5b == "yes": time.sleep(1) print "You take the road on the left. It isn't long before you start to encounter people; traders, merchants, and farmers. You ask a merchant where the road leads. She tells you that you are about two hour's walk away from the city of Aceraea." time.sleep(1) print "You then continue onwards. Within two hours, the woods gives way to expansive farmland, dotted with hamlets. A little bit furthur on, you approach a large stone wall with a gate; guards patrolling the top in front of the wooden roofs behind them. It is built next to a wide river." print "In many places along the wall are flags; dark blue flags containing a motif of a spruce tree framed by leaves of four trees and a mighty red dragon. It is the flag of the Dragonclaw Republic. You have reached Aceraea, the city of maples." time.sleep(4) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END elif Q5b == "no": time.sleep(1) print "You take the road on the right, which heads deep into the woods." elif event2 == "capture": time.sleep(1) print "You turn to the cloaked figure to say thank you, but it quickly jams a magical spell-soaked cloth over your mouth. You then pass out." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END elif Q3 == "no": time.sleep(1) print "You immediately turn and bolt into the woods, without looking back. Behind you, you hear shouts. The bandits are busy fighting the cloaked being. As you try to cross a rocky stream, you slip, fall and hit your head on a rock. You get knocked out." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END END END END END END END END elif event == "necro": time.sleep(1) print "You hear rustling very close by. When you turn around, you watch, horrified, as the skeleton comes to life!" Q3n = block("Do you stay to fight the undead skeleton?") if Q3n == "yes": time.sleep(1) print "The skeleton charges at you! With your new sword, you begin to fight..." outcome = chanceChoice("victory", "injured", "death") if outcome == "victory": time.sleep(1) print "... You slashed and destroyed the undead skeleton, without getting hurt! Looking at the skeleton's remains, you find some gold coins. Taking these, you then continue along." time.sleep(2) print "About three hours later, you finally leave the woods and enter a sunny meadow. You soon happen upon a small road." Q4 = block("Do you take this road?") if Q4 == "yes": time.sleep(1) print "You turn onto this road, which goes west. In about an hour, you meet a trader going in the opposite direction. He tells you that the nearest town is about a day's walk away on this road." time.sleep(2) print "You buy some bread and dried pork from the trader with your gold coins. Out of generosity, he invites you to choose between an iron shield and a crossbow." Q5 = block("Do you take the crossbow?") if Q5 == "yes": time.sleep(1) print "You take the crossbow and kindly thank the trader." time.sleep(1) print "After an hour of walking, it is now noon. Hungry, you sit in the shade of a small tree and begin eating." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END END END END elif Q5 == "no": time.sleep(1) print "You take the iron shield and kindly thank the trader." time.sleep(1) print "After an hour of walking, it is now noon. Hungry, you sit in the shade of a small tree and begin eating." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END END END END elif outcome == "injured": time.sleep(1) print "... You manage to take down the skeleton, but not before your arm and leg gets injured. You limp away and continue your journey. You know that finding help might now be your only chance of survival." time.sleep(1) print "You stagger along for about five hours before you finally collapse in pain and exaustion." time.sleep(1) event3 = chanceRand(1, 5, "rescued", "death") if event3 == "death": print "You succumbed to your injuries." time.sleep(1) print "Your Adventure Ends Here." elif event3 == "rescued": print "You wake up in a small cottage. Nobody is home, but you find that your wounds have been treated and tended to. You find a bowl of hot soup and a cup of water on a nearby table. It is a comfortably furnished place, with a burning fire in the hearth and bright sunlight streaming through the windows. You are safe." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END END END END END END END END elif outcome == "death": time.sleep(1.5) print "... You got slain by the skeleton." time.sleep(1) print "Your Adventure Ends Here." #END END END END END END END END END END END END END END END END END END END END END END END elif Q3n == "no": time.sleep(1) print "You run away, with the skeleton chasing you. Just as you are starting to become exausted, an arrow whizzes past you and strikes the skeleton." print "You turn to see where the arrow came from. You see a green-clad archer rise out of the bushes, firing another arrow from his crossbow. This also hits the skeleton, which then collapses into a lifeless pile of bones." time.sleep(1) print "The archer asks whether you are okay. You say you are. Then, he introduces himself as Private Castor Castana. He tells you how he is an archer from the Dragonclaw Army who got separated from his unit after an ambush by bandits." time.sleep(1) Q4c = block("Do you wish to help Private Castana?") if Q4c == "yes": time.sleep(1) print "You ask Private Castana to accompany you on your journey, as you are also lost like him. He agrees, and together, you continue onwards." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END END END END END END END END elif Q4c == "no": time.sleep(1) print "You thank Private Castana for saving you, and say that you better get going. He then gives you his spare crossbow and some arrows, and bids you farewell. You continue on your journey through the woods." time.sleep(1) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END elif event == "nada": time.sleep(1) print "... nothing happens. You sigh, content and relieved. Gathering up your loot, you get up and continue on your way." time.sleep(1) print "After nearly seven hours of continous walking, you leave the woods and enter the small town of East Meadows. It is located next to a wide river, at the northeastern edge of the Upper Phoneticia plains. You enter a local inn and stay the night there." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END END END elif Q2n == "no": time.sleep(1) print "Unnerved by the skeleton and realizing that this might be bandit country, you hurry on." time.sleep(1) print "Four hours later, you reach the entrance to a cave in the ground." time.sleep(3) print "Your Adventure Ends Here ... For Now!" #END END END END END END END END END END END END END END END END END END END END END END END
ChooseYourAdventure.py
( around 242 lines python code )
Published By:
EM5700
Published on
2019-11-01T15:38:03Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here