![]() |
|
[Ruby] Lockpick - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Coding (https://sinister.ly/Forum-Coding--71) +--- Thread: [Ruby] Lockpick (/Thread-Ruby-Lockpick) |
[Ruby] Lockpick - Inori - 04-24-2015 I got bored in class so I decided to make my first game (discounting Tic Tac Toe because it's not original) in Ruby. I'd like to say it models the Skyrim lockpick system but I know absolutely nothing about TES. The goal of this game is to, well, pick the lock. This is accomplished by using the available actions in a specific order, generated by the computer. I may update later but for the meantime, enjoy! Code: #lockpicker by Touka, ©2015
puts "enter difficulty (1-infinity):"
@diff = gets.to_i + 1
actions = [1, 2, 3, 4, 5, 6]
@sequence = []
@diff.times do |action|
action = actions.sample
@sequence << action
end
@completed = 0
@x = 0
def pick
system "cls"
puts """
_____
// \\\\
// \\\\
|| ||
|| ||
-----------
/ __ \\
| / \\ |
| | | |
| || |
| || |
\\ /
---------
progress:
#{@progress}
last attempt: #{@yn}
Options:
[1] Jab [4] Force
[2] Bump [5] Drag
[3] Tap [6] Swipe
"""
cact = gets.to_i
if cact == @sequence[@x]
@completed += 1
@x += 1
@yn = "Success"
else
if @x != 0
@completed -= 1
@x -= 1
else
@completed = 0
@x = 0
end
@yn = "Failed"
end
if @completed == @diff
system "cls"
puts"""
_____
// \\\\
// \\\\
|| ||
||
||
----------- Success!
/ __ \\
| / \\ |
| | | |
| || |
| || |
\\ /
---------
"""
sleep
else
@progress = "#{@completed} / #{@diff}"
pick
end
end
pickRE: [Ruby] Lockpick - Sikom - 04-24-2015 How do i go about testing the game? RE: [Ruby] Lockpick - Inori - 04-24-2015 (04-24-2015, 03:50 PM)SimPlaysGames Wrote: How do i go about testing the game? If you have the Ruby framework installed, paste the code in a text file and save it as lockpick.rb (or anything ending in .rb). If you don't have Ruby installed, there's instructions for installation here. (if the rubyinstaller.org link doesn't work, remove the "www.") RE: [Ruby] Lockpick - Sikom - 04-24-2015 (04-24-2015, 03:58 PM)Touka Wrote: If you have the Ruby framework installed, paste the code in a text file and save it as lockpick.rb (or anything ending in .rb). Thanks, tested it there is some peoblems You can't pick too high numbers is one of them RE: [Ruby] Lockpick - Inori - 04-24-2015 (04-24-2015, 04:11 PM)SimPlaysGames Wrote: Thanks, tested it there is some peoblems It's supposed to be different actions of picking a padlock, not a combination lock. I may use that, eventually. |