sapling.rb: Multiple fixes
- Add logic for Planter, the editor module - Add logic for catching a bad switch, and reporting accordingly - Add logic for when no tree is included when required, and reporting accordingly - Move YAML file loading from Dialogue/Gardner to here
This commit is contained in:
parent
adecc3b193
commit
4570ee37e6
1 changed files with 27 additions and 5 deletions
|
@ -6,6 +6,7 @@ require 'yaml'
|
|||
require_relative 'sapling/dialogue'
|
||||
require_relative 'sapling/gardner'
|
||||
require_relative 'sapling/planter'
|
||||
require_relative 'sapling/utility'
|
||||
|
||||
# Sapling is the main module for the program. From here, the rest of the world
|
||||
# starts building.
|
||||
|
@ -31,29 +32,50 @@ module Sapling
|
|||
"Begin traversing the provided dialogue tree") do
|
||||
|
||||
if ARGV.empty?
|
||||
puts "No tree file provided. Please provide a tree file."
|
||||
puts opt_parser
|
||||
exit
|
||||
end
|
||||
|
||||
unless Gardner.verify_tree(ARGV[0])
|
||||
unless verify_tree(ARGV[0])
|
||||
puts "\n#{opt}\n"
|
||||
exit
|
||||
end
|
||||
|
||||
puts "Welcome to Sapling, a Dialogue Tree Utility.\n"
|
||||
speaker = Dialogue::Speaker.new
|
||||
speaker.file = ARGV
|
||||
speaker.file = YAML.load_file(ARGV[0])
|
||||
speaker.conversation
|
||||
end
|
||||
|
||||
opt.on("-e", "--edit",
|
||||
"Create or edit a dialogue tree") do
|
||||
puts "We gonna make a tree!"
|
||||
|
||||
if ARGV.empty?
|
||||
puts "Creating a new tree."
|
||||
tree = SKELETON_TREE
|
||||
else
|
||||
puts "Using tree at #{ARGV[0]}."
|
||||
unless verify_tree(ARGV[0])
|
||||
puts "\n#{opt}\n"
|
||||
exit
|
||||
end
|
||||
tree = YAML.load_file(ARGV[0])
|
||||
end
|
||||
|
||||
puts "Welcome to Sapling, a Dialogue Tree Utility.\n"
|
||||
gardner = Planter::Spade.new
|
||||
gardner.file = tree
|
||||
gardner.plant
|
||||
end
|
||||
|
||||
end
|
||||
opt_parser.parse!(options)
|
||||
|
||||
if ARGV.empty?
|
||||
# Hacky way of dealing with bad options
|
||||
begin
|
||||
opt_parser.parse!(options)
|
||||
rescue OptionParser::InvalidOption
|
||||
puts "Invalid option."
|
||||
puts opt_parser
|
||||
exit
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue