diff --git a/index.html b/index.html new file mode 100644 index 0000000..71ba4a7 --- /dev/null +++ b/index.html @@ -0,0 +1,53 @@ + + + + + + Spaceships + + + +

Futuramalama

+

Welcome to Space! You must run your ship properly to survive!

+

+ This means feeding your crew, making sure they don't die of thirst, doing some accounting, + making deliveries, and other interesting things. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Status of ShipCurrent Level
Thirst
Work
Horde
Hunger
Receipt
+ +

Score:

+ 0 + +

Click any of the below buttons to take action on the ship

+ + + + + + diff --git a/spaceship.js b/spaceship.js new file mode 100644 index 0000000..b7595a3 --- /dev/null +++ b/spaceship.js @@ -0,0 +1,129 @@ +var SpaceShip = function(start, end) { + this.thirst = start; + this.work = start; + this.horde = start; + this.hunger = start; + this.receipts = start; + this.stable = true; + this.end = end; + this.totalScore = 0; +} + +SpaceShip.prototype.drink = function(){ + this.thirst--; + this.work++; +}; + +SpaceShip.prototype.deliver = function(){ + this.work--; + this.receipts ++; +}; + +SpaceShip.prototype.steal = function(){ + this.horde++; + this.work++; +}; + +SpaceShip.prototype.eat = function(){ + this.hunger--; + this.work++; +}; + +SpaceShip.prototype.account = function(){ + this.receipts--; + this.horde--; + $("#receipts").text(crew.receipts); +}; + +SpaceShip.prototype.status = function(){ + $("#thirst").text(this.thirst); + $("#work").text(this.work); + $("#horde").text(this.horde); + $("#hunger").text(this.hunger); + $("#receipts").text(this.receipts); +}; + +SpaceShip.prototype.score = function(){ + if (this.totalScore < 0) { + alert("You lost! Try again."); + location.reload(); + } + + if (this.thirst > 70 && this.thirst < this.end) { + this.totalScore --; + } else if (this.thirst <= 70) { + this.totalScore ++; + } else if (this.thirst >= this.end) { + alert("Your crew got too thirsty! You lose - try again."); + location.reload(); + } + + if (this.work > 70) { + this.totalScore --; + } else if (this.work <= 70 && this.work < this.end) { + this.totalScore ++; + } else if (this.work >= this.end) { + alert("Your crew got too hungry! You lose - try again."); + location.reload(); + } + + if (this.receipts < 70) { + this.totalScore ++; + } else if (this.receipts >= 70 && this.receipts > this.end) { + this.totalScore --; + } else if (this.receipts > this.end) { + alert("Your crew got too behind on receipts! You lose - try again."); + location.reload(); +} + +if (this.horde < 70) { + this.totalScore ++; +} else if (this.horde >= 70 && this.horde > this.end) { + this.totalScore --; +} else if (this.horde > this.end) { + alert("You didn't find enough treasure! You lose - try again."); + location.reload(); +} + $("#score").text(this.totalScore); +}; + +var crew = new SpaceShip(0, 3); + +$(document).ready(function(){ + crew.status(); + + $("#drink").click(function(){ + crew.drink(); + alert("You drank something!"); + crew.score(); + crew.status(); + }); + + $("#eat").click(function(){ + crew.eat(); + alert("You ate something!"); + crew.score(); + crew.status(); + }); + + $("#deliver").click(function(){ + crew.deliver(); + alert("You delivered something!"); + crew.score(); + crew.status(); + }); + + $("#account").click(function(){ + crew.account(); + alert("You did some accounting!"); + crew.score(); + crew.status(); + }); + + $("#steal").click(function(){ + crew.steal(); + alert("You stole some treasure!"); + crew.score(); + crew.status(); + }); +}); diff --git a/spaceship.py b/spaceship.py new file mode 100644 index 0000000..0e03006 --- /dev/null +++ b/spaceship.py @@ -0,0 +1,137 @@ +class Spaceship: + + def __init__(self): + self.thirst = 50 + self.work = 50 + self.horde = 50 + self.hunger = 50 + self.receipts = 50 + self.stable = True + self.total = 0 + + def drink(self): + self.thirst -= 10 + self.work += 2 + + def deliver(self): + self.work += 8 + self.receipts += 4 + + def steal(self): + self.horde += 10 + self.work += 7 + + def eat(self): + self.hunger -= 10 + self.work += 2 + + def account(self): + self.receipts -= 10 + self.horde -= 10 + + def thirst_level(self): + if self.thirst < 50: + self.total += 7 + elif self.thirst >= 60: + self.total -= 7 + + def horde_level(self): + if self.horde > 80: + self.total += 5 + elif self.horde <= 80: + self.total -= 1 + + def work_level(self): + if self.work < 70: + self.total += 1 + elif self.work >= 70: + self.total -= 1 + + def hunger_level(self): + if self.hunger > 60: + self.total -= 1 + elif self.hunger <= 60: + self.total -= 1 + + def receipt_level(self): + if self.receipts > 70: + self.total += 3 + elif self.receipts <= 70: + self.total -= 3 + + def total_score(self): + self.thirst_level + self.horde_level + self.work_level + self.receipt_level + self.hunger_level + return self.total + + def stable(self): + if any( [self.thirst > 99, self.work > 99, self.horde < 1, self.hunger > 99, self.receipts < 1] ): + return False + else: + return True + + def check(self): + self.alert() + if self.stable: + return True + else: + return False + print "You lose! Try again!" + + def alert(self): + if any( [self.thirst > 90, self.work > 90, self.horde > 90, self.hunger > 90, self.receipts > 90] ): + print "Uh oh! Your ship is about to sink. Here's what you need to watch out for. Remember, if any value reaches 100, you're DOOMED!" + self.thirst + print "Current thirst level: " + print self.thirst + print "Current work level:" + print self.work + print "Current hording level: " + print self.horde + print "Current hunger level: " + print self.hunger + print "Current receipt level: " + print self.receipts + +def playGame(): + game = Spaceship() + + print "All Aboard the Planet Express!" + print "What would you like to do?" + print "Keep track of your score by typing \"score\" at any time." + print "You can also type 'bye' at any time to leave this game :(." + + stop = False + + while stop != True: + print "What would you like to do aboard the ship?" + action = raw_input("You can type 'eat', 'drink', 'accounting', 'deliver', or 'steal'. ") + if action == "bye": + stop = True + print "Laterz." + else: + if action == "eat": + game.eat() + print "You ate something! Your belly is fuller, but it required work!" + elif action == "drink": + game.drink() + print "You drank something! You're less thirsty, but it required some work!" + elif action == "accounting": + game.account() + print "You did some accounting! Boring! That was a lot of work!" + elif action == "deliver": + print "You did some work for once! That required some work!" + elif action == "steal": + game.steal() + print "You stole some stuff! That's awkward." + elif action == "score": + print "Your total score is: " + print game.total_score() + else: + "I don't understand that command! Try again!" + game.check() + +playGame()