Last active
July 6, 2019 05:48
-
-
Save greysteil/96aa56c0d5e344b750ea9f53c646f6dc to your computer and use it in GitHub Desktop.
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
class StagDo | |
require_relative "../rule_checker" | |
attr_reader :stag, :date, :location | |
def initialize(stag:, date:, location:) | |
@stag = stag | |
@date = date | |
@location = location | |
@completed_challenges = [] | |
@completed_forfeits = [] | |
end | |
def instructions | |
instructions = | |
"Welcome to your stag do, #{stag}! We're headed to #{location}!\n\n"\ | |
"To run the stag do, simply call `run_stag_do` on this class. Stag do "\ | |
"rules will apply from #{stag_do_start} until #{stag_do_end}. These "\ | |
"rules are as follows:\n" | |
Constants::RULES.each do |rule| | |
instructions += "- #{rule}\n" | |
end | |
instructions += | |
"\n"\ | |
"During the stag do you can complete challenges to earn points. You'll "\ | |
"use these points to buy yourself out of forfeits at 23:00 on "\ | |
"#{date}.\n\n"\ | |
"The following challenges can be completed at any time before 23:00:\n" | |
Constants::ALL_DAY_CHALLENGES.each do |challenge| | |
instructions += "- #{challenge.fetch(:name)}\n" | |
end | |
instructions += | |
"\n"\ | |
"In addition, these challenges can only be completed between "\ | |
"18:00 and 23:00:\n" | |
Constants::EVENING_CHALLENGES.each do |challenge| | |
instructions += "- #{challenge.fetch(:name)}\n" | |
end | |
instructions += | |
"\n"\ | |
"At 23:00 on #{date} you will have the chance to decide which of the "\ | |
"following forfeits you wish to avoid, based on your amassed points:\n" | |
Constants::FORFEITS.each do |forfeit| | |
instructions += "- #{forfeit.fetch(:name)}\n" | |
end | |
instructions | |
end | |
def run_stag_do | |
Constants::GAMES.each(&:start) | |
while on_stag_do? | |
Constants::RULES.each do |rule| | |
next unless RuleChecker.rule_broken?(rule) | |
puts "Uh oh! You've broken a rule! To make amends, you must perform "\ | |
"the following forfeit:\n#{random_mystery_forfeit}" | |
RuleChecker.reset_rule!(rule) | |
end | |
end | |
Constants::GAMES.each(&:end) | |
end | |
def current_score | |
score = @completed_challenges.sum do |challenge_slug| | |
Constants::CHALLENGES. | |
find { |c| c.fetch(:slug) == challenge_slug }. | |
fetch(:points) | |
end | |
score += @completed_forfeits.sum do |forfeit_slug| | |
Constants::FORFEITS. | |
find { |c| c.fetch(:slug) == forfeit_slug }. | |
fetch(:points) | |
end | |
score | |
end | |
def mark_challenge_complete(challenge_slug:, password:) | |
unless password == secrets.fetch("best_man_password") | |
return "Nice try, #{stag}" | |
end | |
@completed_challenges << challenge_slug | |
end | |
def mark_forfeit_complete(forfeit_slug:, password:) | |
unless password == secrets.fetch("best_man_password") | |
return "Nice try, #{stag}" | |
end | |
@completed_forfeits << forfeit_slug | |
end | |
private | |
def secrets | |
YAML.load("~/#{stag}s_darkest_secrets.yaml") | |
end | |
def on_stag_do? | |
return false if Time.now < stag_do_start | |
return false if Time.now > stag_do_end | |
true | |
end | |
def stag_do_start | |
Time.parse(date + " 09:00:00") | |
end | |
def stag_do_end | |
Time.parse(date + " 18:00:00") + 1.day | |
end | |
def random_mystery_forfeit | |
secrets.fetch("mystery_forfeits").sample | |
end | |
end | |
class Constants | |
require_relative "../games" | |
RULES = [ | |
"You may only enter a drinking establishment with your left foot first", | |
"You may only drink with your off-hand", | |
"Your ===redacted=== costume must be worn at all times, until challenge :ru_paul is complete", | |
"You must keep an unbroken cracker on your person at all times, to be shown upon request", | |
"Points may be awarded or deducted at the discretion of the stag do party" | |
] | |
GAMES = [ | |
Games::DownMrPresident, | |
Games::TellEm, | |
Games::CopyPaste | |
] | |
ALL_DAY_CHALLENGES = [ | |
{ | |
slug: "photobomb", | |
name: "Get a photo with a group of tourists. The more outrageous, the "\ | |
"better (pts at discretion of stag party)" | |
points: nil | |
}, | |
{ | |
slug: "the_foreigner", | |
name: "Speak in an accent of your choosing (not your own) and convince "\ | |
"a stranger you’re foreign", | |
points: 20 | |
}, | |
{ | |
slug: "congratulations", | |
name: "Without asking for it, be congratulated on getting engaged by a "\ | |
"stranger", | |
points: 5 | |
}, | |
{ | |
slug: "my_musk", | |
name: "Spot a Tesla and declare it by shouting “Elon Musk, have my "\ | |
"babies!” as loud as you can", | |
points: 10 | |
}, | |
{ | |
slug: "tech_support", | |
name: "Randomly tell a stranger to “turn it off and back on“ when "\ | |
"they’re using their phone. If challenged, say “Trust me, I work "\ | |
"at a start-up“", | |
points: 25 | |
}, | |
{ | |
slug: "redacted", | |
name: "During each ===redacted=== session you must ask for a cheap "\ | |
"mixer to go with your drink. The same mixer can not be re-used "\ | |
"in future sessions", | |
points: 20 | |
}, | |
{ | |
slug: "first_responder", | |
name: "Find a bug in this code, and convince the rest of the stag party "\ | |
"of the bug's existence. This challenge may be completed multiple "\ | |
"times and always earns the same amount of points", | |
points: 10 | |
}, | |
] | |
EVENING_CHALLENGES = [ | |
{ | |
slug: "piggy_back", | |
name: "Give a stranger a piggy back round an entire bar or restaurant. "\ | |
"Earn 10 bonus points if your stranger meets any of the following "\ | |
"criteria: Morbidly obese, 70+ years old, Dwarf" | |
points: 20 | |
}, | |
{ | |
slug: "kiss_milf", | |
name: "Get a kiss from a MILF (or DILF, its 2019) who is clearly over "\ | |
"the age of 50" | |
points: 15 | |
}, | |
{ | |
slug: "do_you_even_lift", | |
name: "Beat a total stranger in a 15 press up competition - fastest wins" | |
points: 15 | |
}, | |
{ | |
slug: "kiss_me", | |
name: "Kiss a bride-to-be who's celebrating her hen party" | |
points: 10 | |
}, | |
{ | |
slug: "rupaul" | |
name: "Get a bra from a total stranger and wear it for as long as "\ | |
"they’ll let you", | |
points: 25 | |
}, | |
{ | |
slug: "making_friends", | |
name: "Pretend to be an acquaintance of a stranger for as long as "\ | |
"possible. (10pts for every minute the stranger is convinced)", | |
points: nil | |
}, | |
{ | |
slug: "freeloader", | |
name: "Convince the stranger from evening challenge 5 to buy you a drink", | |
points: 15 | |
} | |
] | |
CHALLENGES = [ | |
*ALL_DAY_CHALLENGES, | |
*EVENING_CHALLENGES | |
] | |
FORFEITS = [ | |
{ | |
slug: "big_night_in", | |
name: "Purchase a porno mag, hand cream, a cucumber and some tissues "\ | |
"all at once. No smirking", | |
points: 25 | |
}, | |
{ | |
slug: "bottoms_up", | |
name: "Down a pint of your choosing", | |
points: 20 | |
}, | |
{ | |
slug: "down_in_fresher", | |
name: "Down a pint of the stag party’s choosing", | |
points: 40 | |
}, | |
{ | |
slug: "minesweeper", | |
name: "Minesweep five unfinished drinks", | |
points: 60 | |
}, | |
{ | |
slug: "put_a_sock_in_it", | |
name: "Put your sock over your glass and drink a whole pint through it", | |
points: 50 | |
}, | |
{ | |
slug: "your_musk", | |
name: "If someone in the stag party spots a Tesla before you and "\ | |
"shouts “Elon Musks is mine!“, do a forfeit of their choosing", | |
points: 100 | |
}, | |
{ | |
slug: "sex_on_the_beach", | |
name: "Order the girliest drink possible at the bar", | |
points: 50 | |
}, | |
{ | |
slug: "niagra_falls", | |
name: "Straight arm a pint of beer", | |
points: 50 | |
} | |
] | |
end | |
stag_do = StagDo.new(stag: "Peter", date: "2019-07-06", location: "EDI") | |
puts stag_do.instructions | |
stag_do.run_stag_do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment