Skip to content

Instantly share code, notes, and snippets.

@drochetti
Last active December 9, 2015 20:28
Show Gist options
  • Save drochetti/4324451 to your computer and use it in GitHub Desktop.
Save drochetti/4324451 to your computer and use it in GitHub Desktop.
A Javascript snippet representing a session, but not the web one... =)
(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);
@flavioalves
Copy link

oh my!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment