Planter: Gardner to Dialogue
This commit is contained in:
parent
783fb886fd
commit
dfc4117527
1 changed files with 8 additions and 7 deletions
|
@ -4,15 +4,17 @@ require_relative './utility'
|
||||||
|
|
||||||
# Planter is the module for creating or editing a tree.
|
# Planter is the module for creating or editing a tree.
|
||||||
module Planter
|
module Planter
|
||||||
|
|
||||||
# In-memory tree
|
# In-memory tree
|
||||||
class Plot
|
class Plot
|
||||||
|
|
||||||
# The tree, trunk, and branches
|
# The tree, trunk, and branches
|
||||||
attr_accessor :tree, :trunk, :branches
|
attr_accessor :tree, :trunk, :branches
|
||||||
|
|
||||||
# Edit the trunk of the tree
|
# Edit the trunk of the tree
|
||||||
def edit_trunk
|
def edit_trunk
|
||||||
puts "Current Trunk:\n"
|
puts "Current Trunk:\n"
|
||||||
Gardner.display_trunk(@trunk, true)
|
Dialogue.display_trunk(@trunk, true)
|
||||||
print "\n[ =EDITING= ](CTRL-C to abort)> "
|
print "\n[ =EDITING= ](CTRL-C to abort)> "
|
||||||
STDOUT.flush
|
STDOUT.flush
|
||||||
begin
|
begin
|
||||||
|
@ -29,7 +31,7 @@ module Planter
|
||||||
# @param branch [Integer] The number of the branch to be edited.
|
# @param branch [Integer] The number of the branch to be edited.
|
||||||
def edit_branch(branch_no)
|
def edit_branch(branch_no)
|
||||||
puts "Current Branch:\n"
|
puts "Current Branch:\n"
|
||||||
Gardner.display_branch(@branches[branch_no], branch_no, true)
|
Dialogue.display_branch(@branches[branch_no], branch_no, true)
|
||||||
print "\n[ =EDITING= ](CTRL-C to abort)> "
|
print "\n[ =EDITING= ](CTRL-C to abort)> "
|
||||||
STDOUT.flush
|
STDOUT.flush
|
||||||
begin
|
begin
|
||||||
|
@ -52,6 +54,7 @@ module Planter
|
||||||
|
|
||||||
# Utilities for editing specific parts of a tree.
|
# Utilities for editing specific parts of a tree.
|
||||||
class Spade
|
class Spade
|
||||||
|
|
||||||
# The file we parse into a tree
|
# The file we parse into a tree
|
||||||
attr_writer :file
|
attr_writer :file
|
||||||
|
|
||||||
|
@ -84,8 +87,8 @@ module Planter
|
||||||
def dig(branch_no)
|
def dig(branch_no)
|
||||||
branch = @plot.branches[branch_no]
|
branch = @plot.branches[branch_no]
|
||||||
|
|
||||||
Gardner.display_trunk(@plot.trunk, true)
|
Dialogue.display_trunk(@plot.trunk, true)
|
||||||
Gardner.display_branch(branch, branch_no, true)
|
Dialogue.display_branch(branch, branch_no, true)
|
||||||
|
|
||||||
response = get_response(branch)
|
response = get_response(branch)
|
||||||
to_branch = parse_response(response, branch_no)
|
to_branch = parse_response(response, branch_no)
|
||||||
|
@ -157,9 +160,7 @@ module Planter
|
||||||
print "Unsaved changes will be lost. Still quit? [y/n]> "
|
print "Unsaved changes will be lost. Still quit? [y/n]> "
|
||||||
verify = STDIN.gets.chomp.to_s.downcase
|
verify = STDIN.gets.chomp.to_s.downcase
|
||||||
|
|
||||||
return 0 if verify == "y"
|
return 0 if verify == "y" else branch_no
|
||||||
|
|
||||||
return branch_no
|
|
||||||
else
|
else
|
||||||
print "Unknown option. Returning to current branch.)\n\n"
|
print "Unknown option. Returning to current branch.)\n\n"
|
||||||
return branch_no
|
return branch_no
|
||||||
|
|
Loading…
Reference in a new issue