meshchat 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0990d41d8c16d59332c7220b14e4f3e95fb6bfc
4
- data.tar.gz: 793bb0946bd2b1944fdbdcb31469682b848b4f12
3
+ metadata.gz: f67f10629cb5af3827cf5ce5fcc8add279c62c87
4
+ data.tar.gz: 1924e99f9fed8009945ad110ec5794a5436fa1d6
5
5
  SHA512:
6
- metadata.gz: d7fdaf5a47e96cc1047604d51c115a118f22cf574ccd74fbf0ea5c15ef1546fc03f0cfdea555d8ee8e2a4384e5cfe4d2f6d160c5b67d31a79d9f56698a7d9b3c
7
- data.tar.gz: b75182aa773d64a418fe23c69bbe0f154bad70b048b929ce0b8a97d48ca822a49a3e16fdf1c850e98cf12d90a9bae08aac6deb7ef50c3599a9f0cb793a35fe77
6
+ metadata.gz: df63be614e8298d186b439d5eabe5d1e25c8df5a883f9ac8fa9b592ba77e15d63ede3374714201b8579ca878286a62c0e5d4bedbc9814a7b99f8dc6efd52f9a2
7
+ data.tar.gz: 64b7e73059734c02b9084e6aeb3cb7aa5bc64af4b4e19873b42b093934d31e8f405d4cc01c0b0843ed58ff91df2d8f5a4d882c0566eb8c4f3d2fa5d58d96ac55
@@ -5,13 +5,20 @@ module Meshchat
5
5
  extend ActiveSupport::Autoload
6
6
 
7
7
  # @see https://github.com/neuravion/mesh-chat/blob/master/message-types.md
8
+ # chat types
8
9
  CHAT = 'chat'
9
10
  EMOTE = 'emote'
11
+ WHISPER = 'whisper'
12
+
13
+ # fake type, actually renders as an emote
14
+ ROLL = 'roll'
15
+
16
+ # status types
10
17
  PING = 'ping'
11
18
  PING_REPLY = 'pingreply'
12
- WHISPER = 'whisper'
13
19
  DISCONNECT = 'disconnect'
14
20
 
21
+ # node list sync types
15
22
  NODE_LIST = 'nodelist'
16
23
  NODE_LIST_HASH = 'nodelisthash'
17
24
  NODE_LIST_DIFF = 'nodelistdiff'
@@ -11,6 +11,7 @@ module Meshchat
11
11
  TYPES = {
12
12
  CHAT => Chat,
13
13
  EMOTE => Emote,
14
+ ROLL => Emote,
14
15
  WHISPER => Whisper,
15
16
  DISCONNECT => Disconnect,
16
17
  PING => Ping,
@@ -42,7 +43,7 @@ module Meshchat
42
43
 
43
44
  parameters = parameters_for(data)
44
45
  klass = TYPES[type]
45
- raise Errors::MessageTypeNotRecognized unless klass
46
+ raise Errors::MessageTypeNotRecognized, type + ' not found' unless klass
46
47
  klass.new(parameters)
47
48
  end
48
49
 
@@ -23,6 +23,7 @@ module Meshchat
23
23
  autoload :Share
24
24
  autoload :Import
25
25
  autoload :Emote
26
+ autoload :Roll
26
27
  end
27
28
 
28
29
  COMMAND_MAP = {
@@ -44,6 +45,7 @@ module Meshchat
44
45
  Base::BIND => Bind,
45
46
  Base::SEND_DISCONNECT => SendDisconnect,
46
47
  Base::EMOTE => Emote,
48
+ Base::ROLL => Roll,
47
49
  Base::CHAT => Chat
48
50
  }.freeze
49
51
  end
@@ -29,6 +29,7 @@ module Meshchat
29
29
  BIND = 'bind'
30
30
  SEND_DISCONNECT = 'senddisconnect'
31
31
  EMOTE = 'me'
32
+ ROLL = 'roll'
32
33
 
33
34
  attr_reader :_input, :_message_dispatcher
34
35
  attr_reader :_message_factory, :_input_factory
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ module Meshchat
3
+ module Ui
4
+ module Command
5
+ class Roll < Command::Chat
6
+ REGEX = /(\d+)d(\d+)(\+(\d+))?/
7
+
8
+ def self.description
9
+ 'rolls a die in the XdY+Z format'
10
+ end
11
+
12
+ def initialize(input, message_dispatcher, message_factory, input_factory)
13
+ super
14
+ Display.debug input
15
+ # input, X, Y, +Z, Z
16
+ _, num, size, _, modifier = REGEX.match(input).to_a.map(&:to_i)
17
+
18
+ result = Array.new(num) { rand(size + 1) }.inject(:+) + modifier
19
+ @_input = "rolls #{num}d#{size}#{modifier != 0 ? "+#{modifier}" : ''} and gets #{result}"
20
+ end
21
+
22
+ def show_myself(message)
23
+ Display.emote message.display
24
+ end
25
+
26
+ def type
27
+ EMOTE
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Meshchat
3
- VERSION = '0.11.0'
3
+ VERSION = '0.11.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meshchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - L. Preston Sego III
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -330,6 +330,7 @@ files:
330
330
  - lib/meshchat/ui/command/online.rb
331
331
  - lib/meshchat/ui/command/ping.rb
332
332
  - lib/meshchat/ui/command/ping_all.rb
333
+ - lib/meshchat/ui/command/roll.rb
333
334
  - lib/meshchat/ui/command/send_disconnect.rb
334
335
  - lib/meshchat/ui/command/server.rb
335
336
  - lib/meshchat/ui/command/share.rb
@@ -365,6 +366,6 @@ rubyforge_project:
365
366
  rubygems_version: 2.5.1
366
367
  signing_key:
367
368
  specification_version: 4
368
- summary: Meshchat-0.11.0
369
+ summary: Meshchat-0.11.1
369
370
  test_files: []
370
371
  has_rdoc: