Last active
December 9, 2015 20:28
-
-
Save drochetti/4324451 to your computer and use it in GitHub Desktop.
A Javascript snippet representing a session, but not the web one... =)
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
(function(global) { | |
var myself = global.people.findById(global.github.me.dna()); // lol | |
myself.roll = myself.roll || function(weed, paper) { | |
weed = this.getGrinder().grind(weed); | |
return _.extend(weed, paper); | |
}; | |
var session = new Session({ | |
location : Location.SAME_OLD_SPOT, | |
people : _.union([myself], myself.getFriends().filter(Person.POT_HEAD)) | |
}); | |
try { | |
session.start(); | |
var weed = myself.getStash().get(Weed.SATIVA); | |
var paper = null; // ooops, out of paper (typical) | |
if (session.hasPaper()) { | |
paper = session.getPapers().first(); | |
} else { | |
var buyer = session.getPeople().find(Person.YOUNGEST); | |
paper = buyer.goTo(Location.NEAREST_STORE).buy(PaperType.RAW_KING_SIZE); | |
} | |
var joint = myself.roll(weed, paper); | |
joint = myself.takePuff(joint.catchFire()); | |
var who = myself; | |
while (!joint.isOver()) { | |
who = session.getNext(who); | |
if (!joint.isOn()) { joint = joint.catchFire(); } | |
joint = who.takePuff(joint); | |
} | |
} catch (exception) { | |
console.log('ignore, probably we\'re all high...'); | |
} finally { | |
var sessionSuccessful = session.isEverybodyHigh() && session.isEverybodyAwake(); | |
session.end(sessionSuccessful); | |
} | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh my!