forked from AdaGold/Languages
-
Notifications
You must be signed in to change notification settings - Fork 16
PlanetExpress in Javascript #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
knaydee
wants to merge
1
commit into
Ada-C4:master
Choose a base branch
from
knaydee:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| 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> |
This file contains hidden or 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
| 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; | ||
| }; | ||
|
|
||
| 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(); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?