Created
April 1, 2012 11:17
-
-
Save solomon081/2274751 to your computer and use it in GitHub Desktop.
Five Days on Mars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#——————————————————# | |
#/////////\\\\\\\\\# | |
#/|-Solomon Wise-|\# | |
#/|-Do Not Steal-|\# | |
#\\\\\\\\\/////////# | |
#——————————————————# | |
# Imports modules | |
from random import randint, choice | |
from os import system | |
listofitems = set() | |
class Player: | |
# Stores player info | |
oxygen = 100 | |
health = randint(50, 100) | |
defense = randint(50, 100) | |
class StoreObj: | |
# Stores store info | |
name = '' | |
oxygen = 0 | |
health = 0 | |
defense = 0 | |
price = 0 | |
class ExploreObj: | |
# The base for the objects the user will find when exploring | |
name = ' ' | |
oxygen = 0 | |
health = 0 | |
defense = 0 | |
coordinate = 0 | |
class OxygenTank(StoreObj): | |
# Stores info about the item Oxygen Tank | |
name = 'Oxygen Tank' | |
oxygen = randint(48, 52) | |
health = 15 | |
defense = 1 | |
price = 50 | |
class Rover(StoreObj): | |
# Stores info about the item Rover | |
name = 'Rover' | |
oxygen = 0 | |
health = 1 | |
defense = randint(48, 52) | |
price = 30 | |
class Apple(StoreObj): | |
# Stores info about the item Apple | |
name = 'Apple' | |
oxygen = 1 | |
health = randint(28, 32) | |
defense = 2 | |
price = 10 | |
class Flower(StoreObj): | |
# Stores info about the item Flower | |
name = 'Flower' | |
oxygen = randint(10, 14) | |
health = 1 | |
defense = 0 | |
price = 5 | |
class LaserGun(StoreObj): | |
# Stores info about the item Laser Gun | |
name = 'Laser Gun' | |
oxygen = randint(0, 15) | |
health = -1 | |
defense = randint(90, 94) | |
price = 100 | |
class Fish(StoreObj): | |
# Stores info about the item Fish | |
name = 'Fish' | |
oxygen = 0 | |
health = randint(48, 52) | |
defense = 0 | |
price = 50 | |
class Box(ExploreObj): | |
# Box attributes | |
name = 'Box' | |
oxygen = 0 | |
health = 0 | |
defense = 1 | |
coordinate = randint(1, 2) | |
class Bomb(ExploreObj): | |
# Bomb attributes | |
name = 'Bomb' | |
oxygen = -10 | |
health = -10 | |
defense = -75 | |
coordinate = randint(3, 4) | |
class Map(ExploreObj): | |
# Map attributes | |
name = 'Map' | |
oxygen = 0 | |
health = 1 | |
defense = 5 | |
coordinate = 5 | |
class Food(ExploreObj): | |
# Food attributes | |
name = 'Food' | |
oxygen = 5 | |
health = 20 | |
defense = 0 | |
coordinate = 6 | |
class Rock(ExploreObj): | |
# Rock attributes | |
name = 'Rock' | |
oxygen = 0 | |
health = 0 | |
defense = 10 | |
coordinate = randint(7, 8) | |
class Food_Two(ExploreObj): | |
food_coordinate = randint(1, 15) | |
# Shortcut to clear the screen | |
c = 'clear' | |
# Info about the program | |
info = 'This game was developed in xCode and Sublime Text 2, by Solomon Wise. He used Python 3.0.1 to build this awesome game' | |
system(c) | |
# Asks for input | |
namein = input("Enter your name: ") | |
system(c) | |
# rizes the oxygen category | |
bonus = randint(-5 , 5) | |
Player.oxygen += bonus | |
# Welcome and info | |
print("Welcome to Five Days on Mars,", namein) | |
print("You are stuck on Mars for five days, you must survive") | |
input("Press ENTER") | |
system(c) | |
# Lists player info | |
print("You start out with:") | |
print(Player.oxygen, "Oxygen") | |
print(Player.health, "Health") | |
print("And", Player.defense, "Defense") | |
input("Press ENTER") | |
system(c) | |
# Prints the info | |
print(info) | |
system("echo 'He also used the OS Module a lot'") | |
def store(): | |
global listofitems | |
# List of items bought | |
# Provides a budget | |
budget = 100 | |
system(c) | |
# Welcome Messages | |
print("Welcome to the store") | |
input("Press ENTER to view the price list") | |
system(c) | |
# Prints price list | |
print("Item Name: Price") | |
print(OxygenTank.name + ":", OxygenTank.price) | |
print(Rover.name + ":", Rover.price) | |
print(Apple.name + ":", Apple.price) | |
print(Flower.name + ":", Flower.price) | |
print(LaserGun.name + ":", LaserGun.price) | |
print(Fish.name + ":", Fish.price) | |
input("Press ENTER to continue") | |
system(c) | |
# Asks the user what the user would like to purchase | |
while budget > 0: | |
wtbuy = input("What would you like to purchase? You have a budget of " + str(budget) + ": ") | |
# Adds Oxygen Tank's attributes to the Player attributes | |
if wtbuy == 'oxygen tank' and budget >= OxygenTank.price: | |
print("You have purchased the Oxygen Tank") | |
budget -= OxygenTank.price | |
Player.oxygen += OxygenTank.oxygen | |
Player.health += OxygenTank.health | |
Player.defense += OxygenTank.defense | |
listofitems.add(OxygenTank.name) | |
print("Your budget is now", budget) | |
input("Press ENTER to continue shopping") | |
system(c) | |
# Adds Rover's attributes to the Player attributes | |
elif wtbuy == 'rover' and budget >= Rover.price: | |
system(c) | |
print("You have purchased the Rover") | |
budget -= Rover.price | |
Player.oxygen += Rover.oxygen | |
Player.health += Rover.health | |
Player.defense += Rover.defense | |
listofitems.add(Rover.name) | |
print("Your budget is now", budget) | |
input("Press ENTER to continue shopping") | |
system(c) | |
# Adds Apple's attributes to the Player attributes | |
elif wtbuy == 'apple' and budget >= Apple.price : | |
system(c) | |
print("You have purchased the Apple") | |
budget -= Apple.price | |
Player.oxygen += Apple.oxygen | |
Player.health += Apple.health | |
Player.defense += Apple.defense | |
listofitems.add(Apple.name) | |
print("Your budget is now", budget) | |
input("Press ENTER to continue shopping") | |
system(c) | |
# Adds Flower's attributes to the Player attributes | |
elif wtbuy == 'flower' and budget >= Flower.price: | |
system(c) | |
print("You have purchased the Flower") | |
budget -= Flower.price | |
Player.oxygen += Flower.oxygen | |
Player.health += Flower.health | |
Player.defense += Flower.defense | |
listofitems.add(Flower.name) | |
print("Your budget is now", budget) | |
input("Press ENTER to continue shopping") | |
system(c) | |
# Adds Laser Gun's attributes to the Player attributes | |
elif wtbuy == 'laser gun' and budget >= LaserGun.price: | |
system(c) | |
print("You have purchased the Laser Gun") | |
budget -= LaserGun.price | |
Player.oxygen += LaserGun.oxygen | |
Player.health += LaserGun.health | |
Player.defense += LaserGun.defense | |
listofitems.add(LaserGun.name) | |
print("Your budget is now", budget) | |
input("Press ENTER to continue shopping") | |
system(c) | |
# Adds Fish's attributes to the Player attributes | |
elif wtbuy == 'fish' and budget >= Fish.price: | |
system(c) | |
print("You have purchased the Fish") | |
budget -= Fish.price | |
Player.oxygen += Fish.oxygen | |
Player.health += Fish.health | |
Player.defense += Fish.defense | |
listofitems.add(Fish.name) | |
print("Your budget is now", budget) | |
input("Press ENTER to continue shopping") | |
system(c) | |
# Executes if the user input is invalid | |
elif wtbuy != 'fish' and wtbuy != 'laser gun' and wtbuy != 'flower' and wtbuy != 'apple' and wtbuy != 'rover' and wtbuy != 'oxygen tank': | |
system(c) | |
print("That's not an option, type 'item' to buy Item, not 'Item'.") | |
input("Press ENTER to continue shopping") | |
system(c) | |
# Executes if the user tries to buy something that costs more than his budget | |
else: | |
print("You don't have enough money to execute the transaction") | |
system(c) | |
# Executes if the user runs out of money | |
if budget == 0: | |
print("You have ran out of money!") | |
input("Press ENTER to view the items you bought") | |
system(c) | |
print("The items you bought are listed below") | |
# Prints items bought | |
for item in listofitems: | |
print(item) | |
# Prints new user attributes | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to exit the store") | |
store() | |
def day(): | |
# Counts the number of days | |
daycounter = 1 | |
while Player.oxygen > 0 and Player.defense > 0 and Player.health > 0 and daycounter <= 5: | |
global c | |
system(c) | |
# Day messages | |
print("This is day number", daycounter, "for you on mars") | |
daycounter += 1 | |
print("You have to survive for five days") | |
print("Every day you must perform a task, your actions in this task will determine how long you will survive") | |
input("Press ENTER to continue") | |
# Attribute subtraction | |
system(c) | |
Player.oxygen -= 3 | |
Player.defense -= 3 | |
Player.health -= 3 | |
# Wager messages | |
print("Every day you have a chance to wager some of your oxygen.") | |
print("The program algorithim will add a number between -'yourwager' and 'yourwager'") | |
wager = input("How much would you like to wager?: ") | |
# Executes if the user enters a valid number | |
try: | |
newag = 0 - int(wager) | |
endwag = randint(int(newag), int(wager)) | |
Player.oxygen += endwag | |
system(c) | |
print("Your oxygen level is now", Player.oxygen) | |
print("It changed by...", endwag) | |
input("Press ENTER to continue") | |
# Executes if the user does not | |
except ValueError: | |
system(c) | |
print("That was not a valid value") | |
input("Press ENTER to continue:") | |
# Cleans up | |
finally: | |
system(c) | |
tasknumber = randint(1, 5) | |
# Chooses a random task | |
if tasknumber == 1: | |
def explore(): | |
system(c) | |
# Welcome messages | |
print("Today we are going to go exploring") | |
if "Rover" in listofitems: | |
print("We'll be going in your Mars Rover!") | |
print("There are five items, hidden between locations one and eight") | |
print("If you get an item, it will most likely increase your attributes, but watch out, there's a bomb hidden somewhere!") | |
# Executes if the user guesses the correct coordinates | |
try: | |
if int(coorinput) == Box.coordinate: | |
system(c) | |
print("You found a box.") | |
Player.oxygen += Box.oxygen | |
Player.health += Box.health | |
Player.defense += Box.defense | |
elif int(coorinput) == Bomb.coordinate: | |
system(c) | |
print("You found a bomb! KABOOM!") | |
Player.oxygen += Bomb.oxygen | |
Player.health += Bomb.health | |
Player.defense += Bomb.defense | |
elif int(coorinput) == Map.coordinate: | |
system(c) | |
print("You found a map! Cool!") | |
Player.oxygen += Map.oxygen | |
Player.health += Map.health | |
Player.defense += Map.defense | |
elif int(coorinput) == Food.coordinate: | |
system(c) | |
print("You found some food! Yum...") | |
Player.oxygen += Food.oxygen | |
Player.health += Food.health | |
Player.defense += Food.defenw3 | |
elif int(coorinput) == Rock.coordinate: | |
system(c) | |
print("You found a goddamn rock...") | |
Player.oxygen += Rock.oxygen | |
Player.health += Rock.health | |
Player.defense += Rock.defense | |
# Executes if the user didn't find anything | |
else: | |
system(c) | |
print("You didn't find anything!") | |
Player.oxygen -= 5 | |
Player.health -= 5 | |
Player.defense -= 5 | |
# Executes if the user inputs an invalid value | |
except ValueError: | |
system(c) | |
print("You entered in an invalid value!") | |
Player.oxygen -= 10 | |
Player.health -= 10 | |
# Executes after the try and except statements | |
finally: | |
print("After assessing the gains and losses to your atrributes...") | |
input("Press ENTER to view attributes") | |
system(c) | |
if "Rover" in listofitems: | |
Player.defense += 1 | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
explore() | |
elif tasknumber == 2: | |
def alienattack(): | |
# Counts the number of shots | |
shotcount = 0 | |
# Messages | |
print("Oh no! Aliens are attacking our base!") | |
if "Rover" in listofitems: | |
print("Quick! Get out your laser gun") | |
else: | |
print("This might be hard, you have to use your pistol, you don't have a laser gun") | |
alienco = randint(1, 20) | |
print("You only have three shots to kill the aliens, or else they will take over our base!") | |
# Limits shots to 3 | |
while shotcount < 3: | |
# Input box | |
alienkill = input("Type a coordinate to shoot at: ") | |
print(alienco) | |
# Executes if there are no errors | |
try: | |
if int(alienkill) > alienco: | |
system(c) | |
print("You need to shoot lower!") | |
print("Quick!") | |
elif int(alienkill) == alienco: | |
system(c) | |
print("Bam! right on the money!") | |
Player.oxygen += randint(5, 15) | |
Player.health += randint(5, 15) | |
Player.defense += randint(5, 15) | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
break | |
else: | |
system(c) | |
print("Shoot higher!") | |
# Executes if there is a ValueError | |
except ValueError: | |
system(c) | |
print("That was an invalid coordinate") | |
input("Press ENTER to continue") | |
system(c) | |
Player.oxygen -= randint(10, 20) | |
Player.health -= randint(10, 20) | |
Player.defense -= randint(15, 20) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
break | |
if shotcount == 2: | |
print("Sorry, you ran out of shots!") | |
Player.oxygen -= randint(10, 20) | |
Player.health -= randint(10, 20) | |
Player.defense -= randint(15, 20) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
# Adds one to shotcount every time a shot is taken | |
shotcount += 1 | |
alienattack() | |
elif tasknumber == 3: | |
def lookforfood(): | |
system(c) | |
eco = 0 | |
counter = 0 | |
print("During this task, you will go looking for food") | |
print("Some food is hidden at a coordinate between 1 and 15") | |
print("You have 5 tries to find it") | |
input("Press ENTER to continue") | |
system(c) | |
try: | |
while counter < 3 and int(eco) != Food_Two.food_coordinate: | |
eco = input("Enter in a number between 1 and 15 to find an item: ") | |
if int(eco) > Food_Two.food_coordinate: | |
system(c) | |
print("You went too far, you need to go back a little") | |
Player.health -= 1 | |
counter += 1 | |
print("Attempts:", counter) | |
input("Press ENTER") | |
system(c) | |
elif int(eco) < Food_Two.food_coordinate: | |
system(c) | |
print("You need to go farther") | |
Player.health -= 1 | |
counter += 1 | |
print("Attempts:", counter) | |
input("Press ENTER") | |
system(c) | |
elif int(eco) == Food_Two.food_coordinate: | |
system(c) | |
print("You found it!") | |
Player.oxygen += 15 | |
Player.health += 10 | |
Player.defense += 5 | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
if counter == 3 and int(eco) != Food_Two.food_coordinate: | |
system(c) | |
print("You ran out of attempts!") | |
Player.oxygen -= 10 | |
Player.health -= 20 | |
Player.defense -= 5 | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
except: | |
system(c) | |
print("Invalid value") | |
input("Press ENTER to view your new attributes") | |
Player.oxygen -= 10 | |
Player.health -= 20 | |
Player.defense -= 5 | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
lookforfood() | |
elif tasknumber == 4: | |
def slots(): | |
system(c) | |
# Welcome messages | |
print("Today, we're just going to take a little rest, and go to the Mars casino to play the slots") | |
input("Press ENTER to spin") | |
system(c) | |
# Possible spin choices | |
choices = ['BAR', '7', 'Apple', 'Cherry', 'Mars Rock', 'Alien'] | |
# Makes lists of random choices | |
fpick = choice(choices) | |
spick = choice(choices) | |
tpick = choice(choices) | |
# Makes an array over which to iterate | |
allpick = [fpick, spick, tpick] | |
# Executes if there is one match | |
if fpick == spick and spick != tpick: | |
print("You had one match") | |
for x in allpick: | |
print(x) | |
print("You gained 5 of each attribute") | |
input("Press ENTER to view your new attributes") | |
system(c) | |
Player.oxygen += 5 | |
Player.health += 5 | |
Player.defense += 5 | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
# Executes if there is one match | |
elif fpick != spick and spick == tpick: | |
print("You had one match") | |
for x in allpick: | |
print(x) | |
print("You gained 5 of each attribute") | |
input("Press ENTER to view your new attributes") | |
system(c) | |
Player.oxygen += 5 | |
Player.health += 5 | |
Player.defense += 5 | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
# Executes if there are two matches | |
elif fpick == spick and spick == tpick: | |
print("You won it all!") | |
for x in allpick: | |
print(x) | |
print("You gained 20 of each attribute") | |
input("Press ENTER to view your new attributes") | |
system(c) | |
Player.oxygen += 20 | |
Player.health += 20 | |
Player.defense += 20 | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
# Executes if there is no matches | |
else: | |
print("You didn't get any matches") | |
for x in allpick: | |
print(x) | |
print("You lost 20 of each attribute") | |
input("Press ENTER to view your new attributes") | |
system(c) | |
Player.oxygen -= 20 | |
Player.health -= 20 | |
Player.defense -= 20 | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
slots() | |
else: | |
def marsrocks(): | |
system(c) | |
print("In this task, you have to remember 5 types of mars rocks") | |
print("The types of rocks you must remember are:") | |
print("1: Obsidian\n2: Mars Lava Rock\n3: Pumice\n4: Mars Crawford\n5: Mars Sediment") | |
input("Press ENTER to continue: ") | |
system(c) | |
print("Type 'rock' to enter in a rock's name, instead of 'Rock'") | |
first_input = input("Enter in the first rock: ") | |
if first_input == 'obsidian': | |
system(c) | |
print("You got it right!") | |
Player.oxygen += 2 | |
Player.defense += 2 | |
Player.health += 2 | |
second_input = input("Enter in the second rock: ") | |
if second_input == 'mars lava rock': | |
system(c) | |
print("You got it right!") | |
Player.oxygen += 5 | |
Player.defense += 5 | |
Player.health += 5 | |
third_input = input("Enter in the third rock: ") | |
if third_input == 'pumice': | |
system(c) | |
print("You got it right!") | |
Player.oxygen += 5 | |
Player.defense += 5 | |
Player.health += 5 | |
fourth_input = input("Enter in the fourth rock: ") | |
if fourth_input == 'mars crawford': | |
system(c) | |
print("You got it right!") | |
Player.oxygen += 7 | |
Player.defense += 7 | |
Player.health += 7 | |
fifth_input = input("Enter in the fifth rock: ") | |
if fifth_input == 'mars sediment': | |
system(c) | |
print("You got it right!") | |
Player.oxygen += 10 | |
Player.defense += 10 | |
Player.health += 10 | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
else: | |
system(c) | |
print("Wrong!") | |
Player.oxygen -= 6 | |
Player.defense -= 6 | |
Player.health -= 6 | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
else: | |
system(c) | |
print("Wrong!") | |
Player.oxygen -= 6 | |
Player.defense -= 6 | |
Player.health -= 6 | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
else: | |
system(c) | |
print("Wrong!") | |
Player.oxygen -= 6 | |
Player.defense -= 6 | |
Player.health -= 6 | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
else: | |
system(c) | |
print("Wrong!") | |
Player.oxygen -= 8 | |
Player.defense -= 8 | |
Player.health -= 8 | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
else: | |
system(c) | |
print("Wrong!") | |
Player.oxygen -= 10 | |
Player.defense -= 10 | |
Player.health -= 10 | |
input("Press ENTER to view your new attributes") | |
system(c) | |
print("Oxygen:", Player.oxygen) | |
print("Health:", Player.health) | |
print("Defense:", Player.defense) | |
input("Press ENTER to continue") | |
if Player.oxygen <= 0 or Player.health <= 0 or Player.defense <= 0: | |
print("Sorry, you died!") | |
break | |
marsrocks() | |
if daycounter == 5 and Player.oxygen <= 0 and Player.health <= 0 and Player.defense <= 0: | |
print("Hooray! You survived!") | |
day() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment