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,43 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/util/init"
|
|
19
|
+
|
|
20
|
+
require "drb"
|
|
21
|
+
|
|
22
|
+
require "yaml"
|
|
23
|
+
|
|
24
|
+
module CARPS
|
|
25
|
+
|
|
26
|
+
# Load the available mods
|
|
27
|
+
#
|
|
28
|
+
# Performs untaint
|
|
29
|
+
def load_mods
|
|
30
|
+
mod_file = CARPS::root_config + "/mods.yaml"
|
|
31
|
+
mods = {}
|
|
32
|
+
begin
|
|
33
|
+
mods = YAML.load(File.read mod_file)
|
|
34
|
+
rescue
|
|
35
|
+
UI::warn "Cannot find mods: could not read #{mod_file}"
|
|
36
|
+
end
|
|
37
|
+
mods.each_value do |mod|
|
|
38
|
+
mod.untaint
|
|
39
|
+
end
|
|
40
|
+
mods
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/service/game"
|
|
19
|
+
require "carps/service/start/config"
|
|
20
|
+
|
|
21
|
+
require "yaml"
|
|
22
|
+
|
|
23
|
+
module CARPS
|
|
24
|
+
|
|
25
|
+
module Player
|
|
26
|
+
|
|
27
|
+
# Class to read game configuration files
|
|
28
|
+
class GameConfig < SessionConfig
|
|
29
|
+
|
|
30
|
+
# Create a new GameConfig
|
|
31
|
+
def initialize filename, mod, dm, about, session
|
|
32
|
+
super session, filename
|
|
33
|
+
@mod = mod
|
|
34
|
+
@dm = dm
|
|
35
|
+
@about = about
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Set the file name
|
|
39
|
+
def filename= fn
|
|
40
|
+
@filename = fn
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Parse a game config file
|
|
44
|
+
def parse_yaml conf
|
|
45
|
+
super
|
|
46
|
+
@mod = read_conf conf, "mod"
|
|
47
|
+
@about = read_conf conf, "about"
|
|
48
|
+
@dm = read_conf conf, "dm"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Display information on this configuration
|
|
52
|
+
def display
|
|
53
|
+
puts "Mod: " + @mod
|
|
54
|
+
puts "Description:"
|
|
55
|
+
puts @about
|
|
56
|
+
puts "DM: " + @dm
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Spawn a game object so we can resume the game
|
|
60
|
+
def spawn
|
|
61
|
+
GameClient.new @dm, @mod, self
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
protected
|
|
65
|
+
|
|
66
|
+
# Emit as hash
|
|
67
|
+
def emit
|
|
68
|
+
{"mod" => @mod,
|
|
69
|
+
"about" => @about,
|
|
70
|
+
"dm" => @dm
|
|
71
|
+
}.merge super
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/service/start/mailer"
|
|
19
|
+
|
|
20
|
+
module CARPS
|
|
21
|
+
|
|
22
|
+
module Player
|
|
23
|
+
|
|
24
|
+
# A bridge between the Player mod and CARPS
|
|
25
|
+
class Mailer < ModMailer
|
|
26
|
+
|
|
27
|
+
# Create from the email address of the dungeon master,
|
|
28
|
+
# a mailer,
|
|
29
|
+
# and a configuration file
|
|
30
|
+
def initialize dm, mailer, conf
|
|
31
|
+
@dm = dm
|
|
32
|
+
super mailer, conf
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Check for mail from the dm
|
|
36
|
+
def check type
|
|
37
|
+
@mailer.check type, @dm
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Send mail to the dm
|
|
41
|
+
def relay message
|
|
42
|
+
@mailer.send @dm, message
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/service/start/interface"
|
|
19
|
+
|
|
20
|
+
require "carps/service/game"
|
|
21
|
+
|
|
22
|
+
require "carps/ui/question"
|
|
23
|
+
|
|
24
|
+
module CARPS
|
|
25
|
+
|
|
26
|
+
module Player
|
|
27
|
+
|
|
28
|
+
# Interface for the player to join games
|
|
29
|
+
class StartInterface < StartGameInterface
|
|
30
|
+
|
|
31
|
+
def initialize continuation, mailer, game_config, manager
|
|
32
|
+
super
|
|
33
|
+
add_command "mail", "Check for mail."
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
protected
|
|
37
|
+
|
|
38
|
+
def mail
|
|
39
|
+
invite = @mailer.check Invite
|
|
40
|
+
if invite
|
|
41
|
+
if config = invite.ask
|
|
42
|
+
config.register_session @manager
|
|
43
|
+
config.save
|
|
44
|
+
game = config.spawn
|
|
45
|
+
@continuation.call lambda {
|
|
46
|
+
game.join_game @mailer
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
elsif shake = @mailer.check_handshake
|
|
50
|
+
@mailer.handle_handshake shake
|
|
51
|
+
else
|
|
52
|
+
puts "No new mail."
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/crypt"
|
|
19
|
+
|
|
20
|
+
require "carps/mod"
|
|
21
|
+
|
|
22
|
+
module CARPS
|
|
23
|
+
|
|
24
|
+
module DM
|
|
25
|
+
|
|
26
|
+
# Create a parser which parses messages for the server
|
|
27
|
+
def DM::parser
|
|
28
|
+
MessageParser.new default_messages + [Sheet::NewSheet, Answers]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "thread"
|
|
19
|
+
|
|
20
|
+
module CARPS
|
|
21
|
+
|
|
22
|
+
# A session manager
|
|
23
|
+
#
|
|
24
|
+
# It coordinates sessions between the game and the email system
|
|
25
|
+
# The idea is to prevent a game from receiving messages
|
|
26
|
+
# intended for another game.
|
|
27
|
+
#
|
|
28
|
+
# Its methods are reentrant
|
|
29
|
+
class SessionManager
|
|
30
|
+
|
|
31
|
+
def initialize
|
|
32
|
+
@session = ""
|
|
33
|
+
@semaphore = Mutex.new
|
|
34
|
+
@syms = (" ".."~").to_a
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Generate a number of random symbols
|
|
38
|
+
def randoms size
|
|
39
|
+
ras = Array.new size do |forget|
|
|
40
|
+
@syms[rand(95)]
|
|
41
|
+
end
|
|
42
|
+
ras.join
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Generate a new session from a key
|
|
46
|
+
def generate key
|
|
47
|
+
t = Time.new
|
|
48
|
+
# It will be unlikely that anyone will guess this session
|
|
49
|
+
ra = randoms 1000
|
|
50
|
+
new_session = ra + key + t.to_f.to_s
|
|
51
|
+
@semaphore.synchronize do
|
|
52
|
+
@session = new_session
|
|
53
|
+
end
|
|
54
|
+
@session
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Set the current session
|
|
58
|
+
def session= sess
|
|
59
|
+
@semaphore.synchronize do
|
|
60
|
+
@session = sess
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Get the session key
|
|
65
|
+
def key
|
|
66
|
+
@session
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Remove the current session
|
|
70
|
+
def none
|
|
71
|
+
@semaphore.synchronize do
|
|
72
|
+
@session = ""
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Is this message appropriate for the current session
|
|
77
|
+
def belong? message
|
|
78
|
+
@semaphore.synchronize do
|
|
79
|
+
if not message.session
|
|
80
|
+
false
|
|
81
|
+
elsif not @session.empty?
|
|
82
|
+
message.session == @session
|
|
83
|
+
else
|
|
84
|
+
true
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Tag a string with a message
|
|
90
|
+
def tag message
|
|
91
|
+
V.session(@session) + message
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/util/config"
|
|
19
|
+
|
|
20
|
+
module CARPS
|
|
21
|
+
|
|
22
|
+
# A configuration file for games which keeps track of sessions,
|
|
23
|
+
# and the mod's saved state
|
|
24
|
+
class SessionConfig < UserConfig
|
|
25
|
+
|
|
26
|
+
# Create from session ID and filename
|
|
27
|
+
def initialize session, filename
|
|
28
|
+
@session = session
|
|
29
|
+
@filename = filename
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Set the session used by a session manager
|
|
33
|
+
def register_session manager
|
|
34
|
+
manager.session = @session
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def parse_yaml conf
|
|
38
|
+
@filename = read_conf conf, "filename"
|
|
39
|
+
@session = read_conf conf, "session"
|
|
40
|
+
@save = conf["save"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Save the mod
|
|
44
|
+
#
|
|
45
|
+
# Also saves the file
|
|
46
|
+
def save_mod mod
|
|
47
|
+
@save = mod
|
|
48
|
+
save
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Load the mod
|
|
52
|
+
def load_mod
|
|
53
|
+
@save
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Save this game
|
|
57
|
+
def save
|
|
58
|
+
save_file "games/" + @filename + ".yaml"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
protected
|
|
62
|
+
|
|
63
|
+
def emit
|
|
64
|
+
{"filename" => @filename,
|
|
65
|
+
"save" => @save,
|
|
66
|
+
"session" => @session}
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/service/interface"
|
|
19
|
+
|
|
20
|
+
require "carps/ui/highlight"
|
|
21
|
+
require "carps/ui/error"
|
|
22
|
+
|
|
23
|
+
require "continuation"
|
|
24
|
+
|
|
25
|
+
module CARPS
|
|
26
|
+
|
|
27
|
+
# Interface to start games
|
|
28
|
+
class StartGameInterface < QuitInterface
|
|
29
|
+
|
|
30
|
+
include ControlInterface
|
|
31
|
+
|
|
32
|
+
# Start interface
|
|
33
|
+
def StartGameInterface.start_game_interface mailer, config, manager
|
|
34
|
+
loop do
|
|
35
|
+
choice = callcc do |continuation|
|
|
36
|
+
interface = self.new continuation, mailer, config, manager
|
|
37
|
+
interface.run
|
|
38
|
+
end
|
|
39
|
+
choice.call
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def initialize continuation, mailer, game_config, manager
|
|
44
|
+
@manager = manager
|
|
45
|
+
@manager.none
|
|
46
|
+
@mailer = mailer
|
|
47
|
+
@game_config = game_config
|
|
48
|
+
@continuation = continuation
|
|
49
|
+
super()
|
|
50
|
+
add_command "games", "List existing games."
|
|
51
|
+
add_command "load", "Load an existing game.", "NAME"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
protected
|
|
55
|
+
|
|
56
|
+
def help
|
|
57
|
+
puts ""
|
|
58
|
+
UI::highlight "Welcome to CARPS #{VERSION}"
|
|
59
|
+
super
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def games
|
|
63
|
+
dir = $CONFIG + "/games"
|
|
64
|
+
fs = files dir
|
|
65
|
+
fs.each do |f|
|
|
66
|
+
name = File.basename(f, ".yaml")
|
|
67
|
+
puts ""
|
|
68
|
+
UI::highlight "Name: " + name
|
|
69
|
+
g = nil
|
|
70
|
+
begin
|
|
71
|
+
g = @game_config.load "games/" + File.basename(f)
|
|
72
|
+
rescue StandardError => e
|
|
73
|
+
UI::put_error "#{e}"
|
|
74
|
+
end
|
|
75
|
+
if g
|
|
76
|
+
g.display
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def load name
|
|
83
|
+
filename = "games/" + name + ".yaml"
|
|
84
|
+
config = nil
|
|
85
|
+
begin
|
|
86
|
+
config = @game_config.load filename
|
|
87
|
+
rescue StandardError => e
|
|
88
|
+
UI::put_error e.to_s
|
|
89
|
+
end
|
|
90
|
+
if config
|
|
91
|
+
game = config.spawn
|
|
92
|
+
@continuation.call lambda {
|
|
93
|
+
config.register_session @manager
|
|
94
|
+
game.resume @mailer
|
|
95
|
+
}
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "drb"
|
|
19
|
+
|
|
20
|
+
module CARPS
|
|
21
|
+
|
|
22
|
+
# ModMailer acts as a bridge between the Mod and CARPS
|
|
23
|
+
class ModMailer
|
|
24
|
+
|
|
25
|
+
include DRbUndumped
|
|
26
|
+
|
|
27
|
+
# Initialize with a mailer and a configuration file
|
|
28
|
+
#
|
|
29
|
+
# FIXME: Doesn't use mailer (only subclasses use it)
|
|
30
|
+
def initialize mailer, config
|
|
31
|
+
@mailer = mailer
|
|
32
|
+
@config = config
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Save the mod
|
|
36
|
+
def save mod
|
|
37
|
+
@config.save_mod mod
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Load a previously saved state
|
|
41
|
+
def load
|
|
42
|
+
@config.load_mod
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/service/start/config"
|
|
19
|
+
require "carps/service/start/interface"
|
|
20
|
+
require "carps/service/start/mailer"
|
|
21
|
+
require "carps/service/dm/new_game"
|
|
22
|
+
require "carps/service/dm/config"
|
|
23
|
+
require "carps/service/dm/mailer"
|
|
24
|
+
require "carps/service/dm/start"
|
|
25
|
+
require "carps/service/player/config"
|
|
26
|
+
require "carps/service/player/mailer"
|
|
27
|
+
require "carps/service/player/start"
|
|
28
|
+
require "carps/service/start/interface"
|
|
29
|
+
require "carps/service/client_parser"
|
|
30
|
+
require "carps/service/game"
|
|
31
|
+
require "carps/service/interface"
|
|
32
|
+
require "carps/service/mod"
|
|
33
|
+
require "carps/service/server_parser"
|
|
34
|
+
require "carps/service/session"
|
|
35
|
+
require "carps/service/invite"
|
data/lib/carps/test.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
module CARPS
|
|
19
|
+
|
|
20
|
+
# Utilities which belong to the testing utility AND to the wizard
|
|
21
|
+
module Test
|
|
22
|
+
|
|
23
|
+
# There can sometimes be more than one reason why the test has failed.
|
|
24
|
+
def Test::multi_fail *reasons
|
|
25
|
+
Test::test_failed "Either:\n\t" + reasons.join("\nor\t")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def Test::test_failed msg
|
|
29
|
+
UI::put_error msg
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "highline"
|
|
19
|
+
|
|
20
|
+
require "carps/util/windows"
|
|
21
|
+
|
|
22
|
+
# If it's windows, we need ansi support
|
|
23
|
+
if CARPS::windows?
|
|
24
|
+
require "Win32/Console/ANSI"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Set up highline colours
|
|
28
|
+
HighLine.color_scheme = HighLine::SampleColorScheme.new
|