Skip to content

Instantly share code, notes, and snippets.

@amirrajan
Created June 22, 2024 16:06
Show Gist options
  • Save amirrajan/e39f94e8a63ca38bf9bebcd105e23840 to your computer and use it in GitHub Desktop.
Save amirrajan/e39f94e8a63ca38bf9bebcd105e23840 to your computer and use it in GitHub Desktop.
The Ensign - Mind Games source
class MindGames
attr_accessor :message_history, :message
def initialize game
@game = game
@message = ""
@message_history = []
@random_tips = []
end
def tutorial_mode?
world.tutorial_mode?
end
def current_message
return false if !@message
return false if @message == ""
return @message if !@message_history.include? @message
false
end
def mark_message_as_seen
@message_history << @message if !seen? @message
end
def will_close
@game.view_state = :mind_games_just_dismissed
end
def world
@game.world
end
def total_deaths
world.food_deaths + world.battle_deaths + world.water_deaths
end
def havent_cleared_tannery?
!world.mine_cleared? :tannery
end
def havent_cleared_iron_mine?
!world.mine_cleared? :iron_mine
end
def dont_give_up
"don't give up. follow the compass."
end
def grit
"grit: (noun) \\ˈgrit\\ - firmness of mind or spirit. unyielding courage in the face of hardship or danger."
end
def only_way_to_lose
"the only way to lose is to give up all together."
end
def perseverance
"perseverance: (noun) \\ˌpər-sə-ˈvir-ən(t)s\\ - continued effort to do or achieve something despite opposition."
end
def seen? message
@message_history.include? message
end
def has_compass?
(@game.stores[:compass] || 0) > 0
end
def house_tip
"need to head for the H."
end
def compass_tip
"follow the compass."
end
def tannery_tip
"heal often. heal after battle."
end
def tannery_tip_2
"focus. channel the frustration. victory worth having is never presented on a silver platter."
end
def progress
"progress with every step."
end
def lessons_learned
"lessons learned with each journey."
end
def havent_found? landmark
!world.has_visited? landmark and has_compass?
end
def tutorial
#BEGINING PHASE
#if it's their first death and they didn't make it to H, tell them to head to the H
#continue to tell them to head to the H if they haven't made it there
if(!world.has_visited? :close_house and !world.has_visited? :house)
@message = house_tip
@message_history.delete house_tip
return
end
#THEY HAVE FOUND THE HOUSE
#if it's their first death, tell them not to give up
if !seen? dont_give_up
@message = dont_give_up
return
end
#if it's their second death, present the definition of grit
if !seen? grit
@message = grit
return
end
if !seen? only_way_to_lose
@message = only_way_to_lose
return
end
#THEY HAVEN'T FOUND THE TANNERY YET
if havent_found? :tannery
@message = compass_tip
@message_history.delete compass_tip
return
end
#MORE WORDS OF ENCOURAGEMENT
if !seen? perseverance
@message = perseverance
return
end
#IF THEY STILL HAVEN'T BEATEN THE TANNERY, HELP THEM OUT WITH A TIP
if havent_cleared_tannery?
if !seen? tannery_tip
@message = tannery_tip
return
end
if !seen? tannery_tip_2
@message = tannery_tip_2
return
end
tip = random_tips.sample
if !seen? tip
@message = tip
return
end
end
#LET THEM KNOW THAT PROGRESS WAS MADE
if !seen? progress
@message = progress
return
end
if !seen? lessons_learned
@message = lessons_learned
return
end
if havent_found? :iron_mine
@message = compass_tip
@message_history.delete compass_tip
return
end
tip = random_tips.sample
if !seen? tip
@message = tip
return
end
end
def process
if tutorial_mode?
tutorial
else
real_game
end
end
def true_game
"the true journey begins now."
end
def lose_hope
"want to give up?"
end
def will_broken
"will broken yet? give up now. just like the rest."
end
def thirsty_messages
hunger_thirsty_messages
end
def hunger_messages
hunger_thirsty_messages
end
def hunger_thirsty_messages
@hunger_thirsty_messages ||= [
"just blame the map generation. that's it. just blame that.",
"only have one thing to say really... never gonna give you up. never gonna let you down.",
"of course there's only one life. survival isn't a game.",
"it's just one number to keep track of. how hard is that?",
"your device wanted me to relay a message to you: 'stop poking me!'"
]
end
def battle_messages
@battle_messages ||= [
"only have one thing to say really... never gonna give you up. never gonna let you down.",
"of course there's only one life. survival isn't a game.",
"how hard is it to activate progress bars? that's all this really is.",
"don't take it out on your device. this isn't its fault.",
"at least you've learned what *not* to do.",
"your device wanted me to relay a message to you: 'stop poking me!'",
"die again and snipers will be sent to take out your bff."
]
end
def impossible_messages
@impossible_messages ||= [
"only have one thing to say really... never gonna give you up. never gonna let you down.",
"it's impossible to beat. just quit.",
"just delete it. it's that simple. maybe that's the only way to win.",
"this is just an experiment to see how much punishment one can take before quitting.",
"ever heard of kobayashi maru?",
"number of deaths so far: a lot. a whole lot.",
"your device wanted me to relay a message to you: 'stop poking me!'",
"die again and snipers will be sent to take out your bff."
]
end
def defector_messages
@defector_messages ||= [
"what's it like to be hunted?",
"i am the one who knocks.",
"try not to have nightmares.",
"an \"&\" will never be viewed the same way again."
]
end
def hint_about_top_left
"what? expecting cake or something? head to the top left corner of the world. the cake's over there."
end
def god_mode
"god mode unlocked. refuse food again. i dare you."
end
def seen_cake_hint?
seen? hint_about_top_left
end
def seen_god_mode_hint?
seen? god_mode
end
def real_game
#IF YOU BEAT THE GAME
if world.death_reason == :complete
if(!seen? hint_about_top_left)
@message = hint_about_top_left
return
end
end
if world.death_reason == :complete_hard
if(!seen? god_mode)
@message = god_mode
return
end
end
if world.death_reason == :crashed
if(!seen? "ouch. so close. *hugs*")
@message = "ouch. so close. *hugs*"
return
end
end
#DEATH AT TANNERY
if world.death_reason == :battle and world.tannery_event?
if !seen? "defeated at the tannery? at this stage? so careless."
@message = "defeated at the tannery? at this stage? so careless."
return
end
end
#DONT RETURN ANYTHING IF THEY KEEP DYING UNDER 3 MINUTES
return if @game.world.move_count < 30
#LET THEM KNOW THE TRUE JOURNEY HAS BEGUN
message_to_place = true_game
if(!seen? message_to_place)
@message = message_to_place
return
end
#DEHYDRATION
if world.death_reason == :dehydration
message_to_place = thirsty_messages.sample
if(!seen? message_to_place)
@message = message_to_place
return
end
end
#STARVATION
if world.death_reason == :starvation
message_to_place = hunger_messages.sample
if(!seen? message_to_place)
@message = message_to_place
return
end
end
#SNIPER
if world.death_reason == :battle and world.sniper_event?
if !seen? "headshot."
@message = "headshot."
return
end
if !seen? "headshot. again."
@message = "headshot. again."
return
end
if !seen? "headshot for the third time. lol."
@message = "headshot for the third time. lol."
return
end
end
#DEATH BY DEFECTORS
if world.death_reason == :battle and world.defector_event?
message_to_place = defector_messages.sample
if(!seen? message_to_place)
@message = message_to_place
return
end
end
#DEATH BY BATTLE
if world.death_reason == :battle
message_to_place = battle_messages.sample
if(!seen? message_to_place)
@message = message_to_place
return
end
end
#WOW, THEY GOT THIS FAR. THEY SHOULD PROBABLY GIVE UP
if (world.death_reason != :complete) && (world.death_reason != :complete_hard)
message_to_place = impossible_messages.sample
if(!seen? message_to_place)
@message = message_to_place
return
end
message_to_place = "go ahead. give up. (don't give up)"
if(!seen? message_to_place)
@message = message_to_place
return
end
else
@message = "hmph. try that again. i dare you."
end
end
def random_tips
@random_tips ||= [
"again!",
"never surrender.",
"houses almost always have food and weapons.",
"the scars of battle bring strength.",
"houses replenish water. quenches wanderer's thirst.",
"gotten this far. can't stop now.",
"bolas to tangle foes.",
"caves for stronger weapons. must fight.",
"how many would have given up by now? the strong willed continue.",
"durability on weapons drop when used.",
"never give up.",
"conquer this test of will.",
"bear down, and conquer.",
]
end
def stub_random_tips tips
@random_tips = tips
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment