diff --git a/lib/aethyr/core/actions/commands/acarea.rb b/lib/aethyr/core/actions/commands/acarea.rb new file mode 100644 index 0000000000000000000000000000000000000000..0b8486fcc91779f502fbfb75601fe7fe7e658ee3 --- /dev/null +++ b/lib/aethyr/core/actions/commands/acarea.rb @@ -0,0 +1,25 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Acarea + class AcareaCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + area = $manager.create_object(Area, nil, nil, nil, {:@name => event[:name]}) + player.output "Created: #{area}" + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/acdoor.rb b/lib/aethyr/core/actions/commands/acdoor.rb new file mode 100644 index 0000000000000000000000000000000000000000..7cfb5fa6b5020c7edb140e0a2f1814e1131230d0 --- /dev/null +++ b/lib/aethyr/core/actions/commands/acdoor.rb @@ -0,0 +1,60 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Acdoor + class AcdoorCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + player = @player + exit_room = nil + if event[:exit_room].nil? + out = find_object event[:direction], event + if out and out.is_a? Exit + exit_room = $manager.find out.exit_room + other_side = $manager.find opposite_dir(event[:direction]), out.exit_room + + if other_side + $manager.delete_object other_side + player.output "Removed opposite exit (#{other_side})." + else + player.output "Could not find opposite exit" + end + + $manager.delete_object out + player.output "Removed exit (#{out})." + end + else + exit_room = $manager.get_object event[:exit_room] + end + + if exit_room.nil? + player.output "Cannot find #{event[:exit_room]} to connect to." + return + end + + door_here = $manager.create_object Door, room, nil, exit_room.goid, :@alt_names => [event[:direction]], :@name => "a door to the #{event[:direction]}" + door_there = $manager.create_object Door, exit_room, nil, room.goid, :@alt_names => [opposite_dir(event[:direction])], :@name => "a door to the #{opposite_dir event[:direction]}" + door_here.connect_to door_there + + player.output "Created: #{door_here}" + player.output "Created: #{door_there}" + + if room + event[:to_player] = "Frowning in concentration, you make vague motions with your hands. There is a small flash of light as #{door_here.name} to #{exit_room.name} appears." + event[:to_other] = "Frowning in concentration, #{player.name} makes vague motions with #{player.pronoun(:possessive)} hands. There is a small flash of light as #{door_here.name} to #{exit_room.name} appears." + room.out_event event + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/acomment.rb b/lib/aethyr/core/actions/commands/acomment.rb new file mode 100644 index 0000000000000000000000000000000000000000..08f07684789960db7126de5651d4c1c1fd778e2b --- /dev/null +++ b/lib/aethyr/core/actions/commands/acomment.rb @@ -0,0 +1,31 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Acomment + class AcommentCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = find_object(event[:target], event) + if object.nil? + player.output "Cannot find:#{event[:target]}" + return + end + + object.comment = event[:comment] + player.output "Added comment: '#{event[:comment]}'\nto#{object}" + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/aconfig.rb b/lib/aethyr/core/actions/commands/aconfig.rb new file mode 100644 index 0000000000000000000000000000000000000000..c941e224c8d83e0d17aa03a0d157c28bc0da51a3 --- /dev/null +++ b/lib/aethyr/core/actions/commands/aconfig.rb @@ -0,0 +1,48 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Aconfig + class AconfigCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + if event[:setting].nil? + player.output "Current configuration:\n#{ServerConfig}" + return + end + + setting = event[:setting].downcase.to_sym + + if setting == :reload + ServerConfig.reload + player.output "Reloaded configuration:\n#{ServerConfig}" + return + elsif not ServerConfig.has_setting? setting + player.output "No such setting." + return + end + + value = event[:value] + if value =~ /^\d+$/ + value = value.to_i + end + + ServerConfig[setting] = value + + player.output "New configuration:\n#{ServerConfig}" + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/acportal.rb b/lib/aethyr/core/actions/commands/acportal.rb new file mode 100644 index 0000000000000000000000000000000000000000..5e42cc92f9cb73d9f51a9ea0f45fea094d87f9fe --- /dev/null +++ b/lib/aethyr/core/actions/commands/acportal.rb @@ -0,0 +1,27 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Acportal + class AcportalCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = Admin.acreate(event, player, room) + if event[:portal_action] and event[:portal_action].downcase != "enter" + object.info.portal_action = event[:portal_action].downcase.to_sym + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/acreate.rb b/lib/aethyr/core/actions/commands/acreate.rb new file mode 100644 index 0000000000000000000000000000000000000000..15c3bc8d2aa1bb0640d0187381cf200d247974fe --- /dev/null +++ b/lib/aethyr/core/actions/commands/acreate.rb @@ -0,0 +1,55 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Acreate + class AcreateCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + class_name = event[:object] + + class_name[0,1] = class_name[0,1].capitalize + + if Object.const_defined? class_name + klass = Object.const_get(class_name) + else + player.output "No such thing. Sorry." + return + end + + if not klass <= GameObject or klass == Player + player.output "You cannot create a #{klass.class}." + return + end + + vars = {} + vars[:@name] = event[:name] if event[:name] + vars[:@alt_names] = event[:alt_names] if event[:alt_names] + vars[:@generic] = event[:generic] if event[:generic] + args = event[:args] + + object = $manager.create_object(klass, room, nil, args, vars) + + if room + event[:to_player] = "Frowning in concentration, you make vague motions with your hands. There is a small flash of light as #{object.name} appears." + event[:to_other] = "Frowning in concentration, #{player.name} makes vague motions with #{player.pronoun(:possessive)} hands. There is a small flash of light as #{object.name} appears." + room.out_event event + end + + player.output "Created: #{object}" + object + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/acroom.rb b/lib/aethyr/core/actions/commands/acroom.rb new file mode 100644 index 0000000000000000000000000000000000000000..abc14cf99bffb18a22b93b75abbd7122a48b35a2 --- /dev/null +++ b/lib/aethyr/core/actions/commands/acroom.rb @@ -0,0 +1,107 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Acroom + class AcroomCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + area = nil + if room.container + area = $manager.get_object(room.container) + end + + unless area.nil? or area.map_type.eql? :none + current_pos = area.position(room) + new_pos = current_pos.dup + case event[:out_dir].downcase.strip + when "north" + new_pos[1] += 1 + when "south" + new_pos[1] -= 1 + when "west" + new_pos[0] -= 1 + when "east" + new_pos[0] += 1 + when "northeast" + player.output "Can not create a #{event[:out_dir]} exit in a mappable area at this time" + return + when "northwest" + player.output "Can not create a #{event[:out_dir]} exit in a mappable area at this time" + return + when "southeast" + player.output "Can not create a #{event[:out_dir]} exit in a mappable area at this time" + return + when "southwest" + player.output "Can not create a #{event[:out_dir]} exit in a mappable area at this time" + return + else + new_pos = nil + end + new_pos_text = new_pos.map{ |e| e.to_s}.join('x') unless new_pos.nil? + end + + unless new_pos.nil? or area.find_by_position(new_pos).nil? + player.output "There is already a room at the coordinates (#{new_pos_text}) that would be occupied by the new room, aborting" + return + end + + new_room = $manager.create_object(Room, area, new_pos, nil, :@name => event[:name]) + out_exit = $manager.create_object(Exit, room, nil, new_room.goid, :@alt_names => [event[:out_dir]]) + in_exit = $manager.create_object(Exit, new_room, nil, room.goid, :@alt_names => [event[:in_dir]]) + + player.output "Created: #{new_room}#{new_pos.nil? ? '' : ' @ ' + new_pos_text}" + player.output "Created: #{out_exit}" + player.output "Created: #{in_exit}" + + if !area.nil? and area.map_type.eql? :world + west = area.find_by_position([new_pos[0] - 1, new_pos[1]]) + east = area.find_by_position([new_pos[0] + 1, new_pos[1]]) + north = area.find_by_position([new_pos[0], new_pos[1] + 1]) + south = area.find_by_position([new_pos[0], new_pos[1] - 1]) + if !west.nil? and !west.eql? room + out_exit = $manager.create_object(Exit, new_room, nil, west.goid, :@alt_names => ["west"]) + in_exit = $manager.create_object(Exit, west, nil, new_room.goid, :@alt_names => ["east"]) + player.output "Created: #{out_exit}" + player.output "Created: #{in_exit}" + west.output "There is a small flash of light as a new room appears to the east." + elsif !east.nil? and !east.eql? room + out_exit = $manager.create_object(Exit, new_room, nil, east.goid, :@alt_names => ["east"]) + in_exit = $manager.create_object(Exit, east, nil, new_room.goid, :@alt_names => ["west"]) + player.output "Created: #{out_exit}" + player.output "Created: #{in_exit}" + east.output "There is a small flash of light as a new room appears to the west." + elsif !north.nil? and !north.eql? room + out_exit = $manager.create_object(Exit, new_room, nil, north.goid, :@alt_names => ["north"]) + in_exit = $manager.create_object(Exit, north, nil, new_room.goid, :@alt_names => ["south"]) + player.output "Created: #{out_exit}" + player.output "Created: #{in_exit}" + north.output "There is a small flash of light as a new room appears to the south." + elsif !south.nil? and !south.eql? room + out_exit = $manager.create_object(Exit, new_room, nil, south.goid, :@alt_names => ["south"]) + in_exit = $manager.create_object(Exit, south, nil, new_room.goid, :@alt_names => ["north"]) + player.output "Created: #{out_exit}" + player.output "Created: #{in_exit}" + south.output "There is a small flash of light as a new room appears to the north." + end + end + + if room + room.output "There is a small flash of light as a new room appears to the #{event[:out_dir]}." + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/adelete.rb b/lib/aethyr/core/actions/commands/adelete.rb new file mode 100644 index 0000000000000000000000000000000000000000..e84f1d80f8e8c841d8a36bf4df7ee49b192f1874 --- /dev/null +++ b/lib/aethyr/core/actions/commands/adelete.rb @@ -0,0 +1,69 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Adelete + class AdeleteCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:object] and event[:object].split.first.downcase == "all" + log event[:object].split + klass = event[:object].split[1] + klass.capitalize! unless klass[0,1] == klass[0,1].upcase + begin + klass = Module.const_get klass.to_sym + rescue NameError + player.output "No such object type." + return + end + + objects = $manager.find_all("class", klass) + + objects.each do |obj| + e = event.dup + e[:object] = obj.goid + + Admin.adelete(e, player, room) + end + + return + end + + object = find_object(event[:object], event) + + if object.nil? + player.output "Cannot find #{event[:object]} to delete." + return + elsif object.is_a? Player + player.output "Use DELETEPLAYER to delete players." + return + end + + object_container = object.container + + $manager.delete_object(object) + + if room and room.goid == object.container + event[:to_player] = "You casually wave your hand and #{object.name} disappears." + event[:to_other] = "With a casual wave of #{player.pronoun(:possessive)} hand, #{player.name} makes #{object.name} disappear." + room.out_event event + else + player.output "You casually wave your hand and #{object.name} disappears." + end + + player.output "#{object} deleted." + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/adesc.rb b/lib/aethyr/core/actions/commands/adesc.rb new file mode 100644 index 0000000000000000000000000000000000000000..312c311f859e97ba51fba3bba8d820c147384c2e --- /dev/null +++ b/lib/aethyr/core/actions/commands/adesc.rb @@ -0,0 +1,47 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Adesc + class AdescCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = nil + if event[:object].downcase == "here" + object = room + else + object = find_object(event[:object], event) + end + + if object.nil? + player.output "Cannot find #{event[:object]}." + return + end + + if event[:inroom] + if event[:desc].nil? or event[:desc].downcase == "false" + object.show_in_look = false + player.output "#{object.name} will not be shown in the room description." + else + object.show_in_look= event[:desc] + player.output "The room will show #{object.show_in_look}" + end + else + object.instance_variable_set(:@short_desc, event[:desc]) + player.output "#{object.name} now looks like:\n#{object.short_desc}" + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/aforce.rb b/lib/aethyr/core/actions/commands/aforce.rb new file mode 100644 index 0000000000000000000000000000000000000000..d7b47e1883baa756ef5807a276bb2d20859dc4e7 --- /dev/null +++ b/lib/aethyr/core/actions/commands/aforce.rb @@ -0,0 +1,33 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Aforce + class AforceCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = find_object(event[:target], event) + if object.nil? + player.output "Force who?" + return + elsif object.is_a? Player + object.handle_input(event[:command]) + else + player.output "You can only force other players to execute a command." + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/agree.rb b/lib/aethyr/core/actions/commands/agree.rb new file mode 100644 index 0000000000000000000000000000000000000000..6386efb95286465f1044597a232dd7fe0ad7e3e9 --- /dev/null +++ b/lib/aethyr/core/actions/commands/agree.rb @@ -0,0 +1,46 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Agree + class AgreeCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You nod your head in agreement." + to_other "#{player.name} nods #{player.pronoun(:possessive)} head in agreement." + to_deaf_other event[:to_other] + end + + self_target do + to_player "You are in complete agreement with yourself." + to_other "#{player.name} nods at #{player.pronoun(:reflexive)}, apparently in complete agreement." + to_deaf_other event[:to_other] + end + + target do + to_player "You nod your head in agreement with #{event.target.name}." + to_target "#{player.name} nods #{player.pronoun(:possessive)} head in agreement with you." + to_other "#{player.name} nods #{player.pronoun(:possessive)} head in agreement with #{event.target.name}." + to_deaf_other event[:to_other] + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/ahelp.rb b/lib/aethyr/core/actions/commands/ahelp.rb new file mode 100644 index 0000000000000000000000000000000000000000..9d02e73f45cff4dd6157fc41fb1745d8364b5f5a --- /dev/null +++ b/lib/aethyr/core/actions/commands/ahelp.rb @@ -0,0 +1,24 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Ahelp + class AhelpCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + Generic.help(event, player, room) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/ahide.rb b/lib/aethyr/core/actions/commands/ahide.rb new file mode 100644 index 0000000000000000000000000000000000000000..e5f1818b6ae177017b91bf00219770c66e37a36f --- /dev/null +++ b/lib/aethyr/core/actions/commands/ahide.rb @@ -0,0 +1,39 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Ahide + class AhideCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = find_object(event[:object], event) + + if object.nil? + player.output "Cannot find #{event[:object]}." + return + end + + if event[:hide] + object.show_in_look = "" + player.output "#{object.name} is now hidden." + elsif object.show_in_look == "" + object.show_in_look = false + player.output "#{object.name} is no longer hidden." + else + player.output "This object is not hidden." + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/ainfo.rb b/lib/aethyr/core/actions/commands/ainfo.rb new file mode 100644 index 0000000000000000000000000000000000000000..3608d14565890eac7c31d2d0edb6e01475940826 --- /dev/null +++ b/lib/aethyr/core/actions/commands/ainfo.rb @@ -0,0 +1,88 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Ainfo + class AinfoCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:object].downcase == "here" + event[:object] = player.container + elsif event[:object].downcase == "me" + event[:object] = player + elsif event[:object] and event[:object].split.first.downcase == "all" + log event[:object].split + klass = event[:object].split[1] + klass.capitalize! unless klass[0,1] == klass[0,1].upcase + begin + klass = Module.const_get klass.to_sym + rescue NameError + player.output "No such object type." + return + end + + objects = $manager.find_all("class", klass) + + objects.each do |obj| + e = event.dup + e[:object] = obj.goid + + Admin.ainfo(e, player, room) + end + + return + end + + object = find_object(event[:object], event) + + if object.nil? + player.output "What object? #{event[:object]}" + return + end + + case event[:command] + when "set" + value = event[:value] #for ease + if value.split.length == 1 + if value == "true" + value = true + elsif value == "false" + value = false + elsif value[0,1] == ":" + value = value[1..-1].to_sym + elsif value == "nil" + value = nil + elsif value.match(/^[0-9]+$/) + value = value.to_i + elsif value.downcase == "!nothing" + value = "" + end + end + object.info.set(event[:attrib], value) + player.output "Set #{event[:attrib]} to #{object.info.get(event[:attrib])}" + when "delete" + object.info.delete(event[:attrib]) + player.output "Deleted #{event[:attrib]} from #{object}" + when "show" + player.output object.info.inspect + when "clear" + object.info = Info.new + player.output "Completely cleared info for #{object}." + else + player.output "Huh? What?" + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/alearn.rb b/lib/aethyr/core/actions/commands/alearn.rb new file mode 100644 index 0000000000000000000000000000000000000000..2fdbba62bca182af9f0a22582df0d215cf5b92e5 --- /dev/null +++ b/lib/aethyr/core/actions/commands/alearn.rb @@ -0,0 +1,23 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Alearn + class AlearnCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/alist.rb b/lib/aethyr/core/actions/commands/alist.rb new file mode 100644 index 0000000000000000000000000000000000000000..504e816c0a94b2225d51f632f2c05aa4144dc9ce --- /dev/null +++ b/lib/aethyr/core/actions/commands/alist.rb @@ -0,0 +1,42 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Alist + class AlistCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + objects = nil + if event[:match].nil? + objects = $manager.find_all("class", :GameObject) + else + objects = $manager.find_all(event[:match], event[:attrib]) + end + + if objects.empty? + player.output "Nothing like that to list!" + else + output = [] + objects.each do |o| + output << "\t" + o.to_s + end + + output = output.join("\n") + + player.output(output) + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/all.rb b/lib/aethyr/core/actions/commands/all.rb new file mode 100644 index 0000000000000000000000000000000000000000..f0b3c5aec7d76b7c193b383ad64789d79afc2e66 --- /dev/null +++ b/lib/aethyr/core/actions/commands/all.rb @@ -0,0 +1,33 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module All + class AllCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + board = find_board(event, room) + + if board.nil? + player.output "There do not seem to be any postings here." + return + end + + wordwrap = player.word_wrap || 100 + + player.output board.list_latest(wordwrap, 0, nil) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/alog.rb b/lib/aethyr/core/actions/commands/alog.rb new file mode 100644 index 0000000000000000000000000000000000000000..4a316204b07caf7db81acacce634c17883d9a55c --- /dev/null +++ b/lib/aethyr/core/actions/commands/alog.rb @@ -0,0 +1,79 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Alog + class AlogCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:command].nil? + player.output "What do you want to do with the log?" + return + else + command = event[:command].downcase + end + + case command + when /^players?$/ + if event[:value] + lines = event[:value].to_i + else + lines = 10 + end + + player.output tail('logs/player.log', lines) + when 'server' + if event[:value] + lines = event[:value].to_i + else + lines = 10 + end + + player.output tail('logs/server.log', lines) + when 'system' + if event[:value] + lines = event[:value].to_i + else + lines = 10 + end + + $LOG.dump + + player.output tail('logs/system.log', lines) + when 'flush' + log('Flushing log') + $LOG.dump + player.output 'Flushed log to disk.' + when 'ultimate' + ServerConfig[:log_level] = 3 + player.output "Log level now set to ULTIMATE." + when 'high' + ServerConfig[:log_level] = 2 + player.output "Log level now set to high." + when 'low', 'normal' + ServerConfig[:log_level] = 1 + player.output "Log level now set to normal." + when 'off' + ServerConfig[:log_level] = 0 + player.output "Logging mostly turned off. You may also want to turn off debugging." + when 'debug' + ServerConfig[:debug] = !$DEBUG + player.output "Debug info is now: #{$DEBUG ? 'on' : 'off'}" + else + player.output 'Possible settings: Off, Debug, Normal, High, or Ultimate' + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/alook.rb b/lib/aethyr/core/actions/commands/alook.rb new file mode 100644 index 0000000000000000000000000000000000000000..394733629663b5ea29bfa42adf2009a6ac3c83e1 --- /dev/null +++ b/lib/aethyr/core/actions/commands/alook.rb @@ -0,0 +1,69 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Alook + class AlookCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:at].nil? + object = room + elsif event[:at].downcase == "here" + object = $manager.find player.container + else + object = find_object(event[:at], event) + end + + if object.nil? + player.output "Cannot find #{event[:at]} to inspect." + return + end + + output = "Object: #{object}\n" + output << "Attributes:\n" + + object.instance_variables.sort.each do |var| + val = object.instance_variable_get(var) + if var == :@observer_peers + val = val.keys.map {|k| k.to_s } + elsif var == :@local_registrations + val = val.map { |e| e.instance_variable_get(:@listener).to_s.tr('#<>', '') } + end + output << "\t#{var} = #{val}\n" + end + + output << "\r\nInventory:\r\n" + + if object.respond_to? :inventory + object.inventory.each do |o| + output << "\t#{o.name} # #{o.goid} #{object.inventory.position(o) == nil ? "" : object.inventory.position(o).map(&:to_s).join('x')}\n" + end + else + output << "\tNo Inventory" + end + + if object.respond_to? :equipment + output << "\r\nEquipment:\r\n" + object.equipment.inventory.each do |o| + output << "\t#{o.name} # #{o.goid}\n" + end + output << "\t#{object.equipment.equipment.inspect}\n" + end + + puts output + player.output(output) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/aput.rb b/lib/aethyr/core/actions/commands/aput.rb new file mode 100644 index 0000000000000000000000000000000000000000..5f80ffda6765d2a669f62ab3b5ea0504bb901817 --- /dev/null +++ b/lib/aethyr/core/actions/commands/aput.rb @@ -0,0 +1,71 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Aput + class AputCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:object].is_a? GameObject + object = event[:object] + else + event[:object] = player.container if event[:object].downcase == "here" + object = find_object(event[:object], event) + end + + container = find_object(event[:in], event) + + if object.nil? + player.output "Cannot find #{event[:object]} to move." + return + elsif event[:in] == "!world" + container = $manager.find object.container + container.inventory.remove(object) unless container.nil? + object.container = nil + player.output "Removed #{object} from any containers." + return + elsif event[:in].downcase == "here" + container = $manager.find player.container + if container.nil? + player.output "Cannot find #{event[:in]} " + return + end + elsif container.nil? + player.output "Cannot find #{event[:in]} " + return + end + + if not object.container.nil? + current_container = $manager.find object.container + current_container.inventory.remove(object) if current_container + end + + unless event[:at] == nil + position = event[:at].split('x').map{ |e| e.to_i} + end + + if container.is_a? Inventory + container.add(object, position) + elsif container.is_a? Container + container.add(object) + else + container.inventory.add(object, position) + object.container = container.goid + end + + player.output "Moved #{object} into #{container}#{event[:at] == nil ? '' : ' at ' + event[:at]}" + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/areaction.rb b/lib/aethyr/core/actions/commands/areaction.rb new file mode 100644 index 0000000000000000000000000000000000000000..96aec3e430ed3b092329324f601a3211baeef5ef --- /dev/null +++ b/lib/aethyr/core/actions/commands/areaction.rb @@ -0,0 +1,111 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Areaction + class AreactionCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + if event[:command] == "reload" and event[:object] and event[:object].downcase == "all" + objects = $manager.find_all("class", Reacts) + + objects.each do |o| + o.reload_reactions + end + + player.output "Updated reactions for #{objects.length} objects." + elsif event[:object] and event[:object].split.first.downcase == "all" + klass = event[:object].split[1] + klass.capitalize! unless klass[0,1] == klass[0,1].upcase + begin + klass = Module.const_get klass.to_sym + rescue NameError + player.output "No such object type." + return + end + + objects = $manager.find_all("class", klass) + + objects.each do |obj| + e = event.dup + e[:object] = obj.goid + + player.output "(Doing #{obj})" + Admin.areaction(e, player, room) + end + else + if event[:object] == "here" + object = room + else + object = find_object(event[:object], event) + end + + if object.nil? + player.output "Cannot find:#{event[:object]}" + return + elsif not object.is_a? Reacts and (event[:command] == "load" or event[:command] == "reload") + player.output "Object cannot react, adding react ability." + object.extend(Reacts) + end + + case event[:command] + when "add" + if object.actions.add? event[:action_name] + player.output "Added #{event[:action_name]}" + else + player.output "Already had a reaction by that name." + end + when "delete" + if object.actions.delete? event[:action_name] + player.output "Removed #{event[:action_name]}" + else + player.output "That verb was not associated with this object." + end + when "load" + unless File.exist? "objects/reactions/#{event[:file]}.rx" + player.output "No such reaction file - #{event[:file]}" + return + end + + object.load_reactions event[:file] + player.output "Probably loaded reactions." + when "reload" + object.reload_reactions if object.can? :reload_reactions + player.output "Probably reloaded reactions." + when "clear" + object.unload_reactions if object.can? :unload_reactions + player.output "Probably cleared out reactions." + when "show" + if object.actions and not object.actions.empty? + player.output "Custom actions: #{object.actions.to_a.sort.join(' ')}", true + end + + if object.can? :show_reactions + player.output object.show_reactions + else + player.output "Object does not react." + end + else + player.output("Options:", true) + player.output("areaction load <object> <file>", true) + player.output("areaction reload <object> <file>", true) + player.output("areaction [add|delete] <object> <action>", true) + player.output("areaction [clear|show] <object>") + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/areas.rb b/lib/aethyr/core/actions/commands/areas.rb new file mode 100644 index 0000000000000000000000000000000000000000..584f26264ff7b68046d57c30a789fa17a825d930 --- /dev/null +++ b/lib/aethyr/core/actions/commands/areas.rb @@ -0,0 +1,31 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Areas + class AreasCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + areas = $manager.find_all('class', Area) + + if areas.empty? + player.output "There are no areas." + return + end + + player.output areas.map {|a| "#{a.name} - #{a.inventory.find_all('class', Room).length} rooms (#{a.info.terrain.area_type})" } + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/areload.rb b/lib/aethyr/core/actions/commands/areload.rb new file mode 100644 index 0000000000000000000000000000000000000000..39edab67639fea1da5cf7e9320d262b4d1f047d5 --- /dev/null +++ b/lib/aethyr/core/actions/commands/areload.rb @@ -0,0 +1,29 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Areload + class AreloadCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + begin + result = load "#{event[:object]}.rb" + player.output "Reloaded #{event[:object]}: #{result}" + rescue LoadError + player.output "Unable to load #{event[:object]}" + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/asave.rb b/lib/aethyr/core/actions/commands/asave.rb new file mode 100644 index 0000000000000000000000000000000000000000..550cc90b1737c9c59cb29c139d50d51d6c349b16 --- /dev/null +++ b/lib/aethyr/core/actions/commands/asave.rb @@ -0,0 +1,26 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Asave + class AsaveCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + log "#{player.name} initiated manual save." + $manager.save_all + player.output "Save complete. Check log for details." + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/aset.rb b/lib/aethyr/core/actions/commands/aset.rb new file mode 100644 index 0000000000000000000000000000000000000000..9b04f83e2348814453ce45fb89be28b8eed3f15a --- /dev/null +++ b/lib/aethyr/core/actions/commands/aset.rb @@ -0,0 +1,145 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Aset + class AsetCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:object].downcase == "here" + event[:object] = player.container + elsif event[:object] and event[:object].split.first.downcase == "all" + log event[:object].split + klass = event[:object].split[1] + klass.capitalize! unless klass[0,1] == klass[0,1].upcase + begin + klass = Module.const_get klass.to_sym + rescue NameError + player.output "No such object type." + return + end + + objects = $manager.find_all("class", klass) + + objects.each do |obj| + e = event.dup + e[:object] = obj.goid + + Admin.aset(e, player, room) + end + + return + end + + object = find_object(event[:object], event) + + if object.nil? + player.output "Cannot find #{event[:object]} to edit." + return + end + + attrib = event[:attribute] + + if attrib[0,1] != "@" + value = event[:value] + if value.downcase == "!nothing" or value.downcase == "nil" + value = nil + end + + if value and value[-1,1] !~ /[!.?"']/ + value << "." + end + + case attrib.downcase + when "smell" + if value.nil? + object.info.delete :smell + player.output "#{object.name} will no longer smell." + else + object.info.smell = value + player.output "#{object.name} will now smell like: #{object.info.smell}" + end + return + when "feel", "texture" + if value.nil? + object.info.delete :texture + player.output "#{object.name} will no longer have a particular texture." + else + object.info.texture = value + player.output "#{object.name} will now feel like: #{object.info.texture}" + end + return + when "taste" + if value.nil? + object.info.delete :taste + player.output "#{object.name} will no longer have a particular taste." + else + object.info.taste = value + player.output "#{object.name} will now taste like: #{object.info.taste}" + end + return + when "sound", "listen" + if value.nil? + object.info.delete :sound + player.output "#{object.name} will no longer make sounds." + else + object.info.sound = value + player.output "#{object.name} will now sound like: #{object.info.sound}" + end + return + else + player.output "What are you trying to set?" + return + end + end + + if not object.instance_variables.include? attrib and not object.instance_variables.include? attrib.to_sym and not event[:force] + player.output "#{object}:No such setting/variable/attribute: #{attrib}" + return + else + current_value = object.instance_variable_get(attrib) + if current_value.is_a? Array + object.instance_variable_set(attrib, event[:value].split(/s*"(.*?)"\s*|\s+/)) + player.output "Set #{object} attribute #{attrib} to #{event[:value].inspect}" + else + value = event[:value] #for ease + if value.split.length == 1 + case value.downcase + when "true" + value = true + when "false" + value = false + when /^:/ + value = value[1..-1].to_sym + when "nil" + value = nil + when /^[0-9]+$/ + value = value.to_i unless current_value.is_a? String + when "!nothing" + value = "" + when "!delete" + object.instance_eval { remove_instance_variable(attrib) } + player.output "Removed attribute #{attrib} from #{object}" + return + end + end + + object.instance_variable_set(attrib, value) + player.output "Set #{object} attribute #{attrib} to #{value}" + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/astatus.rb b/lib/aethyr/core/actions/commands/astatus.rb new file mode 100644 index 0000000000000000000000000000000000000000..c8d92d96bf6fb47d4899e77414c51b281aaef417 --- /dev/null +++ b/lib/aethyr/core/actions/commands/astatus.rb @@ -0,0 +1,30 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Astatus + class AstatusCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + awho(event, player, room) + total_objects = $manager.game_objects_count + player.output("Object Counts:" , true) + $manager.type_count.each do |obj, count| + player.output("#{obj}: #{count}", true) + end + player.output("Total Objects: #{total_objects}") + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/ateach.rb b/lib/aethyr/core/actions/commands/ateach.rb new file mode 100644 index 0000000000000000000000000000000000000000..c5907077f5be55c258dd728f29d26124f0dfc85d --- /dev/null +++ b/lib/aethyr/core/actions/commands/ateach.rb @@ -0,0 +1,30 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Ateach + class AteachCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = find_object(event[:target], event) + if object.nil? + player.output "Teach who what where?" + return + end + + alearn(event, object, room) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/awatch.rb b/lib/aethyr/core/actions/commands/awatch.rb new file mode 100644 index 0000000000000000000000000000000000000000..d5b599ab8b28eddf966b37ac31d1161b66dc607e --- /dev/null +++ b/lib/aethyr/core/actions/commands/awatch.rb @@ -0,0 +1,58 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Awatch + class AwatchCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = find_object(event[:target], event) + if object.nil? + player.output "What mobile do you want to watch?" + return + elsif not object.is_a? Mobile + player.output "You can only use this to watch mobiles." + return + end + + case event[:command] + when "start" + if object.info.redirect_output_to == player.goid + player.output "You are already watching #{object.name}." + else + object.info.redirect_output_to = player.goid + player.output "Watching #{object.name}." + object.output "#{player.name} is watching you." + end + when "stop" + if object.info.redirect_output_to != player.goid + player.output "You are not watching #{object.name}." + else + object.info.redirect_output_to = nil + player.output "No longer watching #{object.name}." + end + else + if object.info.redirect_output_to != player.goid + object.info.redirect_output_to = player.goid + player.output "Watching #{object.name}." + object.output "#{player.name} is watching you." + else + object.info.redirect_output_to = nil + player.output "No longer watching #{object.name}." + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/awho.rb b/lib/aethyr/core/actions/commands/awho.rb new file mode 100644 index 0000000000000000000000000000000000000000..8bbc2a6f51c12498020df0263922c7eaa71d43cd --- /dev/null +++ b/lib/aethyr/core/actions/commands/awho.rb @@ -0,0 +1,32 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Awho + class AwhoCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + players = $manager.find_all('class', Player) + + names = [] + players.each do |playa| + names << playa.name + end + + player.output('Players currently online:', true) + player.output(names.join(', ')) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/back.rb b/lib/aethyr/core/actions/commands/back.rb new file mode 100644 index 0000000000000000000000000000000000000000..b8f388764296d2d4b640ce2f5e5f538d7441eb8e --- /dev/null +++ b/lib/aethyr/core/actions/commands/back.rb @@ -0,0 +1,43 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Back + class BackCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "\"I'm back!\" you happily announce." + to_other "\"I'm back!\" #{player.name} happily announces to those nearby." + to_blind_other "Someone announces, \"I'm back!\"" + end + + self_target do + player.output "Hm? How do you do that?" + end + + target do + to_player "You happily announce your return to #{event.target.name}." + to_target "#{player.name} happily announces #{player.pronoun(:possessive)} return to you." + to_other "#{player.name} announces #{player.pronoun(:possessive)} return to #{event.target.name}." + to_blind_other "Someone says, \"I shall return shortly!\"" + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/blush.rb b/lib/aethyr/core/actions/commands/blush.rb new file mode 100644 index 0000000000000000000000000000000000000000..ab83d886272acac13526dd250d2c8628317fed84 --- /dev/null +++ b/lib/aethyr/core/actions/commands/blush.rb @@ -0,0 +1,46 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Blush + class BlushCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You feel the blood rush to your cheeks and you look down, blushing." + to_other "#{player.name}'s face turns bright red as #{player.pronoun} looks down, blushing." + to_deaf_other event[:to_other] + end + + self_target do + to_player "You blush at your foolishness." + to_other "#{player.name} blushes at #{event.target.pronoun(:possessive)} foolishness." + to_deaf_other event[:to_other] + end + + target do + to_player "Your face turns red and you blush at #{event.target.name} uncomfortably." + to_target "#{player.name} blushes in your direction." + to_deaf_target event[:to_target] + to_other "#{player.name} blushes at #{event.target.name}, clearly uncomfortable." + to_deaf_other event[:to_other] + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/bow.rb b/lib/aethyr/core/actions/commands/bow.rb new file mode 100644 index 0000000000000000000000000000000000000000..3c1ea069fda37976c52898c865d29bea1c8e235b --- /dev/null +++ b/lib/aethyr/core/actions/commands/bow.rb @@ -0,0 +1,44 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Bow + class BowCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You bow deeply and respectfully." + to_other "#{player.name} bows deeply and respectfully." + to_deaf_other event[:to_other] + end + + self_target do + player.output "Huh?" + end + + target do + to_player "You bow respectfully towards #{event.target.name}." + to_target "#{player.name} bows respectfully before you." + to_other "#{player.name} bows respectfully towards #{event.target.name}." + to_deaf_other event[:to_other] + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/brb.rb b/lib/aethyr/core/actions/commands/brb.rb new file mode 100644 index 0000000000000000000000000000000000000000..c6a6dc4534053a3388a978650749578baa255521 --- /dev/null +++ b/lib/aethyr/core/actions/commands/brb.rb @@ -0,0 +1,44 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Brb + class BrbCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "\"I shall return shortly!\" you say to no one in particular." + to_other "#{player.name} says, \"I shall return shortly!\" to no one in particular." + to_blind_other "Someone says, \"I shall return shortly!\"" + end + + self_target do + player.output "Hm? How do you do that?" + end + + target do + to_player "You let #{event.target.name} know you will return shortly." + to_target "#{player.name} lets you know #{player.pronoun} will return shortly." + to_other "#{player.name} tells #{event.target.name} that #{player.pronoun} will return shortly." + to_blind_other "Someone says, \"I shall return shortly!\"" + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/bye.rb b/lib/aethyr/core/actions/commands/bye.rb new file mode 100644 index 0000000000000000000000000000000000000000..678acb3d7fe47d961de8ce657255c8e59fe018a2 --- /dev/null +++ b/lib/aethyr/core/actions/commands/bye.rb @@ -0,0 +1,42 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Bye + class ByeCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You say a hearty \"Goodbye!\" to those around you." + to_other "#{player.name} says a hearty \"Goodbye!\"" + end + + self_target do + player.output "Goodbye." + end + + target do + to_player "You say \"Goodbye!\" to #{event.target.name}." + to_target "#{player.name} says \"Goodbye!\" to you." + to_other "#{player.name} says \"Goodbye!\" to #{event.target.name}" + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/cheer.rb b/lib/aethyr/core/actions/commands/cheer.rb new file mode 100644 index 0000000000000000000000000000000000000000..04f9d4cb4046606371e745602df0c15f34cb4993 --- /dev/null +++ b/lib/aethyr/core/actions/commands/cheer.rb @@ -0,0 +1,43 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Cheer + class CheerCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You throw your hands in the air and cheer wildly!" + to_other "#{player.name} throws #{player.pronoun(:possessive)} hands in the air as #{player.pronoun} cheers wildy!" + to_blind_other "You hear someone cheering." + end + + self_target do + player.output "Hm? How do you do that?" + end + + target do + to_player "Beaming at #{event.target.name}, you throw your hands up and cheer for #{event.target.pronoun(:objective)}." + to_target "Beaming at you, #{player.name} throws #{player.pronoun(:possessive)} hands up and cheers for you." + to_other "#{player.name} throws #{player.pronoun(:possessive)} hands up and cheers for #{event.target.name}." + to_blind_other "You hear someone cheering." + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/cry.rb b/lib/aethyr/core/actions/commands/cry.rb new file mode 100644 index 0000000000000000000000000000000000000000..9b4104f78343962e3055580dc7c1b9923898536e --- /dev/null +++ b/lib/aethyr/core/actions/commands/cry.rb @@ -0,0 +1,31 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Cry + class CryCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + default do + to_player "Tears run down your face as you cry pitifully." + to_other "Tears run down #{player.name}'s face as #{player.pronoun} cries pitifully." + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/curtsey.rb b/lib/aethyr/core/actions/commands/curtsey.rb new file mode 100644 index 0000000000000000000000000000000000000000..24e2ab884c66e595e8101ef333aec51a9c05185f --- /dev/null +++ b/lib/aethyr/core/actions/commands/curtsey.rb @@ -0,0 +1,44 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Curtsey + class CurtseyCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You perform a very graceful curtsey." + to_other "#{player.name} curtseys quite gracefully." + to_deaf_other event[:to_other] + end + + self_target do + player.output "Hm? How do you do that?" + end + + target do + to_player "You curtsey gracefully and respectfully towards #{event.target.name}." + to_target "#{player.name} curtseys gracefully and respectfully in your direction." + to_other "#{player.name} curtseys gracefully and respectfully towards #{event.target.name}." + to_deaf_other event[:to_other] + end + + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/date.rb b/lib/aethyr/core/actions/commands/date.rb new file mode 100644 index 0000000000000000000000000000000000000000..eb9e1cdcf3822976aa7f8acf60e47e8d54492823 --- /dev/null +++ b/lib/aethyr/core/actions/commands/date.rb @@ -0,0 +1,21 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Date + class DateCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + @player.output $manager.date + end + #Show who is in the game. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/delete_player.rb b/lib/aethyr/core/actions/commands/delete_player.rb new file mode 100644 index 0000000000000000000000000000000000000000..c149a55f66a7560b482607637cef77326880c693 --- /dev/null +++ b/lib/aethyr/core/actions/commands/delete_player.rb @@ -0,0 +1,42 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module DeletePlayer + class DeletePlayerCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + name = event.object + if not $manager.player_exist? name + player.output "No such player found: #{name}" + return + elsif $manager.find name + player.output "Player is currently logged in. Deletion aborted." + return + elsif name == player.name.downcase + player.output "You cannot delete yourself this way. Use DELETE ME PLEASE instead." + return + end + + $manager.delete_player name + + if $manager.find name or $manager.player_exist? name + player.output "Something went wrong. Player still exists." + else + player.output "#{name} deleted." + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/delete_post.rb b/lib/aethyr/core/actions/commands/delete_post.rb new file mode 100644 index 0000000000000000000000000000000000000000..59b88716fb326aec94bedead623e6187c22db424 --- /dev/null +++ b/lib/aethyr/core/actions/commands/delete_post.rb @@ -0,0 +1,44 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module DeletePost + class DeletePostCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + + + + board = find_board(event, room) + + if board.nil? + player.output "What newsboard are you talking about?" + return + end + + post = board.get_post event[:post_id] + + if post.nil? + player.output "No such post." + elsif post[:author] != player.name + player.output "You can only delete your own posts." + else + board.delete_post event[:post_id] + player.output "Deleted post ##{event[:post_id]}" + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/deleteme.rb b/lib/aethyr/core/actions/commands/deleteme.rb new file mode 100644 index 0000000000000000000000000000000000000000..b759dce7efc80ac1317b673d34d5df52eef9146c --- /dev/null +++ b/lib/aethyr/core/actions/commands/deleteme.rb @@ -0,0 +1,37 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Deleteme + class DeletemeCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + if event[:password] + if $manager.check_password(@player.name, event[:password]) + @player.output "This character #{@player.name} will no longer exist." + @player.quit + $manager.delete_player(@player.name) + else + @player.output "That password is incorrect. You are allowed to continue existing." + end + else + @player.output "To confirm your deletion, please enter your password:" + @player.io.echo_off + @player.expect do |password| + @player.io.echo_on + event[:password] = password + Generic.deleteme(event) + end + end + end + #Write something. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/drop.rb b/lib/aethyr/core/actions/commands/drop.rb new file mode 100644 index 0000000000000000000000000000000000000000..ede0d2626a860d21a6985a75e22878b798d4c4e2 --- /dev/null +++ b/lib/aethyr/core/actions/commands/drop.rb @@ -0,0 +1,41 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Drop + class DropCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + object = @player.inventory.find(event[:object]) + + if object.nil? + if response = @player.equipment.worn_or_wielded?(event[:object]) + @player.output response + else + @player.output "You have no #{event[:object]} to drop." + end + + return + end + + @player.inventory.remove(object) + + object.container = room.goid + room.add(object) + + event[:to_player] = "You drop #{object.name}." + event[:to_other] = "#{@player.name} drops #{object.name}." + event[:to_blind_other] = "You hear something hit the ground." + room.out_event(event) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/eh.rb b/lib/aethyr/core/actions/commands/eh.rb new file mode 100644 index 0000000000000000000000000000000000000000..ac7bfd29767c7e083d7b904f2957455cf262eb40 --- /dev/null +++ b/lib/aethyr/core/actions/commands/eh.rb @@ -0,0 +1,35 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Eh + class EhCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + make_emote event, player, room do + target do + to_player "After giving #{event.target.name} a cursory glance, you emit an unimpressed, 'Eh.'" + to_other "#{player.name} gives #{event.target.name} a cursory glance and then emits an unimpressed, 'Eh.'" + to_target "#{player.name} gives you a cursory glance and then emits an unimpressed, 'Eh.'" + end + + no_target do + to_player "After a brief consideration, you give an unimpressed, 'Eh.'" + to_other "#{player.name} appears to consider for a moment before giving an unimpressed, 'Eh.'" + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/emote.rb b/lib/aethyr/core/actions/commands/emote.rb new file mode 100644 index 0000000000000000000000000000000000000000..dd9dea4779317b1fc3fc3fae5fd91bca0ba9be38 --- /dev/null +++ b/lib/aethyr/core/actions/commands/emote.rb @@ -0,0 +1,58 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Emote + class EmoteCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + action = event[:show].strip + + unless ['!', '.', '?', '"'].include? action[-1..-1] + action << '.' + end + + if action =~ /\$me[^a-zA-Z]/i + action.gsub!(/\$me/i, player.name) + action[0,1] = action[0,1].capitalize + show = action + elsif action.include? '$' + people = [] + action.gsub!(/\$(\w+)/) do |name| + target = room.find($1) + people << target unless target.nil? + target ? target.name : 'no one' + end + + people.each do |person| + out = action.gsub(person.name, 'you') + person.output("#{player.name} #{out}", message_type = :chat) unless person.can? :blind and person.blind? + end + + room.output("#{player.name} #{action}", player, *people) + player.output("You emote: #{player.name} #{action}") + else + show = "#{player.name} #{action}" + end + + if show + event[:message_type] = :chat + event[:to_player] = "You emote: #{show}" + event[:to_other] = show + room.out_event event + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/er.rb b/lib/aethyr/core/actions/commands/er.rb new file mode 100644 index 0000000000000000000000000000000000000000..8de269c1d8c67a9ec7ce969003e719f487bd2c4a --- /dev/null +++ b/lib/aethyr/core/actions/commands/er.rb @@ -0,0 +1,35 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Er + class ErCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + make_emote event, player, room do + no_target do + to_player "With a look of uncertainty, you say, \"Er...\"" + to_other "With a look of uncertainty, #{player.name} says, \"Er...\"" + end + + target do + to_player "Looking at #{target.name} uncertainly, you say, \"Er...\"" + to_other "Looking at #{target.name} uncertainly, #{player.name} says, \"Er...\"" + to_target "Looking at you uncertainly, #{player.name} says, \"Er...\"" + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/ew.rb b/lib/aethyr/core/actions/commands/ew.rb new file mode 100644 index 0000000000000000000000000000000000000000..2a41c44def0b15502597ae1bc46940a99b957721 --- /dev/null +++ b/lib/aethyr/core/actions/commands/ew.rb @@ -0,0 +1,45 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Ew + class EwCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "\"Ewww!\" you exclaim, looking disgusted." + to_other "#{player.name} exclaims, \"Eww!!\" and looks disgusted." + to_deaf_other "#{player.name} looks disgusted." + to_blind_other "Somone exclaims, \"Eww!!\"" + end + + self_target do + player.output "You think you are digusting?" + end + + target do + to_player "You glance at #{event.target.name} and say \"Ewww!\"" + to_target "#{player.name} glances in your direction and says, \"Ewww!\"" + to_deaf_other "#{player.name} gives #{event.target.name} a disgusted look." + to_blind_other "Somone exclaims, \"Eww!!\"" + to_other "#{player.name} glances at #{event.target.name}, saying \"Ewww!\"" + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/feel.rb b/lib/aethyr/core/actions/commands/feel.rb new file mode 100644 index 0000000000000000000000000000000000000000..a4f5781596809f13359ca22952f857bc2980f88e --- /dev/null +++ b/lib/aethyr/core/actions/commands/feel.rb @@ -0,0 +1,40 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Feel + class FeelCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + object = @player.search_inv(event[:target]) || room.find(event[:target]) + + if object == @player or event[:target] == "me" + @player.output "You feel fine." + return + elsif object.nil? + @player.output "What would you like to feel?" + return + end + + event[:target] = object + event[:to_player] = "You reach out your hand and gingerly feel #{object.name}. " + if object.info.texture.nil? or object.info.texture == "" + event[:to_player] << "#{object.pronoun(:possessive).capitalize} texture is what you would expect." + else + event[:to_player] << object.info.texture + end + event[:to_target] = "#{@player.name} reaches out a hand and gingerly touches you." + event[:to_other] = "#{@player.name} reaches out #{@player.pronoun(:possessive)} hand and touches #{object.name}." + room.out_event event + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/fill.rb b/lib/aethyr/core/actions/commands/fill.rb new file mode 100644 index 0000000000000000000000000000000000000000..bfe43e9a351dccc07e44d5231cbb8b4dbe99fa3f --- /dev/null +++ b/lib/aethyr/core/actions/commands/fill.rb @@ -0,0 +1,46 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Fill + class FillCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + object = @player.search_inv(event[:object]) || room.find(event[:object]) + from = @player.search_inv(event[:from]) || room.find(event[:from]) + + if object.nil? + @player.output("What would you like to fill?") + return + elsif not object.is_a? LiquidContainer + @player.output("You cannot fill #{object.name} with liquids.") + return + elsif from.nil? + @player.output "There isn't any #{event[:from]} around here." + return + elsif not from.is_a? LiquidContainer + @player.output "You cannot fill #{object.name} from #{from.name}." + return + elsif from.empty? + @player.output "That #{object.generic} is empty." + return + elsif object.full? + @player.output("That #{object.generic} is full.") + return + elsif object == from + @player.output "Quickly flipping #{object.name} upside-down then upright again, you manage to fill it from itself." + return + end + end + #Display time. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/frown.rb b/lib/aethyr/core/actions/commands/frown.rb new file mode 100644 index 0000000000000000000000000000000000000000..27d91bc83a7bb4de422012d326b9fa925e20bde8 --- /dev/null +++ b/lib/aethyr/core/actions/commands/frown.rb @@ -0,0 +1,46 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Frown + class FrownCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + no_target do + to_player "The edges of your mouth turn down as you frown." + to_other "The edges of #{player.name}'s mouth turn down as #{player.pronoun} frowns." + to_deaf_other event[:to_other] + end + + self_target do + to_player "You frown sadly at yourself." + to_other "#{player.name} frowns sadly at #{event.target.pronoun(:reflexive)}." + to_deaf_other event[:to_other] + end + + target do + to_player "You frown at #{event.target.name} unhappily." + to_target "#{player.name} frowns at you unhappily." + to_deaf_target event[:to_target] + to_other "#{player.name} frowns at #{event.target.name} unhappily." + to_deaf_other event[:to_other] + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/gait.rb b/lib/aethyr/core/actions/commands/gait.rb new file mode 100644 index 0000000000000000000000000000000000000000..2df647374c8ad0fcba7324c0a0a754a74afb28f5 --- /dev/null +++ b/lib/aethyr/core/actions/commands/gait.rb @@ -0,0 +1,41 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Gait + class GaitCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:phrase].nil? + if player.info.entrance_message + player.output "When you move, it looks something like:", true + player.output player.exit_message("north") + else + player.output "You are walking normally." + end + elsif event[:phrase].downcase == "none" + player.info.entrance_message = nil + player.info.exit_message = nil + player.output "You will now walk normally." + else + player.info.entrance_message = "#{event[:phrase]}, !name comes in from !direction." + player.info.exit_message = "#{event[:phrase]}, !name leaves to !direction." + + player.output "When you move, it will now look something like:", true + player.output player.exit_message("north") + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/get.rb b/lib/aethyr/core/actions/commands/get.rb new file mode 100644 index 0000000000000000000000000000000000000000..e679b2dd0ad9cd889dc4c9fecc740bd538e17e1c --- /dev/null +++ b/lib/aethyr/core/actions/commands/get.rb @@ -0,0 +1,77 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Get + class GetCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + if event[:from].nil? + object = $manager.find(event[:object], room) + + if object.nil? + @player.output("There is no #{event[:object]} to take.") + return + elsif not object.movable + @player.output("You cannot take #{object.name}.") + return + elsif @player.inventory.full? + @player.output("You cannot hold any more objects.") + return + end + + room.remove(object) + object.container = @player.goid + @player.inventory << object + + event[:to_player] = "You take #{object.name}." + event[:to_other] = "#{@player.name} takes #{object.name}." + room.out_event(event) + else + from = event[:from] + container = $manager.find(from, room) + @player.inventory.find(from) if container.nil? + + if container.nil? + @player.output("There is no #{from}.") + return + elsif not container.is_a? Container + @player.output("Not sure how to do that.") + return + elsif container.can? :open and container.closed? + @player.output("You will need to open it first.") + return + end + + object = $manager.find(event[:object], container) + + if object.nil? + @player.output("There is no #{event[:object]} in the #{container.name}.") + return + elsif not object.movable + @player.output("You cannot take the #{object.name}.") + return + elsif @player.inventory.full? + @player.output("You cannot hold any more objects.") + return + end + + container.remove(object) + @player.inventory.add(object) + + event[:to_player] = "You take #{object.name} from #{container.name}." + event[:to_other] = "#{@player.name} takes #{object.name} from #{container.name}." + room.out_event(event) + end + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/give.rb b/lib/aethyr/core/actions/commands/give.rb new file mode 100644 index 0000000000000000000000000000000000000000..9317b8cfe114813b728dbe3ca79cf653e26f6790 --- /dev/null +++ b/lib/aethyr/core/actions/commands/give.rb @@ -0,0 +1,51 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Give + class GiveCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + item = player.inventory.find(event[:item]) + + if item.nil? + if response = player.equipment.worn_or_wielded?(event[:item]) + player.output response + else + player.output "You do not seem to have a #{event[:item]} to give away." + end + + return + end + + receiver = $manager.find(event[:to], room) + + if receiver.nil? + player.output("There is no #{event[:to]}.") + return + elsif not receiver.is_a? Player and not receiver.is_a? Mobile + player.output("You cannot give anything to #{receiver.name}.") + return + end + + player.inventory.remove(item) + receiver.inventory.add(item) + + event[:target] = receiver + event[:to_player] = "You give #{item.name} to #{receiver.name}." + event[:to_target] = "#{player.name} gives you #{item.name}." + event[:to_other] = "#{player.name} gives #{item.name} to #{receiver.name}." + + room.out_event(event) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/grin.rb b/lib/aethyr/core/actions/commands/grin.rb new file mode 100644 index 0000000000000000000000000000000000000000..762e52eac00e30613ecb571946ab9ac8bf2a642d --- /dev/null +++ b/lib/aethyr/core/actions/commands/grin.rb @@ -0,0 +1,47 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Grin + class GrinCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player 'You grin widely, flashing all your teeth.' + to_other "#{player.name} grins widely, flashing all #{player.pronoun(:possessive)} teeth." + to_deaf_other event[:to_other] + end + + self_target do + to_player "You grin madly at yourself." + to_other "#{player.name} grins madly at #{event.target.pronoun(:reflexive)}." + to_deaf_other event[:to_other] + end + + target do + to_player "You give #{event.target.name} a wide grin." + to_target "#{player.name} gives you a wide grin." + to_deaf_target event[:to_target] + to_other "#{player.name} gives #{event.target.name} a wide grin." + to_deaf_other event[:to_other] + end + + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/health.rb b/lib/aethyr/core/actions/commands/health.rb new file mode 100644 index 0000000000000000000000000000000000000000..c38058db9f464565a49c07176c3dcf733c2d2964 --- /dev/null +++ b/lib/aethyr/core/actions/commands/health.rb @@ -0,0 +1,21 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Health + class HealthCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + @player.output "You are #{@player.health}." + end + #Display hunger. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/hi.rb b/lib/aethyr/core/actions/commands/hi.rb new file mode 100644 index 0000000000000000000000000000000000000000..906e5fac63ba5babd3d78f3137462c43576fb12c --- /dev/null +++ b/lib/aethyr/core/actions/commands/hi.rb @@ -0,0 +1,42 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Hi + class HiCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "\"Hi!\" you greet those around you." + to_other "#{player.name} greets those around with a \"Hi!\"" + end + + self_target do + player.output "Hi." + end + + target do + to_player "You say \"Hi!\" in greeting to #{event.target.name}." + to_target "#{player.name} greets you with a \"Hi!\"" + to_other "#{player.name} greets #{event.target.name} with a hearty \"Hi!\"" + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/hm.rb b/lib/aethyr/core/actions/commands/hm.rb new file mode 100644 index 0000000000000000000000000000000000000000..fdb1b0454615572f7600e6fddf11af9037c1a2e0 --- /dev/null +++ b/lib/aethyr/core/actions/commands/hm.rb @@ -0,0 +1,43 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Hm + class HmCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_other "#{player.name} purses #{player.pronoun(:possessive)} lips thoughtfully and says, \"Hmmm...\"" + to_player "You purse your lips thoughtfully and say, \"Hmmm...\"" + end + + self_target do + to_other "#{player.name} looks down at #{player.pronoun(:reflexive)} and says, \"Hmmm...\"" + to_player "You look down at yourself and say, \"Hmmm...\"" + end + + target do + to_other "#{player.name} purses #{player.pronoun(:possessive)} lips as #{player.pronoun} looks thoughtfully at #{event.target.name} and says, \"Hmmm...\"" + to_player "You purse your lips as you look thoughtfully at #{event.target.name} and say, \"Hmmm...\"" + to_target "#{player.name} purses #{player.pronoun(:possessive)} lips as #{player.pronoun} looks thoughtfully at you and says, \"Hmmm...\"" + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/hug.rb b/lib/aethyr/core/actions/commands/hug.rb new file mode 100644 index 0000000000000000000000000000000000000000..6e03ca390d4fbdb3bc9564ba095ac41c4ca9f324 --- /dev/null +++ b/lib/aethyr/core/actions/commands/hug.rb @@ -0,0 +1,44 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Hug + class HugCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + player.output "Who are you trying to hug?" + end + + self_target do + to_player 'You wrap your arms around yourself and give a tight squeeze.' + to_other "#{player.name} gives #{player.pronoun(:reflexive)} a tight squeeze." + to_deaf_other event[:to_other] + end + + target do + to_player "You give #{event.target.name} a great big hug." + to_target "#{player.name} gives you a great big hug." + to_other "#{player.name} gives #{event.target.name} a great big hug." + to_blind_target "Someone gives you a great big hug." + to_deaf_other event[:to_other] + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/huh.rb b/lib/aethyr/core/actions/commands/huh.rb new file mode 100644 index 0000000000000000000000000000000000000000..f94824fe5ce85f306c23bf7cc703ef0809387276 --- /dev/null +++ b/lib/aethyr/core/actions/commands/huh.rb @@ -0,0 +1,41 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Huh + class HuhCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + make_emote event, player, room do + + no_target do + to_player "\"Huh?\" you ask, confused." + to_other "#{player.name} ask, \"Huh?\" and looks confused." + end + + self_target do + player.output "Well, huh!" + end + + target do + to_player "\"Huh?\" you ask #{event.target.name}." + to_target "#{player.name} asks, \"Huh?\"" + to_other "#{player.name} asks #{event.target.name}, \"Huh?\"" + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/inventory.rb b/lib/aethyr/core/actions/commands/inventory.rb new file mode 100644 index 0000000000000000000000000000000000000000..4f916da34d02590474ff58b3fb275d70f0b63bb0 --- /dev/null +++ b/lib/aethyr/core/actions/commands/inventory.rb @@ -0,0 +1,20 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Inventory + class InventoryCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + player.output(player.show_inventory) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/issue.rb b/lib/aethyr/core/actions/commands/issue.rb new file mode 100644 index 0000000000000000000000000000000000000000..0c19e99456389f097d623e2d370403c8f4454d2e --- /dev/null +++ b/lib/aethyr/core/actions/commands/issue.rb @@ -0,0 +1,77 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Issue + class IssueCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + case event[:option] + when "new" + issue = Issues.add_issue event[:itype], player.name, event[:value] + player.output "Thank you for submitting #{event[:itype]} ##{issue[:id]}." + when "add" + if not event[:issue_id] + player.output "Please specify a #{event[:itype]} number." + else + denied = Issues.check_access event[:itype], event[:issue_id], player + if denied + player.output denied + else + player.output Issues.append_issue(event[:itype], event[:issue_id], player.name, event[:value]) + end + end + when "del" + if not event[:issue_id] + player.output "Please specify a #{event[:itype]} number." + else + denied = Issues.check_access event[:itype], event[:issue_id], player + if denied + player.output denied + else + player.output Issues.delete_issue(event[:itype], event[:issue_id]) + end + end + when "list" + if player.admin + list = Issues.list_issues event[:itype] + else + list = Issues.list_issues event[:itype], player.name + end + if list.empty? + player.output "No #{event[:itype]}s to list." + else + player.output list + end + when "show" + if not event[:issue_id] + player.output "Please specify a #{event[:itype]} number." + else + denied = Issues.check_access event[:itype], event[:issue_id], player + if denied + player.output denied + else + player.output Issues.show_issue(event[:itype], event[:issue_id]) + end + end + when "status" + if not player.admin + player.output "Only administrators may change a #{event[:itype]}'s status." + elsif not event[:issue_id] + player.output "Please specify a #{event[:itype]} number." + else + player.output Issues.set_status(event[:itype], event[:issue_id], player.name, event[:value]) + end + + end + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/kick.rb b/lib/aethyr/core/actions/commands/kick.rb new file mode 100644 index 0000000000000000000000000000000000000000..fbc9b271ed33615215cc423117db549e3292e1b8 --- /dev/null +++ b/lib/aethyr/core/actions/commands/kick.rb @@ -0,0 +1,56 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Kick + class KickCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + return if not Combat.ready? player + + target = (event.target && room.find(event.target)) || room.find(player.last_target) + + if target.nil? + player.output "Who are you trying to attack?" + return + else + return unless Combat.valid_target? player, target + end + + player.last_target = target.goid + + event.target = target + + event[:to_other] = "#{player.name} kicks #{player.pronoun(:possessive)} foot out at #{target.name}." + event[:to_target] = "#{player.name} kicks #{player.pronoun(:possessive)} foot at you." + event[:to_player] = "You balance carefully and kick your foot out towards #{target.name}." + event[:blockable] = true + + player.balance = false + player.info.in_combat = true + target.info.in_combat = true + + room.out_event event + + event[:action] = :martial_hit + event[:combat_action] = :kick + event[:to_other] = "#{player.name} kicks #{target.name} with considerable violence." + event[:to_target] = "#{player.name} kicks you rather violently." + event[:to_player] = "Your kick makes good contact with #{target.name}." + + Combat.future_event event + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/latest_news.rb b/lib/aethyr/core/actions/commands/latest_news.rb new file mode 100644 index 0000000000000000000000000000000000000000..c5c5ecff9105bf9c03581725357bade1c8e838d4 --- /dev/null +++ b/lib/aethyr/core/actions/commands/latest_news.rb @@ -0,0 +1,39 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module LatestNews + class LatestNewsCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + board = find_board(event, room) + + if board.nil? + player.output "There do not seem to be any postings here." + return + end + + if not board.is_a? Newsboard + log board.class + end + + offset = event[:offset] || 0 + wordwrap = player.word_wrap || 100 + limit = event[:limit] || player.page_height + + player.output board.list_latest(wordwrap, offset, limit) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/laugh.rb b/lib/aethyr/core/actions/commands/laugh.rb new file mode 100644 index 0000000000000000000000000000000000000000..69909a8a42be0229dcd51614828f2ef228a776b7 --- /dev/null +++ b/lib/aethyr/core/actions/commands/laugh.rb @@ -0,0 +1,48 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Laugh + class LaughCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + self_target do + to_player "You laugh heartily at yourself." + to_other "#{player.name} laughs heartily at #{player.pronoun(:reflexive)}." + to_blind_other "Someone laughs heartily." + end + + target do + to_player "You laugh at #{event.target.name}." + to_target "#{player.name} laughs at you." + to_other "#{player.name} laughs at #{event.target.name}" + to_blind_target "Someone laughs in your direction." + to_blind_other "You hear someone laughing." + end + + no_target do + to_player "You laugh." + to_other "#{player.name} laughs." + to_blind_other "You hear someone laughing." + to_deaf_other "You see #{player.name} laugh." + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/list_unread.rb b/lib/aethyr/core/actions/commands/list_unread.rb new file mode 100644 index 0000000000000000000000000000000000000000..0ebe64bbfebb98da82ff3f81be6ca2f079c62d24 --- /dev/null +++ b/lib/aethyr/core/actions/commands/list_unread.rb @@ -0,0 +1,35 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module ListUnread + class ListUnreadCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + board = find_board(event, room) + + if board.nil? + player.output "There do not seem to be any postings here." + return + end + + if player.info.boards.nil? + player.info.boards = {} + end + + player.output board.list_since(player.info.boards[board.goid], player.word_wrap) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/listen.rb b/lib/aethyr/core/actions/commands/listen.rb new file mode 100644 index 0000000000000000000000000000000000000000..6a150ac91a5d13a221ab4d0c808728471baaef2a --- /dev/null +++ b/lib/aethyr/core/actions/commands/listen.rb @@ -0,0 +1,52 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Listen + class ListenCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + if event[:target].nil? + event[:target] = room + if room.info.sound + event[:to_player] = "You listen carefully. #{room.info.sound}." + else + event[:to_player] = "You listen carefully but hear nothing unusual." + end + event[:to_other] = "A look of concentration forms on #{@player.name}'s face as #{@player.pronoun} listens intently." + room.out_event event + return + end + + object = @player.search_inv(event[:target]) || room.find(event[:target]) + + if object == @player or event[:target] == "me" + @player.output "Listening quietly, you can faintly hear your pulse." + return + elsif object.nil? + @player.output "What would you like to listen to?" + return + end + + event[:target] = object + event[:to_player] = "You bend your head towards #{object.name}. " + if object.info.sound.nil? or object.info.sound == "" + event[:to_player] << "#{object.pronoun.capitalize} emits no unusual sounds." + else + event[:to_player] << object.info.sound + end + event[:to_target] = "#{@player.name} listens to you carefully." + event[:to_other] = "#{@player.name} bends #{@player.pronoun(:possessive)} head towards #{object.name} and listens." + room.out_event event + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/lock.rb b/lib/aethyr/core/actions/commands/lock.rb new file mode 100644 index 0000000000000000000000000000000000000000..6c659df34fc941c6ea4704eeff39c76549cfa4bb --- /dev/null +++ b/lib/aethyr/core/actions/commands/lock.rb @@ -0,0 +1,66 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Lock + class LockCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + object = @player.search_inv(event[:object]) || room.find(event[:object]) + + if object.nil? + @player.output('Lock what?') + return + elsif not object.can? :lock or not object.lockable? + @player.output('That object cannot be locked.') + return + elsif object.locked? + @player.output("#{object.name} is already locked.") + return + end + + has_key = false + object.keys.each do |key| + if @player.inventory.include? key + has_key = key + break + end + end + + if has_key or @player.admin + status = object.lock(has_key, @player.admin) + if status + event[:to_player] = "You lock #{object.name}." + event[:to_other] = "#{@player.name} locks #{object.name}." + event[:to_blind_other] = "You hear the click of a lock." + + room.out_event(event) + + if object.is_a? Door and object.connected? + other_side = $manager.find object.connected_to + other_side.lock(has_key) + other_room = $manager.find other_side.container + o_event = event.dup + event[:to_other] = "#{other_side.name} locks from the other side." + event[:to_blind_other] = "You hear the click of a lock." + other_room.out_event(event) + end + else + @player.output("You are unable to lock that #{object.name}.") + end + else + @player.output("You do not have the key to that #{object.name}.") + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/look.rb b/lib/aethyr/core/actions/commands/look.rb new file mode 100644 index 0000000000000000000000000000000000000000..f2f476993e24cda58b3b3e17067b98b1f2349a6c --- /dev/null +++ b/lib/aethyr/core/actions/commands/look.rb @@ -0,0 +1,74 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Look + class LookCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + if @player.blind? + @player.output "You cannot see while you are blind." + else + if event[:at] + object = room if event[:at] == "here" + object = object || @player.search_inv(event[:at]) || room.find(event[:at]) + + if object.nil? + @player.output("Look at what, again?") + return + end + + if object.is_a? Exit + @player.output object.peer + elsif object.is_a? Room + @player.output("You are indoors.", true) if object.info.terrain.indoors + @player.output("You are underwater.", true) if object.info.terrain.underwater + @player.output("You are swimming.", true) if object.info.terrain.water + + @player.output "You are in a place called #{room.name} in #{room.area ? room.area.name : "an unknown area"}.", true + if room.area + @player.output "The area is generally #{describe_area(room.area)} and this spot is #{describe_area(room)}." + elsif room.info.terrain.room_type + @player.output "Where you are standing is considered to be #{describe_area(room)}." + else + @player.output "You are unsure about anything else concerning the area." + end + elsif @player == object + @player.output "You look over yourself and see:\n#{@player.instance_variable_get("@long_desc")}", true + @player.output object.show_inventory + else + @player.output object.long_desc + end + elsif event[:in] + object = room.find(event[:in]) + object = @player.inventory.find(event[:in]) if object.nil? + + if object.nil? + @player.output("Look inside what?") + elsif not object.can? :look_inside + @player.output("You cannot look inside that.") + else + object.look_inside(event) + end + else + if not room.nil? + look_text = room.look(@player) + @player.output(look_text) + else + @player.output "Nothing to look at." + end + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/map.rb b/lib/aethyr/core/actions/commands/map.rb new file mode 100644 index 0000000000000000000000000000000000000000..cd8bfed10a082bfb2307c33348c165f0e3d77198 --- /dev/null +++ b/lib/aethyr/core/actions/commands/map.rb @@ -0,0 +1,21 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Map + class MapCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + player.output(room.area.render_map(player, room.area.position(room))) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/more.rb b/lib/aethyr/core/actions/commands/more.rb new file mode 100644 index 0000000000000000000000000000000000000000..9b3033f8d583a2bbec07cf3caa432d667c003dd0 --- /dev/null +++ b/lib/aethyr/core/actions/commands/more.rb @@ -0,0 +1,20 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module More + class MoreCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + player.more + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/move.rb b/lib/aethyr/core/actions/commands/move.rb new file mode 100644 index 0000000000000000000000000000000000000000..e7392c4e2aef4e0af45fd637fdaace48a8edb8fa --- /dev/null +++ b/lib/aethyr/core/actions/commands/move.rb @@ -0,0 +1,48 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Move + class MoveCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + exit = room.exit(event[:direction]) + + if exit.nil? + @player.output("You cannot go #{event[:direction]}.") + return + elsif exit.can? :open and not exit.open? + @player.output("That exit is closed. Perhaps you should open it?") + return + end + + new_room = $manager.find(exit.exit_room) + + if new_room.nil? + @player.output("That exit #{exit.name} leads into the void.") + return + end + + room.remove(@player) + new_room.add(@player) + @player.container = new_room.game_object_id + event[:to_player] = "You move #{event[:direction]}." + event[:to_other] = "#{@player.name} leaves #{event[:direction]}." + event[:to_blind_other] = "You hear someone leave." + + room.out_event(event) + look_text = new_room.look(player) + out_text = Window.split_message(look_text, 79).join("\n") + @player.output(out_text, message_type: :look, internal_clear: true) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/no.rb b/lib/aethyr/core/actions/commands/no.rb new file mode 100644 index 0000000000000000000000000000000000000000..b9ecbdf7aa470e621d9885a5ffe9602cf3226a2b --- /dev/null +++ b/lib/aethyr/core/actions/commands/no.rb @@ -0,0 +1,41 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module No + class NoCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + make_emote event, player, room do + no_target do + to_player "\"No,\" you say, shaking your head." + to_other "#{player.name} says, \"No\" and shakes #{player.pronoun(:possessive)} head." + end + self_target do + to_player "You shake your head negatively in your direction. You are kind of strange." + to_other "#{player.name} shakes #{player.pronoun(:possessive)} head at #{player.pronoun(:reflexive)}." + to_deaf_other event[:to_other] + end + target do + to_player "You shake your head, disagreeing with #{event.target.name}." + to_target "#{player.name} shakes #{player.pronoun(:possessive)} head in your direction, disagreeing." + to_other "#{player.name} shakes #{player.pronoun(:possessive)} head in disagreement with #{event.target.name}." + to_deaf_other event[:to_other] + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/nod.rb b/lib/aethyr/core/actions/commands/nod.rb new file mode 100644 index 0000000000000000000000000000000000000000..899a99eebd036c6973a684593608f3526101938a --- /dev/null +++ b/lib/aethyr/core/actions/commands/nod.rb @@ -0,0 +1,46 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Nod + class NodCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You nod your head." + to_other "#{player.name} nods #{player.pronoun(:possessive)} head." + to_deaf_other event[:to_other] + end + + self_target do + to_player 'You nod to yourself thoughtfully.' + to_other "#{player.name} nods to #{player.pronoun(:reflexive)} thoughtfully." + to_deaf_other event[:to_other] + end + + target do + + to_player "You nod your head towards #{event.target.name}." + to_target "#{player.name} nods #{player.pronoun(:possessive)} head towards you." + to_other "#{player.name} nods #{player.pronoun(:possessive)} head towards #{event.target.name}." + to_deaf_other event[:to_other] + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/open.rb b/lib/aethyr/core/actions/commands/open.rb new file mode 100644 index 0000000000000000000000000000000000000000..34ad64ebed1552fcdf681eb84e56fc65affa997c --- /dev/null +++ b/lib/aethyr/core/actions/commands/open.rb @@ -0,0 +1,30 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Open + class OpenCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + object = expand_direction(event[:object]) + object = player.search_inv(object) || $manager.find(object, room) + + if object.nil? + player.output("Open what?") + elsif not object.can? :open + player.output("You cannot open #{object.name}.") + else + object.open(event) + end + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/pet.rb b/lib/aethyr/core/actions/commands/pet.rb new file mode 100644 index 0000000000000000000000000000000000000000..978bbc22a5a0ad742092548bcec8b72916441091 --- /dev/null +++ b/lib/aethyr/core/actions/commands/pet.rb @@ -0,0 +1,45 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Pet + class PetCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + player.output "Who are you trying to pet?" + end + + self_target do + to_player 'You pet yourself on the head in a calming manner.' + to_other "#{player.name} pets #{player.pronoun(:reflexive)} on the head in a calming manner." + to_deaf_other "#{player.name} pets #{player.pronoun(:reflexive)} on the head in a calming manner." + end + + target do + to_player "You pet #{event.target.name} affectionately." + to_target "#{player.name} pets you affectionately." + to_deaf_target event[:to_target] + to_blind_target "Someone pets you affectionately." + to_other "#{player.name} pets #{event.target.name} affectionately." + to_deaf_other event[:to_other] + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/poke.rb b/lib/aethyr/core/actions/commands/poke.rb new file mode 100644 index 0000000000000000000000000000000000000000..9d4818b3dd07a82c4f425b85f0019d6d2d984842 --- /dev/null +++ b/lib/aethyr/core/actions/commands/poke.rb @@ -0,0 +1,45 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Poke + class PokeCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + player.output "Who are you trying to poke?" + end + + self_target do + to_player "You poke yourself in the eye. 'Ow!'" + to_other "#{player.name} pokes #{player.pronoun(:reflexive)} in the eye." + to_deaf_other event[:to_other] + end + + target do + to_player "You poke #{event.target.name} playfully." + to_target "#{player.name} pokes you playfully." + to_blind_target "Someone pokes you playfully." + to_deaf_target event[:to_target] + to_other "#{player.name} pokes #{event.target.name} playfully." + to_deaf_other event[:to_other] + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/ponder.rb b/lib/aethyr/core/actions/commands/ponder.rb new file mode 100644 index 0000000000000000000000000000000000000000..38b6fc7bb8cda06ea54745497409f599671c6c7c --- /dev/null +++ b/lib/aethyr/core/actions/commands/ponder.rb @@ -0,0 +1,45 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Ponder + class PonderCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You ponder that idea for a moment." + to_other "#{player.name} looks thoughtful as #{player.pronoun} ponders a thought." + to_deaf_other event[:to_other] + end + + self_target do + to_player "You look down in deep thought at your navel." + to_other "#{player.name} looks down thoughtfully at #{player.pronoun(:possessive)} navel." + to_deaf_other event[:to_other] + end + + target do + to_player "You give #{event.target.name} a thoughtful look as you reflect and ponder." + to_target "#{player.name} gives you a thoughtful look and seems to be reflecting upon something." + to_other "#{player.name} gives #{event.target.name} a thoughtful look and appears to be absorbed in reflection." + to_deaf_other event[:to_other] + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/portal.rb b/lib/aethyr/core/actions/commands/portal.rb new file mode 100644 index 0000000000000000000000000000000000000000..e65b27131993e695a7b1e33bc59505d6c6059b20 --- /dev/null +++ b/lib/aethyr/core/actions/commands/portal.rb @@ -0,0 +1,79 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Portal + class PortalCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = find_object(event[:object], event) + if object.nil? + player.output "Cannot find #{event[:object]}" + return + elsif not object.is_a? Portal + player.output "That is not a portal." + return + end + + value = event[:value] + + case event[:setting] + when "action" + value.downcase! + if value == "enter" + object.info.delete :portal_action + player.output "Set portal action to enter" + elsif ["jump", "climb", "crawl"].include? value + object.info.portal_action = value.downcase.to_sym + player.output "Set portal action to #{value}" + else + player.output "#{value} is not a valid portal action." + end + when "exit" + if value.downcase == "!nothing" or value.downcase == "nil" + object.info.delete :exit_message + else + if value[-1,1] !~ /[!.?"']/ + value << "." + end + object.info.exit_message = value + end + player.output "#{object.name} exit message set to: #{object.info.exit_message}" + when "entrance" + if value.downcase == "!nothing" or value.downcase == "nil" + object.info.delete :entrance_message + else + if value[-1,1] !~ /[!.?"']/ + value << "." + end + object.info.entrance_message = value + end + player.output "#{object.name} entrance message set to: #{object.info.entrance_message}" + when "portal" + if value.downcase == "!nothing" or value.downcase == "nil" + object.info.delete :portal_message + else + if value[-1,1] !~ /[!.?"']/ + value << "." + end + object.info.portal_message = value + end + player.output "#{object.name} portal message set to: #{object.info.portal_message}" + else + player.output "Valid options: action, exit, entrance, or portal." + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/pose.rb b/lib/aethyr/core/actions/commands/pose.rb new file mode 100644 index 0000000000000000000000000000000000000000..c2d6f39be2f35d9dc58cff7085a8a2e42250e55b --- /dev/null +++ b/lib/aethyr/core/actions/commands/pose.rb @@ -0,0 +1,30 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Pose + class PoseCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:pose].downcase == "none" + player.pose = nil + player.output "You are no longer posing." + else + player.pose = event[:pose] + player.output "Your pose is now: #{event[:pose]}." + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/punch.rb b/lib/aethyr/core/actions/commands/punch.rb new file mode 100644 index 0000000000000000000000000000000000000000..68eec260937060d2239141b3926d3b7665dc2e44 --- /dev/null +++ b/lib/aethyr/core/actions/commands/punch.rb @@ -0,0 +1,56 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Punch + class PunchCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + return unless Combat.ready? player + + target = (event.target && room.find(event.target)) || room.find(player.last_target) + + if target.nil? + player.output "Who are you trying to attack?" + return + else + return unless Combat.valid_target? player, target + end + + player.last_target = target.goid + + event.target = target + + event[:to_other] = "#{player.name} swings #{player.pronoun(:possessive)} clenched fist at #{target.name}." + event[:to_target] = "#{player.name} swings #{player.pronoun(:possessive)} fist straight towards your face." + event[:to_player] = "You clench your hand into a fist and swing it at #{target.name}." + event[:blockable] = true + + player.balance = false + player.info.in_combat = true + target.info.in_combat = true + + room.out_event event + + event[:action] = :martial_hit + event[:combat_action] = :punch + event[:to_other] = "#{player.name} punches #{target.name} directly in the face." + event[:to_target] = "You stagger slightly as #{player.name} punches you in the face." + event[:to_player] = "Your fist lands squarely in #{target.name}'s face." + + Combat.future_event event + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/put.rb b/lib/aethyr/core/actions/commands/put.rb new file mode 100644 index 0000000000000000000000000000000000000000..4aa5481dae563f6bdba538ad861673313f615c19 --- /dev/null +++ b/lib/aethyr/core/actions/commands/put.rb @@ -0,0 +1,52 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Put + class PutCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + item = @player.inventory.find(event[:item]) + + if item.nil? + if response = @player.equipment.worn_or_wielded?(event[:item]) + @player.output response + else + @player.output "You do not seem to have a #{event[:item]}." + end + + return + end + + container = @player.search_inv(event[:container]) || $manager.find(event[:container], room) + + if container.nil? + @player.output("There is no #{event[:container]} in which to put #{item.name}.") + return + elsif not container.is_a? Container + @player.output("You cannot put anything in #{container.name}.") + return + elsif container.can? :open and container.closed? + @player.output("You need to open #{container.name} first.") + return + end + + @player.inventory.remove(item) + container.add(item) + + event[:to_player] = "You put #{item.name} in #{container.name}." + event[:to_other] = "#{@player.name} puts #{item.name} in #{container.name}" + + room.out_event(event) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/quit.rb b/lib/aethyr/core/actions/commands/quit.rb new file mode 100644 index 0000000000000000000000000000000000000000..86ea65cfed98671591bd3c721b3938cf5bbc3912 --- /dev/null +++ b/lib/aethyr/core/actions/commands/quit.rb @@ -0,0 +1,20 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Quit + class QuitCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + $manager.drop_player player + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/read_post.rb b/lib/aethyr/core/actions/commands/read_post.rb new file mode 100644 index 0000000000000000000000000000000000000000..e8f16f6d58741058751178fd5e79254b041beb5c --- /dev/null +++ b/lib/aethyr/core/actions/commands/read_post.rb @@ -0,0 +1,43 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module ReadPost + class ReadPostCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + board = find_board(event, room) + + if board.nil? + player.output "There do not seem to be any postings here." + return + end + + post = board.get_post event[:post_id] + if post.nil? + player.output "No such posting here." + return + end + + if player.info.boards.nil? + player.info.boards = {} + end + + player.info.boards[board.goid] = event[:post_id].to_i + + player.output board.show_post(post, player.word_wrap || 80) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/remove.rb b/lib/aethyr/core/actions/commands/remove.rb new file mode 100644 index 0000000000000000000000000000000000000000..a2a06a895fe97c22b08a506d41b0090cdae08abb --- /dev/null +++ b/lib/aethyr/core/actions/commands/remove.rb @@ -0,0 +1,50 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Remove + class RemoveCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + object = player.equipment.find(event[:object]) + + if object.nil? + player.output("What #{event[:object]} are you trying to remove?") + return + end + + if player.inventory.full? + player.output("There is no room in your inventory.") + return + end + + if object.is_a? Weapon + player.output("You must unwield weapons.") + return + end + + response = player.remove(object, event[:position]) + + if response + event[:to_player] = "You remove #{object.name}." + event[:to_other] = "#{player.name} removes #{object.name}." + room.out_event(event) + else + player.output "Could not remove #{object.name} for some reason." + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/reply.rb b/lib/aethyr/core/actions/commands/reply.rb new file mode 100644 index 0000000000000000000000000000000000000000..f19e2df73b3f5ef7df194f495d197c4a5b4a9981 --- /dev/null +++ b/lib/aethyr/core/actions/commands/reply.rb @@ -0,0 +1,27 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Reply + class ReplyCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + unless @player.reply_to + @player.output "There is no one to reply to." + return + end + + event[:target] = @player.reply_to + + action_tell(event) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/restart.rb b/lib/aethyr/core/actions/commands/restart.rb new file mode 100644 index 0000000000000000000000000000000000000000..8b5765c9e093ec3dc5e3c0e36aefe1aa095335a5 --- /dev/null +++ b/lib/aethyr/core/actions/commands/restart.rb @@ -0,0 +1,24 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Restart + class RestartCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + $manager.restart + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/satiety.rb b/lib/aethyr/core/actions/commands/satiety.rb new file mode 100644 index 0000000000000000000000000000000000000000..29df664872c196edee0c7a5da2709e00f9c54320 --- /dev/null +++ b/lib/aethyr/core/actions/commands/satiety.rb @@ -0,0 +1,21 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Satiety + class SatietyCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + @player.output "You are #{@player.satiety}." + end + #Display status. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/say.rb b/lib/aethyr/core/actions/commands/say.rb new file mode 100644 index 0000000000000000000000000000000000000000..23730f358b40a9438c118254ced2c05bb1281732 --- /dev/null +++ b/lib/aethyr/core/actions/commands/say.rb @@ -0,0 +1,113 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Say + class SayCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data.dup + room = $manager.get_object(@player.container) + + phrase = event[:phrase] + target = event[:target] && room.find(event[:target]) + prefix = event[:pre] + + if prefix + prefix << ", " + else + prefix = "" + end + + if phrase.nil? + @player.output("Huh?") + return + elsif event[:target] and target.nil? + @player.output("Say what to whom?") + return + elsif target and target == @player + @player.output "Talking to yourself again?" + return + elsif target + to_clause = " to #{target.name}" + ask_clause = " #{target.name}" + else + to_clause = "" + ask_clause = "" + end + + phrase[0,1] = phrase[0,1].capitalize + phrase.gsub!(/(\s|^|\W)(i)(\s|$|\W)/) { |match| match.sub('i', 'I') } + + case phrase + when /:\)$/ + rvoice = "smiles and " + pvoice = "smile and " + when /:\($/ + rvoice = "frowns and " + pvoice = "frown and " + when /:D$/ + rvoice = "laughs as #{@player.pronoun} " + pvoice = "laugh as you " + else + rvoice = "" + pvoice = "" + end + + phrase = phrase.gsub(/\s*(:\)|:\()|:D/, '').strip.gsub(/\s{2,}/, ' ') + + case phrase[-1..-1] + when "!" + pvoice += "exclaim" + rvoice += "exclaims" + when "?" + pvoice += "ask" + rvoice += "asks" + when "." + pvoice += "say" + rvoice += "says" + else + pvoice += "say" + rvoice += "says" + ender = "." + end + + phrase = "<say>\"#{phrase}#{ender}\"</say>" + + event[:message_type] = :chat + event[:target] = target + if target and pvoice == "ask" + event[:to_target] = prefix + "#{@player.name} #{rvoice} you, #{phrase}" + event[:to_player] = prefix + "you #{pvoice} #{target.name}, #{phrase}" + event[:to_other] = prefix + "#{@player.name} #{rvoice} #{target.name}, #{phrase}" + event[:to_blind_target] = "Someone asks, #{phrase}" + event[:to_blind_other] = "Someone asks, #{phrase}" + event[:to_deaf_target] = "#{@player.name} seems to be asking you something." + event[:to_deaf_other] = "#{@player.name} seems to be asking #{target.name} something." + elsif target + event[:to_target] = prefix + "#{@player.name} #{rvoice} to you, #{phrase}" + event[:to_player] = prefix + "you #{pvoice} to #{target.name}, #{phrase}" + event[:to_other] = prefix + "#{@player.name} #{rvoice} to #{target.name}, #{phrase}" + event[:to_blind_target] = "Someone #{rvoice}, #{phrase}" + event[:to_blind_other] = "Someone #{rvoice}, #{phrase}" + event[:to_deaf_target] = "You see #{@player.name} say something to you." + event[:to_deaf_other] = "You see #{@player.name} say something to #{target.name}." + else + event[:to_player] = prefix + "you #{pvoice}, #{phrase}" + event[:to_other] = prefix + "#{@player.name} #{rvoice}, #{phrase}" + event[:to_blind_other] = "Someone #{rvoice}, #{phrase}" + event[:to_deaf_target] = "You see #{@player.name} say something." + event[:to_deaf_other] = "You see #{@player.name} say something." + end + + room.out_event(event) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/set.rb b/lib/aethyr/core/actions/commands/set.rb new file mode 100644 index 0000000000000000000000000000000000000000..d6c95990f7cfa32c4ef45bd3c314e9740a86e4c4 --- /dev/null +++ b/lib/aethyr/core/actions/commands/set.rb @@ -0,0 +1,101 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Set + class SetCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + event[:setting].downcase! + case event[:setting] + when 'wordwrap' + value = event[:value] + if player.word_wrap.nil? + player.output("Word wrap is currently off.", true) + else + player.output("Word wrap currently set to #{player.word_wrap}.", true) + end + + if value.nil? + player.output "Please specify 'off' or a value between 10 - 200." + return + elsif value.downcase == 'off' + player.word_wrap = nil + player.output "Word wrap is now disabled." + return + else + value = value.to_i + if value > 200 or value < 10 + player.output "Please use a value between 10 - 200." + return + else + player.word_wrap = value + player.output "Word wrap is now set to: #{value} characters." + return + end + end + when 'pagelength', "page_length" + value = event[:value] + if player.page_height.nil? + player.output("Pagination is currently off.", true) + else + player.output("Page length is currently set to #{player.page_height}.", true) + end + + if value.nil? + player.output "Please specify 'off' or a value between 1 - 200." + return + elsif value.downcase == 'off' + player.page_height = nil + player.output "Output will no longer be paginated." + return + else + value = value.to_i + if value > 200 or value < 1 + player.output "Please use a value between 1 - 200." + return + else + player.page_height = value + player.output "Page length is now set to: #{value} lines." + return + end + + end + when "desc", "description" + player.editor(player.instance_variable_get(:@long_desc) || [], 10) do |data| + unless data.nil? + player.long_desc = data.strip + end + player.output("Set description to:\r\n#{player.long_desc}") + end + when "layout" + case event[:value].downcase + when "basic" + player.layout = :basic + when "partial" + player.layout = :partial + when "full" + player.layout = :full + when "wide" + player.layout = :wide + else + player.output "#{value} is not a valid layout please set one of the following: basic, partial, full, wide." + end + else + player.output "No such setting: #{event[:setting]}" + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/setcolor.rb b/lib/aethyr/core/actions/commands/setcolor.rb new file mode 100644 index 0000000000000000000000000000000000000000..b33246ec3835c1d8d0b88b7799c4cb2b016a7595 --- /dev/null +++ b/lib/aethyr/core/actions/commands/setcolor.rb @@ -0,0 +1,35 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Setcolor + class SetcolorCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:option] == "off" + player.io.use_color = false + player.output "Colors disabled." + elsif event[:option] == "on" + player.io.use_color = true + player.output "Colors enabled." + elsif event[:option] == "default" + player.io.to_default + player.output "Colors set to defaults." + else + player.output player.io.set_color(event[:option], event[:color]) + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/setpassword.rb b/lib/aethyr/core/actions/commands/setpassword.rb new file mode 100644 index 0000000000000000000000000000000000000000..46500ba78310ba5ae56158f911bf1c68c3ed5868 --- /dev/null +++ b/lib/aethyr/core/actions/commands/setpassword.rb @@ -0,0 +1,50 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Setpassword + class SetpasswordCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:new_password] + if event[:new_password] !~ /^\w{6,20}$/ + player.output "Please only use letters and numbers. Password should be between 6 and 20 characters long." + return + else + $manager.set_password(player, event[:new_password]) + player.output "Your password has been changed." + end + else + player.output "Please enter your current password:", true + player.io.echo_off + player.expect do |password| + if $manager.check_password(player.name, password) + player.output "Please enter your new password:", true + player.io.echo_off + player.expect do |password| + player.io.echo_on + event[:new_password] = password + Settings.setpassword(event, player, room) + end + else + player.output "Sorry, that password is invalid." + player.io.echo_on + end + + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/showcolors.rb b/lib/aethyr/core/actions/commands/showcolors.rb new file mode 100644 index 0000000000000000000000000000000000000000..7395fedb81c1b94597061516da00b79dba61bdbf --- /dev/null +++ b/lib/aethyr/core/actions/commands/showcolors.rb @@ -0,0 +1,24 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Showcolors + class ShowcolorsCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + player.output player.io.display.show_color_config + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/shrug.rb b/lib/aethyr/core/actions/commands/shrug.rb new file mode 100644 index 0000000000000000000000000000000000000000..bed18a1b4611ab6011560e826ddd8dcf2b8e1bc3 --- /dev/null +++ b/lib/aethyr/core/actions/commands/shrug.rb @@ -0,0 +1,46 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Shrug + class ShrugCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You shrug your shoulders." + to_other "#{player.name} shrugs #{player.pronoun(:possessive)} shoulders." + to_deaf_other event[:to_other] + end + + self_target do + player.output "Don't just shrug yourself off like that!" + + end + + target do + to_player "You give #{event.target.name} a brief shrug." + to_target "#{player.name} gives you a brief shrug." + to_other "#{player.name} gives #{event.target.name} a brief shrug." + to_deaf_other event[:to_other] + to_deaf_target event[:to_target] + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/sigh.rb b/lib/aethyr/core/actions/commands/sigh.rb new file mode 100644 index 0000000000000000000000000000000000000000..c569907af2e98d706db08d609a38280346c2a6d7 --- /dev/null +++ b/lib/aethyr/core/actions/commands/sigh.rb @@ -0,0 +1,43 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Sigh + class SighCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You exhale, sighing deeply." + to_other "#{player.name} breathes out a deep sigh." + end + + self_target do + to_player "You sigh at your misfortunes." + to_other "#{player.name} sighs at #{player.pronoun(:possessive)} own misfortunes." + end + + target do + to_player "You sigh in #{event.target.name}'s general direction." + to_target "#{player.name} heaves a sigh in your direction." + to_other "#{player.name} sighs heavily in #{event.target.name}'s direction." + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/simple_block.rb b/lib/aethyr/core/actions/commands/simple_block.rb new file mode 100644 index 0000000000000000000000000000000000000000..ef017b6c705544eaa99cb278ff4cef83efa23cea --- /dev/null +++ b/lib/aethyr/core/actions/commands/simple_block.rb @@ -0,0 +1,70 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module SimpleBlock + class SimpleBlockCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + return if not Combat.ready? player + + weapon = get_weapon(player, :block) + if weapon.nil? + player.output "You are not wielding a weapon you can block with." + return + end + + target = (event.target && room.find(event.target)) || room.find(player.last_target) + + if target == player + player.output "You cannot block yourself." + return + elsif target + events = Combat.find_events(:player => target, :target => player, :blockable => true) + else + events = Combat.find_events(:target => player, :blockable => true) + end + + if events.empty? + player.output "What are you trying to block?" + return + end + + if target.nil? + target = events[0].player + end + + player.last_target = target.goid + + b_event = events[0] + if rand > 0.5 + b_event[:action] = :weapon_block + b_event[:type] = :WeaponCombat + b_event[:to_other] = "#{player.name} deftly blocks #{target.name}'s attack with #{weapon.name}." + b_event[:to_player] = "#{player.name} deftly blocks your attack with #{weapon.name}." + b_event[:to_target] = "You deftly block #{target.name}'s attack with #{weapon.name}." + end + + event[:target] = target + event[:to_other] = "#{player.name} raises #{player.pronoun(:possessive)} #{weapon.generic} to block #{target.name}'s attack." + event[:to_target] = "#{player.name} raises #{player.pronoun(:possessive)} #{weapon.generic} to block your attack." + event[:to_player] = "You raise your #{weapon.generic} to block #{target.name}'s attack." + + player.balance = false + room.out_event event + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/simple_dodge.rb b/lib/aethyr/core/actions/commands/simple_dodge.rb new file mode 100644 index 0000000000000000000000000000000000000000..56e5b4c67518f257dac287bc8129d3ed70f421df --- /dev/null +++ b/lib/aethyr/core/actions/commands/simple_dodge.rb @@ -0,0 +1,63 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module SimpleDodge + class SimpleDodgeCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + return unless Combat.ready? player + + target = (event.target && room.find(event.target)) || room.find(player.last_target) + + if target == player + player.output "You cannot block yourself." + return + elsif target + events = Combat.find_events(:player => target, :target => player, :blockable => true) + else + events = Combat.find_events(:target => player, :blockable => true) + end + + if events.empty? + player.output "What are you trying to dodge?" + return + end + + if target.nil? + target = events[0].player + end + + player.last_target = target.goid + + b_event = events[0] + if rand > 0.5 + b_event[:action] = :martial_miss + b_event[:type] = :MartialCombat + b_event[:to_other] = "#{player.name} twists away from #{target.name}'s attack." + b_event[:to_player] = "#{player.name} twists away from your attack." + b_event[:to_target] = "You manage to twist your body away from #{target.name}'s attack." + end + + event[:target] = target + event[:to_other] = "#{player.name} attempts to dodge #{target.name}'s attack." + event[:to_target] = "#{player.name} attempts to dodge your attack." + event[:to_player] = "You attempt to dodge #{target.name}'s attack." + + player.balance = false + room.out_event event + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/sit.rb b/lib/aethyr/core/actions/commands/sit.rb new file mode 100644 index 0000000000000000000000000000000000000000..e42bde5ce003d6d00e1b6cc55b66bdac7a5e9bba --- /dev/null +++ b/lib/aethyr/core/actions/commands/sit.rb @@ -0,0 +1,63 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Sit + class SitCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if not player.balance + player.output "You cannot sit properly while unbalanced." + return + elsif event[:object].nil? + if player.sitting? + player.output('You are already sitting down.') + elsif player.prone? and player.sit + event[:to_player] = 'You stand up then sit on the ground.' + event[:to_other] = "#{player.name} stands up then sits down on the ground." + event[:to_deaf_other] = event[:to_other] + room.output(event) + elsif player.sit + event[:to_player] = 'You sit down on the ground.' + event[:to_other] = "#{player.name} sits down on the ground." + event[:to_deaf_other] = event[:to_other] + room.out_event(event) + else + player.output('You are unable to sit down.') + end + else + object = $manager.find(event[:object], player.room) + + if object.nil? + player.output('What do you want to sit on?') + elsif not object.can? :sittable? + player.output("You cannot sit on #{object.name}.") + elsif object.occupied_by? player + player.output("You are already sitting there!") + elsif not object.has_room? + player.output("The #{object.generic} #{object.plural? ? "are" : "is"} already occupied.") + elsif player.sit(object) + object.sat_on_by(player) + event[:to_player] = "You sit down on #{object.name}." + event[:to_other] = "#{player.name} sits down on #{object.name}." + event[:to_deaf_other] = event[:to_other] + room.out_event(event) + else + player.output('You are unable to sit down.') + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/skills.rb b/lib/aethyr/core/actions/commands/skills.rb new file mode 100644 index 0000000000000000000000000000000000000000..b4324eac2f8d658ff33d381cce2e45b5882334b4 --- /dev/null +++ b/lib/aethyr/core/actions/commands/skills.rb @@ -0,0 +1,62 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Skills + class SkillsCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + box_width = 25 + box_work_width = box_width - 2 + width = @player.word_wrap + width = 200 if @player.word_wrap.nil? + boxes_per_row = width / box_width + + box_top = "┌" + ("─" * box_work_width) + "â”\n" + box_bottom = "â””" + ("─" * box_work_width) + "┘\n" + + output = "" + text_format = "%-#{box_work_width}.#{box_work_width}s" + text_format_right = "%#{box_work_width}.#{box_work_width}s" + @player.info.skills.each do |id, skill| + + output += box_top + + level_width = box_work_width - skill.name.length + level_format = "%#{level_width}.#{level_width}s" + level = "lv #{skill.level}" + title = "#{skill.name}#{level_format % level}" + output += "│<raw fg:white>#{title}</raw fg:white>│\n" + + desc_lines = wrap(skill.help_desc, box_work_width) + desc_lines.each do |line| + output += "│#{text_format % line}│\n" + end + + output += "│#{text_format_right % ''}│\n" + + output += "│#{SkillsHandler::generate_progress(box_work_width, skill.level_percentage)}│\n" + + xp_left = "#{skill.xp_to_go} xp to next" + output += "│#{text_format_right % xp_left}│\n" + + xp_total = "#{skill.xp} xp total" + output += "│#{text_format_right % xp_total}│\n" + + xp_frac = "#{skill.xp_so_far} / #{skill.xp_per_level} xp" + output += "│#{text_format_right % xp_frac}│\n" + + output += box_bottom + "\n" + end + @player.output(output) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/skip.rb b/lib/aethyr/core/actions/commands/skip.rb new file mode 100644 index 0000000000000000000000000000000000000000..7bf91aab526f103fe87ed6d007b06ae78f36de7c --- /dev/null +++ b/lib/aethyr/core/actions/commands/skip.rb @@ -0,0 +1,44 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Skip + class SkipCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You skip around cheerfully." + to_other "#{player.name} skips around cheerfully." + to_deaf_other "#{player.name} skips around cheerfully." + end + + self_target do + player.output 'How?' + end + + target do + to_player "You skip around #{event.target.name} cheerfully." + to_target "#{player.name} skips around you cheerfully." + to_other "#{player.name} skips around #{event.target.name} cheerfully." + to_deaf_other "#{player.name} skips around #{event.target.name} cheerfully." + end + + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/slash.rb b/lib/aethyr/core/actions/commands/slash.rb new file mode 100644 index 0000000000000000000000000000000000000000..cfde4114d6414ffeb7af3cba5b5edc0c0c17429e --- /dev/null +++ b/lib/aethyr/core/actions/commands/slash.rb @@ -0,0 +1,65 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Slash + class SlashCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + return if not Combat.ready? player + + weapon = get_weapon(player, :slash) + if weapon.nil? + player.output "You are not wielding a weapon you can slash with." + return + end + + target = (event.target && room.find(event.target)) || room.find(player.last_target) + + if target.nil? + player.output "Who are you trying to attack?" + return + else + return unless Combat.valid_target? player, target + end + + player.last_target = target.goid + + event.target = target + + event[:to_other] = "#{weapon.name} flashes as #{player.name} swings it at #{target.name}." + event[:to_target] = "#{weapon.name} flashes as #{player.name} swings it towards you." + event[:to_player] = "#{weapon.name} flashes as you swing it towards #{target.name}." + event[:attack_weapon] = weapon + event[:blockable] = true + + player.balance = false + player.info.in_combat = true + target.info.in_combat = true + + room.out_event event + + event[:action] = :weapon_hit + event[:combat_action] = :slash + event[:to_other] = "#{player.name} slashes across #{target.name}'s torso with #{weapon.name}." + event[:to_target] = "#{player.name} slashes across your torso with #{weapon.name}." + event[:to_player] = "You slash across #{target.name}'s torso with #{weapon.name}." + + Combat.future_event event + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/smell.rb b/lib/aethyr/core/actions/commands/smell.rb new file mode 100644 index 0000000000000000000000000000000000000000..3a2d9cb64b548992e936688adb9fd039ab98f31b --- /dev/null +++ b/lib/aethyr/core/actions/commands/smell.rb @@ -0,0 +1,60 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Smell + class SmellCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + if event[:target].nil? + if room.info.smell + event[:to_player] = "You sniff the air. #{room.info.smell}." + else + event[:to_player] = "You sniff the air, but detect no unusual aromas." + end + event[:to_other] = "#{@player.name} sniffs the air." + room.out_event event + return + end + + object = @player.search_inv(event[:target]) || room.find(event[:target]) + + if object == @player or event[:target] == "me" + event[:target] = @player + event[:to_player] = "You cautiously sniff your armpits. " + if rand > 0.6 + event[:to_player] << "Your head snaps back from the revolting stench coming from beneath your arms." + event[:to_other] = "#{@player.name} sniffs #{@player.pronoun(:possessive)} armpits, then recoils in horror." + else + event[:to_player] << "Meh, not too bad." + event[:to_other] = "#{@player.name} sniffs #{@player.pronoun(:possessive)} armpits, then shrugs, apparently unconcerned with #{@player.pronoun(:possessive)} current smell." + end + room.out_event event + return + elsif object.nil? + @player.output "What are you trying to smell?" + return + end + + event[:target] = object + event[:to_player] = "Leaning in slightly, you sniff #{object.name}. " + if object.info.smell.nil? or object.info.smell == "" + event[:to_player] << "#{object.pronoun.capitalize} has no particular aroma." + else + event[:to_player] << object.info.smell + end + event[:to_target] = "#{@player.name} sniffs you curiously." + event[:to_other] = "#{@player.name} thrusts #{@player.pronoun(:possessive)} nose at #{object.name} and sniffs." + room.out_event event + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/smile.rb b/lib/aethyr/core/actions/commands/smile.rb new file mode 100644 index 0000000000000000000000000000000000000000..4eabae9039c0927cc402ea147b1f5ca8b1053d4b --- /dev/null +++ b/lib/aethyr/core/actions/commands/smile.rb @@ -0,0 +1,42 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Smile + class SmileCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + self_target do + to_player "You smile happily at yourself." + to_other "#{player.name} smiles at #{player.pronoun(:reflexive)} sillily." + end + + target do + to_player "You smile at #{event.target.name} kindly." + to_target "#{player.name} smiles at you kindly." + to_other "#{player.name} smiles at #{event.target.name} kindly." + end + + no_target do + to_player "You smile happily." + to_other "#{player.name} smiles happily." + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/snicker.rb b/lib/aethyr/core/actions/commands/snicker.rb new file mode 100644 index 0000000000000000000000000000000000000000..722a5caab2de15bb66e2ba903358e2de22609b7d --- /dev/null +++ b/lib/aethyr/core/actions/commands/snicker.rb @@ -0,0 +1,43 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Snicker + class SnickerCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You snicker softly to yourself." + to_other "You hear #{player.name} snicker softly." + to_blind_other "You hear someone snicker softly." + end + + self_target do + player.output "What are you snickering about?" + end + + target do + to_player "You snicker at #{event.target.name} under your breath." + to_target "#{player.name} snickers at you under #{player.pronoun(:possessive)} breath." + to_other "#{player.name} snickers at #{event.target.name} under #{player.pronoun(:possessive)} breath." + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/stand.rb b/lib/aethyr/core/actions/commands/stand.rb new file mode 100644 index 0000000000000000000000000000000000000000..53ca278fac97206050b6c5e494a0c20780d77e35 --- /dev/null +++ b/lib/aethyr/core/actions/commands/stand.rb @@ -0,0 +1,46 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Stand + class StandCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if not player.prone? + player.output('You are already on your feet.') + return + elsif not player.balance + player.output "You cannot stand while unbalanced." + return + end + + if player.sitting? + object = $manager.find(player.sitting_on, room) + else + object = $manager.find(player.lying_on, room) + end + + if player.stand + event[:to_player] = 'You rise to your feet.' + event[:to_other] = "#{player.name} stands up." + event[:to_deaf_other] = event[:to_other] + room.out_event(event) + object.evacuated_by(player) unless object.nil? + else + player.output('You are unable to stand up.') + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/status.rb b/lib/aethyr/core/actions/commands/status.rb new file mode 100644 index 0000000000000000000000000000000000000000..ae56a36c6a5ff74920f9146da4e7a7080415aa1b --- /dev/null +++ b/lib/aethyr/core/actions/commands/status.rb @@ -0,0 +1,23 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Status + class StatusCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + @player.output("You are #{@player.health}.") + @player.output("You are feeling #{@player.satiety}.") + @player.output "You are currently #{@player.pose || 'standing up'}." + end + #Fill something. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/taste.rb b/lib/aethyr/core/actions/commands/taste.rb new file mode 100644 index 0000000000000000000000000000000000000000..9c7af755dec3cc1de282a4204cd27f3f7458d6eb --- /dev/null +++ b/lib/aethyr/core/actions/commands/taste.rb @@ -0,0 +1,40 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Taste + class TasteCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + object = @player.search_inv(event[:target]) || room.find(event[:target]) + + if object == @player or event[:target] == "me" + @player.output "You covertly lick yourself.\nHmm, not bad." + return + elsif object.nil? + @player.output "What would you like to taste?" + return + end + + event[:target] = object + event[:to_player] = "Sticking your tongue out hesitantly, you taste #{object.name}. " + if object.info.taste.nil? or object.info.taste == "" + event[:to_player] << "#{object.pronoun.capitalize} does not taste that great, but has no particular flavor." + else + event[:to_player] << object.info.taste + end + event[:to_target] = "#{@player.name} licks you, apparently in an attempt to find out your flavor." + event[:to_other] = "#{@player.name} hesitantly sticks out #{@player.pronoun(:possessive)} tongue and licks #{object.name}." + room.out_event event + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/tell.rb b/lib/aethyr/core/actions/commands/tell.rb new file mode 100644 index 0000000000000000000000000000000000000000..a505f342220c4ff28e25c2a75376b4b9713aec53 --- /dev/null +++ b/lib/aethyr/core/actions/commands/tell.rb @@ -0,0 +1,46 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Tell + class TellCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + target = $manager.find event[:target] + unless target and target.is_a? Player + @player.output "That person is not available." + return + end + + if target == @player + @player.output "Talking to yourself?" + return + end + + phrase = event[:message] + + last_char = phrase[-1..-1] + + unless ["!", "?", "."].include? last_char + phrase << "." + end + + phrase[0,1] = phrase[0,1].upcase + phrase = phrase.strip.gsub(/\s{2,}/, ' ') + + @player.output "You tell #{target.name}, <tell>\"#{phrase}\"</tell>" + target.output "#{@player.name} tells you, <tell>\"#{phrase}\"</tell>" + target.reply_to = @player.name + end + + #Reply to a tell. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/terrain.rb b/lib/aethyr/core/actions/commands/terrain.rb new file mode 100644 index 0000000000000000000000000000000000000000..136e2ae579ee37c312ed02f64fe596d04f085fd0 --- /dev/null +++ b/lib/aethyr/core/actions/commands/terrain.rb @@ -0,0 +1,73 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Terrain + class TerrainCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + if event[:target] == "area" + if room.area.nil? + player.output "This room is not in an area." + return + end + + room.area.info.terrain.area_type = event[:value].downcase.to_sym + + player.output "Set #{room.area.name} terrain type to #{room.area.info.terrain.area_type}" + + return + end + + case event[:setting].downcase + when "type" + room.info.terrain.room_type = event[:value].downcase.to_sym + player.output "Set #{room.name} terrain type to #{room.info.terrain.room_type}" + when "indoors" + if event[:value] =~ /yes|true/i + room.info.terrain.indoors = true + player.output "Room is now indoors." + elsif event[:value] =~ /no|false/i + room.info.terrain.indoors = false + player.output "Room is now outdoors." + else + player.output "Indoors: yes or no?" + end + when "water" + if event[:value] =~ /yes|true/i + room.info.terrain.water = true + player.output "Room is now water." + elsif event[:value] =~ /no|false/i + room.info.terrain.water = false + player.output "Room is now dry." + else + player.output "Water: yes or no?" + end + when "underwater" + if event[:value] =~ /yes|true/i + room.info.terrain.underwater = true + player.output "Room is now underwater." + elsif event[:value] =~ /no|false/i + room.info.terrain.underwater = false + player.output "Room is now above water." + else + player.output "Underwater: yes or no?" + end + else + player.output "What are you trying to set?" + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/time.rb b/lib/aethyr/core/actions/commands/time.rb new file mode 100644 index 0000000000000000000000000000000000000000..537202637efd0281ae08f101d5be0721e64a35bb --- /dev/null +++ b/lib/aethyr/core/actions/commands/time.rb @@ -0,0 +1,22 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Time + class TimeCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + @player.output $manager.time + end + + #Display date. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/uh.rb b/lib/aethyr/core/actions/commands/uh.rb new file mode 100644 index 0000000000000000000000000000000000000000..5dec4ae623d97c29cd01ac3e2ff54fc13acf69ea --- /dev/null +++ b/lib/aethyr/core/actions/commands/uh.rb @@ -0,0 +1,35 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Uh + class UhCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + make_emote event, player, room do + no_target do + to_player "\"Uh...\" you say, staring blankly." + to_other "With a blank stare, #{player.name} says, \"Uh...\"" + end + + target do + to_player "With a blank stare at #{target.name}, you say, \"Uh...\"" + to_other "With a blank stare at #{target.name}, #{player.name} says, \"Uh...\"" + to_target "Staring blankly at you, #{player.name} says, \"Uh...\"" + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/unlock.rb b/lib/aethyr/core/actions/commands/unlock.rb new file mode 100644 index 0000000000000000000000000000000000000000..af1775ef89202699af15d805b86b65e290cfb264 --- /dev/null +++ b/lib/aethyr/core/actions/commands/unlock.rb @@ -0,0 +1,69 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Unlock + class UnlockCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + object = @player.search_inv(event[:object]) || room.find(event[:object]) + + if object.nil? + @player.output("Unlock what? #{event[:object]}?") + return + elsif not object.can? :unlock or not object.lockable? + @player.output('That object cannot be unlocked.') + return + elsif not object.locked? + @player.output("#{object.name} is already unlocked.") + return + end + + has_key = false + object.keys.each do |key| + if @player.inventory.include? key + has_key = key + break + end + end + + if has_key or @player.admin + status = object.unlock(has_key, @player.admin) + if status + event[:to_player] = "You unlock #{object.name}." + event[:to_other] = "#{@player.name} unlocks #{object.name}." + event[:to_blind_other] = "You hear the clunk of a lock." + + room.out_event(event) + + if object.is_a? Door and object.connected? + other_side = $manager.find object.connected_to + other_side.unlock(has_key) + other_room = $manager.find other_side.container + o_event = event.dup + event[:to_other] = "#{other_side.name} unlocks from the other side." + event[:to_blind_other] = "You hear the click of a lock." + other_room.out_event(event) + end + + return + else + @player.output("You are unable to unlock #{object.name}.") + return + end + else + @player.output("You do not have the key to #{object.name}.") + return + end + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/unwield.rb b/lib/aethyr/core/actions/commands/unwield.rb new file mode 100644 index 0000000000000000000000000000000000000000..4f36de5373a66a2f43b5afab5017bb6c01e22019 --- /dev/null +++ b/lib/aethyr/core/actions/commands/unwield.rb @@ -0,0 +1,60 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Unwield + class UnwieldCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + if event[:weapon] == "right" || event[:weapon] == "left" + weapon = player.equipment.get_wielded(event[:weapon]) + + if weapon.nil? + player.output "You are not wielding anything in your #{event[:weapon]} hand." + return + end + elsif event[:weapon].nil? + weapon = player.equipment.get_wielded + if weapon.nil? + player.output "You are not wielding anything." + return + end + else + weapon = player.equipment.find(event[:weapon]) + + if weapon.nil? + player.output "What are you trying to unwield?" + return + end + + if not [:left_wield, :right_wield, :dual_wield].include? player.equipment.position_of(weapon) + player.output "You are not wielding #{weapon.name}." + return + end + + end + + if player.equipment.remove(weapon) + player.inventory << weapon + event[:to_player] = "You unwield #{weapon.name}." + event[:to_other] = "#{player.name} unwields #{weapon.name}." + room.out_event(event) + else + player.output "Could not unwield #{weapon.name}." + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/wave.rb b/lib/aethyr/core/actions/commands/wave.rb new file mode 100644 index 0000000000000000000000000000000000000000..2897f62f915f91bcbd16901b3e3b8d74597b4aa8 --- /dev/null +++ b/lib/aethyr/core/actions/commands/wave.rb @@ -0,0 +1,41 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Wave + class WaveCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You wave goodbye to everyone." + to_other "#{player.name} waves goodbye to everyone." + end + + self_target do + player.output "Waving at someone?" + end + + target do + to_player "You wave farewell to #{event.target.name}." + to_target "#{player.name} waves farewell to you." + to_other "#{player.name} waves farewell to #{event.target.name}." + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/wear.rb b/lib/aethyr/core/actions/commands/wear.rb new file mode 100644 index 0000000000000000000000000000000000000000..01042c472edebc0ecd172ab60743717c53b568e0 --- /dev/null +++ b/lib/aethyr/core/actions/commands/wear.rb @@ -0,0 +1,39 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Wear + class WearCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + object = player.inventory.find(event[:object]) + + if object.nil? + player.output("What #{event[:object]} are you trying to wear?") + return + elsif object.is_a? Weapon + player.output "You must wield #{object.name}." + return + end + + if player.wear object + event[:to_player] = "You put on #{object.name}." + event[:to_other] = "#{player.name} puts on #{object.name}." + room.out_event(event) + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/whereis.rb b/lib/aethyr/core/actions/commands/whereis.rb new file mode 100644 index 0000000000000000000000000000000000000000..628965377270a82017b59489e4823805082a7ca0 --- /dev/null +++ b/lib/aethyr/core/actions/commands/whereis.rb @@ -0,0 +1,47 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Whereis + class WhereisCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + object = find_object(event[:object], event) + + if object.nil? + player.output "Could not find #{event[:object]}." + return + end + + if object.container.nil? + if object.can? :area and not object.area.nil? and object.area != object + area = $manager.get_object object.area || "nothing" + player.output "#{object} is in #{area}." + else + player.output "#{object} is not in anything." + end + else + container = $manager.get_object object.container + if container.nil? + player.output "Container for #{object} not found." + else + player.output "#{object} is in #{container}." + event[:object] = container.goid + whereis(event, player, room) + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/whisper.rb b/lib/aethyr/core/actions/commands/whisper.rb new file mode 100644 index 0000000000000000000000000000000000000000..4cab1ae0eb9b19c4c7c98cb7c312b42e756bdf5e --- /dev/null +++ b/lib/aethyr/core/actions/commands/whisper.rb @@ -0,0 +1,65 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Whisper + class WhisperCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + room = $manager.get_object(@player.container) + object = room.find(event[:to], Player) + + if object.nil? + @player.output("To whom are you trying to whisper?") + return + elsif object == @player + @player.output("Whispering to yourself again?") + event[:to_other] = "#{@player.name} whispers to #{@player.pronoun(:reflexive)}." + room.out_event(event, @player) + return + end + + phrase = event[:phrase] + + if phrase.nil? + @player.ouput "What are you trying to whisper?" + return + end + + prefix = event[:pre] + + if prefix + prefix << ", " + else + prefix = "" + end + + phrase[0,1] = phrase[0,1].capitalize + + last_char = phrase[-1..-1] + + unless ["!", "?", "."].include? last_char + ender = "." + end + + phrase = ", <say>\"#{phrase}#{ender}\"</say>" + + event[:target] = object + event[:to_player] = prefix + "you whisper to #{object.name}#{phrase}" + event[:to_target] = prefix + "#{@player.name} whispers to you#{phrase}" + event[:to_other] = prefix + "#{@player.name} whispers quietly into #{object.name}'s ear." + event[:to_other_blind] = "#{@player.name} whispers." + event[:to_target_blind] = "Someone whispers to you#{phrase}" + + room.out_event(event) + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/who.rb b/lib/aethyr/core/actions/commands/who.rb new file mode 100644 index 0000000000000000000000000000000000000000..4656aee08a1d8f6aeabca9b7b0aca3d57516a993 --- /dev/null +++ b/lib/aethyr/core/actions/commands/who.rb @@ -0,0 +1,28 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Who + class WhoCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + players = $manager.find_all("class", Player) + output = ["The following people are visiting Aethyr:"] + players.sort_by {|p| p.name}.each do |playa| + room = $manager.find playa.container + output << "#{playa.name} - #{room.name if room}" + end + + @player.output output + end + #Delete your player. + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/wield.rb b/lib/aethyr/core/actions/commands/wield.rb new file mode 100644 index 0000000000000000000000000000000000000000..0140369a3f67925821eca0ee889e24491d6ab215 --- /dev/null +++ b/lib/aethyr/core/actions/commands/wield.rb @@ -0,0 +1,78 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Wield + class WieldCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + weapon = player.inventory.find(event[:weapon]) + if weapon.nil? + weapon = player.equipment.find(event[:weapon]) + if weapon and player.equipment.get_all_wielded.include? weapon + player.output "You are already wielding that." + else + player.output "What are you trying to wield?" + end + return + end + + if not weapon.is_a? Weapon + player.output "#{weapon.name} is not wieldable." + return + end + + if event[:side] + side = event[:side] + if side != "right" and side != "left" + player.output "Which hand?" + return + end + + result = player.equipment.check_wield(weapon, "#{side} wield") + if result + player.output result + return + end + + result = player.equipment.wear(weapon, "#{side} wield") + if result.nil? + player.output "You are unable to wield that." + return + end + event[:to_player] = "You grip #{weapon.name} firmly in your #{side} hand." + else + result = player.equipment.check_wield(weapon) + + if result + player.output result + return + end + + result = player.equipment.wear(weapon) + if result.nil? + player.output "You are unable to wield that weapon." + return + end + + event[:to_player] = "You firmly grip #{weapon.name} and begin to wield it." + end + + player.inventory.remove weapon + event[:to_other] = "#{player.name} wields #{weapon.name}." + room.out_event(event) + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/write.rb b/lib/aethyr/core/actions/commands/write.rb new file mode 100644 index 0000000000000000000000000000000000000000..59b17426a47fb10e892d0eff141c93f19ae5cbdf --- /dev/null +++ b/lib/aethyr/core/actions/commands/write.rb @@ -0,0 +1,39 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Write + class WriteCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + object = @player.search_inv(event[:target]) + + if object.nil? + @player.output "What do you wish to write on?" + return + end + + if not object.info.writable + @player.output "You cannot write on #{object.name}." + return + end + + @player.output "You begin to write on #{object.name}." + + @player.editor(object.readable_text || [], 100) do |data| + unless data.nil? + object.readable_text = data + end + @player.output "You finish your writing." + end + end + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/write_post.rb b/lib/aethyr/core/actions/commands/write_post.rb new file mode 100644 index 0000000000000000000000000000000000000000..50db09899aad3e9a1e48af53338b924d423245e5 --- /dev/null +++ b/lib/aethyr/core/actions/commands/write_post.rb @@ -0,0 +1,44 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module WritePost + class WritePostCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + board = find_board(event, room) + + if board.nil? + player.output "There do not seem to be any postings here." + return + end + + player.output("What is the subject of this post?", true) + + player.expect do |subj| + player.editor do |message| + unless message.nil? + post_id = board.save_post(player, subj, event[:reply_to], message) + player.output "You have written post ##{post_id}." + if board.announce_new + area = $manager.get_object(board.container).area + area.output board.announce_new + end + end + end + end + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/yawn.rb b/lib/aethyr/core/actions/commands/yawn.rb new file mode 100644 index 0000000000000000000000000000000000000000..19d8ed4cb2319a9d734238d040d00db70921e5e5 --- /dev/null +++ b/lib/aethyr/core/actions/commands/yawn.rb @@ -0,0 +1,45 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Yawn + class YawnCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + + make_emote event, player, room do + + no_target do + to_player "You open your mouth in a wide yawn, then exhale loudly." + to_other "#{player.name} opens #{player.pronoun(:possessive)} mouth in a wide yawn, then exhales loudly." + end + + self_target do + to_player "You yawn at how boring you are." + to_other "#{player.name} yawns at #{player.pronoun(:reflexive)}." + to_deaf_other event[:to_other] + end + + target do + to_player "You yawn at #{event.target.name}, bored out of your mind." + to_target "#{player.name} yawns at you, finding you boring." + to_other "#{player.name} yawns at how boring #{event.target.name} is." + to_deaf_other event[:to_other] + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/actions/commands/yes.rb b/lib/aethyr/core/actions/commands/yes.rb new file mode 100644 index 0000000000000000000000000000000000000000..8431debd4e8154f3776cd65e4e1bd89320583c83 --- /dev/null +++ b/lib/aethyr/core/actions/commands/yes.rb @@ -0,0 +1,44 @@ +require "aethyr/core/actions/command_action" + +module Aethyr + module Core + module Actions + module Yes + class YesCommand < Aethyr::Core::Actions::CommandAction + def initialize(actor, **data) + super(actor, **data) + end + + def action + event = @data + + room = $manager.get_object(@player.container) + player = @player + make_emote event, player, room do + + no_target do + to_player "\"Yes,\" you say, nodding." + to_other "#{player.name} says, \"Yes\" and nods." + end + + self_target do + to_player "You nod in agreement with yourself." + to_other "#{player.name} nods at #{player.pronoun(:reflexive)} strangely." + to_deaf_other event[:to_other] + end + + target do + to_player "You nod in agreement with #{event.target.name}." + to_target "#{player.name} nods in your direction, agreeing." + to_other "#{player.name} nods in agreement with #{event.target.name}." + to_deaf_other event[:to_other] + end + end + + end + + end + end + end + end +end diff --git a/lib/aethyr/core/components/manager.rb b/lib/aethyr/core/components/manager.rb index 469af6f211ecc8f459928c2f33dfbf368d4556e0..2bac117a97f21835d78ce4080987463982344250 100644 --- a/lib/aethyr/core/components/manager.rb +++ b/lib/aethyr/core/components/manager.rb @@ -43,6 +43,10 @@ class Manager < Publisher end end + def submit_action action + action.action + end + #Checks if a game object ID exists already, to avoid conflicts. def existing_goid? goid @game_objects[goid] || @storage.type_of(goid) diff --git a/lib/aethyr/core/input_handlers/admin/acarea.rb b/lib/aethyr/core/input_handlers/admin/acarea.rb index 58cf7b3e65a6d8a7a6052ade5075028c0d7812d0..4c81d82dd538454ce10d9840f896f75c00bb47ab 100644 --- a/lib/aethyr/core/input_handlers/admin/acarea.rb +++ b/lib/aethyr/core/input_handlers/admin/acarea.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acarea" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -36,18 +37,11 @@ EOF case data[:input] when /^acarea\s+(.*)$/i name = $1.strip - acarea({:name => name}) + $manager.submit_action(Aethyr::Core::Actions::Acarea::AcareaCommand.new(@player, {:name => name})) end end private - def acarea(event) - - room = $manager.get_object(@player.container) - player = @player - area = $manager.create_object(Area, nil, nil, nil, {:@name => event[:name]}) - player.output "Created: #{area}" - end end Aethyr::Extend::HandlerRegistry.register_handler(AcareaHandler) diff --git a/lib/aethyr/core/input_handlers/admin/acdoor.rb b/lib/aethyr/core/input_handlers/admin/acdoor.rb index 01e7617930027a1b7d7cd58dc80024cf5acc17f6..014fd6f17bec3aac50474aedd18fb2312afd773a 100644 --- a/lib/aethyr/core/input_handlers/admin/acdoor.rb +++ b/lib/aethyr/core/input_handlers/admin/acdoor.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acdoor" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -36,57 +37,15 @@ EOF case data[:input] when /^acdoor\s+(\w+)$/i direction = $1 - acdoor({:direction => direction}) + $manager.submit_action(Aethyr::Core::Actions::Acdoor::AcdoorCommand.new(@player, {:direction => direction})) when /^acdoor\s+(\w+)\s+(.*)$/i direction = $1.strip exit_room = $2.strip - acdoor({:direction => direction, :exit_room => exit_room}) + $manager.submit_action(Aethyr::Core::Actions::Acdoor::AcdoorCommand.new(@player, {:direction => direction, :exit_room => exit_room})) end end private - def acdoor(event) - room = $manager.get_object(@player.container) - player = @player - exit_room = nil - if event[:exit_room].nil? - out = find_object event[:direction], event - if out and out.is_a? Exit - exit_room = $manager.find out.exit_room - other_side = $manager.find opposite_dir(event[:direction]), out.exit_room - - if other_side - $manager.delete_object other_side - player.output "Removed opposite exit (#{other_side})." - else - player.output "Could not find opposite exit" - end - - $manager.delete_object out - player.output "Removed exit (#{out})." - end - else - exit_room = $manager.get_object event[:exit_room] - end - - if exit_room.nil? - player.output "Cannot find #{event[:exit_room]} to connect to." - return - end - - door_here = $manager.create_object Door, room, nil, exit_room.goid, :@alt_names => [event[:direction]], :@name => "a door to the #{event[:direction]}" - door_there = $manager.create_object Door, exit_room, nil, room.goid, :@alt_names => [opposite_dir(event[:direction])], :@name => "a door to the #{opposite_dir event[:direction]}" - door_here.connect_to door_there - - player.output "Created: #{door_here}" - player.output "Created: #{door_there}" - - if room - event[:to_player] = "Frowning in concentration, you make vague motions with your hands. There is a small flash of light as #{door_here.name} to #{exit_room.name} appears." - event[:to_other] = "Frowning in concentration, #{player.name} makes vague motions with #{player.pronoun(:possessive)} hands. There is a small flash of light as #{door_here.name} to #{exit_room.name} appears." - room.out_event event - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AcdoorHandler) diff --git a/lib/aethyr/core/input_handlers/admin/acexit.rb b/lib/aethyr/core/input_handlers/admin/acexit.rb index ba1e2048c21f306d70eeac020c65f2a0f46f5ca9..86c9437e75599c21d7ed8474aa4bafba8cd73244 100644 --- a/lib/aethyr/core/input_handlers/admin/acexit.rb +++ b/lib/aethyr/core/input_handlers/admin/acexit.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acreate" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -38,48 +39,11 @@ EOF object = "exit" alt_names = [$1.strip] args = [$2.strip] - acreate({:object => object, :alt_names => alt_names, :args => args}) + $manager.submit_action(Aethyr::Core::Actions::Acreate::AcreateCommand.new(@player, {:object => object, :alt_names => alt_names, :args => args})) end end private - def acreate(event) - - room = $manager.get_object(@player.container) - player = @player - class_name = event[:object] - - class_name[0,1] = class_name[0,1].capitalize - - if Object.const_defined? class_name - klass = Object.const_get(class_name) - else - player.output "No such thing. Sorry." - return - end - - if not klass <= GameObject or klass == Player - player.output "You cannot create a #{klass.class}." - return - end - - vars = {} - vars[:@name] = event[:name] if event[:name] - vars[:@alt_names] = event[:alt_names] if event[:alt_names] - vars[:@generic] = event[:generic] if event[:generic] - args = event[:args] - - object = $manager.create_object(klass, room, nil, args, vars) - - if room - event[:to_player] = "Frowning in concentration, you make vague motions with your hands. There is a small flash of light as #{object.name} appears." - event[:to_other] = "Frowning in concentration, #{player.name} makes vague motions with #{player.pronoun(:possessive)} hands. There is a small flash of light as #{object.name} appears." - room.out_event event - end - - player.output "Created: #{object}" - object - end end Aethyr::Extend::HandlerRegistry.register_handler(AcexitHandler) diff --git a/lib/aethyr/core/input_handlers/admin/acomm.rb b/lib/aethyr/core/input_handlers/admin/acomm.rb index 2f2db1a6038e3d7a855a7ba1bfdabf9ba8d5fc4b..77602537dfbcddf87e0968c15791bd97bdd9a4bc 100644 --- a/lib/aethyr/core/input_handlers/admin/acomm.rb +++ b/lib/aethyr/core/input_handlers/admin/acomm.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acomment" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,24 +38,11 @@ EOF when /^(acomm|acomment)\s+(.*?)\s+(.*)$/i target = $2 comment = $3 - acomment({:target => target, :comment => comment}) + $manager.submit_action(Aethyr::Core::Actions::Acomment::AcommentCommand.new(@player, {:target => target, :comment => comment})) end end private - def acomment(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:target], event) - if object.nil? - player.output "Cannot find:#{event[:target]}" - return - end - - object.comment = event[:comment] - player.output "Added comment: '#{event[:comment]}'\nto#{object}" - end end Aethyr::Extend::HandlerRegistry.register_handler(AcommHandler) diff --git a/lib/aethyr/core/input_handlers/admin/acomment.rb b/lib/aethyr/core/input_handlers/admin/acomment.rb index 4c7df10d19581f4627462645debf1843aae409d9..a4caa0151a4afd0931914de6dc3d9f03ce59aed3 100644 --- a/lib/aethyr/core/input_handlers/admin/acomment.rb +++ b/lib/aethyr/core/input_handlers/admin/acomment.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acomment" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,24 +38,11 @@ EOF when /^(acomm|acomment)\s+(.*?)\s+(.*)$/i target = $2 comment = $3 - acomment({:target => target, :comment => comment}) + $manager.submit_action(Aethyr::Core::Actions::Acomment::AcommentCommand.new(@player, {:target => target, :comment => comment})) end end private - def acomment(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:target], event) - if object.nil? - player.output "Cannot find:#{event[:target]}" - return - end - - object.comment = event[:comment] - player.output "Added comment: '#{event[:comment]}'\nto#{object}" - end end Aethyr::Extend::HandlerRegistry.register_handler(AcommentHandler) diff --git a/lib/aethyr/core/input_handlers/admin/aconfig.rb b/lib/aethyr/core/input_handlers/admin/aconfig.rb index ed16361a2cdd616da0a10f19b2b6d496ff36ee26..530aa196c66db31949e11a41c54d4bc7aaa0df74 100644 --- a/lib/aethyr/core/input_handlers/admin/aconfig.rb +++ b/lib/aethyr/core/input_handlers/admin/aconfig.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/aconfig" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -36,45 +37,15 @@ EOF case data[:input] when /^aconfig(\s+reload)?$/i setting = "reload" if $1 - aconfig({:setting => setting}) + $manager.submit_action(Aethyr::Core::Actions::Aconfig::AconfigCommand.new(@player, {:setting => setting})) when /^aconfig\s+(\w+)\s+(.*)$/i setting = $1 value = $2 - aconfig({:setting => setting, :value => value}) + $manager.submit_action(Aethyr::Core::Actions::Aconfig::AconfigCommand.new(@player, {:setting => setting, :value => value})) end end private - def aconfig(event) - - room = $manager.get_object(@player.container) - player = @player - - if event[:setting].nil? - player.output "Current configuration:\n#{ServerConfig}" - return - end - - setting = event[:setting].downcase.to_sym - - if setting == :reload - ServerConfig.reload - player.output "Reloaded configuration:\n#{ServerConfig}" - return - elsif not ServerConfig.has_setting? setting - player.output "No such setting." - return - end - - value = event[:value] - if value =~ /^\d+$/ - value = value.to_i - end - - ServerConfig[setting] = value - - player.output "New configuration:\n#{ServerConfig}" - end end Aethyr::Extend::HandlerRegistry.register_handler(AconfigHandler) diff --git a/lib/aethyr/core/input_handlers/admin/acportal.rb b/lib/aethyr/core/input_handlers/admin/acportal.rb index e7b6a06ae0d0f77276e4314d978f0a887f00861d..13875028595bc6a98921a0076c01d0014da6f2d1 100644 --- a/lib/aethyr/core/input_handlers/admin/acportal.rb +++ b/lib/aethyr/core/input_handlers/admin/acportal.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acportal" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -39,20 +40,11 @@ EOF alt_names = [] portal_action = $2 args = [$4] - acportal({:object => object, :alt_names => alt_names, :portal_action => portal_action, :args => args}) + $manager.submit_action(Aethyr::Core::Actions::Acportal::AcportalCommand.new(@player, {:object => object, :alt_names => alt_names, :portal_action => portal_action, :args => args})) end end private - def acportal(event) - - room = $manager.get_object(@player.container) - player = @player - object = Admin.acreate(event, player, room) - if event[:portal_action] and event[:portal_action].downcase != "enter" - object.info.portal_action = event[:portal_action].downcase.to_sym - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AcportalHandler) diff --git a/lib/aethyr/core/input_handlers/admin/acprop.rb b/lib/aethyr/core/input_handlers/admin/acprop.rb index e59add52ea9da9e72753672f3e08bbba7478270c..f94bab925eeb393a6d3fb88c81f62eb93e6d02da 100644 --- a/lib/aethyr/core/input_handlers/admin/acprop.rb +++ b/lib/aethyr/core/input_handlers/admin/acprop.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acreate" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,48 +38,11 @@ EOF when /^acprop\s+(.*)$/i object = "prop" generic = $1 - acreate({:object => object, :generic => generic}) + $manager.submit_action(Aethyr::Core::Actions::Acreate::AcreateCommand.new(@player, {:object => object, :generic => generic})) end end private - def acreate(event) - - room = $manager.get_object(@player.container) - player = @player - class_name = event[:object] - - class_name[0,1] = class_name[0,1].capitalize - - if Object.const_defined? class_name - klass = Object.const_get(class_name) - else - player.output "No such thing. Sorry." - return - end - - if not klass <= GameObject or klass == Player - player.output "You cannot create a #{klass.class}." - return - end - - vars = {} - vars[:@name] = event[:name] if event[:name] - vars[:@alt_names] = event[:alt_names] if event[:alt_names] - vars[:@generic] = event[:generic] if event[:generic] - args = event[:args] - - object = $manager.create_object(klass, room, nil, args, vars) - - if room - event[:to_player] = "Frowning in concentration, you make vague motions with your hands. There is a small flash of light as #{object.name} appears." - event[:to_other] = "Frowning in concentration, #{player.name} makes vague motions with #{player.pronoun(:possessive)} hands. There is a small flash of light as #{object.name} appears." - room.out_event event - end - - player.output "Created: #{object}" - object - end end Aethyr::Extend::HandlerRegistry.register_handler(AcpropHandler) diff --git a/lib/aethyr/core/input_handlers/admin/acreate.rb b/lib/aethyr/core/input_handlers/admin/acreate.rb index 2ef97997d7b8d47c1b7363181d7bc4ed5746a490..99781b6a573005811b1eb849eb2a28c1baa428db 100644 --- a/lib/aethyr/core/input_handlers/admin/acreate.rb +++ b/lib/aethyr/core/input_handlers/admin/acreate.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acreate" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,48 +38,11 @@ EOF when /^(ac|acreate)\s+(\w+)\s*(.*)$/i object = $2 name = $3.strip - acreate({:object => object, :name => name}) + $manager.submit_action(Aethyr::Core::Actions::Acreate::AcreateCommand.new(@player, {:object => object, :name => name})) end end private - def acreate(event) - - room = $manager.get_object(@player.container) - player = @player - class_name = event[:object] - - class_name[0,1] = class_name[0,1].capitalize - - if Object.const_defined? class_name - klass = Object.const_get(class_name) - else - player.output "No such thing. Sorry." - return - end - - if not klass <= GameObject or klass == Player - player.output "You cannot create a #{klass.class}." - return - end - - vars = {} - vars[:@name] = event[:name] if event[:name] - vars[:@alt_names] = event[:alt_names] if event[:alt_names] - vars[:@generic] = event[:generic] if event[:generic] - args = event[:args] - - object = $manager.create_object(klass, room, nil, args, vars) - - if room - event[:to_player] = "Frowning in concentration, you make vague motions with your hands. There is a small flash of light as #{object.name} appears." - event[:to_other] = "Frowning in concentration, #{player.name} makes vague motions with #{player.pronoun(:possessive)} hands. There is a small flash of light as #{object.name} appears." - room.out_event event - end - - player.output "Created: #{object}" - object - end end Aethyr::Extend::HandlerRegistry.register_handler(AcreateHandler) diff --git a/lib/aethyr/core/input_handlers/admin/acroom.rb b/lib/aethyr/core/input_handlers/admin/acroom.rb index bc897f66398d13c03feb3a5b71730e1096c18e79..40eb1a20f0067b72b8c44125228ebe670475a208 100644 --- a/lib/aethyr/core/input_handlers/admin/acroom.rb +++ b/lib/aethyr/core/input_handlers/admin/acroom.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/acroom" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -38,100 +39,11 @@ EOF out_dir = $1 in_dir = opposite_dir($1) name = $2 - acroom({:out_dir => out_dir, :in_dir => in_dir, :name => name}) + $manager.submit_action(Aethyr::Core::Actions::Acroom::AcroomCommand.new(@player, {:out_dir => out_dir, :in_dir => in_dir, :name => name})) end end private - def acroom(event) - - room = $manager.get_object(@player.container) - player = @player - area = nil - if room.container - area = $manager.get_object(room.container) - end - - unless area.nil? or area.map_type.eql? :none - current_pos = area.position(room) - new_pos = current_pos.dup - case event[:out_dir].downcase.strip - when "north" - new_pos[1] += 1 - when "south" - new_pos[1] -= 1 - when "west" - new_pos[0] -= 1 - when "east" - new_pos[0] += 1 - when "northeast" - player.output "Can not create a #{event[:out_dir]} exit in a mappable area at this time" - return - when "northwest" - player.output "Can not create a #{event[:out_dir]} exit in a mappable area at this time" - return - when "southeast" - player.output "Can not create a #{event[:out_dir]} exit in a mappable area at this time" - return - when "southwest" - player.output "Can not create a #{event[:out_dir]} exit in a mappable area at this time" - return - else - new_pos = nil - end - new_pos_text = new_pos.map{ |e| e.to_s}.join('x') unless new_pos.nil? - end - - unless new_pos.nil? or area.find_by_position(new_pos).nil? - player.output "There is already a room at the coordinates (#{new_pos_text}) that would be occupied by the new room, aborting" - return - end - - new_room = $manager.create_object(Room, area, new_pos, nil, :@name => event[:name]) - out_exit = $manager.create_object(Exit, room, nil, new_room.goid, :@alt_names => [event[:out_dir]]) - in_exit = $manager.create_object(Exit, new_room, nil, room.goid, :@alt_names => [event[:in_dir]]) - - player.output "Created: #{new_room}#{new_pos.nil? ? '' : ' @ ' + new_pos_text}" - player.output "Created: #{out_exit}" - player.output "Created: #{in_exit}" - - if !area.nil? and area.map_type.eql? :world - west = area.find_by_position([new_pos[0] - 1, new_pos[1]]) - east = area.find_by_position([new_pos[0] + 1, new_pos[1]]) - north = area.find_by_position([new_pos[0], new_pos[1] + 1]) - south = area.find_by_position([new_pos[0], new_pos[1] - 1]) - if !west.nil? and !west.eql? room - out_exit = $manager.create_object(Exit, new_room, nil, west.goid, :@alt_names => ["west"]) - in_exit = $manager.create_object(Exit, west, nil, new_room.goid, :@alt_names => ["east"]) - player.output "Created: #{out_exit}" - player.output "Created: #{in_exit}" - west.output "There is a small flash of light as a new room appears to the east." - elsif !east.nil? and !east.eql? room - out_exit = $manager.create_object(Exit, new_room, nil, east.goid, :@alt_names => ["east"]) - in_exit = $manager.create_object(Exit, east, nil, new_room.goid, :@alt_names => ["west"]) - player.output "Created: #{out_exit}" - player.output "Created: #{in_exit}" - east.output "There is a small flash of light as a new room appears to the west." - elsif !north.nil? and !north.eql? room - out_exit = $manager.create_object(Exit, new_room, nil, north.goid, :@alt_names => ["north"]) - in_exit = $manager.create_object(Exit, north, nil, new_room.goid, :@alt_names => ["south"]) - player.output "Created: #{out_exit}" - player.output "Created: #{in_exit}" - north.output "There is a small flash of light as a new room appears to the south." - elsif !south.nil? and !south.eql? room - out_exit = $manager.create_object(Exit, new_room, nil, south.goid, :@alt_names => ["south"]) - in_exit = $manager.create_object(Exit, south, nil, new_room.goid, :@alt_names => ["north"]) - player.output "Created: #{out_exit}" - player.output "Created: #{in_exit}" - south.output "There is a small flash of light as a new room appears to the north." - end - end - - if room - room.output "There is a small flash of light as a new room appears to the #{event[:out_dir]}." - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(AcroomHandler) diff --git a/lib/aethyr/core/input_handlers/admin/adelete.rb b/lib/aethyr/core/input_handlers/admin/adelete.rb index 33cfa9b5a08d25073850850edeb23a681cae82f5..0220da6abc780aab0f5358233d815a4378db66a2 100644 --- a/lib/aethyr/core/input_handlers/admin/adelete.rb +++ b/lib/aethyr/core/input_handlers/admin/adelete.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/adelete" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -36,62 +37,11 @@ EOF case data[:input] when /^adelete\s+(.*)$/i object = $1 - adelete({:object => object}) + $manager.submit_action(Aethyr::Core::Actions::Adelete::AdeleteCommand.new(@player, {:object => object})) end end private - def adelete(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:object] and event[:object].split.first.downcase == "all" - log event[:object].split - klass = event[:object].split[1] - klass.capitalize! unless klass[0,1] == klass[0,1].upcase - begin - klass = Module.const_get klass.to_sym - rescue NameError - player.output "No such object type." - return - end - - objects = $manager.find_all("class", klass) - - objects.each do |obj| - e = event.dup - e[:object] = obj.goid - - Admin.adelete(e, player, room) - end - - return - end - - object = find_object(event[:object], event) - - if object.nil? - player.output "Cannot find #{event[:object]} to delete." - return - elsif object.is_a? Player - player.output "Use DELETEPLAYER to delete players." - return - end - - object_container = object.container - - $manager.delete_object(object) - - if room and room.goid == object.container - event[:to_player] = "You casually wave your hand and #{object.name} disappears." - event[:to_other] = "With a casual wave of #{player.pronoun(:possessive)} hand, #{player.name} makes #{object.name} disappear." - room.out_event event - else - player.output "You casually wave your hand and #{object.name} disappears." - end - - player.output "#{object} deleted." - end end Aethyr::Extend::HandlerRegistry.register_handler(AdeleteHandler) diff --git a/lib/aethyr/core/input_handlers/admin/adesc.rb b/lib/aethyr/core/input_handlers/admin/adesc.rb index c09a1a9f5c0ef612285bdd78f40e048bdd76dcb1..4e73fab5507d9eb1792b3f8e9b5e12e765dafbb2 100644 --- a/lib/aethyr/core/input_handlers/admin/adesc.rb +++ b/lib/aethyr/core/input_handlers/admin/adesc.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/adesc" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -38,44 +39,15 @@ EOF object = $1 inroom = true desc = $2 - adesc({:object => object, :inroom => inroom, :desc => desc}) + $manager.submit_action(Aethyr::Core::Actions::Adesc::AdescCommand.new(@player, {:object => object, :inroom => inroom, :desc => desc})) when /^adesc\s+(.*?)\s+(.*)$/i object = $1 desc = $2 - adesc({:object => object, :desc => desc}) + $manager.submit_action(Aethyr::Core::Actions::Adesc::AdescCommand.new(@player, {:object => object, :desc => desc})) end end private - def adesc(event) - - room = $manager.get_object(@player.container) - player = @player - object = nil - if event[:object].downcase == "here" - object = room - else - object = find_object(event[:object], event) - end - - if object.nil? - player.output "Cannot find #{event[:object]}." - return - end - - if event[:inroom] - if event[:desc].nil? or event[:desc].downcase == "false" - object.show_in_look = false - player.output "#{object.name} will not be shown in the room description." - else - object.show_in_look= event[:desc] - player.output "The room will show #{object.show_in_look}" - end - else - object.instance_variable_set(:@short_desc, event[:desc]) - player.output "#{object.name} now looks like:\n#{object.short_desc}" - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AdescHandler) diff --git a/lib/aethyr/core/input_handlers/admin/admin_handler.rb b/lib/aethyr/core/input_handlers/admin/admin_handler.rb index 05c1a80679cdceaa50e963a31c208750e844d4d0..e1a4f345f0f813a72b16f030fe12721ccd768349 100644 --- a/lib/aethyr/core/input_handlers/admin/admin_handler.rb +++ b/lib/aethyr/core/input_handlers/admin/admin_handler.rb @@ -1,4 +1,4 @@ -require 'aethyr/core/actions/commands/command_handler' +require 'aethyr/core/input_handlers/command_handler' module Aethyr module Extend diff --git a/lib/aethyr/core/input_handlers/admin/aforce.rb b/lib/aethyr/core/input_handlers/admin/aforce.rb index 0daed912b409d3962a4eba32ee3bb3f41d10f095..a5ad5da83ee063d544f1d754db6b903a444d3514 100644 --- a/lib/aethyr/core/input_handlers/admin/aforce.rb +++ b/lib/aethyr/core/input_handlers/admin/aforce.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/aforce" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,26 +38,11 @@ EOF when /^aforce\s+(.*?)\s+(.*)$/i target = $1 command = $2 - aforce({:target => target, :command => command}) + $manager.submit_action(Aethyr::Core::Actions::Aforce::AforceCommand.new(@player, {:target => target, :command => command})) end end private - def aforce(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:target], event) - if object.nil? - player.output "Force who?" - return - elsif object.is_a? Player - object.handle_input(event[:command]) - else - player.output "You can only force other players to execute a command." - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(AforceHandler) diff --git a/lib/aethyr/core/input_handlers/admin/ahelp.rb b/lib/aethyr/core/input_handlers/admin/ahelp.rb index 478c9f02026f7b0359b521aa5b655ee6f1ca0aeb..2be30404068e9ef489e86d5f046e4d59f418a434 100644 --- a/lib/aethyr/core/input_handlers/admin/ahelp.rb +++ b/lib/aethyr/core/input_handlers/admin/ahelp.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/ahelp" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -36,17 +37,11 @@ EOF case data[:input] when /^ahelp(.*)$/i object = $1 - ahelp({:object => object}) + $manager.submit_action(Aethyr::Core::Actions::Ahelp::AhelpCommand.new(@player, {:object => object})) end end private - def ahelp(event) - - room = $manager.get_object(@player.container) - player = @player - Generic.help(event, player, room) - end end Aethyr::Extend::HandlerRegistry.register_handler(AhelpHandler) diff --git a/lib/aethyr/core/input_handlers/admin/ahide.rb b/lib/aethyr/core/input_handlers/admin/ahide.rb index 2489fa09d5a71e8b5c9d6b02e41ceeb80e8b3eb3..1a2831ce45caffe1943a0060f8f0f12b6b2d3b5b 100644 --- a/lib/aethyr/core/input_handlers/admin/ahide.rb +++ b/lib/aethyr/core/input_handlers/admin/ahide.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/ahide" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,32 +38,11 @@ EOF when /^ahide\s+(.*)$/i object = $1 hide = true - ahide({:object => object, :hide => hide}) + $manager.submit_action(Aethyr::Core::Actions::Ahide::AhideCommand.new(@player, {:object => object, :hide => hide})) end end private - def ahide(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:object], event) - - if object.nil? - player.output "Cannot find #{event[:object]}." - return - end - - if event[:hide] - object.show_in_look = "" - player.output "#{object.name} is now hidden." - elsif object.show_in_look == "" - object.show_in_look = false - player.output "#{object.name} is no longer hidden." - else - player.output "This object is not hidden." - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AhideHandler) diff --git a/lib/aethyr/core/input_handlers/admin/ainfo.rb b/lib/aethyr/core/input_handlers/admin/ainfo.rb index 183a004b9bef25136c2a22736b81dd71b43ee68d..6214170702c7a3969cc7aa05cda3269dcb723f43 100644 --- a/lib/aethyr/core/input_handlers/admin/ainfo.rb +++ b/lib/aethyr/core/input_handlers/admin/ainfo.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/ainfo" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -39,90 +40,20 @@ EOF object = $1 attrib = $2 value = $4 - ainfo({:command => command, :object => object, :attrib => attrib, :value => value}) + $manager.submit_action(Aethyr::Core::Actions::Ainfo::AinfoCommand.new(@player, {:command => command, :object => object, :attrib => attrib, :value => value})) when /^ainfo\s+(show|clear)\s+(.*)$/i object = $2 command = $1 - ainfo({:object => object, :command => command}) + $manager.submit_action(Aethyr::Core::Actions::Ainfo::AinfoCommand.new(@player, {:object => object, :command => command})) when /^ainfo\s+(del|delete)\s+(.+)\s+@((\w|\.|\_)+)$/i command = "delete" object = $2 attrib = $3 - ainfo({:command => command, :object => object, :attrib => attrib}) + $manager.submit_action(Aethyr::Core::Actions::Ainfo::AinfoCommand.new(@player, {:command => command, :object => object, :attrib => attrib})) end end private - def ainfo(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:object].downcase == "here" - event[:object] = player.container - elsif event[:object].downcase == "me" - event[:object] = player - elsif event[:object] and event[:object].split.first.downcase == "all" - log event[:object].split - klass = event[:object].split[1] - klass.capitalize! unless klass[0,1] == klass[0,1].upcase - begin - klass = Module.const_get klass.to_sym - rescue NameError - player.output "No such object type." - return - end - - objects = $manager.find_all("class", klass) - - objects.each do |obj| - e = event.dup - e[:object] = obj.goid - - Admin.ainfo(e, player, room) - end - - return - end - - object = find_object(event[:object], event) - - if object.nil? - player.output "What object? #{event[:object]}" - return - end - - case event[:command] - when "set" - value = event[:value] #for ease - if value.split.length == 1 - if value == "true" - value = true - elsif value == "false" - value = false - elsif value[0,1] == ":" - value = value[1..-1].to_sym - elsif value == "nil" - value = nil - elsif value.match(/^[0-9]+$/) - value = value.to_i - elsif value.downcase == "!nothing" - value = "" - end - end - object.info.set(event[:attrib], value) - player.output "Set #{event[:attrib]} to #{object.info.get(event[:attrib])}" - when "delete" - object.info.delete(event[:attrib]) - player.output "Deleted #{event[:attrib]} from #{object}" - when "show" - player.output object.info.inspect - when "clear" - object.info = Info.new - player.output "Completely cleared info for #{object}." - else - player.output "Huh? What?" - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AinfoHandler) diff --git a/lib/aethyr/core/input_handlers/admin/alearn.rb b/lib/aethyr/core/input_handlers/admin/alearn.rb index 909cd98aedc95e73d59c4de8759e66ee0b18abf2..f1b03d224a310c225a8b95ece210c2c8cebd851a 100644 --- a/lib/aethyr/core/input_handlers/admin/alearn.rb +++ b/lib/aethyr/core/input_handlers/admin/alearn.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/alearn" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -36,16 +37,11 @@ EOF case data[:input] when /^alearn\s+(\w+)$/i skill = $1 - alearn({:skill => skill}) + $manager.submit_action(Aethyr::Core::Actions::Alearn::AlearnCommand.new(@player, {:skill => skill})) end end private - def alearn(event) - - room = $manager.get_object(@player.container) - player = @player - end end Aethyr::Extend::HandlerRegistry.register_handler(AlearnHandler) diff --git a/lib/aethyr/core/input_handlers/admin/alist.rb b/lib/aethyr/core/input_handlers/admin/alist.rb index 718141e0904e40424f6f94af766ca6cc7563cab0..cfbd20d13017daa2d9731a6768b445364a5c8787 100644 --- a/lib/aethyr/core/input_handlers/admin/alist.rb +++ b/lib/aethyr/core/input_handlers/admin/alist.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/alist" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -35,39 +36,15 @@ EOF super(data) case data[:input] when /^alist$/i - alist({}) + $manager.submit_action(Aethyr::Core::Actions::Alist::AlistCommand.new(@player, {})) when /^alist\s+(@\w+|class)\s+(.*)/i attrib = $2 match = $1 - alist({:attrib => attrib, :match => match}) + $manager.submit_action(Aethyr::Core::Actions::Alist::AlistCommand.new(@player, {:attrib => attrib, :match => match})) end end private - def alist(event) - - room = $manager.get_object(@player.container) - player = @player - objects = nil - if event[:match].nil? - objects = $manager.find_all("class", :GameObject) - else - objects = $manager.find_all(event[:match], event[:attrib]) - end - - if objects.empty? - player.output "Nothing like that to list!" - else - output = [] - objects.each do |o| - output << "\t" + o.to_s - end - - output = output.join("\n") - - player.output(output) - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AlistHandler) diff --git a/lib/aethyr/core/input_handlers/admin/alog.rb b/lib/aethyr/core/input_handlers/admin/alog.rb index 0d4a48cfb6ea94af235377a0d21a4db1299d1bbe..5ac6900e0a0523995744870a1721cf0af187fd0f 100644 --- a/lib/aethyr/core/input_handlers/admin/alog.rb +++ b/lib/aethyr/core/input_handlers/admin/alog.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/alog" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,72 +38,11 @@ EOF when /^alog\s+(\w+)(\s+(\d+))?$/i command = $1 value = $3.downcase if $3 - alog({:command => command, :value => value}) + $manager.submit_action(Aethyr::Core::Actions::Alog::AlogCommand.new(@player, {:command => command, :value => value})) end end private - def alog(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:command].nil? - player.output "What do you want to do with the log?" - return - else - command = event[:command].downcase - end - - case command - when /^players?$/ - if event[:value] - lines = event[:value].to_i - else - lines = 10 - end - - player.output tail('logs/player.log', lines) - when 'server' - if event[:value] - lines = event[:value].to_i - else - lines = 10 - end - - player.output tail('logs/server.log', lines) - when 'system' - if event[:value] - lines = event[:value].to_i - else - lines = 10 - end - - $LOG.dump - - player.output tail('logs/system.log', lines) - when 'flush' - log('Flushing log') - $LOG.dump - player.output 'Flushed log to disk.' - when 'ultimate' - ServerConfig[:log_level] = 3 - player.output "Log level now set to ULTIMATE." - when 'high' - ServerConfig[:log_level] = 2 - player.output "Log level now set to high." - when 'low', 'normal' - ServerConfig[:log_level] = 1 - player.output "Log level now set to normal." - when 'off' - ServerConfig[:log_level] = 0 - player.output "Logging mostly turned off. You may also want to turn off debugging." - when 'debug' - ServerConfig[:debug] = !$DEBUG - player.output "Debug info is now: #{$DEBUG ? 'on' : 'off'}" - else - player.output 'Possible settings: Off, Debug, Normal, High, or Ultimate' - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AlogHandler) diff --git a/lib/aethyr/core/input_handlers/admin/alook.rb b/lib/aethyr/core/input_handlers/admin/alook.rb index 52a0e49d7f5127779bf90feeeff6055a47a1a2f4..3877f7108ae395d1eb7ed3ab926cd4783251ad95 100644 --- a/lib/aethyr/core/input_handlers/admin/alook.rb +++ b/lib/aethyr/core/input_handlers/admin/alook.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/alook" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -35,65 +36,14 @@ EOF super(data) case data[:input] when /^alook$/i - alook({}) + $manager.submit_action(Aethyr::Core::Actions::Alook::AlookCommand.new(@player, {})) when /^alook\s+(.*)$/i at = $1 - alook({:at => at}) + $manager.submit_action(Aethyr::Core::Actions::Alook::AlookCommand.new(@player, {:at => at})) end end private - def alook(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:at].nil? - object = room - elsif event[:at].downcase == "here" - object = $manager.find player.container - else - object = find_object(event[:at], event) - end - - if object.nil? - player.output "Cannot find #{event[:at]} to inspect." - return - end - - output = "Object: #{object}\n" - output << "Attributes:\n" - - object.instance_variables.sort.each do |var| - val = object.instance_variable_get(var) - if var == :@observer_peers - val = val.keys.map {|k| k.to_s } - elsif var == :@local_registrations - val = val.map { |e| e.instance_variable_get(:@listener).to_s.tr('#<>', '') } - end - output << "\t#{var} = #{val}\n" - end - - output << "\r\nInventory:\r\n" - - if object.respond_to? :inventory - object.inventory.each do |o| - output << "\t#{o.name} # #{o.goid} #{object.inventory.position(o) == nil ? "" : object.inventory.position(o).map(&:to_s).join('x')}\n" - end - else - output << "\tNo Inventory" - end - - if object.respond_to? :equipment - output << "\r\nEquipment:\r\n" - object.equipment.inventory.each do |o| - output << "\t#{o.name} # #{o.goid}\n" - end - output << "\t#{object.equipment.equipment.inspect}\n" - end - - puts output - player.output(output) - end end Aethyr::Extend::HandlerRegistry.register_handler(AlookHandler) diff --git a/lib/aethyr/core/input_handlers/admin/aput.rb b/lib/aethyr/core/input_handlers/admin/aput.rb index 556b6c5183d814a4b05648c3299c9a5e2e11c5e2..db726fc1f1f792bb2cccd76d749cf0f05c74547d 100644 --- a/lib/aethyr/core/input_handlers/admin/aput.rb +++ b/lib/aethyr/core/input_handlers/admin/aput.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/aput" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -38,68 +39,15 @@ EOF object = $1 in_var = $2 at = $3 - aput({:object => object, :in => in_var, :at => at}) + $manager.submit_action(Aethyr::Core::Actions::Aput::AputCommand.new(@player, {:object => object, :in => in_var, :at => at})) when /^aput\s+(.*?)\s+in\s+(.*?)$/i object = $1 in_var = $2 - aput({:object => object, :in => in_var}) + $manager.submit_action(Aethyr::Core::Actions::Aput::AputCommand.new(@player, {:object => object, :in => in_var})) end end private - def aput(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:object].is_a? GameObject - object = event[:object] - else - event[:object] = player.container if event[:object].downcase == "here" - object = find_object(event[:object], event) - end - - container = find_object(event[:in], event) - - if object.nil? - player.output "Cannot find #{event[:object]} to move." - return - elsif event[:in] == "!world" - container = $manager.find object.container - container.inventory.remove(object) unless container.nil? - object.container = nil - player.output "Removed #{object} from any containers." - return - elsif event[:in].downcase == "here" - container = $manager.find player.container - if container.nil? - player.output "Cannot find #{event[:in]} " - return - end - elsif container.nil? - player.output "Cannot find #{event[:in]} " - return - end - - if not object.container.nil? - current_container = $manager.find object.container - current_container.inventory.remove(object) if current_container - end - - unless event[:at] == nil - position = event[:at].split('x').map{ |e| e.to_i} - end - - if container.is_a? Inventory - container.add(object, position) - elsif container.is_a? Container - container.add(object) - else - container.inventory.add(object, position) - object.container = container.goid - end - - player.output "Moved #{object} into #{container}#{event[:at] == nil ? '' : ' at ' + event[:at]}" - end end Aethyr::Extend::HandlerRegistry.register_handler(AputHandler) diff --git a/lib/aethyr/core/input_handlers/admin/areact.rb b/lib/aethyr/core/input_handlers/admin/areact.rb index feae722c0a6a4b29efbe743a60b680c9b0e86c50..1a8b57d56e5240513e3e0eba78c661a1834f06ff 100644 --- a/lib/aethyr/core/input_handlers/admin/areact.rb +++ b/lib/aethyr/core/input_handlers/admin/areact.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/areaction" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -38,113 +39,20 @@ EOF object = $1 command = "load" file = $2 - areaction({:object => object, :command => command, :file => file}) + $manager.submit_action(Aethyr::Core::Actions::Areaction::AreactionCommand.new(@player, {:object => object, :command => command, :file => file})) when /^areact\s+(reload|clear|show)\s+(.*?)$/i object = $2 command = $1 - areaction({:object => object, :command => command}) + $manager.submit_action(Aethyr::Core::Actions::Areaction::AreactionCommand.new(@player, {:object => object, :command => command})) when /^areact\s+(add|delete)\s+(.*?)\s+(\w+)$/i object = $2 command = $1 action_name = $3 - areaction({:object => object, :command => command, :action_name => action_name}) + $manager.submit_action(Aethyr::Core::Actions::Areaction::AreactionCommand.new(@player, {:object => object, :command => command, :action_name => action_name})) end end private - def areaction(event) - - room = $manager.get_object(@player.container) - player = @player - - if event[:command] == "reload" and event[:object] and event[:object].downcase == "all" - objects = $manager.find_all("class", Reacts) - - objects.each do |o| - o.reload_reactions - end - - player.output "Updated reactions for #{objects.length} objects." - elsif event[:object] and event[:object].split.first.downcase == "all" - klass = event[:object].split[1] - klass.capitalize! unless klass[0,1] == klass[0,1].upcase - begin - klass = Module.const_get klass.to_sym - rescue NameError - player.output "No such object type." - return - end - - objects = $manager.find_all("class", klass) - - objects.each do |obj| - e = event.dup - e[:object] = obj.goid - - player.output "(Doing #{obj})" - Admin.areaction(e, player, room) - end - else - if event[:object] == "here" - object = room - else - object = find_object(event[:object], event) - end - - if object.nil? - player.output "Cannot find:#{event[:object]}" - return - elsif not object.is_a? Reacts and (event[:command] == "load" or event[:command] == "reload") - player.output "Object cannot react, adding react ability." - object.extend(Reacts) - end - - case event[:command] - when "add" - if object.actions.add? event[:action_name] - player.output "Added #{event[:action_name]}" - else - player.output "Already had a reaction by that name." - end - when "delete" - if object.actions.delete? event[:action_name] - player.output "Removed #{event[:action_name]}" - else - player.output "That verb was not associated with this object." - end - when "load" - unless File.exist? "objects/reactions/#{event[:file]}.rx" - player.output "No such reaction file - #{event[:file]}" - return - end - - object.load_reactions event[:file] - player.output "Probably loaded reactions." - when "reload" - object.reload_reactions if object.can? :reload_reactions - player.output "Probably reloaded reactions." - when "clear" - object.unload_reactions if object.can? :unload_reactions - player.output "Probably cleared out reactions." - when "show" - if object.actions and not object.actions.empty? - player.output "Custom actions: #{object.actions.to_a.sort.join(' ')}", true - end - - if object.can? :show_reactions - player.output object.show_reactions - else - player.output "Object does not react." - end - else - player.output("Options:", true) - player.output("areaction load <object> <file>", true) - player.output("areaction reload <object> <file>", true) - player.output("areaction [add|delete] <object> <action>", true) - player.output("areaction [clear|show] <object>") - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AreactHandler) diff --git a/lib/aethyr/core/input_handlers/admin/areas.rb b/lib/aethyr/core/input_handlers/admin/areas.rb index 90ef902f6e90db0abcb460321a8b361893a17881..b320ed3b0e2974f59443ff1adc3c2fc4a97eeecf 100644 --- a/lib/aethyr/core/input_handlers/admin/areas.rb +++ b/lib/aethyr/core/input_handlers/admin/areas.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/areas" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -35,24 +36,11 @@ EOF super(data) case data[:input] when /^areas$/i - areas({}) + $manager.submit_action(Aethyr::Core::Actions::Areas::AreasCommand.new(@player, {})) end end private - def areas(event) - - room = $manager.get_object(@player.container) - player = @player - areas = $manager.find_all('class', Area) - - if areas.empty? - player.output "There are no areas." - return - end - - player.output areas.map {|a| "#{a.name} - #{a.inventory.find_all('class', Room).length} rooms (#{a.info.terrain.area_type})" } - end end Aethyr::Extend::HandlerRegistry.register_handler(AreasHandler) diff --git a/lib/aethyr/core/input_handlers/admin/areload.rb b/lib/aethyr/core/input_handlers/admin/areload.rb index a65e7bda5bcc82e4a8c7f83acab0b628547ce23e..b3949165ec9b0f3b696f4e9a907970b0fb86da89 100644 --- a/lib/aethyr/core/input_handlers/admin/areload.rb +++ b/lib/aethyr/core/input_handlers/admin/areload.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/areload" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -36,22 +37,11 @@ EOF case data[:input] when /^areload\s+(.*)$/i object = $1 - areload({:object => object}) + $manager.submit_action(Aethyr::Core::Actions::Areload::AreloadCommand.new(@player, {:object => object})) end end private - def areload(event) - - room = $manager.get_object(@player.container) - player = @player - begin - result = load "#{event[:object]}.rb" - player.output "Reloaded #{event[:object]}: #{result}" - rescue LoadError - player.output "Unable to load #{event[:object]}" - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AreloadHandler) diff --git a/lib/aethyr/core/input_handlers/admin/asave.rb b/lib/aethyr/core/input_handlers/admin/asave.rb index f8518d70a1339e332ae1ae3146f87d7b63b5c38f..5fe068ed2ae629316744d142600f598e3bdd1148 100644 --- a/lib/aethyr/core/input_handlers/admin/asave.rb +++ b/lib/aethyr/core/input_handlers/admin/asave.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/asave" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -35,19 +36,11 @@ EOF super(data) case data[:input] when /^asave$/i - asave({}) + $manager.submit_action(Aethyr::Core::Actions::Asave::AsaveCommand.new(@player, {})) end end private - def asave(event) - - room = $manager.get_object(@player.container) - player = @player - log "#{player.name} initiated manual save." - $manager.save_all - player.output "Save complete. Check log for details." - end end Aethyr::Extend::HandlerRegistry.register_handler(AsaveHandler) diff --git a/lib/aethyr/core/input_handlers/admin/aset.rb b/lib/aethyr/core/input_handlers/admin/aset.rb index 513465778f90ea78a5398effe29255124a262472..bdc3e8f4d2b210b16ace9b12efc014e54de429e3 100644 --- a/lib/aethyr/core/input_handlers/admin/aset.rb +++ b/lib/aethyr/core/input_handlers/admin/aset.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/aset" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -38,150 +39,23 @@ EOF object = $1 attribute = $2 value = $3 - aset({:object => object, :attribute => attribute, :value => value}) + $manager.submit_action(Aethyr::Core::Actions::Aset::AsetCommand.new(@player, {:object => object, :attribute => attribute, :value => value})) when /^aset!\s+(.+?)\s+(@\w+|smell|feel|texture|taste|sound|listen)\s+(.*)$/i object = $1 attribute = $2 value = $3 force = true - aset({:object => object, :attribute => attribute, :value => value, :force => force}) + $manager.submit_action(Aethyr::Core::Actions::Aset::AsetCommand.new(@player, {:object => object, :attribute => attribute, :value => value, :force => force})) when /^aset!\s+(.+?)\s+(@\w+|smell|feel|texture|taste|sound|listen)\s+(.*)$/i object = $1 attribute = $2 value = $3 force = true - aset({:object => object, :attribute => attribute, :value => value, :force => force}) + $manager.submit_action(Aethyr::Core::Actions::Aset::AsetCommand.new(@player, {:object => object, :attribute => attribute, :value => value, :force => force})) end end private - def aset(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:object].downcase == "here" - event[:object] = player.container - elsif event[:object] and event[:object].split.first.downcase == "all" - log event[:object].split - klass = event[:object].split[1] - klass.capitalize! unless klass[0,1] == klass[0,1].upcase - begin - klass = Module.const_get klass.to_sym - rescue NameError - player.output "No such object type." - return - end - - objects = $manager.find_all("class", klass) - - objects.each do |obj| - e = event.dup - e[:object] = obj.goid - - Admin.aset(e, player, room) - end - - return - end - - object = find_object(event[:object], event) - - if object.nil? - player.output "Cannot find #{event[:object]} to edit." - return - end - - attrib = event[:attribute] - - if attrib[0,1] != "@" - value = event[:value] - if value.downcase == "!nothing" or value.downcase == "nil" - value = nil - end - - if value and value[-1,1] !~ /[!.?"']/ - value << "." - end - - case attrib.downcase - when "smell" - if value.nil? - object.info.delete :smell - player.output "#{object.name} will no longer smell." - else - object.info.smell = value - player.output "#{object.name} will now smell like: #{object.info.smell}" - end - return - when "feel", "texture" - if value.nil? - object.info.delete :texture - player.output "#{object.name} will no longer have a particular texture." - else - object.info.texture = value - player.output "#{object.name} will now feel like: #{object.info.texture}" - end - return - when "taste" - if value.nil? - object.info.delete :taste - player.output "#{object.name} will no longer have a particular taste." - else - object.info.taste = value - player.output "#{object.name} will now taste like: #{object.info.taste}" - end - return - when "sound", "listen" - if value.nil? - object.info.delete :sound - player.output "#{object.name} will no longer make sounds." - else - object.info.sound = value - player.output "#{object.name} will now sound like: #{object.info.sound}" - end - return - else - player.output "What are you trying to set?" - return - end - end - - if not object.instance_variables.include? attrib and not object.instance_variables.include? attrib.to_sym and not event[:force] - player.output "#{object}:No such setting/variable/attribute: #{attrib}" - return - else - current_value = object.instance_variable_get(attrib) - if current_value.is_a? Array - object.instance_variable_set(attrib, event[:value].split(/s*"(.*?)"\s*|\s+/)) - player.output "Set #{object} attribute #{attrib} to #{event[:value].inspect}" - else - value = event[:value] #for ease - if value.split.length == 1 - case value.downcase - when "true" - value = true - when "false" - value = false - when /^:/ - value = value[1..-1].to_sym - when "nil" - value = nil - when /^[0-9]+$/ - value = value.to_i unless current_value.is_a? String - when "!nothing" - value = "" - when "!delete" - object.instance_eval { remove_instance_variable(attrib) } - player.output "Removed attribute #{attrib} from #{object}" - return - end - end - - object.instance_variable_set(attrib, value) - player.output "Set #{object} attribute #{attrib} to #{value}" - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AsetHandler) diff --git a/lib/aethyr/core/input_handlers/admin/ashow.rb b/lib/aethyr/core/input_handlers/admin/ashow.rb index e984d6f4873ad89f851db0d495a74d2cd4b41eeb..a02b6b88e482109737897351d6474ace40e0e4be 100644 --- a/lib/aethyr/core/input_handlers/admin/ashow.rb +++ b/lib/aethyr/core/input_handlers/admin/ashow.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/ahide" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,32 +38,11 @@ EOF when /^ashow\s+(.*)$/i object = $1 hide = false - ahide({:object => object, :hide => hide}) + $manager.submit_action(Aethyr::Core::Actions::Ahide::AhideCommand.new(@player, {:object => object, :hide => hide})) end end private - def ahide(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:object], event) - - if object.nil? - player.output "Cannot find #{event[:object]}." - return - end - - if event[:hide] - object.show_in_look = "" - player.output "#{object.name} is now hidden." - elsif object.show_in_look == "" - object.show_in_look = false - player.output "#{object.name} is no longer hidden." - else - player.output "This object is not hidden." - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AshowHandler) diff --git a/lib/aethyr/core/input_handlers/admin/astatus.rb b/lib/aethyr/core/input_handlers/admin/astatus.rb index 283b06520ccb17c7d02f5aa2c8d21dc2deb47c58..2464bd1e9506cffbae00f7b3840c46b27b8a9cfe 100644 --- a/lib/aethyr/core/input_handlers/admin/astatus.rb +++ b/lib/aethyr/core/input_handlers/admin/astatus.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/astatus" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -35,23 +36,11 @@ EOF super(data) case data[:input] when /^astatus/i - astatus({}) + $manager.submit_action(Aethyr::Core::Actions::Astatus::AstatusCommand.new(@player, {})) end end private - def astatus(event) - - room = $manager.get_object(@player.container) - player = @player - awho(event, player, room) - total_objects = $manager.game_objects_count - player.output("Object Counts:" , true) - $manager.type_count.each do |obj, count| - player.output("#{obj}: #{count}", true) - end - player.output("Total Objects: #{total_objects}") - end end Aethyr::Extend::HandlerRegistry.register_handler(AstatusHandler) diff --git a/lib/aethyr/core/input_handlers/admin/ateach.rb b/lib/aethyr/core/input_handlers/admin/ateach.rb index 11ca68a8156b05b582e70500db55ff1adc61729a..08c0693a710243d89736e3d607aa7b884d315705 100644 --- a/lib/aethyr/core/input_handlers/admin/ateach.rb +++ b/lib/aethyr/core/input_handlers/admin/ateach.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/ateach" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,23 +38,11 @@ EOF when /^ateach\s+(\w+)\s+(\w+)$/i target = $1 skill = $2 - ateach({:target => target, :skill => skill}) + $manager.submit_action(Aethyr::Core::Actions::Ateach::AteachCommand.new(@player, {:target => target, :skill => skill})) end end private - def ateach(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:target], event) - if object.nil? - player.output "Teach who what where?" - return - end - - alearn(event, object, room) - end end Aethyr::Extend::HandlerRegistry.register_handler(AteachHandler) diff --git a/lib/aethyr/core/input_handlers/admin/awatch.rb b/lib/aethyr/core/input_handlers/admin/awatch.rb index ef1920b15a93fb52a03240e1e2bf49f4a86a7b2d..705fb7e3d71b4a10ce4988032b2b08fedfa5951c 100644 --- a/lib/aethyr/core/input_handlers/admin/awatch.rb +++ b/lib/aethyr/core/input_handlers/admin/awatch.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/awatch" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,51 +38,11 @@ EOF when /^awatch\s+((start|stop)\s+)?(.*)$/i target = $3.downcase if $3 command = $2.downcase if $2 - awatch({:target => target, :command => command}) + $manager.submit_action(Aethyr::Core::Actions::Awatch::AwatchCommand.new(@player, {:target => target, :command => command})) end end private - def awatch(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:target], event) - if object.nil? - player.output "What mobile do you want to watch?" - return - elsif not object.is_a? Mobile - player.output "You can only use this to watch mobiles." - return - end - - case event[:command] - when "start" - if object.info.redirect_output_to == player.goid - player.output "You are already watching #{object.name}." - else - object.info.redirect_output_to = player.goid - player.output "Watching #{object.name}." - object.output "#{player.name} is watching you." - end - when "stop" - if object.info.redirect_output_to != player.goid - player.output "You are not watching #{object.name}." - else - object.info.redirect_output_to = nil - player.output "No longer watching #{object.name}." - end - else - if object.info.redirect_output_to != player.goid - object.info.redirect_output_to = player.goid - player.output "Watching #{object.name}." - object.output "#{player.name} is watching you." - else - object.info.redirect_output_to = nil - player.output "No longer watching #{object.name}." - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(AwatchHandler) diff --git a/lib/aethyr/core/input_handlers/admin/awho.rb b/lib/aethyr/core/input_handlers/admin/awho.rb index db30e80a16bb117a53cb85180afa9c7042bbda0d..3c7578f7479ce6ff6265554536d74b814249995c 100644 --- a/lib/aethyr/core/input_handlers/admin/awho.rb +++ b/lib/aethyr/core/input_handlers/admin/awho.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/awho" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -35,25 +36,11 @@ EOF super(data) case data[:input] when /^awho/i - awho({}) + $manager.submit_action(Aethyr::Core::Actions::Awho::AwhoCommand.new(@player, {})) end end private - def awho(event) - - room = $manager.get_object(@player.container) - player = @player - players = $manager.find_all('class', Player) - - names = [] - players.each do |playa| - names << playa.name - end - - player.output('Players currently online:', true) - player.output(names.join(', ')) - end end Aethyr::Extend::HandlerRegistry.register_handler(AwhoHandler) diff --git a/lib/aethyr/core/input_handlers/admin/deleteplayer.rb b/lib/aethyr/core/input_handlers/admin/deleteplayer.rb index a3cc6d6bf2a34c5ab0dc69c4cd5344a13153d2f0..c9592a0f5db99de833df6709c57a04f6169cefae 100644 --- a/lib/aethyr/core/input_handlers/admin/deleteplayer.rb +++ b/lib/aethyr/core/input_handlers/admin/deleteplayer.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/delete_player" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -36,35 +37,11 @@ EOF case data[:input] when /^deleteplayer\s+(\w+)$/i object = $1.downcase - delete_player({:object => object}) + $manager.submit_action(Aethyr::Core::Actions::DeletePlayer::DeletePlayerCommand.new(@player, {:object => object})) end end private - def delete_player(event) - - room = $manager.get_object(@player.container) - player = @player - name = event.object - if not $manager.player_exist? name - player.output "No such player found: #{name}" - return - elsif $manager.find name - player.output "Player is currently logged in. Deletion aborted." - return - elsif name == player.name.downcase - player.output "You cannot delete yourself this way. Use DELETE ME PLEASE instead." - return - end - - $manager.delete_player name - - if $manager.find name or $manager.player_exist? name - player.output "Something went wrong. Player still exists." - else - player.output "#{name} deleted." - end - end end Aethyr::Extend::HandlerRegistry.register_handler(DeleteplayerHandler) diff --git a/lib/aethyr/core/input_handlers/admin/restart.rb b/lib/aethyr/core/input_handlers/admin/restart.rb index 6ef7809630b6275b99c12877eb3706672de2804e..3a944fa8d244a464c1a2d035aedb1d97f7a8bf42 100644 --- a/lib/aethyr/core/input_handlers/admin/restart.rb +++ b/lib/aethyr/core/input_handlers/admin/restart.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/restart" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -35,17 +36,11 @@ EOF super(data) case data[:input] when /^restart$/i - restart({}) + $manager.submit_action(Aethyr::Core::Actions::Restart::RestartCommand.new(@player, {})) end end private - def restart(event) - - room = $manager.get_object(@player.container) - player = @player - $manager.restart - end end Aethyr::Extend::HandlerRegistry.register_handler(RestartHandler) diff --git a/lib/aethyr/core/input_handlers/admin/terrain.rb b/lib/aethyr/core/input_handlers/admin/terrain.rb index f452e332e667168aceca76cef3973b49c09eeda1..07656ae6a301af7859d74456cf95136514f85da8 100644 --- a/lib/aethyr/core/input_handlers/admin/terrain.rb +++ b/lib/aethyr/core/input_handlers/admin/terrain.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/terrain" require "aethyr/core/registry" -require "aethyr/core/actions/commands/admin/admin_handler" +require "aethyr/core/input_handlers/admin/admin_handler" module Aethyr module Core @@ -37,71 +38,16 @@ EOF when /^terrain\s+area\s+(.*)$/i target = "area" value = $1 - terrain({:target => target, :value => value}) + $manager.submit_action(Aethyr::Core::Actions::Terrain::TerrainCommand.new(@player, {:target => target, :value => value})) when /^terrain\s+(room|here)\s+(type|indoors|underwater|water)\s+(.*)$/ target = "room" setting = $2.downcase value = $3 - terrain({:target => target, :setting => setting, :value => value}) + $manager.submit_action(Aethyr::Core::Actions::Terrain::TerrainCommand.new(@player, {:target => target, :setting => setting, :value => value})) end end private - def terrain(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:target] == "area" - if room.area.nil? - player.output "This room is not in an area." - return - end - - room.area.info.terrain.area_type = event[:value].downcase.to_sym - - player.output "Set #{room.area.name} terrain type to #{room.area.info.terrain.area_type}" - - return - end - - case event[:setting].downcase - when "type" - room.info.terrain.room_type = event[:value].downcase.to_sym - player.output "Set #{room.name} terrain type to #{room.info.terrain.room_type}" - when "indoors" - if event[:value] =~ /yes|true/i - room.info.terrain.indoors = true - player.output "Room is now indoors." - elsif event[:value] =~ /no|false/i - room.info.terrain.indoors = false - player.output "Room is now outdoors." - else - player.output "Indoors: yes or no?" - end - when "water" - if event[:value] =~ /yes|true/i - room.info.terrain.water = true - player.output "Room is now water." - elsif event[:value] =~ /no|false/i - room.info.terrain.water = false - player.output "Room is now dry." - else - player.output "Water: yes or no?" - end - when "underwater" - if event[:value] =~ /yes|true/i - room.info.terrain.underwater = true - player.output "Room is now underwater." - elsif event[:value] =~ /no|false/i - room.info.terrain.underwater = false - player.output "Room is now above water." - else - player.output "Underwater: yes or no?" - end - else - player.output "What are you trying to set?" - end - end end Aethyr::Extend::HandlerRegistry.register_handler(TerrainHandler) diff --git a/lib/aethyr/core/input_handlers/block.rb b/lib/aethyr/core/input_handlers/block.rb index 9d6580cd8e09189c79415007ef240dcf0ffc7e5d..8f36778b44b810575258fcc261ad1dd4762976f0 100644 --- a/lib/aethyr/core/input_handlers/block.rb +++ b/lib/aethyr/core/input_handlers/block.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/simple_block" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -37,63 +38,11 @@ EOF case data[:input] when /^block(\s+(.*))?$/i target = $2 - simple_block({:target => target}) + $manager.submit_action(Aethyr::Core::Actions::SimpleBlock::SimpleBlockCommand.new(@player, {:target => target})) end end private - def simple_block(event) - - room = $manager.get_object(@player.container) - player = @player - - return if not Combat.ready? player - - weapon = get_weapon(player, :block) - if weapon.nil? - player.output "You are not wielding a weapon you can block with." - return - end - - target = (event.target && room.find(event.target)) || room.find(player.last_target) - - if target == player - player.output "You cannot block yourself." - return - elsif target - events = Combat.find_events(:player => target, :target => player, :blockable => true) - else - events = Combat.find_events(:target => player, :blockable => true) - end - - if events.empty? - player.output "What are you trying to block?" - return - end - - if target.nil? - target = events[0].player - end - - player.last_target = target.goid - - b_event = events[0] - if rand > 0.5 - b_event[:action] = :weapon_block - b_event[:type] = :WeaponCombat - b_event[:to_other] = "#{player.name} deftly blocks #{target.name}'s attack with #{weapon.name}." - b_event[:to_player] = "#{player.name} deftly blocks your attack with #{weapon.name}." - b_event[:to_target] = "You deftly block #{target.name}'s attack with #{weapon.name}." - end - - event[:target] = target - event[:to_other] = "#{player.name} raises #{player.pronoun(:possessive)} #{weapon.generic} to block #{target.name}'s attack." - event[:to_target] = "#{player.name} raises #{player.pronoun(:possessive)} #{weapon.generic} to block your attack." - event[:to_player] = "You raise your #{weapon.generic} to block #{target.name}'s attack." - - player.balance = false - room.out_event event - end end Aethyr::Extend::HandlerRegistry.register_handler(BlockHandler) diff --git a/lib/aethyr/core/input_handlers/close.rb b/lib/aethyr/core/input_handlers/close.rb index d6c744e3536ee4c4f2cdbb60176061b5e3d0f4ba..26030578e13dec2ff7d27aa6ebd0987ab3aa436f 100644 --- a/lib/aethyr/core/input_handlers/close.rb +++ b/lib/aethyr/core/input_handlers/close.rb @@ -1,5 +1,5 @@ require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" require "aethyr/core/util/direction" require "aethyr/core/help/help_entry" require "aethyr/core/actions/command_action" diff --git a/lib/aethyr/core/input_handlers/command_handler.rb b/lib/aethyr/core/input_handlers/command_handler.rb index f225186578fd3d270b604d26dbd61032609c9077..c3386f0bca0b130add07d84fb1b605b0bce48a42 100644 --- a/lib/aethyr/core/input_handlers/command_handler.rb +++ b/lib/aethyr/core/input_handlers/command_handler.rb @@ -1,4 +1,4 @@ -require 'aethyr/core/actions/commands/help_handler' +require 'aethyr/core/input_handlers/help_handler' module Aethyr module Extend diff --git a/lib/aethyr/core/input_handlers/dodge.rb b/lib/aethyr/core/input_handlers/dodge.rb index 9cd25e2a951e493c285cda17aa7aca42023bf4ad..6e18a7bf66e8dff374ebd163e0c7b6284da55aff 100644 --- a/lib/aethyr/core/input_handlers/dodge.rb +++ b/lib/aethyr/core/input_handlers/dodge.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/simple_dodge" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -36,56 +37,11 @@ EOF case data[:input] when /^dodge(\s+(.*))?$/i target = $2 if $2 - simple_dodge({:target => target}) + $manager.submit_action(Aethyr::Core::Actions::SimpleDodge::SimpleDodgeCommand.new(@player, {:target => target})) end end private - def simple_dodge(event) - - room = $manager.get_object(@player.container) - player = @player - return unless Combat.ready? player - - target = (event.target && room.find(event.target)) || room.find(player.last_target) - - if target == player - player.output "You cannot block yourself." - return - elsif target - events = Combat.find_events(:player => target, :target => player, :blockable => true) - else - events = Combat.find_events(:target => player, :blockable => true) - end - - if events.empty? - player.output "What are you trying to dodge?" - return - end - - if target.nil? - target = events[0].player - end - - player.last_target = target.goid - - b_event = events[0] - if rand > 0.5 - b_event[:action] = :martial_miss - b_event[:type] = :MartialCombat - b_event[:to_other] = "#{player.name} twists away from #{target.name}'s attack." - b_event[:to_player] = "#{player.name} twists away from your attack." - b_event[:to_target] = "You manage to twist your body away from #{target.name}'s attack." - end - - event[:target] = target - event[:to_other] = "#{player.name} attempts to dodge #{target.name}'s attack." - event[:to_target] = "#{player.name} attempts to dodge your attack." - event[:to_player] = "You attempt to dodge #{target.name}'s attack." - - player.balance = false - room.out_event event - end end Aethyr::Extend::HandlerRegistry.register_handler(DodgeHandler) diff --git a/lib/aethyr/core/input_handlers/drop.rb b/lib/aethyr/core/input_handlers/drop.rb index 32ccca7c777be8cc089d3551e2b9da90d89b9bed..702b41233783c1bbfe2e28fdd2d59537e76dcf47 100644 --- a/lib/aethyr/core/input_handlers/drop.rb +++ b/lib/aethyr/core/input_handlers/drop.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/drop" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -36,36 +37,13 @@ EOF super(data) case data[:input] when /^drop\s+((\w+\s*)*)$/i - action({ :object => $1.strip }) + $manager.submit_action(Aethyr::Core::Actions::Drop::DropCommand.new(@player, { :object => $1.strip })) end end private #Drops an item from the player's inventory into the room. - def action(event) - room = $manager.get_object(@player.container) - object = @player.inventory.find(event[:object]) - if object.nil? - if response = @player.equipment.worn_or_wielded?(event[:object]) - @player.output response - else - @player.output "You have no #{event[:object]} to drop." - end - - return - end - - @player.inventory.remove(object) - - object.container = room.goid - room.add(object) - - event[:to_player] = "You drop #{object.name}." - event[:to_other] = "#{@player.name} drops #{object.name}." - event[:to_blind_other] = "You hear something hit the ground." - room.out_event(event) - end end Aethyr::Extend::HandlerRegistry.register_handler(DropHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/agree.rb b/lib/aethyr/core/input_handlers/emotes/agree.rb index b57067c7f27cf36750a5408b07784ba627323a4d..c3ecbd349574b5d1266862d0e4abc97f22b89390 100644 --- a/lib/aethyr/core/input_handlers/emotes/agree.rb +++ b/lib/aethyr/core/input_handlers/emotes/agree.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/agree" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,39 +38,11 @@ EOF when /^(agree)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - agree({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Agree::AgreeCommand.new(@player, {:object => object, :post => post})) end end private - def agree(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You nod your head in agreement." - to_other "#{player.name} nods #{player.pronoun(:possessive)} head in agreement." - to_deaf_other event[:to_other] - end - - self_target do - to_player "You are in complete agreement with yourself." - to_other "#{player.name} nods at #{player.pronoun(:reflexive)}, apparently in complete agreement." - to_deaf_other event[:to_other] - end - - target do - to_player "You nod your head in agreement with #{event.target.name}." - to_target "#{player.name} nods #{player.pronoun(:possessive)} head in agreement with you." - to_other "#{player.name} nods #{player.pronoun(:possessive)} head in agreement with #{event.target.name}." - to_deaf_other event[:to_other] - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(AgreeHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/back.rb b/lib/aethyr/core/input_handlers/emotes/back.rb index e30390948c36195dc6e188de64e5be0a9ced65de..18410f7c204fb94b6f5d175a50c9baae9007b2d2 100644 --- a/lib/aethyr/core/input_handlers/emotes/back.rb +++ b/lib/aethyr/core/input_handlers/emotes/back.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/back" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,36 +38,11 @@ EOF when /^(back)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - back({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Back::BackCommand.new(@player, {:object => object, :post => post})) end end private - def back(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "\"I'm back!\" you happily announce." - to_other "\"I'm back!\" #{player.name} happily announces to those nearby." - to_blind_other "Someone announces, \"I'm back!\"" - end - - self_target do - player.output "Hm? How do you do that?" - end - - target do - to_player "You happily announce your return to #{event.target.name}." - to_target "#{player.name} happily announces #{player.pronoun(:possessive)} return to you." - to_other "#{player.name} announces #{player.pronoun(:possessive)} return to #{event.target.name}." - to_blind_other "Someone says, \"I shall return shortly!\"" - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(BackHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/blush.rb b/lib/aethyr/core/input_handlers/emotes/blush.rb index b5fcec3f20922039af82b7483055b18829ed004a..7cd80cd049a3cb40633f27bbaf8df4e020100acb 100644 --- a/lib/aethyr/core/input_handlers/emotes/blush.rb +++ b/lib/aethyr/core/input_handlers/emotes/blush.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/blush" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,39 +38,11 @@ EOF when /^(blush)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - blush({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Blush::BlushCommand.new(@player, {:object => object, :post => post})) end end private - def blush(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You feel the blood rush to your cheeks and you look down, blushing." - to_other "#{player.name}'s face turns bright red as #{player.pronoun} looks down, blushing." - to_deaf_other event[:to_other] - end - - self_target do - to_player "You blush at your foolishness." - to_other "#{player.name} blushes at #{event.target.pronoun(:possessive)} foolishness." - to_deaf_other event[:to_other] - end - - target do - to_player "Your face turns red and you blush at #{event.target.name} uncomfortably." - to_target "#{player.name} blushes in your direction." - to_deaf_target event[:to_target] - to_other "#{player.name} blushes at #{event.target.name}, clearly uncomfortable." - to_deaf_other event[:to_other] - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(BlushHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/bow.rb b/lib/aethyr/core/input_handlers/emotes/bow.rb index eef67ece34e76c3e9ef289f34d667418309579eb..f8c086cd22dac92f0e9a34a058b53675a6200b12 100644 --- a/lib/aethyr/core/input_handlers/emotes/bow.rb +++ b/lib/aethyr/core/input_handlers/emotes/bow.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/bow" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,37 +38,11 @@ EOF when /^(bow)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - bow({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Bow::BowCommand.new(@player, {:object => object, :post => post})) end end private - def bow(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You bow deeply and respectfully." - to_other "#{player.name} bows deeply and respectfully." - to_deaf_other event[:to_other] - end - - self_target do - player.output "Huh?" - end - - target do - to_player "You bow respectfully towards #{event.target.name}." - to_target "#{player.name} bows respectfully before you." - to_other "#{player.name} bows respectfully towards #{event.target.name}." - to_deaf_other event[:to_other] - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(BowHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/brb.rb b/lib/aethyr/core/input_handlers/emotes/brb.rb index 9e3765e072d18611f3d36a2293fea2516af25c81..53a7585f1100eb8c0864188d65cb2b7368fee835 100644 --- a/lib/aethyr/core/input_handlers/emotes/brb.rb +++ b/lib/aethyr/core/input_handlers/emotes/brb.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/brb" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,37 +38,11 @@ EOF when /^(brb)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - brb({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Brb::BrbCommand.new(@player, {:object => object, :post => post})) end end private - def brb(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "\"I shall return shortly!\" you say to no one in particular." - to_other "#{player.name} says, \"I shall return shortly!\" to no one in particular." - to_blind_other "Someone says, \"I shall return shortly!\"" - end - - self_target do - player.output "Hm? How do you do that?" - end - - target do - to_player "You let #{event.target.name} know you will return shortly." - to_target "#{player.name} lets you know #{player.pronoun} will return shortly." - to_other "#{player.name} tells #{event.target.name} that #{player.pronoun} will return shortly." - to_blind_other "Someone says, \"I shall return shortly!\"" - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(BrbHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/bye.rb b/lib/aethyr/core/input_handlers/emotes/bye.rb index 33ae7f184b7b5fbc211691def144085c0d6dcd86..4d186511f31d1b405ad9300322f4b962e761d092 100644 --- a/lib/aethyr/core/input_handlers/emotes/bye.rb +++ b/lib/aethyr/core/input_handlers/emotes/bye.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/bye" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,35 +38,11 @@ EOF when /^(bye)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - bye({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Bye::ByeCommand.new(@player, {:object => object, :post => post})) end end private - def bye(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You say a hearty \"Goodbye!\" to those around you." - to_other "#{player.name} says a hearty \"Goodbye!\"" - end - - self_target do - player.output "Goodbye." - end - - target do - to_player "You say \"Goodbye!\" to #{event.target.name}." - to_target "#{player.name} says \"Goodbye!\" to you." - to_other "#{player.name} says \"Goodbye!\" to #{event.target.name}" - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(ByeHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/cheer.rb b/lib/aethyr/core/input_handlers/emotes/cheer.rb index 010240066ccafd7f2ed45bd5888fe42cde1f8217..5b7701a33d6d334dfd8f5299552f65e23ec817bb 100644 --- a/lib/aethyr/core/input_handlers/emotes/cheer.rb +++ b/lib/aethyr/core/input_handlers/emotes/cheer.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/cheer" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,36 +38,11 @@ EOF when /^(cheer)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - cheer({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Cheer::CheerCommand.new(@player, {:object => object, :post => post})) end end private - def cheer(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You throw your hands in the air and cheer wildly!" - to_other "#{player.name} throws #{player.pronoun(:possessive)} hands in the air as #{player.pronoun} cheers wildy!" - to_blind_other "You hear someone cheering." - end - - self_target do - player.output "Hm? How do you do that?" - end - - target do - to_player "Beaming at #{event.target.name}, you throw your hands up and cheer for #{event.target.pronoun(:objective)}." - to_target "Beaming at you, #{player.name} throws #{player.pronoun(:possessive)} hands up and cheers for you." - to_other "#{player.name} throws #{player.pronoun(:possessive)} hands up and cheers for #{event.target.name}." - to_blind_other "You hear someone cheering." - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(CheerHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/cry.rb b/lib/aethyr/core/input_handlers/emotes/cry.rb index 9d9cdeb70295c83a04715639aab6ee0717f4188b..e6d4ad4c50d7a27a04f2b97ce4e2da35ef10919e 100644 --- a/lib/aethyr/core/input_handlers/emotes/cry.rb +++ b/lib/aethyr/core/input_handlers/emotes/cry.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/cry" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,24 +38,11 @@ EOF when /^(cry)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - cry({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Cry::CryCommand.new(@player, {:object => object, :post => post})) end end private - def cry(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - default do - to_player "Tears run down your face as you cry pitifully." - to_other "Tears run down #{player.name}'s face as #{player.pronoun} cries pitifully." - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(CryHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/curtsey.rb b/lib/aethyr/core/input_handlers/emotes/curtsey.rb index 6631ec93f53d18b90532dfc9375396eb5a71611e..fda04183d97c8a031ef872322b24dc0dc166d756 100644 --- a/lib/aethyr/core/input_handlers/emotes/curtsey.rb +++ b/lib/aethyr/core/input_handlers/emotes/curtsey.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/curtsey" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,37 +38,11 @@ EOF when /^(curtsey)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - curtsey({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Curtsey::CurtseyCommand.new(@player, {:object => object, :post => post})) end end private - def curtsey(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You perform a very graceful curtsey." - to_other "#{player.name} curtseys quite gracefully." - to_deaf_other event[:to_other] - end - - self_target do - player.output "Hm? How do you do that?" - end - - target do - to_player "You curtsey gracefully and respectfully towards #{event.target.name}." - to_target "#{player.name} curtseys gracefully and respectfully in your direction." - to_other "#{player.name} curtseys gracefully and respectfully towards #{event.target.name}." - to_deaf_other event[:to_other] - end - - end - end end Aethyr::Extend::HandlerRegistry.register_handler(CurtseyHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/eh.rb b/lib/aethyr/core/input_handlers/emotes/eh.rb index 937e5efe78759f5393ec65070ae827a5a2aae29c..57eec23cf7399a193b255ce57fe4e4bb49d78837 100644 --- a/lib/aethyr/core/input_handlers/emotes/eh.rb +++ b/lib/aethyr/core/input_handlers/emotes/eh.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/eh" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -34,55 +35,12 @@ EOF def player_input(data) super(data) case data[:input] - when /^(eh\?)( +([^()]*))?( +((.*)))?$/i - object = $3 - post = $5 - eh?({:object => object, :post => post}) when /^(eh)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - eh({:object => object, :post => post}) - end - end - - private - def eh(event) - - room = $manager.get_object(@player.container) - player = @player - make_emote event, player, room do - target do - to_player "After giving #{event.target.name} a cursory glance, you emit an unimpressed, 'Eh.'" - to_other "#{player.name} gives #{event.target.name} a cursory glance and then emits an unimpressed, 'Eh.'" - to_target "#{player.name} gives you a cursory glance and then emits an unimpressed, 'Eh.'" - end - - no_target do - to_player "After a brief consideration, you give an unimpressed, 'Eh.'" - to_other "#{player.name} appears to consider for a moment before giving an unimpressed, 'Eh.'" - end + $manager.submit_action(Aethyr::Core::Actions::Eh::EhCommand.new(@player, {:object => object, :post => post})) end end - - def eh?(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - no_target do - to_player "Thoughtfully, you murmur, \"Eh?\"" - to_other "#{player.name} murmurs, \"Eh?\" with a thoughtful appearance." - end - - target do - to_player "Looking perplexed, you ask #{target.name}, \"Eh?\"" - to_other "\"Eh?\" #{player.name} asks #{target.name}, looking perplexed." - to_target "\"Eh?\" #{player.name} asks you, with a perplexed expression." - end - end - end - end Aethyr::Extend::HandlerRegistry.register_handler(EhHandler) end diff --git a/lib/aethyr/core/input_handlers/emotes/emote.rb b/lib/aethyr/core/input_handlers/emotes/emote.rb index 43613f11279548f12c3921f205edfb46f723ee4f..da804e9e5dfe87bbf7a700535e8cedff7d56f02a 100644 --- a/lib/aethyr/core/input_handlers/emotes/emote.rb +++ b/lib/aethyr/core/input_handlers/emotes/emote.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/emote" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -65,51 +66,11 @@ EOF case data[:input] when /^emote\s+(.*)/i show = $1 - emote({:show => show}) + $manager.submit_action(Aethyr::Core::Actions::Emote::EmoteCommand.new(@player, {:show => show})) end end private - def emote(event) - - room = $manager.get_object(@player.container) - player = @player - action = event[:show].strip - - unless ['!', '.', '?', '"'].include? action[-1..-1] - action << '.' - end - - if action =~ /\$me[^a-zA-Z]/i - action.gsub!(/\$me/i, player.name) - action[0,1] = action[0,1].capitalize - show = action - elsif action.include? '$' - people = [] - action.gsub!(/\$(\w+)/) do |name| - target = room.find($1) - people << target unless target.nil? - target ? target.name : 'no one' - end - - people.each do |person| - out = action.gsub(person.name, 'you') - person.output("#{player.name} #{out}", message_type = :chat) unless person.can? :blind and person.blind? - end - - room.output("#{player.name} #{action}", player, *people) - player.output("You emote: #{player.name} #{action}") - else - show = "#{player.name} #{action}" - end - - if show - event[:message_type] = :chat - event[:to_player] = "You emote: #{show}" - event[:to_other] = show - room.out_event event - end - end end Aethyr::Extend::HandlerRegistry.register_handler(EmoteHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/emote_handler.rb b/lib/aethyr/core/input_handlers/emotes/emote_handler.rb index 660e7e7f008b68f1e6c7d99d32671a69ab6e52aa..db00b9398fffc2f9e25f95e99d207a7f1a0ea1d3 100644 --- a/lib/aethyr/core/input_handlers/emotes/emote_handler.rb +++ b/lib/aethyr/core/input_handlers/emotes/emote_handler.rb @@ -1,4 +1,4 @@ -require 'aethyr/core/actions/commands/command_handler' +require 'aethyr/core/input_handlers/command_handler' module Aethyr module Extend diff --git a/lib/aethyr/core/input_handlers/emotes/er.rb b/lib/aethyr/core/input_handlers/emotes/er.rb index 9ffe19f809740d69f91342e75ed2923235b91253..35dd66cad4c31a69bd453c2974623ad9619d23a7 100644 --- a/lib/aethyr/core/input_handlers/emotes/er.rb +++ b/lib/aethyr/core/input_handlers/emotes/er.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/er" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,28 +38,11 @@ EOF when /^(er)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - er({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Er::ErCommand.new(@player, {:object => object, :post => post})) end end private - def er(event) - - room = $manager.get_object(@player.container) - player = @player - make_emote event, player, room do - no_target do - to_player "With a look of uncertainty, you say, \"Er...\"" - to_other "With a look of uncertainty, #{player.name} says, \"Er...\"" - end - - target do - to_player "Looking at #{target.name} uncertainly, you say, \"Er...\"" - to_other "Looking at #{target.name} uncertainly, #{player.name} says, \"Er...\"" - to_target "Looking at you uncertainly, #{player.name} says, \"Er...\"" - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(ErHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/ew.rb b/lib/aethyr/core/input_handlers/emotes/ew.rb index b103a3646d4dfd81e98a604b3eecb0bdef10dffd..df1ea55dedb667be1b1775330dce7ec45a7408d5 100644 --- a/lib/aethyr/core/input_handlers/emotes/ew.rb +++ b/lib/aethyr/core/input_handlers/emotes/ew.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/ew" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -18,7 +19,6 @@ module Aethyr Please see help for emote instead. EOF help_entries.push(Aethyr::Core::Help::HelpEntry.new(command, content: content, syntax_formats: syntax_formats, see_also: see_also, aliases: aliases)) - return help_entries end @@ -37,38 +37,11 @@ EOF when /^(ew)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - ew({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Ew::EwCommand.new(@player, {:object => object, :post => post})) end end private - def ew(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "\"Ewww!\" you exclaim, looking disgusted." - to_other "#{player.name} exclaims, \"Eww!!\" and looks disgusted." - to_deaf_other "#{player.name} looks disgusted." - to_blind_other "Somone exclaims, \"Eww!!\"" - end - - self_target do - player.output "You think you are digusting?" - end - - target do - to_player "You glance at #{event.target.name} and say \"Ewww!\"" - to_target "#{player.name} glances in your direction and says, \"Ewww!\"" - to_deaf_other "#{player.name} gives #{event.target.name} a disgusted look." - to_blind_other "Somone exclaims, \"Eww!!\"" - to_other "#{player.name} glances at #{event.target.name}, saying \"Ewww!\"" - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(EwHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/frown.rb b/lib/aethyr/core/input_handlers/emotes/frown.rb index e6b9d6ea6208a78750bac560221e938502da4be8..e6f68f6629b2568190568e3d70636ce74641409c 100644 --- a/lib/aethyr/core/input_handlers/emotes/frown.rb +++ b/lib/aethyr/core/input_handlers/emotes/frown.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/frown" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,39 +38,11 @@ EOF when /^(frown)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - frown({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Frown::FrownCommand.new(@player, {:object => object, :post => post})) end end private - def frown(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - no_target do - to_player "The edges of your mouth turn down as you frown." - to_other "The edges of #{player.name}'s mouth turn down as #{player.pronoun} frowns." - to_deaf_other event[:to_other] - end - - self_target do - to_player "You frown sadly at yourself." - to_other "#{player.name} frowns sadly at #{event.target.pronoun(:reflexive)}." - to_deaf_other event[:to_other] - end - - target do - to_player "You frown at #{event.target.name} unhappily." - to_target "#{player.name} frowns at you unhappily." - to_deaf_target event[:to_target] - to_other "#{player.name} frowns at #{event.target.name} unhappily." - to_deaf_other event[:to_other] - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(FrownHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/grin.rb b/lib/aethyr/core/input_handlers/emotes/grin.rb index e0fe4c20d74447069de9c64293ae9b735f0e14da..eab8842bb14f7fac7e11dead8d9fef67f55dac30 100644 --- a/lib/aethyr/core/input_handlers/emotes/grin.rb +++ b/lib/aethyr/core/input_handlers/emotes/grin.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/grin" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,40 +38,11 @@ EOF when /^(grin)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - grin({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Grin::GrinCommand.new(@player, {:object => object, :post => post})) end end private - def grin(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player 'You grin widely, flashing all your teeth.' - to_other "#{player.name} grins widely, flashing all #{player.pronoun(:possessive)} teeth." - to_deaf_other event[:to_other] - end - - self_target do - to_player "You grin madly at yourself." - to_other "#{player.name} grins madly at #{event.target.pronoun(:reflexive)}." - to_deaf_other event[:to_other] - end - - target do - to_player "You give #{event.target.name} a wide grin." - to_target "#{player.name} gives you a wide grin." - to_deaf_target event[:to_target] - to_other "#{player.name} gives #{event.target.name} a wide grin." - to_deaf_other event[:to_other] - end - - end - end end Aethyr::Extend::HandlerRegistry.register_handler(GrinHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/hi.rb b/lib/aethyr/core/input_handlers/emotes/hi.rb index 83ef47707c8800742eb3d38b90e0c8197e913952..d5799e6172b6ea1e73ce069a9df3bf5a63934719 100644 --- a/lib/aethyr/core/input_handlers/emotes/hi.rb +++ b/lib/aethyr/core/input_handlers/emotes/hi.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/hi" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,35 +38,11 @@ EOF when /^(hi)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - hi({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Hi::HiCommand.new(@player, {:object => object, :post => post})) end end private - def hi(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "\"Hi!\" you greet those around you." - to_other "#{player.name} greets those around with a \"Hi!\"" - end - - self_target do - player.output "Hi." - end - - target do - to_player "You say \"Hi!\" in greeting to #{event.target.name}." - to_target "#{player.name} greets you with a \"Hi!\"" - to_other "#{player.name} greets #{event.target.name} with a hearty \"Hi!\"" - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(HiHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/hm.rb b/lib/aethyr/core/input_handlers/emotes/hm.rb index ee047e205e5270d63c7c7a2a490fac34d544d286..2d6745e45f62c0cf551d46504a04fcb740c5c6cd 100644 --- a/lib/aethyr/core/input_handlers/emotes/hm.rb +++ b/lib/aethyr/core/input_handlers/emotes/hm.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/hm" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,36 +38,11 @@ EOF when /^(hm)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - hm({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Hm::HmCommand.new(@player, {:object => object, :post => post})) end end private - def hm(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_other "#{player.name} purses #{player.pronoun(:possessive)} lips thoughtfully and says, \"Hmmm...\"" - to_player "You purse your lips thoughtfully and say, \"Hmmm...\"" - end - - self_target do - to_other "#{player.name} looks down at #{player.pronoun(:reflexive)} and says, \"Hmmm...\"" - to_player "You look down at yourself and say, \"Hmmm...\"" - end - - target do - to_other "#{player.name} purses #{player.pronoun(:possessive)} lips as #{player.pronoun} looks thoughtfully at #{event.target.name} and says, \"Hmmm...\"" - to_player "You purse your lips as you look thoughtfully at #{event.target.name} and say, \"Hmmm...\"" - to_target "#{player.name} purses #{player.pronoun(:possessive)} lips as #{player.pronoun} looks thoughtfully at you and says, \"Hmmm...\"" - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(HmHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/hug.rb b/lib/aethyr/core/input_handlers/emotes/hug.rb index 47aa4b1ce95e6e66659d7f711ac4fb47196b1ac5..24d0c40d93c7ab7eb73d73f3cfc2185c697609e1 100644 --- a/lib/aethyr/core/input_handlers/emotes/hug.rb +++ b/lib/aethyr/core/input_handlers/emotes/hug.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/hug" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,37 +38,11 @@ EOF when /^(hug)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - hug({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Hug::HugCommand.new(@player, {:object => object, :post => post})) end end private - def hug(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - player.output "Who are you trying to hug?" - end - - self_target do - to_player 'You wrap your arms around yourself and give a tight squeeze.' - to_other "#{player.name} gives #{player.pronoun(:reflexive)} a tight squeeze." - to_deaf_other event[:to_other] - end - - target do - to_player "You give #{event.target.name} a great big hug." - to_target "#{player.name} gives you a great big hug." - to_other "#{player.name} gives #{event.target.name} a great big hug." - to_blind_target "Someone gives you a great big hug." - to_deaf_other event[:to_other] - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(HugHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/huh.rb b/lib/aethyr/core/input_handlers/emotes/huh.rb index 3ac36423767445d846118757f3aa06ef81cf3748..325b201788267a652581a83e49145798b28b6c68 100644 --- a/lib/aethyr/core/input_handlers/emotes/huh.rb +++ b/lib/aethyr/core/input_handlers/emotes/huh.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/huh" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,34 +38,11 @@ EOF when /^(huh)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - huh({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Huh::HuhCommand.new(@player, {:object => object, :post => post})) end end private - def huh(event) - - room = $manager.get_object(@player.container) - player = @player - make_emote event, player, room do - - no_target do - to_player "\"Huh?\" you ask, confused." - to_other "#{player.name} ask, \"Huh?\" and looks confused." - end - - self_target do - player.output "Well, huh!" - end - - target do - to_player "\"Huh?\" you ask #{event.target.name}." - to_target "#{player.name} asks, \"Huh?\"" - to_other "#{player.name} asks #{event.target.name}, \"Huh?\"" - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(HuhHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/laugh.rb b/lib/aethyr/core/input_handlers/emotes/laugh.rb index f303e3d10a32d75b46d867e977bae6c08c919b39..25ba10351eb8c5fd9dbac8c85d90e57e1203867b 100644 --- a/lib/aethyr/core/input_handlers/emotes/laugh.rb +++ b/lib/aethyr/core/input_handlers/emotes/laugh.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/laugh" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,41 +38,11 @@ EOF when /^(laugh)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - laugh({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Laugh::LaughCommand.new(@player, {:object => object, :post => post})) end end private - def laugh(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - self_target do - to_player "You laugh heartily at yourself." - to_other "#{player.name} laughs heartily at #{player.pronoun(:reflexive)}." - to_blind_other "Someone laughs heartily." - end - - target do - to_player "You laugh at #{event.target.name}." - to_target "#{player.name} laughs at you." - to_other "#{player.name} laughs at #{event.target.name}" - to_blind_target "Someone laughs in your direction." - to_blind_other "You hear someone laughing." - end - - no_target do - to_player "You laugh." - to_other "#{player.name} laughs." - to_blind_other "You hear someone laughing." - to_deaf_other "You see #{player.name} laugh." - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(LaughHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/no.rb b/lib/aethyr/core/input_handlers/emotes/no.rb index 69c11048a1553277e4d4379efedeef71a7c77b1e..adbd8b5e60fd6abe3c353f5a5bd267111e360c2f 100644 --- a/lib/aethyr/core/input_handlers/emotes/no.rb +++ b/lib/aethyr/core/input_handlers/emotes/no.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/no" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,34 +38,11 @@ EOF when /^(no)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - no({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::No::NoCommand.new(@player, {:object => object, :post => post})) end end private - def no(event) - - room = $manager.get_object(@player.container) - player = @player - make_emote event, player, room do - no_target do - to_player "\"No,\" you say, shaking your head." - to_other "#{player.name} says, \"No\" and shakes #{player.pronoun(:possessive)} head." - end - self_target do - to_player "You shake your head negatively in your direction. You are kind of strange." - to_other "#{player.name} shakes #{player.pronoun(:possessive)} head at #{player.pronoun(:reflexive)}." - to_deaf_other event[:to_other] - end - target do - to_player "You shake your head, disagreeing with #{event.target.name}." - to_target "#{player.name} shakes #{player.pronoun(:possessive)} head in your direction, disagreeing." - to_other "#{player.name} shakes #{player.pronoun(:possessive)} head in disagreement with #{event.target.name}." - to_deaf_other event[:to_other] - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(NoHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/nod.rb b/lib/aethyr/core/input_handlers/emotes/nod.rb index ce0a84a7d34e3ecad3f2401448913be78546a89e..8a1a8413e30baa19cac333ff8216051b61658f2d 100644 --- a/lib/aethyr/core/input_handlers/emotes/nod.rb +++ b/lib/aethyr/core/input_handlers/emotes/nod.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/nod" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,39 +38,11 @@ EOF when /^(nod)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - nod({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Nod::NodCommand.new(@player, {:object => object, :post => post})) end end private - def nod(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You nod your head." - to_other "#{player.name} nods #{player.pronoun(:possessive)} head." - to_deaf_other event[:to_other] - end - - self_target do - to_player 'You nod to yourself thoughtfully.' - to_other "#{player.name} nods to #{player.pronoun(:reflexive)} thoughtfully." - to_deaf_other event[:to_other] - end - - target do - - to_player "You nod your head towards #{event.target.name}." - to_target "#{player.name} nods #{player.pronoun(:possessive)} head towards you." - to_other "#{player.name} nods #{player.pronoun(:possessive)} head towards #{event.target.name}." - to_deaf_other event[:to_other] - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(NodHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/pet.rb b/lib/aethyr/core/input_handlers/emotes/pet.rb index 77a210cd84a46388a5844f8e259b3f29d0822afe..7ed820f967583f2a25f6215e65903b96da274f4c 100644 --- a/lib/aethyr/core/input_handlers/emotes/pet.rb +++ b/lib/aethyr/core/input_handlers/emotes/pet.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/pet" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,38 +38,11 @@ EOF when /^(pet)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - pet({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Pet::PetCommand.new(@player, {:object => object, :post => post})) end end private - def pet(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - player.output "Who are you trying to pet?" - end - - self_target do - to_player 'You pet yourself on the head in a calming manner.' - to_other "#{player.name} pets #{player.pronoun(:reflexive)} on the head in a calming manner." - to_deaf_other "#{player.name} pets #{player.pronoun(:reflexive)} on the head in a calming manner." - end - - target do - to_player "You pet #{event.target.name} affectionately." - to_target "#{player.name} pets you affectionately." - to_deaf_target event[:to_target] - to_blind_target "Someone pets you affectionately." - to_other "#{player.name} pets #{event.target.name} affectionately." - to_deaf_other event[:to_other] - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(PetHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/poke.rb b/lib/aethyr/core/input_handlers/emotes/poke.rb index 5a9238558d97f3b10e9dee431ecbba14005490a0..b42bb9a8d0ffd709bab363d3ba29993382e33d3e 100644 --- a/lib/aethyr/core/input_handlers/emotes/poke.rb +++ b/lib/aethyr/core/input_handlers/emotes/poke.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/poke" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,38 +38,11 @@ EOF when /^(poke)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - poke({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Poke::PokeCommand.new(@player, {:object => object, :post => post})) end end private - def poke(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - player.output "Who are you trying to poke?" - end - - self_target do - to_player "You poke yourself in the eye. 'Ow!'" - to_other "#{player.name} pokes #{player.pronoun(:reflexive)} in the eye." - to_deaf_other event[:to_other] - end - - target do - to_player "You poke #{event.target.name} playfully." - to_target "#{player.name} pokes you playfully." - to_blind_target "Someone pokes you playfully." - to_deaf_target event[:to_target] - to_other "#{player.name} pokes #{event.target.name} playfully." - to_deaf_other event[:to_other] - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(PokeHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/ponder.rb b/lib/aethyr/core/input_handlers/emotes/ponder.rb index 17f9d509790e1f5ef796fe5dc07aed6863f77415..09f9307e3632a64fb6e68b2291a4b9d85e2dc1c3 100644 --- a/lib/aethyr/core/input_handlers/emotes/ponder.rb +++ b/lib/aethyr/core/input_handlers/emotes/ponder.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/ponder" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,38 +38,11 @@ EOF when /^(ponder)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - ponder({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Ponder::PonderCommand.new(@player, {:object => object, :post => post})) end end private - def ponder(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You ponder that idea for a moment." - to_other "#{player.name} looks thoughtful as #{player.pronoun} ponders a thought." - to_deaf_other event[:to_other] - end - - self_target do - to_player "You look down in deep thought at your navel." - to_other "#{player.name} looks down thoughtfully at #{player.pronoun(:possessive)} navel." - to_deaf_other event[:to_other] - end - - target do - to_player "You give #{event.target.name} a thoughtful look as you reflect and ponder." - to_target "#{player.name} gives you a thoughtful look and seems to be reflecting upon something." - to_other "#{player.name} gives #{event.target.name} a thoughtful look and appears to be absorbed in reflection." - to_deaf_other event[:to_other] - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(PonderHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/shrug.rb b/lib/aethyr/core/input_handlers/emotes/shrug.rb index 0cddb53ccf261d5942c519d5baa38435926b5661..19d9b869ee1a94cc1bcd618f37447e2ed81e413a 100644 --- a/lib/aethyr/core/input_handlers/emotes/shrug.rb +++ b/lib/aethyr/core/input_handlers/emotes/shrug.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/shrug" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,39 +38,11 @@ EOF when /^(shrug)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - shrug({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Shrug::ShrugCommand.new(@player, {:object => object, :post => post})) end end private - def shrug(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You shrug your shoulders." - to_other "#{player.name} shrugs #{player.pronoun(:possessive)} shoulders." - to_deaf_other event[:to_other] - end - - self_target do - player.output "Don't just shrug yourself off like that!" - - end - - target do - to_player "You give #{event.target.name} a brief shrug." - to_target "#{player.name} gives you a brief shrug." - to_other "#{player.name} gives #{event.target.name} a brief shrug." - to_deaf_other event[:to_other] - to_deaf_target event[:to_target] - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(ShrugHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/sigh.rb b/lib/aethyr/core/input_handlers/emotes/sigh.rb index d5e458a64d820e5897722a7cbe2d155e0f8cb209..5532ac3da1f2b17414ab87d6707c1d32e765b633 100644 --- a/lib/aethyr/core/input_handlers/emotes/sigh.rb +++ b/lib/aethyr/core/input_handlers/emotes/sigh.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/sigh" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,36 +38,11 @@ EOF when /^(sigh)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - sigh({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Sigh::SighCommand.new(@player, {:object => object, :post => post})) end end private - def sigh(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You exhale, sighing deeply." - to_other "#{player.name} breathes out a deep sigh." - end - - self_target do - to_player "You sigh at your misfortunes." - to_other "#{player.name} sighs at #{player.pronoun(:possessive)} own misfortunes." - end - - target do - to_player "You sigh in #{event.target.name}'s general direction." - to_target "#{player.name} heaves a sigh in your direction." - to_other "#{player.name} sighs heavily in #{event.target.name}'s direction." - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(SighHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/skip.rb b/lib/aethyr/core/input_handlers/emotes/skip.rb index d7cf8a197091b081b50ef7cb1d20245de830d259..7b5a70f98e3b5192a78993e7834ed3b92cb1070a 100644 --- a/lib/aethyr/core/input_handlers/emotes/skip.rb +++ b/lib/aethyr/core/input_handlers/emotes/skip.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/skip" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,37 +38,11 @@ EOF when /^(skip)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - skip({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Skip::SkipCommand.new(@player, {:object => object, :post => post})) end end private - def skip(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You skip around cheerfully." - to_other "#{player.name} skips around cheerfully." - to_deaf_other "#{player.name} skips around cheerfully." - end - - self_target do - player.output 'How?' - end - - target do - to_player "You skip around #{event.target.name} cheerfully." - to_target "#{player.name} skips around you cheerfully." - to_other "#{player.name} skips around #{event.target.name} cheerfully." - to_deaf_other "#{player.name} skips around #{event.target.name} cheerfully." - end - - end - end end Aethyr::Extend::HandlerRegistry.register_handler(SkipHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/smile.rb b/lib/aethyr/core/input_handlers/emotes/smile.rb index 9682eaffc45b23a6ec4c6174cc2918f58662394c..c78d3328c6c00ce714af60fb04f791242ee2c992 100644 --- a/lib/aethyr/core/input_handlers/emotes/smile.rb +++ b/lib/aethyr/core/input_handlers/emotes/smile.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/smile" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,35 +38,11 @@ EOF when /^(smile)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - smile({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Smile::SmileCommand.new(@player, {:object => object, :post => post})) end end private - def smile(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - self_target do - to_player "You smile happily at yourself." - to_other "#{player.name} smiles at #{player.pronoun(:reflexive)} sillily." - end - - target do - to_player "You smile at #{event.target.name} kindly." - to_target "#{player.name} smiles at you kindly." - to_other "#{player.name} smiles at #{event.target.name} kindly." - end - - no_target do - to_player "You smile happily." - to_other "#{player.name} smiles happily." - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(SmileHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/snicker.rb b/lib/aethyr/core/input_handlers/emotes/snicker.rb index cdf45ddedb75ec03f77c138b2c17594aca9257b8..c71ae1ee99a32ea4d8b1a62bffb7882dc5bcb911 100644 --- a/lib/aethyr/core/input_handlers/emotes/snicker.rb +++ b/lib/aethyr/core/input_handlers/emotes/snicker.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/snicker" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,36 +38,11 @@ EOF when /^(snicker)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - snicker({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Snicker::SnickerCommand.new(@player, {:object => object, :post => post})) end end private - def snicker(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You snicker softly to yourself." - to_other "You hear #{player.name} snicker softly." - to_blind_other "You hear someone snicker softly." - end - - self_target do - player.output "What are you snickering about?" - end - - target do - to_player "You snicker at #{event.target.name} under your breath." - to_target "#{player.name} snickers at you under #{player.pronoun(:possessive)} breath." - to_other "#{player.name} snickers at #{event.target.name} under #{player.pronoun(:possessive)} breath." - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(SnickerHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/uh.rb b/lib/aethyr/core/input_handlers/emotes/uh.rb index c7b8ad5764cdb0f74073543a886eb3c9b88e8889..860fd93902a74fa0b2373937db0de3987cdd9376 100644 --- a/lib/aethyr/core/input_handlers/emotes/uh.rb +++ b/lib/aethyr/core/input_handlers/emotes/uh.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/uh" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,28 +38,11 @@ EOF when /^(uh)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - uh({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Uh::UhCommand.new(@player, {:object => object, :post => post})) end end private - def uh(event) - - room = $manager.get_object(@player.container) - player = @player - make_emote event, player, room do - no_target do - to_player "\"Uh...\" you say, staring blankly." - to_other "With a blank stare, #{player.name} says, \"Uh...\"" - end - - target do - to_player "With a blank stare at #{target.name}, you say, \"Uh...\"" - to_other "With a blank stare at #{target.name}, #{player.name} says, \"Uh...\"" - to_target "Staring blankly at you, #{player.name} says, \"Uh...\"" - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(UhHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/wave.rb b/lib/aethyr/core/input_handlers/emotes/wave.rb index d8d03ed150493032d6d7a70bb4c8a2dd6ca0036c..d65a18917b3b68303062a1973027e49806b1999c 100644 --- a/lib/aethyr/core/input_handlers/emotes/wave.rb +++ b/lib/aethyr/core/input_handlers/emotes/wave.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/wave" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,34 +38,11 @@ EOF when /^(wave)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - wave({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Wave::WaveCommand.new(@player, {:object => object, :post => post})) end end private - def wave(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You wave goodbye to everyone." - to_other "#{player.name} waves goodbye to everyone." - end - - self_target do - player.output "Waving at someone?" - end - - target do - to_player "You wave farewell to #{event.target.name}." - to_target "#{player.name} waves farewell to you." - to_other "#{player.name} waves farewell to #{event.target.name}." - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(WaveHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/yawn.rb b/lib/aethyr/core/input_handlers/emotes/yawn.rb index e5a8bcefdc98c1dfece2d3e8276cd3bb1eae2608..0f06d9fc243a18b84d1850ecb2ba8e343f87d309 100644 --- a/lib/aethyr/core/input_handlers/emotes/yawn.rb +++ b/lib/aethyr/core/input_handlers/emotes/yawn.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/yawn" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,38 +38,11 @@ EOF when /^(yawn)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - yawn({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Yawn::YawnCommand.new(@player, {:object => object, :post => post})) end end private - def yawn(event) - - room = $manager.get_object(@player.container) - player = @player - - make_emote event, player, room do - - no_target do - to_player "You open your mouth in a wide yawn, then exhale loudly." - to_other "#{player.name} opens #{player.pronoun(:possessive)} mouth in a wide yawn, then exhales loudly." - end - - self_target do - to_player "You yawn at how boring you are." - to_other "#{player.name} yawns at #{player.pronoun(:reflexive)}." - to_deaf_other event[:to_other] - end - - target do - to_player "You yawn at #{event.target.name}, bored out of your mind." - to_target "#{player.name} yawns at you, finding you boring." - to_other "#{player.name} yawns at how boring #{event.target.name} is." - to_deaf_other event[:to_other] - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(YawnHandler) diff --git a/lib/aethyr/core/input_handlers/emotes/yes.rb b/lib/aethyr/core/input_handlers/emotes/yes.rb index 540baca420f1c1b5f1af272bceafda19b9a708b9..cb7db80170efb2abe7701d6b177a51ccbd6d6c6f 100644 --- a/lib/aethyr/core/input_handlers/emotes/yes.rb +++ b/lib/aethyr/core/input_handlers/emotes/yes.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/yes" require "aethyr/core/registry" -require "aethyr/core/actions/commands/emotes/emote_handler" +require "aethyr/core/input_handlers/emotes/emote_handler" module Aethyr module Core @@ -37,37 +38,11 @@ EOF when /^(yes)( +([^()]*))?( +((.*)))?$/i object = $3 post = $5 - yes({:object => object, :post => post}) + $manager.submit_action(Aethyr::Core::Actions::Yes::YesCommand.new(@player, {:object => object, :post => post})) end end private - def yes(event) - - room = $manager.get_object(@player.container) - player = @player - make_emote event, player, room do - - no_target do - to_player "\"Yes,\" you say, nodding." - to_other "#{player.name} says, \"Yes\" and nods." - end - - self_target do - to_player "You nod in agreement with yourself." - to_other "#{player.name} nods at #{player.pronoun(:reflexive)} strangely." - to_deaf_other event[:to_other] - end - - target do - to_player "You nod in agreement with #{event.target.name}." - to_target "#{player.name} nods in your direction, agreeing." - to_other "#{player.name} nods in agreement with #{event.target.name}." - to_deaf_other event[:to_other] - end - end - - end end Aethyr::Extend::HandlerRegistry.register_handler(YesHandler) diff --git a/lib/aethyr/core/input_handlers/gait.rb b/lib/aethyr/core/input_handlers/gait.rb index 4f88ea45ee68e7936fd56e0a6d35fdc301835f92..76ba34801d4e753706f872299c15bd4443a8cefb 100644 --- a/lib/aethyr/core/input_handlers/gait.rb +++ b/lib/aethyr/core/input_handlers/gait.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/gait" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -36,34 +37,11 @@ EOF case data[:input] when /^gait(\s+(.*))?$/i phrase = $2 if $2 - gait({:phrase => phrase}) + $manager.submit_action(Aethyr::Core::Actions::Gait::GaitCommand.new(@player, {:phrase => phrase})) end end private - def gait(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:phrase].nil? - if player.info.entrance_message - player.output "When you move, it looks something like:", true - player.output player.exit_message("north") - else - player.output "You are walking normally." - end - elsif event[:phrase].downcase == "none" - player.info.entrance_message = nil - player.info.exit_message = nil - player.output "You will now walk normally." - else - player.info.entrance_message = "#{event[:phrase]}, !name comes in from !direction." - player.info.exit_message = "#{event[:phrase]}, !name leaves to !direction." - - player.output "When you move, it will now look something like:", true - player.output player.exit_message("north") - end - end end Aethyr::Extend::HandlerRegistry.register_handler(GaitHandler) diff --git a/lib/aethyr/core/input_handlers/generic.rb b/lib/aethyr/core/input_handlers/generic.rb index 11ed1f8c81207f7e28d8cb5c3f73906849e655d0..8c766919d94cb7708716ad8eb098f747f7c34d9e 100644 --- a/lib/aethyr/core/input_handlers/generic.rb +++ b/lib/aethyr/core/input_handlers/generic.rb @@ -1,6 +1,19 @@ +require "aethyr/core/actions/commands/feel" +require "aethyr/core/actions/commands/listen" +require "aethyr/core/actions/commands/smell" +require "aethyr/core/actions/commands/taste" +require "aethyr/core/actions/commands/write" +require "aethyr/core/actions/commands/deleteme" +require "aethyr/core/actions/commands/who" +require "aethyr/core/actions/commands/date" +require "aethyr/core/actions/commands/time" +require "aethyr/core/actions/commands/fill" +require "aethyr/core/actions/commands/status" +require "aethyr/core/actions/commands/satiety" +require "aethyr/core/actions/commands/health" require 'aethyr/core/issues' require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -203,265 +216,49 @@ EOF super(data) case data[:input] when /^delete me please$/i - action_deleteme({}) + $manager.submit_action(Aethyr::Core::Actions::Deleteme::DeletemeCommand.new(@player, {})) when /^(health)$/i - action_health({}) + $manager.submit_action(Aethyr::Core::Actions::Health::HealthCommand.new(@player, {})) when /^(satiety|hunger)$/i - action_satiety({}) + $manager.submit_action(Aethyr::Core::Actions::Satiety::SatietyCommand.new(@player, {})) when /^(st|stat|status)$/i - action_status({}) + $manager.submit_action(Aethyr::Core::Actions::Status::StatusCommand.new(@player, {})) when /^write\s+(.*)/i - action_write({ :target => $1.strip}) + $manager.submit_action(Aethyr::Core::Actions::Write::WriteCommand.new(@player, { :target => $1.strip})) when /^(listen)(\s+(.+))?$/i - action_listen({ :target => $3}) + $manager.submit_action(Aethyr::Core::Actions::Listen::ListenCommand.new(@player, { :target => $3})) when /^(smell|sniff)(\s+(.+))?$/i - action_smell({ :target => $3}) + $manager.submit_action(Aethyr::Core::Actions::Smell::SmellCommand.new(@player, { :target => $3})) when /^(taste|lick)(\s+(.+))?$/i - action_taste({ :target => $3}) + $manager.submit_action(Aethyr::Core::Actions::Taste::TasteCommand.new(@player, { :target => $3})) when /^(feel)(\s+(.+))?$/i - action_feel({ :target => $3}) + $manager.submit_action(Aethyr::Core::Actions::Feel::FeelCommand.new(@player, { :target => $3})) when /^fill\s+(\w+)\s+from\s+(\w+)$/i - action_fill({ :object => $1, :from => $2}) + $manager.submit_action(Aethyr::Core::Actions::Fill::FillCommand.new(@player, { :object => $1, :from => $2})) when /^who$/i - action_who({}) + $manager.submit_action(Aethyr::Core::Actions::Who::WhoCommand.new(@player, {})) when /^time$/i - action_time({}) + $manager.submit_action(Aethyr::Core::Actions::Time::TimeCommand.new(@player, {})) when /^date$/i - action_date({}) + $manager.submit_action(Aethyr::Core::Actions::Date::DateCommand.new(@player, {})) end end private #Display health. - def action_health(event) - @player.output "You are #{@player.health}." - end - #Display hunger. - def action_satiety(event) - @player.output "You are #{@player.satiety}." - end - #Display status. - def action_status(event) - @player.output("You are #{@player.health}.") - @player.output("You are feeling #{@player.satiety}.") - @player.output "You are currently #{@player.pose || 'standing up'}." - end - #Fill something. - def action_fill(event) - room = $manager.get_object(@player.container) - object = @player.search_inv(event[:object]) || room.find(event[:object]) - from = @player.search_inv(event[:from]) || room.find(event[:from]) - - if object.nil? - @player.output("What would you like to fill?") - return - elsif not object.is_a? LiquidContainer - @player.output("You cannot fill #{object.name} with liquids.") - return - elsif from.nil? - @player.output "There isn't any #{event[:from]} around here." - return - elsif not from.is_a? LiquidContainer - @player.output "You cannot fill #{object.name} from #{from.name}." - return - elsif from.empty? - @player.output "That #{object.generic} is empty." - return - elsif object.full? - @player.output("That #{object.generic} is full.") - return - elsif object == from - @player.output "Quickly flipping #{object.name} upside-down then upright again, you manage to fill it from itself." - return - end - end - #Display time. - def action_time(event) - @player.output $manager.time - end - #Display date. - def action_date(event) - @player.output $manager.date - end - #Show who is in the game. - def action_who(event) - players = $manager.find_all("class", Player) - output = ["The following people are visiting Aethyr:"] - players.sort_by {|p| p.name}.each do |playa| - room = $manager.find playa.container - output << "#{playa.name} - #{room.name if room}" - end - @player.output output - end - #Delete your player. - def action_deleteme(event) - if event[:password] - if $manager.check_password(@player.name, event[:password]) - @player.output "This character #{@player.name} will no longer exist." - @player.quit - $manager.delete_player(@player.name) - else - @player.output "That password is incorrect. You are allowed to continue existing." - end - else - @player.output "To confirm your deletion, please enter your password:" - @player.io.echo_off - @player.expect do |password| - @player.io.echo_on - event[:password] = password - Generic.deleteme(event) - end - end - end - #Write something. - def action_write(event) - object = @player.search_inv(event[:target]) - if object.nil? - @player.output "What do you wish to write on?" - return - end - if not object.info.writable - @player.output "You cannot write on #{object.name}." - return - end - @player.output "You begin to write on #{object.name}." - @player.editor(object.readable_text || [], 100) do |data| - unless data.nil? - object.readable_text = data - end - @player.output "You finish your writing." - end - end - def action_taste(event) - room = $manager.get_object(@player.container) - object = @player.search_inv(event[:target]) || room.find(event[:target]) - - if object == @player or event[:target] == "me" - @player.output "You covertly lick yourself.\nHmm, not bad." - return - elsif object.nil? - @player.output "What would you like to taste?" - return - end - event[:target] = object - event[:to_player] = "Sticking your tongue out hesitantly, you taste #{object.name}. " - if object.info.taste.nil? or object.info.taste == "" - event[:to_player] << "#{object.pronoun.capitalize} does not taste that great, but has no particular flavor." - else - event[:to_player] << object.info.taste - end - event[:to_target] = "#{@player.name} licks you, apparently in an attempt to find out your flavor." - event[:to_other] = "#{@player.name} hesitantly sticks out #{@player.pronoun(:possessive)} tongue and licks #{object.name}." - room.out_event event - end - def action_smell(event) - room = $manager.get_object(@player.container) - if event[:target].nil? - if room.info.smell - event[:to_player] = "You sniff the air. #{room.info.smell}." - else - event[:to_player] = "You sniff the air, but detect no unusual aromas." - end - event[:to_other] = "#{@player.name} sniffs the air." - room.out_event event - return - end - object = @player.search_inv(event[:target]) || room.find(event[:target]) - - if object == @player or event[:target] == "me" - event[:target] = @player - event[:to_player] = "You cautiously sniff your armpits. " - if rand > 0.6 - event[:to_player] << "Your head snaps back from the revolting stench coming from beneath your arms." - event[:to_other] = "#{@player.name} sniffs #{@player.pronoun(:possessive)} armpits, then recoils in horror." - else - event[:to_player] << "Meh, not too bad." - event[:to_other] = "#{@player.name} sniffs #{@player.pronoun(:possessive)} armpits, then shrugs, apparently unconcerned with #{@player.pronoun(:possessive)} current smell." - end - room.out_event event - return - elsif object.nil? - @player.output "What are you trying to smell?" - return - end - event[:target] = object - event[:to_player] = "Leaning in slightly, you sniff #{object.name}. " - if object.info.smell.nil? or object.info.smell == "" - event[:to_player] << "#{object.pronoun.capitalize} has no particular aroma." - else - event[:to_player] << object.info.smell - end - event[:to_target] = "#{@player.name} sniffs you curiously." - event[:to_other] = "#{@player.name} thrusts #{@player.pronoun(:possessive)} nose at #{object.name} and sniffs." - room.out_event event - end - def action_listen(event) - room = $manager.get_object(@player.container) - if event[:target].nil? - event[:target] = room - if room.info.sound - event[:to_player] = "You listen carefully. #{room.info.sound}." - else - event[:to_player] = "You listen carefully but hear nothing unusual." - end - event[:to_other] = "A look of concentration forms on #{@player.name}'s face as #{@player.pronoun} listens intently." - room.out_event event - return - end - object = @player.search_inv(event[:target]) || room.find(event[:target]) - if object == @player or event[:target] == "me" - @player.output "Listening quietly, you can faintly hear your pulse." - return - elsif object.nil? - @player.output "What would you like to listen to?" - return - end - event[:target] = object - event[:to_player] = "You bend your head towards #{object.name}. " - if object.info.sound.nil? or object.info.sound == "" - event[:to_player] << "#{object.pronoun.capitalize} emits no unusual sounds." - else - event[:to_player] << object.info.sound - end - event[:to_target] = "#{@player.name} listens to you carefully." - event[:to_other] = "#{@player.name} bends #{@player.pronoun(:possessive)} head towards #{object.name} and listens." - room.out_event event - end - def action_feel(event) - room = $manager.get_object(@player.container) - object = @player.search_inv(event[:target]) || room.find(event[:target]) - - if object == @player or event[:target] == "me" - @player.output "You feel fine." - return - elsif object.nil? - @player.output "What would you like to feel?" - return - end - event[:target] = object - event[:to_player] = "You reach out your hand and gingerly feel #{object.name}. " - if object.info.texture.nil? or object.info.texture == "" - event[:to_player] << "#{object.pronoun(:possessive).capitalize} texture is what you would expect." - else - event[:to_player] << object.info.texture - end - event[:to_target] = "#{@player.name} reaches out a hand and gingerly touches you." - event[:to_other] = "#{@player.name} reaches out #{@player.pronoun(:possessive)} hand and touches #{object.name}." - room.out_event event - end end Aethyr::Extend::HandlerRegistry.register_handler(GenericHandler) diff --git a/lib/aethyr/core/input_handlers/get.rb b/lib/aethyr/core/input_handlers/get.rb index 6bab145116d2cba6ed96fc0519298f00b97b5d96..27bea9f44b5368dd39633442f270dc84b07b2ff1 100644 --- a/lib/aethyr/core/input_handlers/get.rb +++ b/lib/aethyr/core/input_handlers/get.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/get" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -36,75 +37,16 @@ EOF super(data) case data[:input] when /^(get|grab|take)\s+((\w+|\s)*)(\s+from\s+(\w+))/i - action({ :object => $2.strip, :from => $5 }) + $manager.submit_action(Aethyr::Core::Actions::Get::GetCommand.new(@player, { :object => $2.strip, :from => $5 })) when /^(get|grab|take)\s+(.*)$/i - action({ :object => $2.strip }) + $manager.submit_action(Aethyr::Core::Actions::Get::GetCommand.new(@player, { :object => $2.strip })) end end private #Gets (or takes) an object and puts it in the player's inventory. - def action(event) - room = $manager.get_object(@player.container) - if event[:from].nil? - object = $manager.find(event[:object], room) - if object.nil? - @player.output("There is no #{event[:object]} to take.") - return - elsif not object.movable - @player.output("You cannot take #{object.name}.") - return - elsif @player.inventory.full? - @player.output("You cannot hold any more objects.") - return - end - - room.remove(object) - object.container = @player.goid - @player.inventory << object - - event[:to_player] = "You take #{object.name}." - event[:to_other] = "#{@player.name} takes #{object.name}." - room.out_event(event) - else - from = event[:from] - container = $manager.find(from, room) - @player.inventory.find(from) if container.nil? - - if container.nil? - @player.output("There is no #{from}.") - return - elsif not container.is_a? Container - @player.output("Not sure how to do that.") - return - elsif container.can? :open and container.closed? - @player.output("You will need to open it first.") - return - end - - object = $manager.find(event[:object], container) - - if object.nil? - @player.output("There is no #{event[:object]} in the #{container.name}.") - return - elsif not object.movable - @player.output("You cannot take the #{object.name}.") - return - elsif @player.inventory.full? - @player.output("You cannot hold any more objects.") - return - end - - container.remove(object) - @player.inventory.add(object) - - event[:to_player] = "You take #{object.name} from #{container.name}." - event[:to_other] = "#{@player.name} takes #{object.name} from #{container.name}." - room.out_event(event) - end - end end Aethyr::Extend::HandlerRegistry.register_handler(GetHandler) diff --git a/lib/aethyr/core/input_handlers/give.rb b/lib/aethyr/core/input_handlers/give.rb index dcd6e684b4f51163608df542ad5296cc589fc135..e1c964a97550db1b90145f1a3d3f13fb819b0915 100644 --- a/lib/aethyr/core/input_handlers/give.rb +++ b/lib/aethyr/core/input_handlers/give.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/give" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -38,47 +39,14 @@ EOF super(data) case data[:input] when /^give\s+((\w+\s*)*)\s+to\s+(\w+)/i - action({ :item => $2.strip, :to => $3 }) + $manager.submit_action(Aethyr::Core::Actions::Give::GiveCommand.new(@player, { :item => $2.strip, :to => $3 })) end end private #Gives an item to someone else. - def action(event) - room = $manager.get_object(@player.container) - item = player.inventory.find(event[:item]) - if item.nil? - if response = player.equipment.worn_or_wielded?(event[:item]) - player.output response - else - player.output "You do not seem to have a #{event[:item]} to give away." - end - - return - end - - receiver = $manager.find(event[:to], room) - - if receiver.nil? - player.output("There is no #{event[:to]}.") - return - elsif not receiver.is_a? Player and not receiver.is_a? Mobile - player.output("You cannot give anything to #{receiver.name}.") - return - end - - player.inventory.remove(item) - receiver.inventory.add(item) - - event[:target] = receiver - event[:to_player] = "You give #{item.name} to #{receiver.name}." - event[:to_target] = "#{player.name} gives you #{item.name}." - event[:to_other] = "#{player.name} gives #{item.name} to #{receiver.name}." - - room.out_event(event) - end end Aethyr::Extend::HandlerRegistry.register_handler(GiveHandler) diff --git a/lib/aethyr/core/input_handlers/help.rb b/lib/aethyr/core/input_handlers/help.rb index 8ff591043eeaa06c59644158b878f8e3fd2b4668..36672c40aaf5cc19911e39a59de1be700fed63f0 100644 --- a/lib/aethyr/core/input_handlers/help.rb +++ b/lib/aethyr/core/input_handlers/help.rb @@ -1,5 +1,5 @@ require 'aethyr/core/registry' -require 'aethyr/core/actions/commands/command_handler' +require 'aethyr/core/input_handlers/command_handler' module Aethyr module Core diff --git a/lib/aethyr/core/input_handlers/inventory.rb b/lib/aethyr/core/input_handlers/inventory.rb index 800e41fd0455dc95d4d212f11058964b2c50cae9..739379e295466c20c5afe8e3a8e7368d4cb94ef3 100644 --- a/lib/aethyr/core/input_handlers/inventory.rb +++ b/lib/aethyr/core/input_handlers/inventory.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/inventory" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -38,16 +39,14 @@ EOF super(data) case data[:input] when /^(i|inv|inventory)$/i - action({}) + $manager.submit_action(Aethyr::Core::Actions::Inventory::InventoryCommand.new(@player, {})) end end private #Shows the inventory of the player. - def action(event) - player.output(player.show_inventory) - end + end Aethyr::Extend::HandlerRegistry.register_handler(InventoryHandler) diff --git a/lib/aethyr/core/input_handlers/issue.rb b/lib/aethyr/core/input_handlers/issue.rb index cfbd1fa3f8934d595160adab7008a9d4d3b755fc..c3290652a8a5a5dcc4d4d927c12b5759b2e72646 100644 --- a/lib/aethyr/core/input_handlers/issue.rb +++ b/lib/aethyr/core/input_handlers/issue.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/issue" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -48,79 +49,20 @@ EOF super(data) case data[:input] when /^(bug|typo|idea)\s+(\d+)\s+(show|del|add|status)(\s+(.+))?$/i - action({ :itype => $1.downcase.to_sym, :issue_id => $2, :option => $3.downcase, :value => $5 }) + $manager.submit_action(Aethyr::Core::Actions::Issue::IssueCommand.new(@player, { :itype => $1.downcase.to_sym, :issue_id => $2, :option => $3.downcase, :value => $5 })) when /^(bug|typo|idea)\s+(\d+)/i - action({ :itype => $1.downcase.to_sym, :option => "show", :issue_id => $2 }) + $manager.submit_action(Aethyr::Core::Actions::Issue::IssueCommand.new(@player, { :itype => $1.downcase.to_sym, :option => "show", :issue_id => $2 })) when /^(bug|typo|idea)\s+(del|add|show|status)\s+(\d+)(\s+(.+))?/i - action({ :itype => $1.downcase.to_sym, :option => $2.downcase, :issue_id => $3, :value => $5 }) + $manager.submit_action(Aethyr::Core::Actions::Issue::IssueCommand.new(@player, { :itype => $1.downcase.to_sym, :option => $2.downcase, :issue_id => $3, :value => $5 })) when /^(bug|typo|idea)\s+(new|show|del|add|status|list)(\s+(.+))?$/i - action({ :itype => $1.downcase.to_sym, :option => $2.downcase, :value => $4 }) + $manager.submit_action(Aethyr::Core::Actions::Issue::IssueCommand.new(@player, { :itype => $1.downcase.to_sym, :option => $2.downcase, :value => $4 })) when /^(bug|typo|idea)\s+(.*)$/i - action({ :itype => $1.downcase.to_sym, :option => "new", :value => $2 }) + $manager.submit_action(Aethyr::Core::Actions::Issue::IssueCommand.new(@player, { :itype => $1.downcase.to_sym, :option => "new", :value => $2 })) end end private - def action(event) - case event[:option] - when "new" - issue = Issues.add_issue event[:itype], player.name, event[:value] - player.output "Thank you for submitting #{event[:itype]} ##{issue[:id]}." - when "add" - if not event[:issue_id] - player.output "Please specify a #{event[:itype]} number." - else - denied = Issues.check_access event[:itype], event[:issue_id], player - if denied - player.output denied - else - player.output Issues.append_issue(event[:itype], event[:issue_id], player.name, event[:value]) - end - end - when "del" - if not event[:issue_id] - player.output "Please specify a #{event[:itype]} number." - else - denied = Issues.check_access event[:itype], event[:issue_id], player - if denied - player.output denied - else - player.output Issues.delete_issue(event[:itype], event[:issue_id]) - end - end - when "list" - if player.admin - list = Issues.list_issues event[:itype] - else - list = Issues.list_issues event[:itype], player.name - end - if list.empty? - player.output "No #{event[:itype]}s to list." - else - player.output list - end - when "show" - if not event[:issue_id] - player.output "Please specify a #{event[:itype]} number." - else - denied = Issues.check_access event[:itype], event[:issue_id], player - if denied - player.output denied - else - player.output Issues.show_issue(event[:itype], event[:issue_id]) - end - end - when "status" - if not player.admin - player.output "Only administrators may change a #{event[:itype]}'s status." - elsif not event[:issue_id] - player.output "Please specify a #{event[:itype]} number." - else - player.output Issues.set_status(event[:itype], event[:issue_id], player.name, event[:value]) - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(IssueHandler) diff --git a/lib/aethyr/core/input_handlers/kick.rb b/lib/aethyr/core/input_handlers/kick.rb index 9d2de1ecaeb3f9e722e2b91d6cebfe2cd34db213..8efb03c9c5c125cef219d77d014106a70e515f9a 100644 --- a/lib/aethyr/core/input_handlers/kick.rb +++ b/lib/aethyr/core/input_handlers/kick.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/kick" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -35,52 +36,14 @@ EOF super(data) case data[:input] when /^kick$/i - kick({}) + $manager.submit_action(Aethyr::Core::Actions::Kick::KickCommand.new(@player, {})) when /^kick\s+(.*)$/i target = $1 - kick({:target => target}) + $manager.submit_action(Aethyr::Core::Actions::Kick::KickCommand.new(@player, {:target => target})) end end private - def kick(event) - - room = $manager.get_object(@player.container) - player = @player - return if not Combat.ready? player - - target = (event.target && room.find(event.target)) || room.find(player.last_target) - - if target.nil? - player.output "Who are you trying to attack?" - return - else - return unless Combat.valid_target? player, target - end - - player.last_target = target.goid - - event.target = target - - event[:to_other] = "#{player.name} kicks #{player.pronoun(:possessive)} foot out at #{target.name}." - event[:to_target] = "#{player.name} kicks #{player.pronoun(:possessive)} foot at you." - event[:to_player] = "You balance carefully and kick your foot out towards #{target.name}." - event[:blockable] = true - - player.balance = false - player.info.in_combat = true - target.info.in_combat = true - - room.out_event event - - event[:action] = :martial_hit - event[:combat_action] = :kick - event[:to_other] = "#{player.name} kicks #{target.name} with considerable violence." - event[:to_target] = "#{player.name} kicks you rather violently." - event[:to_player] = "Your kick makes good contact with #{target.name}." - - Combat.future_event event - end end Aethyr::Extend::HandlerRegistry.register_handler(KickHandler) diff --git a/lib/aethyr/core/input_handlers/locking.rb b/lib/aethyr/core/input_handlers/locking.rb index b6927faf4e8f9a7353aa7753ac9941a87fb662e0..0f2a992ebcc87240a846dca0d9983075aad36577 100644 --- a/lib/aethyr/core/input_handlers/locking.rb +++ b/lib/aethyr/core/input_handlers/locking.rb @@ -1,5 +1,7 @@ +require "aethyr/core/actions/commands/unlock" +require "aethyr/core/actions/commands/lock" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -38,114 +40,15 @@ EOF super(data) case data[:input] when /^lock\s+(.*)$/i - action_lock({ :object => $1 }) + $manager.submit_action(Aethyr::Core::Actions::Lock::LockCommand.new(@player, { :object => $1 })) when /^unlock\s+(.*)$/i - action_unlock({ :object => $1 }) + $manager.submit_action(Aethyr::Core::Actions::Unlock::UnlockCommand.new(@player, { :object => $1 })) end end private - def action_lock(event) - room = $manager.get_object(@player.container) - object = @player.search_inv(event[:object]) || room.find(event[:object]) - if object.nil? - @player.output('Lock what?') - return - elsif not object.can? :lock or not object.lockable? - @player.output('That object cannot be locked.') - return - elsif object.locked? - @player.output("#{object.name} is already locked.") - return - end - - has_key = false - object.keys.each do |key| - if @player.inventory.include? key - has_key = key - break - end - end - - if has_key or @player.admin - status = object.lock(has_key, @player.admin) - if status - event[:to_player] = "You lock #{object.name}." - event[:to_other] = "#{@player.name} locks #{object.name}." - event[:to_blind_other] = "You hear the click of a lock." - - room.out_event(event) - if object.is_a? Door and object.connected? - other_side = $manager.find object.connected_to - other_side.lock(has_key) - other_room = $manager.find other_side.container - o_event = event.dup - event[:to_other] = "#{other_side.name} locks from the other side." - event[:to_blind_other] = "You hear the click of a lock." - other_room.out_event(event) - end - else - @player.output("You are unable to lock that #{object.name}.") - end - else - @player.output("You do not have the key to that #{object.name}.") - end - end - - def action_unlock(event) - room = $manager.get_object(@player.container) - object = @player.search_inv(event[:object]) || room.find(event[:object]) - - if object.nil? - @player.output("Unlock what? #{event[:object]}?") - return - elsif not object.can? :unlock or not object.lockable? - @player.output('That object cannot be unlocked.') - return - elsif not object.locked? - @player.output("#{object.name} is already unlocked.") - return - end - - has_key = false - object.keys.each do |key| - if @player.inventory.include? key - has_key = key - break - end - end - - if has_key or @player.admin - status = object.unlock(has_key, @player.admin) - if status - event[:to_player] = "You unlock #{object.name}." - event[:to_other] = "#{@player.name} unlocks #{object.name}." - event[:to_blind_other] = "You hear the clunk of a lock." - - room.out_event(event) - - if object.is_a? Door and object.connected? - other_side = $manager.find object.connected_to - other_side.unlock(has_key) - other_room = $manager.find other_side.container - o_event = event.dup - event[:to_other] = "#{other_side.name} unlocks from the other side." - event[:to_blind_other] = "You hear the click of a lock." - other_room.out_event(event) - end - - return - else - @player.output("You are unable to unlock #{object.name}.") - return - end - else - @player.output("You do not have the key to #{object.name}.") - return - end - end end Aethyr::Extend::HandlerRegistry.register_handler(LockingHandler) diff --git a/lib/aethyr/core/input_handlers/look.rb b/lib/aethyr/core/input_handlers/look.rb index 2c53016c27c0ed2f23b501bf183404d52aac186d..085d2fe8b0c2a719e050642e34869f675ea12269 100644 --- a/lib/aethyr/core/input_handlers/look.rb +++ b/lib/aethyr/core/input_handlers/look.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/look" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -41,71 +42,15 @@ EOF super(data) case data[:input] when /^(l|look)$/i - action({}) + $manager.submit_action(Aethyr::Core::Actions::Look::LookCommand.new(@player, {})) when /^(l|look)\s+(in|inside)\s+(.*)$/i - action({ :in => $3 }) + $manager.submit_action(Aethyr::Core::Actions::Look::LookCommand.new(@player, { :in => $3 })) when /^(l|look)\s+(.*)$/i - action({ :at => $2 }) + $manager.submit_action(Aethyr::Core::Actions::Look::LookCommand.new(@player, { :at => $2 })) end end private - def action(event) - room = $manager.get_object(@player.container) - if @player.blind? - @player.output "You cannot see while you are blind." - else - if event[:at] - object = room if event[:at] == "here" - object = object || @player.search_inv(event[:at]) || room.find(event[:at]) - - if object.nil? - @player.output("Look at what, again?") - return - end - - if object.is_a? Exit - @player.output object.peer - elsif object.is_a? Room - @player.output("You are indoors.", true) if object.info.terrain.indoors - @player.output("You are underwater.", true) if object.info.terrain.underwater - @player.output("You are swimming.", true) if object.info.terrain.water - - @player.output "You are in a place called #{room.name} in #{room.area ? room.area.name : "an unknown area"}.", true - if room.area - @player.output "The area is generally #{describe_area(room.area)} and this spot is #{describe_area(room)}." - elsif room.info.terrain.room_type - @player.output "Where you are standing is considered to be #{describe_area(room)}." - else - @player.output "You are unsure about anything else concerning the area." - end - elsif @player == object - @player.output "You look over yourself and see:\n#{@player.instance_variable_get("@long_desc")}", true - @player.output object.show_inventory - else - @player.output object.long_desc - end - elsif event[:in] - object = room.find(event[:in]) - object = @player.inventory.find(event[:in]) if object.nil? - - if object.nil? - @player.output("Look inside what?") - elsif not object.can? :look_inside - @player.output("You cannot look inside that.") - else - object.look_inside(event) - end - else - if not room.nil? - look_text = room.look(@player) - @player.output(look_text) - else - @player.output "Nothing to look at." - end - end - end - end def describe_area(object) if object.is_a? Room diff --git a/lib/aethyr/core/input_handlers/map.rb b/lib/aethyr/core/input_handlers/map.rb index d50dea1a9328e2ed2fe5998e536155a1ec3f3649..daf9d5431b930559832250023eaf22ac6fbd4c8c 100644 --- a/lib/aethyr/core/input_handlers/map.rb +++ b/lib/aethyr/core/input_handlers/map.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/map" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -35,15 +36,12 @@ EOF super(data) case data[:input] when /^(m|map)$/i - action({}) + $manager.submit_action(Aethyr::Core::Actions::Map::MapCommand.new(@player, {})) end end private - def action(event) - room = $manager.get_object(@player.container) - player.output(room.area.render_map(player, room.area.position(room))) - end + end Aethyr::Extend::HandlerRegistry.register_handler(MapHandler) diff --git a/lib/aethyr/core/input_handlers/more.rb b/lib/aethyr/core/input_handlers/more.rb index d7a8d9a4e5e086b4b0d5b848918c80466a77799d..73bec9ebda6e99a3a8081cb1518d6abe695bd33c 100644 --- a/lib/aethyr/core/input_handlers/more.rb +++ b/lib/aethyr/core/input_handlers/more.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/more" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -38,14 +39,12 @@ EOF super(data) case data[:input] when /^more/i - action({}) + $manager.submit_action(Aethyr::Core::Actions::More::MoreCommand.new(@player, {})) end end private - def action(event) - player.more - end + end Aethyr::Extend::HandlerRegistry.register_handler(MoreHandler) diff --git a/lib/aethyr/core/input_handlers/move.rb b/lib/aethyr/core/input_handlers/move.rb index 139db045d9e1ad669bf184f82b4343cd374e36cb..0f0a5fe43192569830929865551127f5af21aafe 100644 --- a/lib/aethyr/core/input_handlers/move.rb +++ b/lib/aethyr/core/input_handlers/move.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/move" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" require "aethyr/core/util/direction" module Aethyr @@ -46,7 +47,7 @@ EOF super(data) case data[:input] when /^go\s+(.*)$/i - action({:direction => $1.downcase}) + $manager.submit_action(Aethyr::Core::Actions::Move::MoveCommand.new(@player, {:direction => $1.downcase})) when /^(east|west|northeast|northwest|north|southeast|southwest|south|e|w|nw|ne|sw|se|n|s|up|down|u|d|in|out)(\s+\((.*)\))?$/i action({:direction => expand_direction($1), :pre => $3}) @@ -54,37 +55,7 @@ EOF end private - def action(event) - room = $manager.get_object(@player.container) - exit = room.exit(event[:direction]) - - if exit.nil? - @player.output("You cannot go #{event[:direction]}.") - return - elsif exit.can? :open and not exit.open? - @player.output("That exit is closed. Perhaps you should open it?") - return - end - - new_room = $manager.find(exit.exit_room) - if new_room.nil? - @player.output("That exit #{exit.name} leads into the void.") - return - end - - room.remove(@player) - new_room.add(@player) - @player.container = new_room.game_object_id - event[:to_player] = "You move #{event[:direction]}." - event[:to_other] = "#{@player.name} leaves #{event[:direction]}." - event[:to_blind_other] = "You hear someone leave." - - room.out_event(event) - look_text = new_room.look(player) - out_text = Window.split_message(look_text, 79).join("\n") - @player.output(out_text, message_type: :look, internal_clear: true) - end end Aethyr::Extend::HandlerRegistry.register_handler(MoveHandler) diff --git a/lib/aethyr/core/input_handlers/news.rb b/lib/aethyr/core/input_handlers/news.rb index 7e6eb456cbfe49380cc40a77a5bb6b063d7dd7a8..e350a14be2d6b309aa3cb7c8d812333f6694b032 100644 --- a/lib/aethyr/core/input_handlers/news.rb +++ b/lib/aethyr/core/input_handlers/news.rb @@ -1,5 +1,11 @@ +require "aethyr/core/actions/commands/all" +require "aethyr/core/actions/commands/delete_post" +require "aethyr/core/actions/commands/list_unread" +require "aethyr/core/actions/commands/write_post" +require "aethyr/core/actions/commands/read_post" +require "aethyr/core/actions/commands/latest_news" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -62,164 +68,34 @@ EOF super(data) case data[:input] when "news" - latest_news({}) + $manager.submit_action(Aethyr::Core::Actions::LatestNews::LatestNewsCommand.new(@player, {})) when /^news\s+(read\s+)?(\d+)$/i post_id = $2 - read_post({:post_id => post_id}) + $manager.submit_action(Aethyr::Core::Actions::ReadPost::ReadPostCommand.new(@player, {:post_id => post_id})) when /^news\s+reply(\s+to\s+)?\s+(\d+)$/i reply_to = $2 - write_post({:reply_to => reply_to}) + $manager.submit_action(Aethyr::Core::Actions::WritePost::WritePostCommand.new(@player, {:reply_to => reply_to})) when /^news\s+unread/i - list_unread({}) + $manager.submit_action(Aethyr::Core::Actions::ListUnread::ListUnreadCommand.new(@player, {})) when /^news\s+last\s+(\d+)/i limit = $1.to_i - latest_news({:limit => limit}) + $manager.submit_action(Aethyr::Core::Actions::LatestNews::LatestNewsCommand.new(@player, {:limit => limit})) when /^news\s+delete\s+(\d+)/i post_id = $1 - delete_post({:post_id => post_id}) + $manager.submit_action(Aethyr::Core::Actions::DeletePost::DeletePostCommand.new(@player, {:post_id => post_id})) when /^news\s+write$/i - write_post({}) + $manager.submit_action(Aethyr::Core::Actions::WritePost::WritePostCommand.new(@player, {})) when /^news\s+all/i - all({}) + $manager.submit_action(Aethyr::Core::Actions::All::AllCommand.new(@player, {})) end end private - def latest_news(event) - room = $manager.get_object(@player.container) - player = @player - board = find_board(event, room) - if board.nil? - player.output "There do not seem to be any postings here." - return - end - - if not board.is_a? Newsboard - log board.class - end - - offset = event[:offset] || 0 - wordwrap = player.word_wrap || 100 - limit = event[:limit] || player.page_height - - player.output board.list_latest(wordwrap, offset, limit) - end - - def read_post(event) - - room = $manager.get_object(@player.container) - player = @player - board = find_board(event, room) - - if board.nil? - player.output "There do not seem to be any postings here." - return - end - - post = board.get_post event[:post_id] - if post.nil? - player.output "No such posting here." - return - end - - if player.info.boards.nil? - player.info.boards = {} - end - - player.info.boards[board.goid] = event[:post_id].to_i - - player.output board.show_post(post, player.word_wrap || 80) - end - - def write_post(event) - - room = $manager.get_object(@player.container) - player = @player - board = find_board(event, room) - - if board.nil? - player.output "There do not seem to be any postings here." - return - end - - player.output("What is the subject of this post?", true) - - player.expect do |subj| - player.editor do |message| - unless message.nil? - post_id = board.save_post(player, subj, event[:reply_to], message) - player.output "You have written post ##{post_id}." - if board.announce_new - area = $manager.get_object(board.container).area - area.output board.announce_new - end - end - end - end - end - def list_unread(event) - room = $manager.get_object(@player.container) - player = @player - board = find_board(event, room) - if board.nil? - player.output "There do not seem to be any postings here." - return - end - - if player.info.boards.nil? - player.info.boards = {} - end - - player.output board.list_since(player.info.boards[board.goid], player.word_wrap) - end - - def delete_post(event) - - room = $manager.get_object(@player.container) - player = @player - - - - - board = find_board(event, room) - - if board.nil? - player.output "What newsboard are you talking about?" - return - end - - post = board.get_post event[:post_id] - - if post.nil? - player.output "No such post." - elsif post[:author] != player.name - player.output "You can only delete your own posts." - else - board.delete_post event[:post_id] - player.output "Deleted post ##{event[:post_id]}" - end - end - - def all(event) - - room = $manager.get_object(@player.container) - player = @player - board = find_board(event, room) - - if board.nil? - player.output "There do not seem to be any postings here." - return - end - - wordwrap = player.word_wrap || 100 - - player.output board.list_latest(wordwrap, 0, nil) - end end Aethyr::Extend::HandlerRegistry.register_handler(NewsHandler) diff --git a/lib/aethyr/core/input_handlers/open.rb b/lib/aethyr/core/input_handlers/open.rb index 59e381e0fc3a24393051bbf4b6233b363212a497..db71a41cafcf713874268941024fce285e9f4ca5 100644 --- a/lib/aethyr/core/input_handlers/open.rb +++ b/lib/aethyr/core/input_handlers/open.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/open" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" require "aethyr/core/util/direction" module Aethyr @@ -45,24 +46,12 @@ EOF super(data) case data[:input] when /^open\s+(\w+)$/i - action({ :object => $1 }) + $manager.submit_action(Aethyr::Core::Actions::Open::OpenCommand.new(@player, { :object => $1 })) end end private - def action(event) - room = $manager.get_object(@player.container) - object = expand_direction(event[:object]) - object = player.search_inv(object) || $manager.find(object, room) - - if object.nil? - player.output("Open what?") - elsif not object.can? :open - player.output("You cannot open #{object.name}.") - else - object.open(event) - end - end + end Aethyr::Extend::HandlerRegistry.register_handler(OpenHandler) diff --git a/lib/aethyr/core/input_handlers/portal.rb b/lib/aethyr/core/input_handlers/portal.rb index 0bf04890b59091a9f7ab2ae824a0d439d3e49643..a935b9aeca42e96d2e4efa3e48b0509cf8111644 100644 --- a/lib/aethyr/core/input_handlers/portal.rb +++ b/lib/aethyr/core/input_handlers/portal.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/portal" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -38,72 +39,11 @@ EOF object = $1 setting = $2.downcase value = $3.strip - portal({:object => object, :setting => setting, :value => value}) + $manager.submit_action(Aethyr::Core::Actions::Portal::PortalCommand.new(@player, {:object => object, :setting => setting, :value => value})) end end private - def portal(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:object], event) - if object.nil? - player.output "Cannot find #{event[:object]}" - return - elsif not object.is_a? Portal - player.output "That is not a portal." - return - end - - value = event[:value] - - case event[:setting] - when "action" - value.downcase! - if value == "enter" - object.info.delete :portal_action - player.output "Set portal action to enter" - elsif ["jump", "climb", "crawl"].include? value - object.info.portal_action = value.downcase.to_sym - player.output "Set portal action to #{value}" - else - player.output "#{value} is not a valid portal action." - end - when "exit" - if value.downcase == "!nothing" or value.downcase == "nil" - object.info.delete :exit_message - else - if value[-1,1] !~ /[!.?"']/ - value << "." - end - object.info.exit_message = value - end - player.output "#{object.name} exit message set to: #{object.info.exit_message}" - when "entrance" - if value.downcase == "!nothing" or value.downcase == "nil" - object.info.delete :entrance_message - else - if value[-1,1] !~ /[!.?"']/ - value << "." - end - object.info.entrance_message = value - end - player.output "#{object.name} entrance message set to: #{object.info.entrance_message}" - when "portal" - if value.downcase == "!nothing" or value.downcase == "nil" - object.info.delete :portal_message - else - if value[-1,1] !~ /[!.?"']/ - value << "." - end - object.info.portal_message = value - end - player.output "#{object.name} portal message set to: #{object.info.portal_message}" - else - player.output "Valid options: action, exit, entrance, or portal." - end - end end Aethyr::Extend::HandlerRegistry.register_handler(PortalHandler) diff --git a/lib/aethyr/core/input_handlers/pose.rb b/lib/aethyr/core/input_handlers/pose.rb index 476d37f65b60340b6750da6b7a9f66b924360677..de0e113d2c072b0cacf3f1d4dab0e1821cf11cea 100644 --- a/lib/aethyr/core/input_handlers/pose.rb +++ b/lib/aethyr/core/input_handlers/pose.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/pose" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -36,23 +37,11 @@ EOF case data[:input] when /^pose\s+(.*)$/i pose = $1.strip - pose({:pose => pose}) + $manager.submit_action(Aethyr::Core::Actions::Pose::PoseCommand.new(@player, {:pose => pose})) end end private - def pose(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:pose].downcase == "none" - player.pose = nil - player.output "You are no longer posing." - else - player.pose = event[:pose] - player.output "Your pose is now: #{event[:pose]}." - end - end end Aethyr::Extend::HandlerRegistry.register_handler(PoseHandler) diff --git a/lib/aethyr/core/input_handlers/punch.rb b/lib/aethyr/core/input_handlers/punch.rb index 7239c5bff5261cab45dc566ad3bd7d5da969256a..b9f4d99acd3f1ded701e416e2f0d25af98f410e6 100644 --- a/lib/aethyr/core/input_handlers/punch.rb +++ b/lib/aethyr/core/input_handlers/punch.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/punch" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -35,52 +36,14 @@ EOF super(data) case data[:input] when /^punch$/i - punch({}) + $manager.submit_action(Aethyr::Core::Actions::Punch::PunchCommand.new(@player, {})) when /^punch\s+(.*)$/i target = $1 - punch({:target => target}) + $manager.submit_action(Aethyr::Core::Actions::Punch::PunchCommand.new(@player, {:target => target})) end end private - def punch(event) - - room = $manager.get_object(@player.container) - player = @player - return unless Combat.ready? player - - target = (event.target && room.find(event.target)) || room.find(player.last_target) - - if target.nil? - player.output "Who are you trying to attack?" - return - else - return unless Combat.valid_target? player, target - end - - player.last_target = target.goid - - event.target = target - - event[:to_other] = "#{player.name} swings #{player.pronoun(:possessive)} clenched fist at #{target.name}." - event[:to_target] = "#{player.name} swings #{player.pronoun(:possessive)} fist straight towards your face." - event[:to_player] = "You clench your hand into a fist and swing it at #{target.name}." - event[:blockable] = true - - player.balance = false - player.info.in_combat = true - target.info.in_combat = true - - room.out_event event - - event[:action] = :martial_hit - event[:combat_action] = :punch - event[:to_other] = "#{player.name} punches #{target.name} directly in the face." - event[:to_target] = "You stagger slightly as #{player.name} punches you in the face." - event[:to_player] = "Your fist lands squarely in #{target.name}'s face." - - Combat.future_event event - end end Aethyr::Extend::HandlerRegistry.register_handler(PunchHandler) diff --git a/lib/aethyr/core/input_handlers/put.rb b/lib/aethyr/core/input_handlers/put.rb index c828ecad48cd53cd7fe6af02d87836a6f5c9032c..f58fb04759d253204d295a0d147ae94f4db27445 100644 --- a/lib/aethyr/core/input_handlers/put.rb +++ b/lib/aethyr/core/input_handlers/put.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/put" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -36,46 +37,12 @@ EOF super(data) case data[:input] when /^put((\s+(\d+)\s+)|\s+)(\w+)\s+in\s+(\w+)$/i - action({ :item => $4, :count => $3.to_i, :container => $5 }) + $manager.submit_action(Aethyr::Core::Actions::Put::PutCommand.new(@player, { :item => $4, :count => $3.to_i, :container => $5 })) end end private - def action(event) - room = $manager.get_object(@player.container) - item = @player.inventory.find(event[:item]) - if item.nil? - if response = @player.equipment.worn_or_wielded?(event[:item]) - @player.output response - else - @player.output "You do not seem to have a #{event[:item]}." - end - - return - end - - container = @player.search_inv(event[:container]) || $manager.find(event[:container], room) - - if container.nil? - @player.output("There is no #{event[:container]} in which to put #{item.name}.") - return - elsif not container.is_a? Container - @player.output("You cannot put anything in #{container.name}.") - return - elsif container.can? :open and container.closed? - @player.output("You need to open #{container.name} first.") - return - end - - @player.inventory.remove(item) - container.add(item) - - event[:to_player] = "You put #{item.name} in #{container.name}." - event[:to_other] = "#{@player.name} puts #{item.name} in #{container.name}" - - room.out_event(event) - end end Aethyr::Extend::HandlerRegistry.register_handler(PutHandler) diff --git a/lib/aethyr/core/input_handlers/quit.rb b/lib/aethyr/core/input_handlers/quit.rb index 1810271b0ae4370b8acc27e0db0a5639ab8b0f15..cf2e25f6dbfff35f51b71594292faf1b63a9bba2 100644 --- a/lib/aethyr/core/input_handlers/quit.rb +++ b/lib/aethyr/core/input_handlers/quit.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/quit" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -37,15 +38,13 @@ EOF def player_input(data) case data[:input] when /^quit$/i - action({}) + $manager.submit_action(Aethyr::Core::Actions::Quit::QuitCommand.new(@player, {})) end end private - def action(event) - $manager.drop_player player - end + end Aethyr::Extend::HandlerRegistry.register_handler(QuitHandler) diff --git a/lib/aethyr/core/input_handlers/remove.rb b/lib/aethyr/core/input_handlers/remove.rb index a1fff5d7333a6ce949fb28e7e1e801fe2d03ed8f..3a65d45e8daae3de3cbccf2598ef46ac5fbc82c7 100644 --- a/lib/aethyr/core/input_handlers/remove.rb +++ b/lib/aethyr/core/input_handlers/remove.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/remove" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -38,43 +39,11 @@ EOF when /^remove\s+(\w+)(\s+from\s+(.*))?$/i object = $1 position = $3 - remove({:object => object, :position => position}) + $manager.submit_action(Aethyr::Core::Actions::Remove::RemoveCommand.new(@player, {:object => object, :position => position})) end end private - def remove(event) - - room = $manager.get_object(@player.container) - player = @player - - object = player.equipment.find(event[:object]) - - if object.nil? - player.output("What #{event[:object]} are you trying to remove?") - return - end - - if player.inventory.full? - player.output("There is no room in your inventory.") - return - end - - if object.is_a? Weapon - player.output("You must unwield weapons.") - return - end - - response = player.remove(object, event[:position]) - - if response - event[:to_player] = "You remove #{object.name}." - event[:to_other] = "#{player.name} removes #{object.name}." - room.out_event(event) - else - player.output "Could not remove #{object.name} for some reason." - end - end end Aethyr::Extend::HandlerRegistry.register_handler(RemoveHandler) diff --git a/lib/aethyr/core/input_handlers/say.rb b/lib/aethyr/core/input_handlers/say.rb index 28ee3b7ba76f6320ca939e05acecf561e02c3672..e65ba73154c880edda3ba103b5078721252bd581 100644 --- a/lib/aethyr/core/input_handlers/say.rb +++ b/lib/aethyr/core/input_handlers/say.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/say" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -70,111 +71,16 @@ EOF super(data) case data[:input] when /^say\s+(\((.*?)\)\s*)?(.*)$/i - action({ :phrase => $3, :pre => $2 }) + $manager.submit_action(Aethyr::Core::Actions::Say::SayCommand.new(@player, { :phrase => $3, :pre => $2 })) when /^sayto\s+(\w+)\s+(\((.*?)\)\s*)?(.*)$/i - action({:target => $1, :phrase => $4, :pre => $3 }) + $manager.submit_action(Aethyr::Core::Actions::Say::SayCommand.new(@player, {:target => $1, :phrase => $4, :pre => $3 })) end end private #Says something to the room or to a specific player. - def action(event) - room = $manager.get_object(@player.container) - phrase = event[:phrase] - target = event[:target] && room.find(event[:target]) - prefix = event[:pre] - - if prefix - prefix << ", " - else - prefix = "" - end - - if phrase.nil? - @player.output("Huh?") - return - elsif event[:target] and target.nil? - @player.output("Say what to whom?") - return - elsif target and target == @player - @player.output "Talking to yourself again?" - return - elsif target - to_clause = " to #{target.name}" - ask_clause = " #{target.name}" - else - to_clause = "" - ask_clause = "" - end - - phrase[0,1] = phrase[0,1].capitalize - phrase.gsub!(/(\s|^|\W)(i)(\s|$|\W)/) { |match| match.sub('i', 'I') } - - case phrase - when /:\)$/ - rvoice = "smiles and " - pvoice = "smile and " - when /:\($/ - rvoice = "frowns and " - pvoice = "frown and " - when /:D$/ - rvoice = "laughs as #{@player.pronoun} " - pvoice = "laugh as you " - else - rvoice = "" - pvoice = "" - end - - phrase = phrase.gsub(/\s*(:\)|:\()|:D/, '').strip.gsub(/\s{2,}/, ' ') - - case phrase[-1..-1] - when "!" - pvoice += "exclaim" - rvoice += "exclaims" - when "?" - pvoice += "ask" - rvoice += "asks" - when "." - pvoice += "say" - rvoice += "says" - else - pvoice += "say" - rvoice += "says" - ender = "." - end - - phrase = "<say>\"#{phrase}#{ender}\"</say>" - - event[:message_type] = :chat - event[:target] = target - if target and pvoice == "ask" - event[:to_target] = prefix + "#{@player.name} #{rvoice} you, #{phrase}" - event[:to_player] = prefix + "you #{pvoice} #{target.name}, #{phrase}" - event[:to_other] = prefix + "#{@player.name} #{rvoice} #{target.name}, #{phrase}" - event[:to_blind_target] = "Someone asks, #{phrase}" - event[:to_blind_other] = "Someone asks, #{phrase}" - event[:to_deaf_target] = "#{@player.name} seems to be asking you something." - event[:to_deaf_other] = "#{@player.name} seems to be asking #{target.name} something." - elsif target - event[:to_target] = prefix + "#{@player.name} #{rvoice} to you, #{phrase}" - event[:to_player] = prefix + "you #{pvoice} to #{target.name}, #{phrase}" - event[:to_other] = prefix + "#{@player.name} #{rvoice} to #{target.name}, #{phrase}" - event[:to_blind_target] = "Someone #{rvoice}, #{phrase}" - event[:to_blind_other] = "Someone #{rvoice}, #{phrase}" - event[:to_deaf_target] = "You see #{@player.name} say something to you." - event[:to_deaf_other] = "You see #{@player.name} say something to #{target.name}." - else - event[:to_player] = prefix + "you #{pvoice}, #{phrase}" - event[:to_other] = prefix + "#{@player.name} #{rvoice}, #{phrase}" - event[:to_blind_other] = "Someone #{rvoice}, #{phrase}" - event[:to_deaf_target] = "You see #{@player.name} say something." - event[:to_deaf_other] = "You see #{@player.name} say something." - end - - room.out_event(event) - end end Aethyr::Extend::HandlerRegistry.register_handler(SayHandler) diff --git a/lib/aethyr/core/input_handlers/set.rb b/lib/aethyr/core/input_handlers/set.rb index 7763a05db11d5b23e897f76090cdd653adf2d577..f4d125a18a644a4a80533de7c257e0004b3abb47 100644 --- a/lib/aethyr/core/input_handlers/set.rb +++ b/lib/aethyr/core/input_handlers/set.rb @@ -1,5 +1,9 @@ +require "aethyr/core/actions/commands/setpassword" +require "aethyr/core/actions/commands/set" +require "aethyr/core/actions/commands/showcolors" +require "aethyr/core/actions/commands/setcolor" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -48,164 +52,26 @@ EOF case data[:input] when /^set\s+colors?\s+(on|off|default)$/i option = $1 - setcolor({:option => option}) + $manager.submit_action(Aethyr::Core::Actions::Setcolor::SetcolorCommand.new(@player, {:option => option})) when /^set\s+colors?.*/i - showcolors({}) + $manager.submit_action(Aethyr::Core::Actions::Showcolors::ShowcolorsCommand.new(@player, {})) when /^set\s+(\w+)\s*(.*)$/i setting = $1.strip value = $2.strip if $2 - set({:setting => setting, :value => value}) + $manager.submit_action(Aethyr::Core::Actions::Set::SetCommand.new(@player, {:setting => setting, :value => value})) when /^set\s+colors?\s+(\w+)\s+(.+)$/i option = $1 color = $2 - setcolor({:option => option, :color => color}) + $manager.submit_action(Aethyr::Core::Actions::Setcolor::SetcolorCommand.new(@player, {:option => option, :color => color})) when /^set\s+password$/i - setpassword({}) + $manager.submit_action(Aethyr::Core::Actions::Setpassword::SetpasswordCommand.new(@player, {})) end end private - def setcolor(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:option] == "off" - player.io.use_color = false - player.output "Colors disabled." - elsif event[:option] == "on" - player.io.use_color = true - player.output "Colors enabled." - elsif event[:option] == "default" - player.io.to_default - player.output "Colors set to defaults." - else - player.output player.io.set_color(event[:option], event[:color]) - end - end - def showcolors(event) - - room = $manager.get_object(@player.container) - player = @player - player.output player.io.display.show_color_config - end - def set(event) - - room = $manager.get_object(@player.container) - player = @player - event[:setting].downcase! - case event[:setting] - when 'wordwrap' - value = event[:value] - if player.word_wrap.nil? - player.output("Word wrap is currently off.", true) - else - player.output("Word wrap currently set to #{player.word_wrap}.", true) - end - - if value.nil? - player.output "Please specify 'off' or a value between 10 - 200." - return - elsif value.downcase == 'off' - player.word_wrap = nil - player.output "Word wrap is now disabled." - return - else - value = value.to_i - if value > 200 or value < 10 - player.output "Please use a value between 10 - 200." - return - else - player.word_wrap = value - player.output "Word wrap is now set to: #{value} characters." - return - end - end - when 'pagelength', "page_length" - value = event[:value] - if player.page_height.nil? - player.output("Pagination is currently off.", true) - else - player.output("Page length is currently set to #{player.page_height}.", true) - end - - if value.nil? - player.output "Please specify 'off' or a value between 1 - 200." - return - elsif value.downcase == 'off' - player.page_height = nil - player.output "Output will no longer be paginated." - return - else - value = value.to_i - if value > 200 or value < 1 - player.output "Please use a value between 1 - 200." - return - else - player.page_height = value - player.output "Page length is now set to: #{value} lines." - return - end - - end - when "desc", "description" - player.editor(player.instance_variable_get(:@long_desc) || [], 10) do |data| - unless data.nil? - player.long_desc = data.strip - end - player.output("Set description to:\r\n#{player.long_desc}") - end - when "layout" - case event[:value].downcase - when "basic" - player.layout = :basic - when "partial" - player.layout = :partial - when "full" - player.layout = :full - when "wide" - player.layout = :wide - else - player.output "#{value} is not a valid layout please set one of the following: basic, partial, full, wide." - end - else - player.output "No such setting: #{event[:setting]}" - end - end - def setpassword(event) - - room = $manager.get_object(@player.container) - player = @player - if event[:new_password] - if event[:new_password] !~ /^\w{6,20}$/ - player.output "Please only use letters and numbers. Password should be between 6 and 20 characters long." - return - else - $manager.set_password(player, event[:new_password]) - player.output "Your password has been changed." - end - else - player.output "Please enter your current password:", true - player.io.echo_off - player.expect do |password| - if $manager.check_password(player.name, password) - player.output "Please enter your new password:", true - player.io.echo_off - player.expect do |password| - player.io.echo_on - event[:new_password] = password - Settings.setpassword(event, player, room) - end - else - player.output "Sorry, that password is invalid." - player.io.echo_on - end - - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(SetHandler) diff --git a/lib/aethyr/core/input_handlers/sit.rb b/lib/aethyr/core/input_handlers/sit.rb index 862edefcf6c9fa65d2087fa21cbdc0f139569f52..f8912e7eac5fa1838893b033e99e7d0fcd535133 100644 --- a/lib/aethyr/core/input_handlers/sit.rb +++ b/lib/aethyr/core/input_handlers/sit.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/sit" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -43,56 +44,11 @@ EOF case data[:input] when /^sit\s+on\s+(.*)$/i, /^sit\s+(.*)$/i, /^sit$/i object = $1.strip if $1 - sit({:object => object}) + $manager.submit_action(Aethyr::Core::Actions::Sit::SitCommand.new(@player, {:object => object})) end end private - def sit(event) - - room = $manager.get_object(@player.container) - player = @player - if not player.balance - player.output "You cannot sit properly while unbalanced." - return - elsif event[:object].nil? - if player.sitting? - player.output('You are already sitting down.') - elsif player.prone? and player.sit - event[:to_player] = 'You stand up then sit on the ground.' - event[:to_other] = "#{player.name} stands up then sits down on the ground." - event[:to_deaf_other] = event[:to_other] - room.output(event) - elsif player.sit - event[:to_player] = 'You sit down on the ground.' - event[:to_other] = "#{player.name} sits down on the ground." - event[:to_deaf_other] = event[:to_other] - room.out_event(event) - else - player.output('You are unable to sit down.') - end - else - object = $manager.find(event[:object], player.room) - - if object.nil? - player.output('What do you want to sit on?') - elsif not object.can? :sittable? - player.output("You cannot sit on #{object.name}.") - elsif object.occupied_by? player - player.output("You are already sitting there!") - elsif not object.has_room? - player.output("The #{object.generic} #{object.plural? ? "are" : "is"} already occupied.") - elsif player.sit(object) - object.sat_on_by(player) - event[:to_player] = "You sit down on #{object.name}." - event[:to_other] = "#{player.name} sits down on #{object.name}." - event[:to_deaf_other] = event[:to_other] - room.out_event(event) - else - player.output('You are unable to sit down.') - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(SitHandler) diff --git a/lib/aethyr/core/input_handlers/skills.rb b/lib/aethyr/core/input_handlers/skills.rb index 351212e588af041369793306f6f2b0c175ad520c..7c7d945e1b716122259fde63c8413a088a1bb2ed 100644 --- a/lib/aethyr/core/input_handlers/skills.rb +++ b/lib/aethyr/core/input_handlers/skills.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/skills" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" require 'aethyr/core/render/text_util' include TextUtil @@ -37,56 +38,12 @@ EOF super(data) case data[:input] when /^skills$/i - action({}) + $manager.submit_action(Aethyr::Core::Actions::Skills::SkillsCommand.new(@player, {})) end end private - def action(event) - box_width = 25 - box_work_width = box_width - 2 - width = @player.word_wrap - width = 200 if @player.word_wrap.nil? - boxes_per_row = width / box_width - box_top = "┌" + ("─" * box_work_width) + "â”\n" - box_bottom = "â””" + ("─" * box_work_width) + "┘\n" - - output = "" - text_format = "%-#{box_work_width}.#{box_work_width}s" - text_format_right = "%#{box_work_width}.#{box_work_width}s" - @player.info.skills.each do |id, skill| - - output += box_top - - level_width = box_work_width - skill.name.length - level_format = "%#{level_width}.#{level_width}s" - level = "lv #{skill.level}" - title = "#{skill.name}#{level_format % level}" - output += "│<raw fg:white>#{title}</raw fg:white>│\n" - - desc_lines = wrap(skill.help_desc, box_work_width) - desc_lines.each do |line| - output += "│#{text_format % line}│\n" - end - - output += "│#{text_format_right % ''}│\n" - - output += "│#{SkillsHandler::generate_progress(box_work_width, skill.level_percentage)}│\n" - - xp_left = "#{skill.xp_to_go} xp to next" - output += "│#{text_format_right % xp_left}│\n" - - xp_total = "#{skill.xp} xp total" - output += "│#{text_format_right % xp_total}│\n" - - xp_frac = "#{skill.xp_so_far} / #{skill.xp_per_level} xp" - output += "│#{text_format_right % xp_frac}│\n" - - output += box_bottom + "\n" - end - @player.output(output) - end def self.generate_progress(width, percentage, style = :vertical_smooth) if (style.eql? :horizontal_smooth) or (style.eql? :vertical_smooth) working_space = width - 7 diff --git a/lib/aethyr/core/input_handlers/slash.rb b/lib/aethyr/core/input_handlers/slash.rb index 42362896067fddf3d20c8c68a23c186341085d70..df0862a9d812e559e92f4b302b65e3903b8fb706 100644 --- a/lib/aethyr/core/input_handlers/slash.rb +++ b/lib/aethyr/core/input_handlers/slash.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/slash" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -35,61 +36,14 @@ EOF super(data) case data[:input] when /^slash$/i - slash({}) + $manager.submit_action(Aethyr::Core::Actions::Slash::SlashCommand.new(@player, {})) when /^slash\s+(.*)$/i target = $1 - slash({:target => target}) + $manager.submit_action(Aethyr::Core::Actions::Slash::SlashCommand.new(@player, {:target => target})) end end private - def slash(event) - - room = $manager.get_object(@player.container) - player = @player - - return if not Combat.ready? player - - weapon = get_weapon(player, :slash) - if weapon.nil? - player.output "You are not wielding a weapon you can slash with." - return - end - - target = (event.target && room.find(event.target)) || room.find(player.last_target) - - if target.nil? - player.output "Who are you trying to attack?" - return - else - return unless Combat.valid_target? player, target - end - - player.last_target = target.goid - - event.target = target - - event[:to_other] = "#{weapon.name} flashes as #{player.name} swings it at #{target.name}." - event[:to_target] = "#{weapon.name} flashes as #{player.name} swings it towards you." - event[:to_player] = "#{weapon.name} flashes as you swing it towards #{target.name}." - event[:attack_weapon] = weapon - event[:blockable] = true - - player.balance = false - player.info.in_combat = true - target.info.in_combat = true - - room.out_event event - - event[:action] = :weapon_hit - event[:combat_action] = :slash - event[:to_other] = "#{player.name} slashes across #{target.name}'s torso with #{weapon.name}." - event[:to_target] = "#{player.name} slashes across your torso with #{weapon.name}." - event[:to_player] = "You slash across #{target.name}'s torso with #{weapon.name}." - - Combat.future_event event - - end end Aethyr::Extend::HandlerRegistry.register_handler(SlashHandler) diff --git a/lib/aethyr/core/input_handlers/stand.rb b/lib/aethyr/core/input_handlers/stand.rb index 49dee43979b1cd5c6d95bc79ca80823b29ce8a93..963178da94b4556fb4f1635a6eb07a05d2a076f4 100644 --- a/lib/aethyr/core/input_handlers/stand.rb +++ b/lib/aethyr/core/input_handlers/stand.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/stand" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -36,39 +37,11 @@ EOF super(data) case data[:input] when /^stand$/i - stand({}) + $manager.submit_action(Aethyr::Core::Actions::Stand::StandCommand.new(@player, {})) end end private - def stand(event) - - room = $manager.get_object(@player.container) - player = @player - if not player.prone? - player.output('You are already on your feet.') - return - elsif not player.balance - player.output "You cannot stand while unbalanced." - return - end - - if player.sitting? - object = $manager.find(player.sitting_on, room) - else - object = $manager.find(player.lying_on, room) - end - - if player.stand - event[:to_player] = 'You rise to your feet.' - event[:to_other] = "#{player.name} stands up." - event[:to_deaf_other] = event[:to_other] - room.out_event(event) - object.evacuated_by(player) unless object.nil? - else - player.output('You are unable to stand up.') - end - end end Aethyr::Extend::HandlerRegistry.register_handler(StandHandler) diff --git a/lib/aethyr/core/input_handlers/tell.rb b/lib/aethyr/core/input_handlers/tell.rb index c90cab0ec6f2a2aebcf6e607836e94b561135e89..807c901695907d2a8b4f423fd7160e871194e91d 100644 --- a/lib/aethyr/core/input_handlers/tell.rb +++ b/lib/aethyr/core/input_handlers/tell.rb @@ -1,5 +1,7 @@ +require "aethyr/core/actions/commands/reply" +require "aethyr/core/actions/commands/tell" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -51,54 +53,17 @@ EOF super(data) case data[:input] when /^tell\s+(\w+)\s+(.*)$/i - action_tell({:target => $1, :message => $2 }) + $manager.submit_action(Aethyr::Core::Actions::Tell::TellCommand.new(@player, {:target => $1, :message => $2 })) when /^reply\s+(.*)$/i - action_reply({:message => $1 }) + $manager.submit_action(Aethyr::Core::Actions::Reply::ReplyCommand.new(@player, {:message => $1 })) end end private #Tells someone something. - def action_tell(event) - target = $manager.find event[:target] - unless target and target.is_a? Player - @player.output "That person is not available." - return - end - - if target == @player - @player.output "Talking to yourself?" - return - end - - phrase = event[:message] - - last_char = phrase[-1..-1] - - unless ["!", "?", "."].include? last_char - phrase << "." - end - phrase[0,1] = phrase[0,1].upcase - phrase = phrase.strip.gsub(/\s{2,}/, ' ') - @player.output "You tell #{target.name}, <tell>\"#{phrase}\"</tell>" - target.output "#{@player.name} tells you, <tell>\"#{phrase}\"</tell>" - target.reply_to = @player.name - end - - #Reply to a tell. - def action_reply(event) - unless @player.reply_to - @player.output "There is no one to reply to." - return - end - - event[:target] = @player.reply_to - - action_tell(event) - end end Aethyr::Extend::HandlerRegistry.register_handler(TellHandler) diff --git a/lib/aethyr/core/input_handlers/unwield.rb b/lib/aethyr/core/input_handlers/unwield.rb index 6fa87668da17d1018de14fa5a2535b123f67540d..334e635e2ed7e48d2a283aeb9f3604657d0a485b 100644 --- a/lib/aethyr/core/input_handlers/unwield.rb +++ b/lib/aethyr/core/input_handlers/unwield.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/unwield" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -42,53 +43,11 @@ EOF case data[:input] when /^unwield(\s+(.*))?$/i weapon = $2 - unwield({:weapon => weapon}) + $manager.submit_action(Aethyr::Core::Actions::Unwield::UnwieldCommand.new(@player, {:weapon => weapon})) end end private - def unwield(event) - - room = $manager.get_object(@player.container) - player = @player - - if event[:weapon] == "right" || event[:weapon] == "left" - weapon = player.equipment.get_wielded(event[:weapon]) - - if weapon.nil? - player.output "You are not wielding anything in your #{event[:weapon]} hand." - return - end - elsif event[:weapon].nil? - weapon = player.equipment.get_wielded - if weapon.nil? - player.output "You are not wielding anything." - return - end - else - weapon = player.equipment.find(event[:weapon]) - - if weapon.nil? - player.output "What are you trying to unwield?" - return - end - - if not [:left_wield, :right_wield, :dual_wield].include? player.equipment.position_of(weapon) - player.output "You are not wielding #{weapon.name}." - return - end - - end - - if player.equipment.remove(weapon) - player.inventory << weapon - event[:to_player] = "You unwield #{weapon.name}." - event[:to_other] = "#{player.name} unwields #{weapon.name}." - room.out_event(event) - else - player.output "Could not unwield #{weapon.name}." - end - end end Aethyr::Extend::HandlerRegistry.register_handler(UnwieldHandler) diff --git a/lib/aethyr/core/input_handlers/wear.rb b/lib/aethyr/core/input_handlers/wear.rb index 18445b571acf841e86ddb694400ee5bf9c3c57be..7bec97e4bc35aefd1351fa2fa69dcbd80d6cbd5d 100644 --- a/lib/aethyr/core/input_handlers/wear.rb +++ b/lib/aethyr/core/input_handlers/wear.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/wear" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -40,32 +41,11 @@ EOF when /^wear\s+(\w+)(\s+on\s+(.*))?$/i object = $1 position = $3 - wear({:object => object, :position => position}) + $manager.submit_action(Aethyr::Core::Actions::Wear::WearCommand.new(@player, {:object => object, :position => position})) end end private - def wear(event) - - room = $manager.get_object(@player.container) - player = @player - - object = player.inventory.find(event[:object]) - - if object.nil? - player.output("What #{event[:object]} are you trying to wear?") - return - elsif object.is_a? Weapon - player.output "You must wield #{object.name}." - return - end - - if player.wear object - event[:to_player] = "You put on #{object.name}." - event[:to_other] = "#{player.name} puts on #{object.name}." - room.out_event(event) - end - end end Aethyr::Extend::HandlerRegistry.register_handler(WearHandler) diff --git a/lib/aethyr/core/input_handlers/whereis.rb b/lib/aethyr/core/input_handlers/whereis.rb index 0ab22b9d29f1b7cb23baf3679ca757a5abbb2ce9..fb783be5806f0ac3748cc7439846d07ad6f75f50 100644 --- a/lib/aethyr/core/input_handlers/whereis.rb +++ b/lib/aethyr/core/input_handlers/whereis.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/whereis" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -36,40 +37,11 @@ EOF case data[:input] when /^whereis\s(.*)$/ object = $1 - whereis({:object => object}) + $manager.submit_action(Aethyr::Core::Actions::Whereis::WhereisCommand.new(@player, {:object => object})) end end private - def whereis(event) - - room = $manager.get_object(@player.container) - player = @player - object = find_object(event[:object], event) - - if object.nil? - player.output "Could not find #{event[:object]}." - return - end - - if object.container.nil? - if object.can? :area and not object.area.nil? and object.area != object - area = $manager.get_object object.area || "nothing" - player.output "#{object} is in #{area}." - else - player.output "#{object} is not in anything." - end - else - container = $manager.get_object object.container - if container.nil? - player.output "Container for #{object} not found." - else - player.output "#{object} is in #{container}." - event[:object] = container.goid - whereis(event, player, room) - end - end - end end Aethyr::Extend::HandlerRegistry.register_handler(WhereisHandler) diff --git a/lib/aethyr/core/input_handlers/whisper.rb b/lib/aethyr/core/input_handlers/whisper.rb index 8bd292efe549323cf49117e1789bab502ba623db..063e17e39bddea9ba8e4f67c5fca8b106bbdfa8b 100644 --- a/lib/aethyr/core/input_handlers/whisper.rb +++ b/lib/aethyr/core/input_handlers/whisper.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/whisper" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -44,60 +45,13 @@ EOF super(data) case data[:input] when /^whisper\s+(\w+)\s+(\((.*?)\)\s*)?(.*)$/i - action({ :to => $1, :phrase => $4, :pre => $3 }) + $manager.submit_action(Aethyr::Core::Actions::Whisper::WhisperCommand.new(@player, { :to => $1, :phrase => $4, :pre => $3 })) end end private #Whispers to another thing. - def action(event) - room = $manager.get_object(@player.container) - object = room.find(event[:to], Player) - - if object.nil? - @player.output("To whom are you trying to whisper?") - return - elsif object == @player - @player.output("Whispering to yourself again?") - event[:to_other] = "#{@player.name} whispers to #{@player.pronoun(:reflexive)}." - room.out_event(event, @player) - return - end - - phrase = event[:phrase] - - if phrase.nil? - @player.ouput "What are you trying to whisper?" - return - end - - prefix = event[:pre] - - if prefix - prefix << ", " - else - prefix = "" - end - phrase[0,1] = phrase[0,1].capitalize - - last_char = phrase[-1..-1] - - unless ["!", "?", "."].include? last_char - ender = "." - end - - phrase = ", <say>\"#{phrase}#{ender}\"</say>" - - event[:target] = object - event[:to_player] = prefix + "you whisper to #{object.name}#{phrase}" - event[:to_target] = prefix + "#{@player.name} whispers to you#{phrase}" - event[:to_other] = prefix + "#{@player.name} whispers quietly into #{object.name}'s ear." - event[:to_other_blind] = "#{@player.name} whispers." - event[:to_target_blind] = "Someone whispers to you#{phrase}" - - room.out_event(event) - end end Aethyr::Extend::HandlerRegistry.register_handler(WhisperHandler) diff --git a/lib/aethyr/core/input_handlers/wield.rb b/lib/aethyr/core/input_handlers/wield.rb index cf78b4244d01d33f78781bad33c6da30a161c6ed..78f370e2f075197756573f8768c792ef435d3a91 100644 --- a/lib/aethyr/core/input_handlers/wield.rb +++ b/lib/aethyr/core/input_handlers/wield.rb @@ -1,5 +1,6 @@ +require "aethyr/core/actions/commands/wield" require "aethyr/core/registry" -require "aethyr/core/actions/commands/command_handler" +require "aethyr/core/input_handlers/command_handler" module Aethyr module Core @@ -44,71 +45,11 @@ EOF when /^wield\s+(.*?)(\s+(\w+))?$/i weapon = $1 side = $3 - wield({:weapon => weapon, :side => side}) + $manager.submit_action(Aethyr::Core::Actions::Wield::WieldCommand.new(@player, {:weapon => weapon, :side => side})) end end private - def wield(event) - - room = $manager.get_object(@player.container) - player = @player - weapon = player.inventory.find(event[:weapon]) - if weapon.nil? - weapon = player.equipment.find(event[:weapon]) - if weapon and player.equipment.get_all_wielded.include? weapon - player.output "You are already wielding that." - else - player.output "What are you trying to wield?" - end - return - end - - if not weapon.is_a? Weapon - player.output "#{weapon.name} is not wieldable." - return - end - - if event[:side] - side = event[:side] - if side != "right" and side != "left" - player.output "Which hand?" - return - end - - result = player.equipment.check_wield(weapon, "#{side} wield") - if result - player.output result - return - end - - result = player.equipment.wear(weapon, "#{side} wield") - if result.nil? - player.output "You are unable to wield that." - return - end - event[:to_player] = "You grip #{weapon.name} firmly in your #{side} hand." - else - result = player.equipment.check_wield(weapon) - - if result - player.output result - return - end - - result = player.equipment.wear(weapon) - if result.nil? - player.output "You are unable to wield that weapon." - return - end - - event[:to_player] = "You firmly grip #{weapon.name} and begin to wield it." - end - - player.inventory.remove weapon - event[:to_other] = "#{player.name} wields #{weapon.name}." - room.out_event(event) - end end Aethyr::Extend::HandlerRegistry.register_handler(WieldHandler) diff --git a/lib/aethyr/core/util/all-commands.rb b/lib/aethyr/core/util/all-commands.rb index a343cb0cf9d70ebda05f8dd303485bc83e2e75d3..2c32c6886c1ac03721d9db31692ceb357e7f1af8 100644 --- a/lib/aethyr/core/util/all-commands.rb +++ b/lib/aethyr/core/util/all-commands.rb @@ -22,5 +22,5 @@ #require 'aethyr/core/actions/commands/weapon_combat' require 'require_all' -require_all 'lib/aethyr/core/actions/input_handlers/' -require_all 'lib/aethyr/extensions/actions/input_handlers/' +require_all 'lib/aethyr/core/input_handlers/' +require_all 'lib/aethyr/extensions/input_handlers/' diff --git a/lib/aethyr/extensions/input_handlers/.keep b/lib/aethyr/extensions/input_handlers/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391