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.
Files changed (157) hide show
  1. data/COPYING +674 -0
  2. data/GEM_DESCRIPTION +10 -0
  3. data/History.txt +4 -0
  4. data/Manifest.txt +156 -0
  5. data/PostInstall.txt +20 -0
  6. data/README.rdoc +141 -0
  7. data/Rakefile +28 -0
  8. data/bin/carps +123 -0
  9. data/bin/carps_init +29 -0
  10. data/bin/carps_ipc_test +44 -0
  11. data/bin/carps_mod_saver_test +71 -0
  12. data/bin/carps_mod_test +62 -0
  13. data/config/website.yml +2 -0
  14. data/features/character_sheet.feature +40 -0
  15. data/features/crash.feature +15 -0
  16. data/features/crypt.feature +22 -0
  17. data/features/dice.feature +173 -0
  18. data/features/dm.feature +36 -0
  19. data/features/dmll.feature +51 -0
  20. data/features/edit.feature +10 -0
  21. data/features/email.feature +29 -0
  22. data/features/interface.feature +17 -0
  23. data/features/ipc.feature +10 -0
  24. data/features/mailbox.feature +33 -0
  25. data/features/mod.feature +31 -0
  26. data/features/parser.feature +9 -0
  27. data/features/persistent_protocol.feature +14 -0
  28. data/features/player.feature +22 -0
  29. data/features/player_turn.feature +29 -0
  30. data/features/random.feature +15 -0
  31. data/features/rule.feature +19 -0
  32. data/features/safety.feature +13 -0
  33. data/features/sessions.feature +16 -0
  34. data/features/start_dm.feature +18 -0
  35. data/features/start_player.feature +8 -0
  36. data/features/step_definitions/common_steps.rb +170 -0
  37. data/features/steps/character_sheet.rb +89 -0
  38. data/features/steps/crash.rb +27 -0
  39. data/features/steps/crypt.rb +166 -0
  40. data/features/steps/dice.rb +91 -0
  41. data/features/steps/dm.rb +147 -0
  42. data/features/steps/dmll.rb +47 -0
  43. data/features/steps/edit.rb +7 -0
  44. data/features/steps/email.rb +108 -0
  45. data/features/steps/general.rb +5 -0
  46. data/features/steps/interface.rb +64 -0
  47. data/features/steps/ipc.rb +22 -0
  48. data/features/steps/mailbox.rb +126 -0
  49. data/features/steps/mod.rb +25 -0
  50. data/features/steps/parser.rb +23 -0
  51. data/features/steps/persistent_protocol.rb +29 -0
  52. data/features/steps/player.rb +82 -0
  53. data/features/steps/player_turn.rb +56 -0
  54. data/features/steps/random.rb +47 -0
  55. data/features/steps/rule.rb +53 -0
  56. data/features/steps/safety.rb +17 -0
  57. data/features/steps/sessions.rb +37 -0
  58. data/features/steps/start_dm.rb +46 -0
  59. data/features/steps/start_player.rb +65 -0
  60. data/features/steps/timeout.rb +32 -0
  61. data/features/steps/type_verification.rb +36 -0
  62. data/features/steps/wizard.rb +123 -0
  63. data/features/support/common.rb +29 -0
  64. data/features/support/env.rb +14 -0
  65. data/features/support/matchers.rb +11 -0
  66. data/features/timeout.feature +11 -0
  67. data/features/type_verification.feature +48 -0
  68. data/features/wizard.feature +50 -0
  69. data/lib/carps/crypt/accept_handshake.rb +40 -0
  70. data/lib/carps/crypt/default_messages.rb +29 -0
  71. data/lib/carps/crypt/handshake.rb +41 -0
  72. data/lib/carps/crypt/mailbox.rb +265 -0
  73. data/lib/carps/crypt/mailer.rb +220 -0
  74. data/lib/carps/crypt/peer.rb +123 -0
  75. data/lib/carps/crypt/public_key.rb +60 -0
  76. data/lib/carps/crypt.rb +23 -0
  77. data/lib/carps/email/config.rb +122 -0
  78. data/lib/carps/email/imap.rb +156 -0
  79. data/lib/carps/email/smtp.rb +119 -0
  80. data/lib/carps/email/string.rb +30 -0
  81. data/lib/carps/email.rb +21 -0
  82. data/lib/carps/mod/action.rb +36 -0
  83. data/lib/carps/mod/answers.rb +76 -0
  84. data/lib/carps/mod/client_turn.rb +88 -0
  85. data/lib/carps/mod/dice.rb +360 -0
  86. data/lib/carps/mod/dm/interface.rb +160 -0
  87. data/lib/carps/mod/dm/mod.rb +409 -0
  88. data/lib/carps/mod/dm/reporter.rb +112 -0
  89. data/lib/carps/mod/dm/resource.rb +88 -0
  90. data/lib/carps/mod/dm/room.rb +33 -0
  91. data/lib/carps/mod/interface.rb +73 -0
  92. data/lib/carps/mod/launch.rb +108 -0
  93. data/lib/carps/mod/mod.rb +52 -0
  94. data/lib/carps/mod/player/interface.rb +76 -0
  95. data/lib/carps/mod/player/mod.rb +109 -0
  96. data/lib/carps/mod/question.rb +63 -0
  97. data/lib/carps/mod/rule.rb +112 -0
  98. data/lib/carps/mod/sheet/character.rb +82 -0
  99. data/lib/carps/mod/sheet/editor.rb +97 -0
  100. data/lib/carps/mod/sheet/new_sheet.rb +71 -0
  101. data/lib/carps/mod/sheet/schema.rb +84 -0
  102. data/lib/carps/mod/sheet/type.rb +161 -0
  103. data/lib/carps/mod/sheet/verifier.rb +41 -0
  104. data/lib/carps/mod/status_report.rb +51 -0
  105. data/lib/carps/mod.rb +40 -0
  106. data/lib/carps/protocol/keyword.rb +104 -0
  107. data/lib/carps/protocol/message.rb +138 -0
  108. data/lib/carps/protocol.rb +19 -0
  109. data/lib/carps/service/client_parser.rb +34 -0
  110. data/lib/carps/service/dm/config.rb +76 -0
  111. data/lib/carps/service/dm/mailer.rb +70 -0
  112. data/lib/carps/service/dm/new_game.rb +101 -0
  113. data/lib/carps/service/dm/start.rb +47 -0
  114. data/lib/carps/service/game.rb +101 -0
  115. data/lib/carps/service/interface.rb +174 -0
  116. data/lib/carps/service/invite.rb +79 -0
  117. data/lib/carps/service/mod.rb +43 -0
  118. data/lib/carps/service/player/config.rb +78 -0
  119. data/lib/carps/service/player/mailer.rb +49 -0
  120. data/lib/carps/service/player/start.rb +60 -0
  121. data/lib/carps/service/server_parser.rb +33 -0
  122. data/lib/carps/service/session.rb +96 -0
  123. data/lib/carps/service/start/config.rb +71 -0
  124. data/lib/carps/service/start/interface.rb +101 -0
  125. data/lib/carps/service/start/mailer.rb +46 -0
  126. data/lib/carps/service.rb +35 -0
  127. data/lib/carps/test.rb +34 -0
  128. data/lib/carps/ui/colour.rb +28 -0
  129. data/lib/carps/ui/error.rb +39 -0
  130. data/lib/carps/ui/highlight.rb +32 -0
  131. data/lib/carps/ui/question.rb +63 -0
  132. data/lib/carps/ui/warn.rb +37 -0
  133. data/lib/carps/ui.rb +21 -0
  134. data/lib/carps/util/config.rb +162 -0
  135. data/lib/carps/util/editor.rb +147 -0
  136. data/lib/carps/util/error.rb +75 -0
  137. data/lib/carps/util/files.rb +48 -0
  138. data/lib/carps/util/init.rb +93 -0
  139. data/lib/carps/util/process.rb +150 -0
  140. data/lib/carps/util/timeout.rb +31 -0
  141. data/lib/carps/util/windows.rb +29 -0
  142. data/lib/carps/util.rb +24 -0
  143. data/lib/carps/wizard/dm.rb +41 -0
  144. data/lib/carps/wizard/player.rb +40 -0
  145. data/lib/carps/wizard/steps.rb +494 -0
  146. data/lib/carps/wizard/wizard.rb +126 -0
  147. data/lib/carps/wizard.rb +21 -0
  148. data/lib/carps.rb +45 -0
  149. data/permission +16 -0
  150. data/script/console +10 -0
  151. data/script/destroy +14 -0
  152. data/script/generate +14 -0
  153. data/tasks/readme_site.rake +28 -0
  154. data/test/test_carps.rb +11 -0
  155. data/test/test_helper.rb +3 -0
  156. data/website/index.html +271 -0
  157. metadata +304 -0
data/GEM_DESCRIPTION ADDED
@@ -0,0 +1,10 @@
1
+ CARPS, the Computer Assisted Role-Playing Game System,
2
+ is a tool for playing pen and paper RPGs over the internet.
3
+
4
+ CARPS is:
5
+
6
+ extensible; game rules are provided by extensions to CARPS.
7
+
8
+ decentralized; CARPS' protocol is a layer on top of email.
9
+
10
+ secure; CARPS messages are cryptographically signed to prevent spoofing.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2010-09-29
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,156 @@
1
+ COPYING
2
+ GEM_DESCRIPTION
3
+ History.txt
4
+ Manifest.txt
5
+ PostInstall.txt
6
+ README.rdoc
7
+ Rakefile
8
+ bin/carps
9
+ bin/carps_init
10
+ bin/carps_ipc_test
11
+ bin/carps_mod_saver_test
12
+ bin/carps_mod_test
13
+ config/website.yml
14
+ features/character_sheet.feature
15
+ features/crash.feature
16
+ features/crypt.feature
17
+ features/dice.feature
18
+ features/dm.feature
19
+ features/dmll.feature
20
+ features/edit.feature
21
+ features/email.feature
22
+ features/interface.feature
23
+ features/ipc.feature
24
+ features/mailbox.feature
25
+ features/mod.feature
26
+ features/parser.feature
27
+ features/persistent_protocol.feature
28
+ features/player.feature
29
+ features/player_turn.feature
30
+ features/random.feature
31
+ features/rule.feature
32
+ features/safety.feature
33
+ features/sessions.feature
34
+ features/start_dm.feature
35
+ features/start_player.feature
36
+ features/step_definitions/common_steps.rb
37
+ features/steps/character_sheet.rb
38
+ features/steps/crash.rb
39
+ features/steps/crypt.rb
40
+ features/steps/dice.rb
41
+ features/steps/dm.rb
42
+ features/steps/dmll.rb
43
+ features/steps/edit.rb
44
+ features/steps/email.rb
45
+ features/steps/general.rb
46
+ features/steps/interface.rb
47
+ features/steps/ipc.rb
48
+ features/steps/mailbox.rb
49
+ features/steps/mod.rb
50
+ features/steps/parser.rb
51
+ features/steps/persistent_protocol.rb
52
+ features/steps/player.rb
53
+ features/steps/player_turn.rb
54
+ features/steps/random.rb
55
+ features/steps/rule.rb
56
+ features/steps/safety.rb
57
+ features/steps/sessions.rb
58
+ features/steps/start_dm.rb
59
+ features/steps/start_player.rb
60
+ features/steps/timeout.rb
61
+ features/steps/type_verification.rb
62
+ features/steps/wizard.rb
63
+ features/support/common.rb
64
+ features/support/env.rb
65
+ features/support/matchers.rb
66
+ features/timeout.feature
67
+ features/type_verification.feature
68
+ features/wizard.feature
69
+ lib/carps.rb
70
+ lib/carps/crypt.rb
71
+ lib/carps/crypt/accept_handshake.rb
72
+ lib/carps/crypt/default_messages.rb
73
+ lib/carps/crypt/handshake.rb
74
+ lib/carps/crypt/mailbox.rb
75
+ lib/carps/crypt/mailer.rb
76
+ lib/carps/crypt/peer.rb
77
+ lib/carps/crypt/public_key.rb
78
+ lib/carps/email.rb
79
+ lib/carps/email/config.rb
80
+ lib/carps/email/imap.rb
81
+ lib/carps/email/smtp.rb
82
+ lib/carps/email/string.rb
83
+ lib/carps/mod.rb
84
+ lib/carps/mod/action.rb
85
+ lib/carps/mod/answers.rb
86
+ lib/carps/mod/client_turn.rb
87
+ lib/carps/mod/dice.rb
88
+ lib/carps/mod/dm/interface.rb
89
+ lib/carps/mod/dm/mod.rb
90
+ lib/carps/mod/dm/reporter.rb
91
+ lib/carps/mod/dm/resource.rb
92
+ lib/carps/mod/dm/room.rb
93
+ lib/carps/mod/interface.rb
94
+ lib/carps/mod/launch.rb
95
+ lib/carps/mod/mod.rb
96
+ lib/carps/mod/player/interface.rb
97
+ lib/carps/mod/player/mod.rb
98
+ lib/carps/mod/question.rb
99
+ lib/carps/mod/rule.rb
100
+ lib/carps/mod/sheet/character.rb
101
+ lib/carps/mod/sheet/editor.rb
102
+ lib/carps/mod/sheet/new_sheet.rb
103
+ lib/carps/mod/sheet/schema.rb
104
+ lib/carps/mod/sheet/type.rb
105
+ lib/carps/mod/sheet/verifier.rb
106
+ lib/carps/mod/status_report.rb
107
+ lib/carps/protocol.rb
108
+ lib/carps/protocol/keyword.rb
109
+ lib/carps/protocol/message.rb
110
+ lib/carps/service.rb
111
+ lib/carps/service/client_parser.rb
112
+ lib/carps/service/dm/config.rb
113
+ lib/carps/service/dm/mailer.rb
114
+ lib/carps/service/dm/new_game.rb
115
+ lib/carps/service/dm/start.rb
116
+ lib/carps/service/game.rb
117
+ lib/carps/service/interface.rb
118
+ lib/carps/service/invite.rb
119
+ lib/carps/service/mod.rb
120
+ lib/carps/service/player/config.rb
121
+ lib/carps/service/player/mailer.rb
122
+ lib/carps/service/player/start.rb
123
+ lib/carps/service/server_parser.rb
124
+ lib/carps/service/session.rb
125
+ lib/carps/service/start/config.rb
126
+ lib/carps/service/start/interface.rb
127
+ lib/carps/service/start/mailer.rb
128
+ lib/carps/test.rb
129
+ lib/carps/ui.rb
130
+ lib/carps/ui/colour.rb
131
+ lib/carps/ui/error.rb
132
+ lib/carps/ui/highlight.rb
133
+ lib/carps/ui/question.rb
134
+ lib/carps/ui/warn.rb
135
+ lib/carps/util.rb
136
+ lib/carps/util/config.rb
137
+ lib/carps/util/editor.rb
138
+ lib/carps/util/error.rb
139
+ lib/carps/util/files.rb
140
+ lib/carps/util/init.rb
141
+ lib/carps/util/process.rb
142
+ lib/carps/util/timeout.rb
143
+ lib/carps/util/windows.rb
144
+ lib/carps/wizard.rb
145
+ lib/carps/wizard/dm.rb
146
+ lib/carps/wizard/player.rb
147
+ lib/carps/wizard/steps.rb
148
+ lib/carps/wizard/wizard.rb
149
+ permission
150
+ script/console
151
+ script/destroy
152
+ script/generate
153
+ tasks/readme_site.rake
154
+ test/test_carps.rb
155
+ test/test_helper.rb
156
+ website/index.html
data/PostInstall.txt ADDED
@@ -0,0 +1,20 @@
1
+ =========================================================================
2
+
3
+ 0
4
+ O
5
+ o
6
+ ><> ><> ><>
7
+
8
+ Thank you for installing CARPS 0.2.1
9
+
10
+ For help, run:
11
+
12
+ carps -h
13
+
14
+
15
+ CARPS is hosted on github at
16
+ http://github.com/elginer/carps
17
+
18
+ CARPS is copyright John Morrice 2010
19
+
20
+ =========================================================================
data/README.rdoc ADDED
@@ -0,0 +1,141 @@
1
+ = CARPS, the Computer Assisted Role-Playing Game System
2
+
3
+ == CARPS is hosted on github:
4
+
5
+ * http://github.com/elginer/carps
6
+
7
+ == Description:
8
+
9
+ CARPS, the Computer Assisted Role-Playing Game System,
10
+ is a tool for playing pen and paper RPGs over the internet.
11
+
12
+ CARPS differs from other such systems because CARPS is not a 'real-time' system. It suits people who want to log on once or twice a day, take a turn, and then log out again. While _OpenRPG_ could be described as being similar to a chat-room, CARPS is more similar to an email client.
13
+
14
+ CARPS is an extensible system: game rules are provided by 'mods'.
15
+
16
+ CARPS supports these mods by providing:
17
+
18
+ * Text-mode user interfaces for the players and the dungeon master.
19
+
20
+ * An easy to use probabilistic API which not only rolls the dice, but can report the probability of various game events occurring.
21
+
22
+ * Automated static character sheet verification, according to a schema defined in YAML. For example, a game might require your strength to be an integer.
23
+
24
+ * Support for the semantic validation of character sheets according to game rules. For example, a game might require the sum of character's attributes to be below a certain maximum value.
25
+
26
+ * Together the validation features allow a mod writer to encode game rules cleanly, as they do not need to consider the possibility of receiving an invalid sheet.
27
+
28
+ CARPS has other strengths:
29
+
30
+ * *Anyone* can play or host a CARPS game! All you need is an email account.
31
+
32
+ * CARPS is designed to be secure. Multiple email security options are supported, and all CARPS messages are cryptographically signed to prevent spoofing.
33
+
34
+ * You can instruct CARPS to use your favourite text editor and terminal emulator.
35
+
36
+ * CARPS is easy to configure because it includes a wizard.
37
+
38
+ *However*, CARPS is new and the following features, which you might take for granted, are not yet supported:
39
+
40
+ * No GUI
41
+
42
+ * No support for maps
43
+
44
+ * No chat - all communication goes through the Game Master.
45
+
46
+ * Games are currently invite only, at the discretion of the Game Master.
47
+
48
+ * Security mechanisms are *not* well audited.
49
+
50
+ == Requirements:
51
+
52
+ For users:
53
+
54
+ * ruby 1.9
55
+
56
+ * rubygems
57
+
58
+ * openssl
59
+
60
+ * highline
61
+
62
+ For developing CARPS, you will also need:
63
+
64
+ * hoe
65
+
66
+ * rake
67
+
68
+ * newgem
69
+
70
+ * cucumber
71
+
72
+ == To Install:
73
+
74
+ <tt># Install the gem</tt>
75
+
76
+ <tt>sudo gem install carps</tt>
77
+
78
+ <tt># Initialize the carps user directory. Run this as your everyday user.</tt>
79
+
80
+ <tt>carps_init</tt>
81
+
82
+ == Basic Instructions:
83
+
84
+ Run carps -h for help
85
+
86
+ The first time CARPS is run, it will launch a wizard to help you configure
87
+ your email settings, and choose a text editor and a terminal emulator.
88
+
89
+ It is a good idea to specify a terminal emulator, as then CARPS can launch a
90
+ mod in a new window (or similar). Then the first CARPS window will act as an
91
+ email logger, letting you see when you receive mails, without interfering with
92
+ the text you type into the new window.
93
+
94
+ You're also going to need to install a mod to play CARPS. See the example 'fools' mod:
95
+
96
+ * http://fools.rubyforge.org
97
+
98
+
99
+ == Campaigns (For the DM):
100
+
101
+ When you set up a new game, CARPS will ask for you to enter the name of a campaign.
102
+
103
+ This allows you to create game resources prior to starting a game.
104
+
105
+ For example, the following applies if your mod is called foo, the campaign is called bar, and your carps user data directory is /home/user/carps
106
+
107
+ You should create the following directories
108
+
109
+ the campaign directory:
110
+
111
+ <tt>/home/user/carps/dm/campaigns/foo/bar</tt>
112
+
113
+ the NPCSs directory:
114
+
115
+ <tt>/home/user/carps/dm/campaigns/foo/bar/npcs</tt>
116
+
117
+ the rooms directory:
118
+
119
+ <tt>/home/user/carps/dm/campaigns/foo/bar/rooms</tt>
120
+
121
+ NPCs are defined as YAML files, according to the mod's schema. Put them in the NPCs directory. They MUST have the <tt>.yaml</tt> extension.
122
+
123
+ Rooms are defined as text files. These are just predefined pieces of prose that the DM will send to the players when they enter a room, for instance. Put them in the rooms directory. They MUST have the <tt>.txt</tt> extension.
124
+
125
+
126
+ == License:
127
+
128
+ Copyright 2010 John Morrice
129
+
130
+ CARPS is free software: you can redistribute it and/or modify
131
+ it under the terms of the GNU General Public License as published by
132
+ the Free Software Foundation, either version 3 of the License, or
133
+ (at your option) any later version.
134
+
135
+ CARPS is distributed in the hope that it will be useful,
136
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
137
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138
+ GNU General Public License for more details.
139
+
140
+ You should have received a copy of the GNU General Public License
141
+ along with CARPS. If not, see http://www.gnu.org/licenses/.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ $IN_RAKE = true
6
+ require './lib/carps'
7
+
8
+ Hoe.plugin :newgem
9
+ Hoe.plugin :website
10
+ Hoe.plugin :cucumberfeatures
11
+
12
+ # Generate all the Rake tasks
13
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
14
+ $hoe = Hoe.spec 'carps' do
15
+ self.developer 'John Morrice', 'spoon@killersmurf.com'
16
+ self.post_install_message = File.read 'PostInstall.txt'
17
+ self.rubyforge_name = self.name
18
+ self.description = File.read "GEM_DESCRIPTION"
19
+ self.summary = "Computer Assisted Role-Playing Game System"
20
+ self.extra_deps = [['highline','>= 1.6.1']]
21
+ end
22
+
23
+ require 'newgem/tasks'
24
+ Dir['tasks/**/*.rake'].each { |t| load t }
25
+
26
+ # TODO - want other tests/tasks run by default? Add them to the list
27
+ # remove_task :default
28
+ # task :default => [:spec, :features]
data/bin/carps ADDED
@@ -0,0 +1,123 @@
1
+ #!/usr/local/bin/ruby
2
+ # Copyright 2010 John Morrice
3
+
4
+ # This file is part of CARPS.
5
+
6
+ # CARPS is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+
11
+ # CARPS is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with CARPS. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require "optparse"
20
+
21
+ require "carps"
22
+
23
+ include CARPS
24
+
25
+ # Set up the email
26
+ def setup_email parser, session
27
+ config = EmailConfig.load
28
+ config.connect!
29
+ config.mailer parser, session
30
+ end
31
+
32
+ # Launch a CARPS session for a given role
33
+ def play_role config, role
34
+ wizard = role::Wizard.new
35
+ if wizard.first_time?
36
+ wizard.create_files
37
+ wizard.create_directories
38
+ config = true
39
+ end
40
+ if config
41
+ wizard.run
42
+ else
43
+ CARPS::init
44
+ session = SessionManager.new
45
+ mailer = setup_email role::parser, session
46
+ role::StartInterface.start_game_interface mailer, role::GameConfig, session
47
+ end
48
+ end
49
+
50
+ # Run CARPS
51
+ def carps
52
+ # The user is a player
53
+ player = false
54
+ # The user is a dungeon master
55
+ dm = false
56
+ # Configure CARPS
57
+ config = false
58
+
59
+ opts = OptionParser.new do |opts|
60
+
61
+ opts.banner = "Usage: carps [OPTION]"
62
+
63
+ opts.separator ""
64
+ opts.separator "Game options:"
65
+
66
+ opts.on "-p", "--player", "Play a game." do
67
+ player = true
68
+ end
69
+
70
+ opts.on "-m", "--master", "Host a game." do
71
+ dm = true
72
+ end
73
+
74
+ opts.separator ""
75
+ opts.separator "Other options:"
76
+
77
+ opts.on "-w", "--wizard", "Use this option to configure your settings. Use with either --master or --player." do
78
+ config = true
79
+ end
80
+
81
+ opts.on "-h", "--help", "Print help." do
82
+ puts opts
83
+ exit
84
+ end
85
+
86
+ opts.on "-v", "--version", "Print version number." do
87
+ puts VERSION
88
+ exit
89
+ end
90
+
91
+ opts.on "-d", "--debug", "Debug mode." do
92
+ $DEBUG = true
93
+ end
94
+
95
+ end
96
+
97
+ begin
98
+ opts.parse! ARGV
99
+ rescue StandardError => e
100
+ puts e.to_s
101
+ puts opts
102
+ exit 1
103
+ end
104
+
105
+
106
+ if player and not dm
107
+ CARPS::config_dir "player"
108
+ play_role config, Player
109
+
110
+ elsif dm and not player
111
+ CARPS::config_dir "dm"
112
+ play_role config, DM
113
+ else
114
+ puts opts
115
+ exit 1
116
+ end
117
+ end
118
+
119
+
120
+ # Run CARPS, emitting a nice crash report if it fails
121
+ CARPS::with_crash_report do
122
+ carps
123
+ end
data/bin/carps_init ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/local/bin/ruby
2
+ # Copyright 2010 John Morrice
3
+
4
+ # This file is part of CARPS.
5
+
6
+ # CARPS is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+
11
+ # CARPS is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with CARPS. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ # Create the user directory for carps
20
+
21
+ require "carps"
22
+
23
+ require "fileutils"
24
+
25
+ root = CARPS::root_config
26
+ FileUtils.mkdir root
27
+ FileUtils.mkdir root + "player/"
28
+ FileUtils.mkdir root + "dm/"
29
+ FileUtils.touch root + "mods.yaml"
@@ -0,0 +1,44 @@
1
+ #!/usr/local/bin/ruby
2
+ # Copyright 2010 John Morrice
3
+
4
+ # This file is part of CARPS.
5
+
6
+ # CARPS is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+
11
+ # CARPS is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with CARPS. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ # Test CARPS IPC. Used for unit testing and as part of the wizard.
20
+ require "drb"
21
+
22
+ require "highline"
23
+
24
+ require "carps/util"
25
+
26
+ DRb.start_service
27
+
28
+ url = ARGV.shift
29
+
30
+ puts "Listening on " + url
31
+ puts "Waiting to see if it triggers a race condition bug..."
32
+ sleep 2
33
+
34
+ begin
35
+ mut = DRbObject.new nil, url
36
+ mut.mutate!
37
+ puts mut.works?
38
+ rescue StandardError => e
39
+ puts "ERROR:"
40
+ puts e
41
+ CARPS::enter_quit 1
42
+ end
43
+
44
+ CARPS::enter_quit
@@ -0,0 +1,71 @@
1
+ #!/usr/local/bin/ruby
2
+ # Copyright 2010 John Morrice
3
+
4
+ # This file is part of CARPS.
5
+
6
+ # CARPS is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+
11
+ # CARPS is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with CARPS. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ # Test that a mod running in another process can save its state via CARPS.
20
+
21
+ require "carps"
22
+
23
+ class Saver
24
+
25
+ def mailer= mailer
26
+ @mailer = mailer
27
+ end
28
+
29
+ def initialize
30
+ @state = 99
31
+ end
32
+
33
+ def inc
34
+ @state += 1
35
+ puts "Saver: state now #{@state}"
36
+ @mailer.save self
37
+ end
38
+
39
+ end
40
+
41
+ module SaverMod
42
+
43
+ module Player
44
+
45
+ def Player::create_mod
46
+ Saver.new
47
+ end
48
+
49
+ def Player::launch mod
50
+ mod.inc
51
+ end
52
+
53
+ end
54
+
55
+ module DM
56
+
57
+ def DM::create_mod campaign
58
+ Saver.new
59
+ end
60
+
61
+ def DM::launch mod
62
+ mod.inc
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+
69
+ CARPS::Launcher.launch SaverMod
70
+
71
+ CARPS::enter_quit
@@ -0,0 +1,62 @@
1
+ #!/usr/local/bin/ruby
2
+ # Copyright 2010 John Morrice
3
+
4
+ # This file is part of CARPS.
5
+
6
+ # CARPS is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+
11
+ # CARPS is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with CARPS. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ # Test CARPS mod launching. Used for unit testing and as part of the wizard.
20
+
21
+ require "carps"
22
+
23
+ module TestMod
24
+
25
+ module Player
26
+
27
+ class Mod < CARPS::Player::Mod
28
+
29
+ end
30
+
31
+ def Player::create_mod
32
+ puts "Creating Player mod with"
33
+ Mod.new
34
+ end
35
+
36
+ def Player::launch mod
37
+ puts "Launching mod: #{mod.class}"
38
+ end
39
+
40
+ end
41
+
42
+ module DM
43
+
44
+ class Mod < CARPS::DM::Mod
45
+ end
46
+
47
+ def DM::create_mod campaign
48
+ puts "Creating DM mod running campaign: #{campaign}"
49
+ Mod.new CARPS::Resource.new campaign
50
+ end
51
+
52
+ def DM::launch mod
53
+ puts "Launching mod: #{mod.class}"
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+
60
+ CARPS::Launcher.launch TestMod
61
+
62
+ CARPS::enter_quit
@@ -0,0 +1,2 @@
1
+ host: spoon@rubyforge.org
2
+ remote_dir: /var/www/gforge-projects/carps