Skip to content

Commit

Permalink
Merge pull request #40 from AresMUSH/dev
Browse files Browse the repository at this point in the history
Beta 39
  • Loading branch information
lynnfaraday committed Feb 1, 2019
2 parents 52247b5 + 566ddda commit d3be0c3
Show file tree
Hide file tree
Showing 59 changed files with 565 additions and 149 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Expand Up @@ -18,15 +18,13 @@ gem 'timezone', '~> 1.2.10'
gem 'dentaku', '~>3.1'
gem 'json', '~> 2.1.0'
gem 'redcarpet', '~> 3.4.0'
gem 'html2markdown', '0.0.3'
gem 'sinatra', '~> 2.0.4'
gem 'thin', '~> 1.7.2'
gem 'sinatra-cross_origin', '~>0.4.0'
gem 'aws-sdk-s3', '~> 1.8.2'
gem 'rubyzip', '~> 1.2.2'
gem 'diff-lcs', '~> 1.3'
gem 'diffy', '~> 3.2.0'
gem "nokogiri", "~> 1.8.5"
gem 'sassc', '~> 2.0.0'
gem 'htmlentities', '~>4.3.4'
gem 'handlebars', '~>0.8.0'
7 changes: 0 additions & 7 deletions Gemfile.lock
Expand Up @@ -37,8 +37,6 @@ GEM
therubyracer (~> 0.12.1)
handlebars-source (4.0.12)
hiredis (0.6.1)
html2markdown (0.0.3)
nokogiri
htmlentities (4.3.4)
http_parser.rb (0.6.0)
i18n (0.9.5)
Expand All @@ -47,13 +45,10 @@ GEM
json (2.1.0)
libv8 (3.16.14.19)
log4r (1.1.10)
mini_portile2 (2.3.0)
minitest (5.11.3)
mustermann (1.0.3)
nest (3.1.1)
redic
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
ohm (3.1.1)
nest (~> 3)
redic (~> 1.5.0)
Expand Down Expand Up @@ -119,12 +114,10 @@ DEPENDENCIES
erubis (~> 2.7.0)
eventmachine (~> 1.2.5)
handlebars (~> 0.8.0)
html2markdown (= 0.0.3)
htmlentities (~> 4.3.4)
i18n (~> 0.7)
json (~> 2.1.0)
log4r (~> 1.1.10)
nokogiri (~> 1.8.5)
ohm (~> 3.1.1)
rake (~> 12.3)
redcarpet (~> 3.4.0)
Expand Down
12 changes: 0 additions & 12 deletions bin/setup_test_game
Expand Up @@ -68,18 +68,6 @@ chmod +x bin/*

# #########################################################################################

echo -e "${ARES_INSTALL_TEXT} Run the configure script to set up basic game options."

bin/configure

# #########################################################################################

echo -e "${ARES_INSTALL_TEXT} Initialize the database."

bin/wipedb

# #########################################################################################

echo -e "${ARES_INSTALL_TEXT} Installing Node for Ember."

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
Expand Down
1 change: 0 additions & 1 deletion engine/aresmush.rb
Expand Up @@ -18,7 +18,6 @@
require 'rspec/core/rake_task'
require 'pp'
require 'net/http'
require 'html2markdown'
require 'handlebars'
require 'htmlentities'

Expand Down
8 changes: 6 additions & 2 deletions engine/aresmush/connection.rb
Expand Up @@ -18,6 +18,7 @@ def post_init
@negotiator.send_naws_request
@negotiator.send_charset_request


rescue Exception => e
Global.logger.warn "Could not decode IP address. error=#{e} backtrace=#{e.backtrace[0,10]}"
@ip_addr = "0.0.0.0"
Expand All @@ -40,6 +41,7 @@ def connect_client(client)

def send_data(msg)
begin
##telnet_debug(msg, "SEND")
super msg
rescue Exception => e
Global.logger.warn "Could not send to connection: error=#{e} backtrace=#{e.backtrace[0,10]}."
Expand Down Expand Up @@ -91,6 +93,8 @@ def receive_data(data)
end

parts.each do |part|
##telnet_debug(part, "RECV")

next if !part
part = "#{part.chomp}\n"
input = @negotiator.handle_input(part)
Expand Down Expand Up @@ -130,7 +134,7 @@ def strip_control_chars(data)
stripped.gsub(/\^@/,"")
end

def telnet_debug(part)
def telnet_debug(part, prefix)
chars = part.split("").map { |c| c.ord }

special = {
Expand Down Expand Up @@ -170,7 +174,7 @@ def telnet_debug(part)

end

puts "---------------"
puts "#{prefix} ---------------"
puts part.inspect
puts output.join(" ")

Expand Down
36 changes: 24 additions & 12 deletions engine/aresmush/helpers/online_char_finder.rb
Expand Up @@ -8,29 +8,43 @@ def initialize(client, char)
end

class OnlineCharFinder
def self.find(name, client, allow_handles = false)
return FindResult.new(OnlineCharResult.new(client, client.char), nil) if (name.downcase == "me")
def self.find(name)
online = Global.client_monitor.logged_in
.select { |other_client, other_char| exact_match?(other_char, name, allow_handles, client)}
.select { |other_client, other_char| exact_match?(other_char, name)}
.map { |other_client, other_char| OnlineCharResult.new(other_client, other_char )}
if (online.count == 0)
online = Global.client_monitor.logged_in
.select { |other_client, other_char| partial_match?(other_char, name, allow_handles, client)}
.select { |other_client, other_char| partial_match?(other_char, name)}
.map { |other_client, other_char| OnlineCharResult.new(other_client, other_char )}
end

if (online.count == 0)
return FindResult.new(nil, t('db.no_char_online_found', :name => name))
if (Character.all.select { |c| c.name_upcase.start_with?(name.upcase) }.first)
return FindResult.new(nil, t('db.no_char_online_found', :name => name))
else
return FindResult.new(nil, t('db.object_not_found', :name => name))
end
elsif (online.count == 1)
return FindResult.new(online.first, nil)
end
FindResult.new(nil, t('db.ambiguous_char_online', :name => name))
end

def self.with_online_chars(names, client, allow_handles = false, &block)

def self.with_an_online_char(name, client, &block)
result = self.find(name)

if (!result.found?)
client.emit_failure(result.error)
return
end

yield result.target
end

def self.with_online_chars(names, client, &block)
to_clients = []
names.each do |name|
result = self.find(name, client, allow_handles)
result = self.find(name)

if (!result.found?)
client.emit_failure(result.error)
Expand All @@ -43,22 +57,20 @@ def self.with_online_chars(names, client, allow_handles = false, &block)

private

def self.exact_match?(char, name, allow_handles, viewer)
def self.exact_match?(char, name)
name = name.upcase
return false if name.blank?
return false if !char
return true if char.name_upcase == name
return true if char.alias_upcase == name
return true if allow_handles && char.handle && char.handle.upcase == name && char.handle_visible_to?(viewer)
return false
end

def self.partial_match?(char, name, allow_handles, viewer)
def self.partial_match?(char, name)
name = name.upcase
return false if name.blank?
return false if !char
return true if char.name_upcase.start_with?(name)
return true if allow_handles && char.handle && char.handle.upcase.start_with?(name) && char.handle_visible_to?(viewer)
return false
end
end
Expand Down
4 changes: 4 additions & 0 deletions engine/aresmush/models/find_by_name.rb
Expand Up @@ -28,6 +28,10 @@ def find_any_by_name(name_or_id)
find(name_upcase: name_or_id.upcase).to_a.select { |x| x }
end

def named(name)
find_one_by_name(name)
end

def find_one_by_name(name)
find_any_by_name(name).first
end
Expand Down
3 changes: 3 additions & 0 deletions engine/styles/ares.scss
Expand Up @@ -673,6 +673,9 @@ CHARGEN SCREEN
SCENES SCREEN
------------------------- */

.pose-box {
}

.scene-pose {
padding: 10px;
margin: 15px;
Expand Down
11 changes: 11 additions & 0 deletions plugins/arescentral/public/arescentral_api.rb
Expand Up @@ -28,5 +28,16 @@ def self.is_alt?(char1, char2)
def self.is_registered?
!!Game.master.api_game_id
end

# Includes both handle linking and player tag linking.
def self.are_chars_linked?(char1, char2)
return true if AresCentral.is_alt?(char1, char2)
tag1 = Profile.get_player_tag(char1)
tag2 = Profile.get_player_tag(char2)
return false if !tag1
return false if !tag2
return tag1 == tag2
end

end
end
6 changes: 2 additions & 4 deletions plugins/arescentral/web/get_players_handler.rb
Expand Up @@ -15,12 +15,10 @@ def handle(request)
add_alt(players, c.name, c)
end

player_tag = c.profile_tags.select { |t| t.start_with?("player") }.first
player_tag = Profile.get_player_tag(c)
next if !player_tag

player_tag = player_tag.after(":").titleize

add_alt(players, player_tag, c)
add_alt(players, player_tag.titleize, c)
end

players.sort.map { |name, alts| { name: name, alts: alts }}
Expand Down
2 changes: 1 addition & 1 deletion plugins/describe/locales/locale_en.yml
Expand Up @@ -33,7 +33,7 @@ en:
exits_title: "Exits:"
no_way_out: "No way out!"

scene_log_active: "+++ The scene log is active in this room. +++"
scene_log_active: "+++ The scene log (%{num}) is active in this room. +++"
watching_from_web: "(Via Web)"
no_such_detail: "No such detail available."
detail_deleted: "Detail deleted."
Expand Down
2 changes: 1 addition & 1 deletion plugins/describe/templates/room.erb
Expand Up @@ -14,7 +14,7 @@
<% end %>
<% if logging_enabled %>

%xy<%= center( t('describe.scene_log_active'), 78 )%>%xn
%xy<%= center( t('describe.scene_log_active', :num => room.scene.id), 78 )%>%xn
<% end %>
<%= divider %>
%xg<%= t('describe.players_title') %>%xn
Expand Down
29 changes: 29 additions & 0 deletions plugins/forum/commands/forum_hide_cmd.rb
@@ -0,0 +1,29 @@
module AresMUSH
module Forum
class ForumHideCmd
include CommandHandler

attr_accessor :hide, :category_name

def parse_args
self.hide = cmd.switch_is?("hide") ? true : false
self.category_name = titlecase_arg(cmd.args)
end

def handle
Forum.with_a_category(self.category_name, client, enactor) do |category|
prefs = Forum.get_forum_prefs(enactor, category)
if (!prefs)
prefs = BbsPrefs.create(bbs_board: category, character: enactor)
end
prefs.update(hidden: self.hide)
if (self.hide)
client.emit_success t('forum.category_hidden', :name => self.category_name)
else
client.emit_success t('forum.category_shown', :name => self.category_name)
end
end
end
end
end
end
19 changes: 19 additions & 0 deletions plugins/forum/commands/forum_mute_cmd.rb
@@ -0,0 +1,19 @@
module AresMUSH
module Forum
class ForumMuteCmd
include CommandHandler

attr_accessor :option

def parse_args
self.option = cmd.switch_is?("mute") ? true : false
end

def handle
enactor.update(forum_muted: self.option)
message = self.option ? t('forum.forum_muted') : t('forum.forum_unmuted')
client.emit_success message
end
end
end
end
12 changes: 12 additions & 0 deletions plugins/forum/events/char_connected_event_handler.rb
@@ -0,0 +1,12 @@
module AresMUSH
module Forum
class CharDisconnectedEventHandler
def on_event(event)
client = event.client
char = Character[event.char_id]

char.update(forum_muted: false)
end
end
end
end
12 changes: 11 additions & 1 deletion plugins/forum/forum.rb
Expand Up @@ -32,9 +32,13 @@ def self.get_cmd_handler(client, cmd, enactor)
when "describe"
return ForumDescCmd
when "edit"
return ForumEditCmd
return ForumEditCmd
when "hide", "show"
return ForumHideCmd
when "move"
return ForumMoveCmd
when "mute", "unmute"
return ForumMuteCmd
when "new"
return ForumNewCmd
when "order"
Expand Down Expand Up @@ -66,6 +70,8 @@ def self.get_event_handler(event_name)
case event_name
when "RoleDeletedEvent"
return RoleDeletedEventHandler
when "CharDisconnectedEvent"
return CharDisconnectedEventHandler
end

nil
Expand All @@ -79,8 +85,12 @@ def self.get_web_request_handler(request)
return AddReplyRequestHandler
when "forumCategory"
return ForumCategoryRequestHandler
when "forumHide"
return ForumHideRequestHandler
when "forumList"
return ForumListRequestHandler
when "forumMute"
return ForumMuteRequestHandler
when "forumTopic"
return ForumTopicRequestHandler
when "forumUnread"
Expand Down

0 comments on commit d3be0c3

Please sign in to comment.