carps 0.2.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.
- data/COPYING +674 -0
- data/GEM_DESCRIPTION +10 -0
- data/History.txt +4 -0
- data/Manifest.txt +156 -0
- data/PostInstall.txt +20 -0
- data/README.rdoc +141 -0
- data/Rakefile +28 -0
- data/bin/carps +123 -0
- data/bin/carps_init +29 -0
- data/bin/carps_ipc_test +44 -0
- data/bin/carps_mod_saver_test +71 -0
- data/bin/carps_mod_test +62 -0
- data/config/website.yml +2 -0
- data/features/character_sheet.feature +40 -0
- data/features/crash.feature +15 -0
- data/features/crypt.feature +22 -0
- data/features/dice.feature +173 -0
- data/features/dm.feature +36 -0
- data/features/dmll.feature +51 -0
- data/features/edit.feature +10 -0
- data/features/email.feature +29 -0
- data/features/interface.feature +17 -0
- data/features/ipc.feature +10 -0
- data/features/mailbox.feature +33 -0
- data/features/mod.feature +31 -0
- data/features/parser.feature +9 -0
- data/features/persistent_protocol.feature +14 -0
- data/features/player.feature +22 -0
- data/features/player_turn.feature +29 -0
- data/features/random.feature +15 -0
- data/features/rule.feature +19 -0
- data/features/safety.feature +13 -0
- data/features/sessions.feature +16 -0
- data/features/start_dm.feature +18 -0
- data/features/start_player.feature +8 -0
- data/features/step_definitions/common_steps.rb +170 -0
- data/features/steps/character_sheet.rb +89 -0
- data/features/steps/crash.rb +27 -0
- data/features/steps/crypt.rb +166 -0
- data/features/steps/dice.rb +91 -0
- data/features/steps/dm.rb +147 -0
- data/features/steps/dmll.rb +47 -0
- data/features/steps/edit.rb +7 -0
- data/features/steps/email.rb +108 -0
- data/features/steps/general.rb +5 -0
- data/features/steps/interface.rb +64 -0
- data/features/steps/ipc.rb +22 -0
- data/features/steps/mailbox.rb +126 -0
- data/features/steps/mod.rb +25 -0
- data/features/steps/parser.rb +23 -0
- data/features/steps/persistent_protocol.rb +29 -0
- data/features/steps/player.rb +82 -0
- data/features/steps/player_turn.rb +56 -0
- data/features/steps/random.rb +47 -0
- data/features/steps/rule.rb +53 -0
- data/features/steps/safety.rb +17 -0
- data/features/steps/sessions.rb +37 -0
- data/features/steps/start_dm.rb +46 -0
- data/features/steps/start_player.rb +65 -0
- data/features/steps/timeout.rb +32 -0
- data/features/steps/type_verification.rb +36 -0
- data/features/steps/wizard.rb +123 -0
- data/features/support/common.rb +29 -0
- data/features/support/env.rb +14 -0
- data/features/support/matchers.rb +11 -0
- data/features/timeout.feature +11 -0
- data/features/type_verification.feature +48 -0
- data/features/wizard.feature +50 -0
- data/lib/carps/crypt/accept_handshake.rb +40 -0
- data/lib/carps/crypt/default_messages.rb +29 -0
- data/lib/carps/crypt/handshake.rb +41 -0
- data/lib/carps/crypt/mailbox.rb +265 -0
- data/lib/carps/crypt/mailer.rb +220 -0
- data/lib/carps/crypt/peer.rb +123 -0
- data/lib/carps/crypt/public_key.rb +60 -0
- data/lib/carps/crypt.rb +23 -0
- data/lib/carps/email/config.rb +122 -0
- data/lib/carps/email/imap.rb +156 -0
- data/lib/carps/email/smtp.rb +119 -0
- data/lib/carps/email/string.rb +30 -0
- data/lib/carps/email.rb +21 -0
- data/lib/carps/mod/action.rb +36 -0
- data/lib/carps/mod/answers.rb +76 -0
- data/lib/carps/mod/client_turn.rb +88 -0
- data/lib/carps/mod/dice.rb +360 -0
- data/lib/carps/mod/dm/interface.rb +160 -0
- data/lib/carps/mod/dm/mod.rb +409 -0
- data/lib/carps/mod/dm/reporter.rb +112 -0
- data/lib/carps/mod/dm/resource.rb +88 -0
- data/lib/carps/mod/dm/room.rb +33 -0
- data/lib/carps/mod/interface.rb +73 -0
- data/lib/carps/mod/launch.rb +108 -0
- data/lib/carps/mod/mod.rb +52 -0
- data/lib/carps/mod/player/interface.rb +76 -0
- data/lib/carps/mod/player/mod.rb +109 -0
- data/lib/carps/mod/question.rb +63 -0
- data/lib/carps/mod/rule.rb +112 -0
- data/lib/carps/mod/sheet/character.rb +82 -0
- data/lib/carps/mod/sheet/editor.rb +97 -0
- data/lib/carps/mod/sheet/new_sheet.rb +71 -0
- data/lib/carps/mod/sheet/schema.rb +84 -0
- data/lib/carps/mod/sheet/type.rb +161 -0
- data/lib/carps/mod/sheet/verifier.rb +41 -0
- data/lib/carps/mod/status_report.rb +51 -0
- data/lib/carps/mod.rb +40 -0
- data/lib/carps/protocol/keyword.rb +104 -0
- data/lib/carps/protocol/message.rb +138 -0
- data/lib/carps/protocol.rb +19 -0
- data/lib/carps/service/client_parser.rb +34 -0
- data/lib/carps/service/dm/config.rb +76 -0
- data/lib/carps/service/dm/mailer.rb +70 -0
- data/lib/carps/service/dm/new_game.rb +101 -0
- data/lib/carps/service/dm/start.rb +47 -0
- data/lib/carps/service/game.rb +101 -0
- data/lib/carps/service/interface.rb +174 -0
- data/lib/carps/service/invite.rb +79 -0
- data/lib/carps/service/mod.rb +43 -0
- data/lib/carps/service/player/config.rb +78 -0
- data/lib/carps/service/player/mailer.rb +49 -0
- data/lib/carps/service/player/start.rb +60 -0
- data/lib/carps/service/server_parser.rb +33 -0
- data/lib/carps/service/session.rb +96 -0
- data/lib/carps/service/start/config.rb +71 -0
- data/lib/carps/service/start/interface.rb +101 -0
- data/lib/carps/service/start/mailer.rb +46 -0
- data/lib/carps/service.rb +35 -0
- data/lib/carps/test.rb +34 -0
- data/lib/carps/ui/colour.rb +28 -0
- data/lib/carps/ui/error.rb +39 -0
- data/lib/carps/ui/highlight.rb +32 -0
- data/lib/carps/ui/question.rb +63 -0
- data/lib/carps/ui/warn.rb +37 -0
- data/lib/carps/ui.rb +21 -0
- data/lib/carps/util/config.rb +162 -0
- data/lib/carps/util/editor.rb +147 -0
- data/lib/carps/util/error.rb +75 -0
- data/lib/carps/util/files.rb +48 -0
- data/lib/carps/util/init.rb +93 -0
- data/lib/carps/util/process.rb +150 -0
- data/lib/carps/util/timeout.rb +31 -0
- data/lib/carps/util/windows.rb +29 -0
- data/lib/carps/util.rb +24 -0
- data/lib/carps/wizard/dm.rb +41 -0
- data/lib/carps/wizard/player.rb +40 -0
- data/lib/carps/wizard/steps.rb +494 -0
- data/lib/carps/wizard/wizard.rb +126 -0
- data/lib/carps/wizard.rb +21 -0
- data/lib/carps.rb +45 -0
- data/permission +16 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/tasks/readme_site.rake +28 -0
- data/test/test_carps.rb +11 -0
- data/test/test_helper.rb +3 -0
- data/website/index.html +271 -0
- metadata +304 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require "carps/mod"
|
|
2
|
+
|
|
3
|
+
Then /^the reporter is registered with the resource manager$/ do
|
|
4
|
+
$resource.reporter = $reporter
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Given /^(.+) are in the (.+)$/ do |monikers_text, room|
|
|
8
|
+
monikers = monikers_text.split
|
|
9
|
+
$resource.players_in monikers, room
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Given /^a resource manager$/ do
|
|
13
|
+
$resource = Resource.new "resource"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Given /^a reporter$/ do
|
|
17
|
+
$reporter = Reporter.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
Then /^customize report for (.+)$/ do |player|
|
|
21
|
+
$reporter.edit player
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Then /^take turns for (.+)/ do |name_text|
|
|
25
|
+
names = name_text.split
|
|
26
|
+
turns = $reporter.player_turns names
|
|
27
|
+
turns.each do |moniker, turn|
|
|
28
|
+
answers = turn.take
|
|
29
|
+
answers.from = moniker
|
|
30
|
+
answers.display
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Then /^ask (.+): (.+)$/ do |players_text, question|
|
|
35
|
+
players = players_text.split
|
|
36
|
+
players.each do |player|
|
|
37
|
+
$reporter.ask_player player, question
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Then /^create an NPC of type human$/ do
|
|
42
|
+
npc = $resource.new_npc "human"
|
|
43
|
+
unless npc
|
|
44
|
+
raise "Could not load human"
|
|
45
|
+
end
|
|
46
|
+
puts npc.to_s
|
|
47
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Test email functionality
|
|
2
|
+
|
|
3
|
+
require "carps/email/config"
|
|
4
|
+
|
|
5
|
+
require "carps/ui/question"
|
|
6
|
+
|
|
7
|
+
require "yaml"
|
|
8
|
+
|
|
9
|
+
# Clone the original settings and apply the changes to create an array of new settings
|
|
10
|
+
def make_settings settings, changes
|
|
11
|
+
changes.map do |field, val|
|
|
12
|
+
new_setting = settings.clone
|
|
13
|
+
new_setting[field] = val
|
|
14
|
+
new_setting
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class EmailConfig
|
|
19
|
+
|
|
20
|
+
def imap
|
|
21
|
+
@imap
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def smtp
|
|
25
|
+
@smtp
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def address
|
|
29
|
+
@address
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Given /^default IMAP settings$/ do
|
|
35
|
+
$imap_options = {
|
|
36
|
+
"user" => "carps",
|
|
37
|
+
"server" => "killersmurf.com",
|
|
38
|
+
"tls" => true,
|
|
39
|
+
"port" => 993,
|
|
40
|
+
"certificate" => nil,
|
|
41
|
+
"verify" => false,
|
|
42
|
+
"login" => false,
|
|
43
|
+
"cram_md5" => false}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
Given /^default SMTP settings$/ do
|
|
47
|
+
$smtp_options = {
|
|
48
|
+
"login" => false,
|
|
49
|
+
"cram_md5" => false,
|
|
50
|
+
"starttls" => true,
|
|
51
|
+
"tls" => false,
|
|
52
|
+
"port" => 25,
|
|
53
|
+
"user" => "carps",
|
|
54
|
+
"server" => "killersmurf.com"}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Then /^attempt connections with various SMTP security settings$/ do
|
|
58
|
+
pass = UI::secret "Enter SMTP password for #{$smtp_options["user"]}"
|
|
59
|
+
log = ["login", true]
|
|
60
|
+
cram = ["cram_md5", true]
|
|
61
|
+
tls = ["tls", true]
|
|
62
|
+
nostarttls = ["starttls", false]
|
|
63
|
+
settings = make_settings $smtp_options, [log, cram, tls, nostarttls]
|
|
64
|
+
settings.each do |setting|
|
|
65
|
+
puts "Testing setting:"
|
|
66
|
+
puts setting.to_yaml
|
|
67
|
+
smtp = SMTP.new setting, pass
|
|
68
|
+
smtp.ok?
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Then /^attempt connections with various IMAP security settings$/ do
|
|
73
|
+
pass = UI::secret "Enter IMAP password for #{$imap_options["user"]}"
|
|
74
|
+
log = ["login", true]
|
|
75
|
+
cram = ["cram_md5", true]
|
|
76
|
+
notls = ["tls", false]
|
|
77
|
+
cert = ["certificate", "/home/spoon/cert"]
|
|
78
|
+
verify = ["verify", true]
|
|
79
|
+
settings = make_settings $imap_options, [log, cram, notls, cert, verify]
|
|
80
|
+
settings.each do |setting|
|
|
81
|
+
puts "Testing setting:"
|
|
82
|
+
puts setting.to_yaml
|
|
83
|
+
imap = IMAP.new setting, pass
|
|
84
|
+
imap.ok?
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
Given /^the email account$/ do
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
$email_config = EmailConfig.new "carps@killersmurf.com", true, $imap_options, $smtp_options
|
|
93
|
+
$email_config.connect!
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
Then /^an email is sent$/ do
|
|
97
|
+
smtp = $email_config.smtp
|
|
98
|
+
smtp.send $email_config.address, "It works!"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
Then /^an email is received$/ do
|
|
102
|
+
puts "The email reads:"
|
|
103
|
+
imap = $email_config.imap
|
|
104
|
+
message = imap.read[0].to_s
|
|
105
|
+
puts "Ruby encodes the message as: #{message.encoding.name}"
|
|
106
|
+
puts message
|
|
107
|
+
puts "End email."
|
|
108
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require "carps/service/interface"
|
|
2
|
+
|
|
3
|
+
class Cheesey < QuitInterface
|
|
4
|
+
|
|
5
|
+
include ControlInterface
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
super
|
|
9
|
+
add_command "cheese", "Have some cheese.", "AGE", "TYPE"
|
|
10
|
+
add_raw_command "echo", "I say what you say!", "MESSAGE"
|
|
11
|
+
add_command "cracker", "Have a cracker."
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def echo arg
|
|
15
|
+
puts arg
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def cheese age, type
|
|
19
|
+
puts "Mmmmm, #{age} #{type}!"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def cracker
|
|
23
|
+
puts "You may have a cracker."
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class Broken < Cheesey
|
|
29
|
+
|
|
30
|
+
def initialize
|
|
31
|
+
super
|
|
32
|
+
add_command "wine", "Have a glass of wine", "YEAR", "TYPE"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
Given /^a cheesey interface$/ do
|
|
38
|
+
$interface = Cheesey.new
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Then /^present the cheesey interface to the user$/ do
|
|
42
|
+
child = fork do
|
|
43
|
+
$interface.run
|
|
44
|
+
end
|
|
45
|
+
Process.wait child
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Test an interface by calling the commands
|
|
49
|
+
def test_interface interface, commands
|
|
50
|
+
commands.each do |cmd|
|
|
51
|
+
interface.send *cmd
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Given /^a broken interface created by a drunk$/ do
|
|
56
|
+
$interface = Broken.new
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Then /^present the interface, reporting the mistake to the user$/ do
|
|
60
|
+
child = fork do
|
|
61
|
+
$interface.run
|
|
62
|
+
end
|
|
63
|
+
Process.wait child
|
|
64
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "carps/util/process"
|
|
2
|
+
|
|
3
|
+
require "drb"
|
|
4
|
+
|
|
5
|
+
include Test
|
|
6
|
+
|
|
7
|
+
Given /an object to be mutated/ do
|
|
8
|
+
$mut = Mutate.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Then /^I should see 'It works' from the server side$/ do
|
|
12
|
+
puts "On server side:"
|
|
13
|
+
puts "\t" + $mut.works?
|
|
14
|
+
unless $mut.working?
|
|
15
|
+
raise StandardError, "IPC fucked."
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
When /^the Process.launch method is called with the name of a ruby subprogram, which I should see in another window$/ do
|
|
20
|
+
test_ipc CARPS::Process.singleton, $mut
|
|
21
|
+
puts "DONE!"
|
|
22
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
require "carps/crypt/mailbox"
|
|
2
|
+
require "carps/crypt/mailer"
|
|
3
|
+
|
|
4
|
+
require "carps/protocol/message"
|
|
5
|
+
|
|
6
|
+
require "carps/service/session"
|
|
7
|
+
|
|
8
|
+
require "fileutils"
|
|
9
|
+
|
|
10
|
+
require "highline"
|
|
11
|
+
|
|
12
|
+
class SessionManager
|
|
13
|
+
def session
|
|
14
|
+
@session
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class MailboxTestMessage < Message
|
|
19
|
+
|
|
20
|
+
def MailboxTestMessage.parse blob
|
|
21
|
+
if blob.match(/uhh/)
|
|
22
|
+
[MailboxTestMessage.new, ""]
|
|
23
|
+
else
|
|
24
|
+
raise Expected, "Expected 'uhh'."
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def emit
|
|
29
|
+
text = "uhh"
|
|
30
|
+
text = $mailbox.tag text
|
|
31
|
+
addr = "bobby"
|
|
32
|
+
sig = "hiya"
|
|
33
|
+
mail = (V.addr addr) + (V.sig sig) + text + K.end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Test the mailbox by sending and receiving mails
|
|
40
|
+
class TestingIO
|
|
41
|
+
|
|
42
|
+
def initialize
|
|
43
|
+
@messages = []
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# send the mailbox a message with a given session_id
|
|
47
|
+
def in id
|
|
48
|
+
$session.session = id
|
|
49
|
+
$mailbox.send "wayhey", MailboxTestMessage.new.emit
|
|
50
|
+
$session.none
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# receive a message from the mailbox within 10 seconds or return nil
|
|
54
|
+
def out
|
|
55
|
+
msg = nil
|
|
56
|
+
thrd = Thread.fork do
|
|
57
|
+
msg = $mailbox.insecure_read MailboxTestMessage
|
|
58
|
+
end
|
|
59
|
+
10.times do
|
|
60
|
+
if msg
|
|
61
|
+
break
|
|
62
|
+
else
|
|
63
|
+
sleep 1
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
thrd.kill
|
|
67
|
+
msg
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def send to, msg
|
|
71
|
+
@messages.push msg
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def read
|
|
75
|
+
messages = @messages
|
|
76
|
+
@messages = []
|
|
77
|
+
messages
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
When /^the user presses enter, continue$/ do
|
|
84
|
+
h = HighLine.new
|
|
85
|
+
h.ask "Press enter to continue..."
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
Then /^\.mail is cleaned$/ do
|
|
89
|
+
FileUtils.rm_rf $CONFIG + ".mail"
|
|
90
|
+
FileUtils.mkdir $CONFIG + ".mail"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Given /^a testing mailbox$/ do
|
|
94
|
+
parser = MessageParser.new [MailboxTestMessage]
|
|
95
|
+
$io = TestingIO.new
|
|
96
|
+
if $mailbox
|
|
97
|
+
$mailbox.shutdown
|
|
98
|
+
end
|
|
99
|
+
$mailbox = Mailbox.new $io, $io, parser, $session
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
Then /^send mail with session (\d+) to the mailbox$/ do |session|
|
|
103
|
+
$io.in session
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
Then /^receive mail with session (\d+)$/ do |session|
|
|
107
|
+
mail = $io.out
|
|
108
|
+
if not mail
|
|
109
|
+
raise StandardError, "Did not receive mail with session #{session}"
|
|
110
|
+
elsif not mail.session == session
|
|
111
|
+
raise StandardError, "Received mail with session #{session}"
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
Then /^set session to (\d+)$/ do |id|
|
|
116
|
+
$session.session = id
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
Then /^check that the mail with session (\d+) has not been received$/ do |session|
|
|
120
|
+
mail = $io.out
|
|
121
|
+
if mail
|
|
122
|
+
if mail.session == session
|
|
123
|
+
raise StandardError, "Received mail with session #{mail.session}"
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require "carps/service/dm/config"
|
|
2
|
+
require "carps/service/player/config"
|
|
3
|
+
|
|
4
|
+
require "carps/service/start/mailer"
|
|
5
|
+
|
|
6
|
+
Given /^a dm game config, for mod (.+)$/ do |mod|
|
|
7
|
+
$game_config = DM::GameConfig.new "save_test", mod, "fun campaign", "game about stuff", $session.key, "dm@dm.dm"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Then /^resume the mod$/ do
|
|
11
|
+
game = $game_config.spawn
|
|
12
|
+
game.resume ModMailer.new nil, $game_config
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Then /^load the DM mod$/ do
|
|
16
|
+
$game_config = DM::GameConfig.load "games/save_test.yaml"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Then /^load the Player mod$/ do
|
|
20
|
+
$game_config = Player::GameConfig.load "games/save_test.yaml"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Given /^a player game config, for mod (.+)$/ do |mod|
|
|
24
|
+
$game_config = Player::GameConfig.new "save_test", mod, "the dm", "game about stuff", $session.key
|
|
25
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "carps/protocol"
|
|
2
|
+
|
|
3
|
+
require "carps/service"
|
|
4
|
+
|
|
5
|
+
When /^an invitation is sent$/ do
|
|
6
|
+
$message = Invite.new "the dm", "the mod", "the description", "The session"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Given /^a parser$/ do
|
|
10
|
+
$parser = Player::parser
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Then /^emit the message$/ do
|
|
14
|
+
$mail = $message.emit
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Then /^parse the message$/ do
|
|
18
|
+
message = $parser.parse $mail
|
|
19
|
+
newmsg = message.emit
|
|
20
|
+
unless $mail == newmsg
|
|
21
|
+
raise StandardError, "Did not correctly parse invite:\nold emitings:\n#{$mail}\nnew emittings:\n#{newmsg}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "carps/protocol/message"
|
|
2
|
+
|
|
3
|
+
class TestMessage < Message
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
Given /^a persistent message$/ do
|
|
7
|
+
$message = TestMessage.new
|
|
8
|
+
$message.from = "someone"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Then /^save the message, noting the file name$/ do
|
|
12
|
+
$file = $message.save "BLAHBLAHBLAH"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Then /^make sure the file exists$/ do
|
|
16
|
+
unless File.exists?($file)
|
|
17
|
+
raise StandardError, "TestMessage did not save itself."
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Then /^delete the message$/ do
|
|
22
|
+
$message.delete
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Then /^make sure the file was deleted$/ do
|
|
26
|
+
if File.exists?($file)
|
|
27
|
+
raise StandardError, "TestMessage did not delete itself."
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require "carps/mod/player/mod"
|
|
2
|
+
require "carps/mod/player/interface"
|
|
3
|
+
|
|
4
|
+
require "carps/mod/client_turn"
|
|
5
|
+
require "carps/mod/status_report"
|
|
6
|
+
|
|
7
|
+
class PlayerTestMod < Player::Mod
|
|
8
|
+
def schema
|
|
9
|
+
$schema
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def description
|
|
13
|
+
<<-END
|
|
14
|
+
You are testing the CARPS player mod system and interface.
|
|
15
|
+
This text was returned by the description method of the test mod.
|
|
16
|
+
|
|
17
|
+
You are about to fill in a character sheet for the 'fruit' game used
|
|
18
|
+
throughout the CARPS testing utility.
|
|
19
|
+
END
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class PlayerModTestMailer
|
|
25
|
+
def relay message
|
|
26
|
+
puts "Sending:"
|
|
27
|
+
puts message.emit
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def check type
|
|
31
|
+
mail = @mail
|
|
32
|
+
@mail = nil
|
|
33
|
+
return mail
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def turn t
|
|
37
|
+
@mail = t
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def save mod
|
|
41
|
+
puts "Saving"
|
|
42
|
+
puts mod.to_s
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Then /^test all inputs to the player's interface$/ do
|
|
48
|
+
commands = []
|
|
49
|
+
commands.push [:act]
|
|
50
|
+
commands.push [:edit]
|
|
51
|
+
commands.push [:sheet]
|
|
52
|
+
test_interface $interface, commands
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
Given /^a player test mailer$/ do
|
|
57
|
+
$mailer = PlayerModTestMailer.new
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
Given /^a player mod$/ do
|
|
61
|
+
$mod = PlayerTestMod.new
|
|
62
|
+
$mod.mailer = $mailer
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
When /^the player receives turn information$/ do
|
|
66
|
+
status = StatusReport.new "You are a player don't you know!"
|
|
67
|
+
questions = [Question.new("Who are you, you strange man?")]
|
|
68
|
+
t = ClientTurn.new Sheet::NewSheet.new({}), status, questions
|
|
69
|
+
$mailer.turn t
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Given /^a player interface$/ do
|
|
73
|
+
$interface = Player::Interface.new $mod
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
Then /^present a user interface to the player$/ do
|
|
77
|
+
begin
|
|
78
|
+
$interface.run
|
|
79
|
+
rescue SystemExit => e
|
|
80
|
+
"Quit program: #{e}"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require "carps/mod"
|
|
2
|
+
|
|
3
|
+
require "carps/protocol"
|
|
4
|
+
|
|
5
|
+
Given /^a status report$/ do
|
|
6
|
+
$status = StatusReport.new "This is some might important information here!"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Then /^the status report should be printed$/ do
|
|
10
|
+
$status.display
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Given /^a question$/ do
|
|
14
|
+
$question = Question.new "What do you do?"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Given /^a parser for the turn$/ do
|
|
18
|
+
$parser = MessageParser.new [ClientTurn]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Then /^the question should be asked$/ do
|
|
22
|
+
ans = Answers.new
|
|
23
|
+
$question.ask ans
|
|
24
|
+
puts "Our conversation:"
|
|
25
|
+
ans.display
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Given /^a status report and a number of questions$/ do
|
|
29
|
+
s = StatusReport.new "Halt, mortal!"
|
|
30
|
+
q1 = Question.new "Who are you?"
|
|
31
|
+
q2 = Question.new "What are you doing here?"
|
|
32
|
+
$turn = ClientTurn.new Sheet::NewSheet.new({}), s, [q1, q2]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
When /^a turn is sent$/ do
|
|
36
|
+
$message = $turn
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
Given /^answers from a player's turn$/ do
|
|
40
|
+
$message = Answers.new({"What do you do?" => "Things!", "Who are you?" => "me."})
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Given /^a parser for the answers$/ do
|
|
44
|
+
$parser = MessageParser.new [Answers]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Then /^all the questions should be asked$/ do
|
|
48
|
+
class Tester
|
|
49
|
+
def send to, answers
|
|
50
|
+
puts "To be sent to #{to}"
|
|
51
|
+
answers.display
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
tester = Tester.new
|
|
55
|
+
tester.send "dungeon master", $turn.take
|
|
56
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require "carps/mod/dice"
|
|
2
|
+
|
|
3
|
+
require "carps/mod/interface"
|
|
4
|
+
|
|
5
|
+
def fill_randoms n
|
|
6
|
+
$randoms = []
|
|
7
|
+
n.times do
|
|
8
|
+
$randoms.push yield
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Given /^(\d+) random integers between (\d+) and (\d+)$/ do |n, min, max|
|
|
13
|
+
n = n.to_i
|
|
14
|
+
min = min.to_i
|
|
15
|
+
max = max.to_i
|
|
16
|
+
fill_randoms n do
|
|
17
|
+
Dice::rint min, max
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Given /^(\d+) random floats between (\d+) and (\d+)$/ do |n, min, max|
|
|
22
|
+
n = n.to_i
|
|
23
|
+
min = min.to_f
|
|
24
|
+
max = max.to_f
|
|
25
|
+
fill_randoms n do
|
|
26
|
+
Dice::rfloat min, max
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Then /^ensure each of the random numbers are between (.+) and (.+)$/ do |min, max|
|
|
31
|
+
min = min.to_i
|
|
32
|
+
max = max.to_i
|
|
33
|
+
works = $randoms.all? do |i|
|
|
34
|
+
i >= min and i <= max
|
|
35
|
+
end
|
|
36
|
+
unless works
|
|
37
|
+
raise StandardError, "Random generator is fucked."
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Given /^an interface to dice rolling$/ do
|
|
42
|
+
$interface = RolePlayInterface.new
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Then /^launch the probabalistic interface$/ do
|
|
46
|
+
$interface.run
|
|
47
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require "carps/mod"
|
|
2
|
+
|
|
3
|
+
class OneTenAction < CARPS::Action
|
|
4
|
+
|
|
5
|
+
def summary
|
|
6
|
+
"The result was between one and ten."
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def execute roll, sheet
|
|
10
|
+
puts "Executing, roll was #{roll}, sheet was #{sheet}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class ElevenThirtyAction < CARPS::Action
|
|
16
|
+
|
|
17
|
+
def summary
|
|
18
|
+
"The result was between eleven and thirty."
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def execute roll, sheet
|
|
22
|
+
puts "Executing, roll was #{roll}, sheet was #{sheet}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class TestRule < CARPS::Rule
|
|
28
|
+
|
|
29
|
+
def initialize
|
|
30
|
+
super
|
|
31
|
+
add_action 1..10, OneTenAction
|
|
32
|
+
add_action :>=, 11, ElevenThirtyAction
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
protected
|
|
36
|
+
|
|
37
|
+
def dice sheet
|
|
38
|
+
CARPS::Dice::d 30
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Then /^show the odds for the rule$/ do
|
|
44
|
+
$rule.show_odds $sheet
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Given /^a rule which operates on a character sheet$/ do
|
|
48
|
+
$rule = TestRule.new
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
Then /^apply the rule$/ do
|
|
52
|
+
$rule.apply $sheet
|
|
53
|
+
end
|