Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="planetexpress.js"></script>
</head>
<body>
<h3>Welcome to Planet Express</h3>
<h4>Let's make sure this crew runs like a well oiled-machine!</h4>

<table>
<tr>
<th>Crew Member</th>
<th>Property</th>
<th>Current Level</th>
</tr>
<tr>
<td>Fry's</td>
<td>Thirstiness</td>
<td id="thirst"></td>
</tr>
<tr>
<td>Leela's</td>
<td>Work Load</td>
<td id="work"></td>
</tr>
<tr>
<td>Bender's</td>
<td>Stock Pile</td>
<td id="horde"></td>
</tr>
<tr>
<td>Zoidberg's</td>
<td>Growly Tummy</td>
<td id="hunger"></td>
</tr>
<tr>
<td>Hermes'</td>
<td>Receipt Stack</td>
<td id="receipts"></td>
</tr>
</table>

<h4>What would you like to do?</h4>
<h6>*Warning: Be wary of each action, as they have unintended consequences, and it may lead to peril for the entire crew</h6>
<button id="drink">Give Fry a drink</button>
<button id="deliver">Give more work to Leela</button>
<button id="steal">Take from Bender's horde</button>
<button id="eat">Give Zoidberg something to eat</button>
<button id="account">Tell Hermes to reconcile some receipts</button>
</body>
108 changes: 108 additions & 0 deletions planetexpress.js
Original file line number Diff line number Diff line change
@@ -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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite see how these scores play into anything, what are they used for?

};

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();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget your semi-colons!



$(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();
});
});