From 1a9eb6378b9d6e9b358574ad606393e011c3edb1 Mon Sep 17 00:00:00 2001 From: Meighan Rasley Date: Thu, 7 Apr 2016 10:01:45 -0700 Subject: [PATCH] forgot to fork so no probably lost all my prior commits --- index.html | 50 ++++++++++++++++++++++ planetexpress.js | 108 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 index.html create mode 100644 planetexpress.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..f9f7fb8 --- /dev/null +++ b/index.html @@ -0,0 +1,50 @@ + + + + + + +

Welcome to Planet Express

+

Let's make sure this crew runs like a well oiled-machine!

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Crew MemberPropertyCurrent Level
Fry'sThirstiness
Leela'sWork Load
Bender'sStock Pile
Zoidberg'sGrowly Tummy
Hermes'Receipt Stack
+ +

What would you like to do?

+
*Warning: Be wary of each action, as they have unintended consequences, and it may lead to peril for the entire crew
+ + + + + + diff --git a/planetexpress.js b/planetexpress.js new file mode 100644 index 0000000..23fb8a7 --- /dev/null +++ b/planetexpress.js @@ -0,0 +1,108 @@ +var Crew = function() { + this.thirst = 50; + this.work = 50; + this.horde = 50; + this.hunger = 50; + this.receipts = 50; + this.stable = true; + }; + +Crew.prototype.drink = function() { + this.thirst -= 5; + this.work += 10; +}; + +Crew.prototype.deliver = function() { + this.work -= 10; + this.receipts += 10; +}; + +Crew.prototype.steal = function() { + this.horde += 15; + this.work += 30; +}; + +Crew.prototype.eat = function() { + this.hunger -= 5; + this.work += 10; +}; + +Crew.prototype.account = function() { + this.receipts -= 10; + this.horde -= 10; +}; + +Crew.prototype.score = function() { + thirst_score = this.thirst * 5; + work_score = this.work * 10; + horde_score = this.horde * 50; + hunger_score = this.hunger * 5; + receipts_score = this.receipts * 50; +}; + +Crew.prototype.check = function() { + if (this.thirst >= 85 && this.thirst < 100) { + window.alert("Warning! Give Fry a drink before he crashes the ship!"); + } + if (this.work >= 85 && this.work < 100) { + window.alert("Warning! Leela is swamped with work and can't keep up!"); + } + if (this.horde > 0 && this.horde <= 15) { + window.alert("Warning! Bender's horde is rapidly depleting!"); + } + if (this.hunger >= 85 && this.hunger < 100) { + window.alert("Warning! Make Zoidberg's stomach stop growling, it's distracting the crew!"); + } + if (this.receipts > 0 && this.receipts <= 15) { + window.alert("Warning! Hermes needs more receipts to process!"); + } + if (this.thirst > 100 || this.work > 100 || this.horde <= 0 || this.hunger > 100 || this.receipts <= 0) { + window.alert("The crew fell apart under pressure. You lose!"); + stable = false; + } +}; + +var c = new Crew(); + +Crew.prototype.level = function() { + $("#thirst").text(c.thirst); + $("#work").text(c.work); + $("#horde").text(c.horde); + $("#hunger").text(c.hunger); + $("#receipts").text(c.receipts); +}; + +Crew.prototype.checkLevel = function() { + c.level(); + c.check(); +} + + +$(document).ready(function(){ + c.level(); + + $("#drink").click(function(){ + c.drink(); + c.checkLevel(); + }); + + $("#deliver").click(function(){ + c.deliver(); + c.checkLevel(); + }); + + $("#steal").click(function(){ + c.steal(); + c.checkLevel(); + }); + + $("#eat").click(function(){ + c.eat(); + c.checkLevel(); + }); + + $("#account").click(function(){ + c.account(); + c.checkLevel(); + }); +});