mr_holmes 0.0.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 +7 -0
- data/.DS_Store +0 -0
- data/.autotest +25 -0
- data/Changelog.md +7 -0
- data/LICENSE.md +61 -0
- data/Manifest.md +13 -0
- data/README.md +6 -0
- data/bin/mr_holmes +4 -0
- data/lib/.DS_Store +0 -0
- data/lib/locations/.DS_Store +0 -0
- data/lib/locations/baker_street.rb +131 -0
- data/lib/mr_holmes/node.rb +325 -0
- data/lib/mr_holmes/player.rb +168 -0
- data/lib/mr_holmes/string.rb +29 -0
- data/lib/mr_holmes.rb +43 -0
- data/mr_holmes.gemspec +13 -0
- data/save.yaml +176 -0
- data/test/test_mr_holmes.rb +6 -0
- metadata +66 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 42150cd33b1cbe622295a226cbbd24fbcb1dd450
|
|
4
|
+
data.tar.gz: 53dadcfae8249d4a9a64fb7effcb3b517af014bb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ee82e6e37d9fe17f6f3c4e70f8a949e836e949cb8780cecea82d95fd051a3bfad4c511542bd77c84c9eb9e41134892a11520056412191ad7b37f04bfcca412fb
|
|
7
|
+
data.tar.gz: f9481b4d092f3ca88c461ae9431ee803264937132cc0c433dbea4f1d58ee03f80547a1eda51760d68f03f5c409a70131ba8dce3b63881477bb1e8610b301dfb1
|
data/.DS_Store
ADDED
|
Binary file
|
data/.autotest
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require "autotest/restart"
|
|
4
|
+
|
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
|
6
|
+
# at.testlib = "minitest/unit"
|
|
7
|
+
#
|
|
8
|
+
# at.extra_files << "../some/external/dependency.rb"
|
|
9
|
+
#
|
|
10
|
+
# at.libs << ":../some/external"
|
|
11
|
+
#
|
|
12
|
+
# at.add_exception "vendor"
|
|
13
|
+
#
|
|
14
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
|
15
|
+
# at.files_matching(/test_.*rb$/)
|
|
16
|
+
# end
|
|
17
|
+
#
|
|
18
|
+
# %w(TestA TestB).each do |klass|
|
|
19
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
|
20
|
+
# end
|
|
21
|
+
# end
|
|
22
|
+
|
|
23
|
+
# Autotest.add_hook :run_command do |at|
|
|
24
|
+
# system "rake build"
|
|
25
|
+
# end
|
data/Changelog.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
__CHANGELOG__
|
|
2
|
+
|
|
3
|
+
__0.0.0__ */ 13-10-2013*
|
|
4
|
+
Initial project file structure generated using the [Hoe](http://docs.seattlerb.org/hoe/) gem. The default `.txt` files where renamed to `.md` for the use of [Markdown](http://daringfireball.net/projects/markdown/). The `LICENSE.md` file was added, and `git` was initialized.
|
|
5
|
+
|
|
6
|
+
__0.0.1__ */ 13-10-2013*
|
|
7
|
+
Basic storyline and implemented logic for the most important functions of the game engine. /bin now contains an executable. Gem was renamed to mr_holmes.
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
__CREATIVE COMMONS ATTRIBUTION-NONCOMMERCIAL__
|
|
2
|
+
|
|
3
|
+
License
|
|
4
|
+
|
|
5
|
+
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
|
6
|
+
|
|
7
|
+
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
|
|
8
|
+
|
|
9
|
+
1. Definitions
|
|
10
|
+
|
|
11
|
+
__Adaptation__ means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
|
|
12
|
+
__Collection__ means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License.
|
|
13
|
+
__Distribute__ means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.
|
|
14
|
+
__Licensor__ means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
|
|
15
|
+
__Original Author__ means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
|
|
16
|
+
__Work__ means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
|
|
17
|
+
__You__ means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
|
|
18
|
+
__Publicly Perform__ means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
|
|
19
|
+
__Reproduce__ means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
|
|
20
|
+
|
|
21
|
+
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
|
|
22
|
+
|
|
23
|
+
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
|
|
24
|
+
|
|
25
|
+
to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;
|
|
26
|
+
to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";
|
|
27
|
+
to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
|
|
28
|
+
to Distribute and Publicly Perform Adaptations.
|
|
29
|
+
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(d).
|
|
30
|
+
|
|
31
|
+
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
|
|
32
|
+
|
|
33
|
+
You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(c), as requested.
|
|
34
|
+
You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works.
|
|
35
|
+
If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and, (iv) consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
|
|
36
|
+
For the avoidance of doubt:
|
|
37
|
+
|
|
38
|
+
Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
|
|
39
|
+
Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and,
|
|
40
|
+
Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c).
|
|
41
|
+
Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.
|
|
42
|
+
|
|
43
|
+
5. Representations, Warranties and Disclaimer
|
|
44
|
+
|
|
45
|
+
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
|
46
|
+
|
|
47
|
+
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
48
|
+
|
|
49
|
+
7. Termination
|
|
50
|
+
|
|
51
|
+
This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
|
|
52
|
+
Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
|
|
53
|
+
|
|
54
|
+
8. Miscellaneous
|
|
55
|
+
|
|
56
|
+
Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
|
|
57
|
+
Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
|
|
58
|
+
If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
|
|
59
|
+
No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
|
|
60
|
+
This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
|
|
61
|
+
The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
|
data/Manifest.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
__MANIFEST__
|
|
2
|
+
|
|
3
|
+
The manifest file lists all the files existing in the current version of the project.
|
|
4
|
+
|
|
5
|
+
+ bin/mr_holmes
|
|
6
|
+
+ lib/mr_holmes.rb
|
|
7
|
+
+ test/test_mr_holmes.rb
|
|
8
|
+
+ .autotest
|
|
9
|
+
+ Changelog.md
|
|
10
|
+
+ LICENSE.md
|
|
11
|
+
+ Manifest.md
|
|
12
|
+
+ Rakefile
|
|
13
|
+
+ README.md
|
data/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
__Mr Holmes__
|
|
2
|
+
|
|
3
|
+
*__Mr Holmes__ is a text-based game based on the magnificent works of Sir Arthur Conan Doyle. Release your inner sleuth as you work your way through a wide variaty of criminal mysteries. With the help of your loyal friend Dr. Watson, you'll have to solve complex puzzles whilst playing a dangerous game of chess with your arch-enemy: Moriarty.*
|
|
4
|
+
|
|
5
|
+
> __Note:__ This project is still in the early stages of development.
|
|
6
|
+
> The first working version (1.0.0) is yet to be released.
|
data/bin/mr_holmes
ADDED
data/lib/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
@root.location(:baker_street) do
|
|
2
|
+
self.desc = <<-DESC
|
|
3
|
+
Your current location is Baker Street, London. It's the street that you call home, and where your chambers are. You share your
|
|
4
|
+
rooms with dr. Watson, on the first and second floor of 221B. The landlady is a kind, older woman called Mrs. Hudson.
|
|
5
|
+
DESC
|
|
6
|
+
|
|
7
|
+
self.short_desc = <<-DESC
|
|
8
|
+
LOCATION: Baker Street
|
|
9
|
+
DESC
|
|
10
|
+
|
|
11
|
+
scene(:side_walk) do
|
|
12
|
+
self.exit_west = :hall_way_ground_floor
|
|
13
|
+
self.desc = <<-DESC
|
|
14
|
+
You are standing on the sidewalk in front of 221B Baker Str. You are facing north, with the front door of your chambers to your west.
|
|
15
|
+
DESC
|
|
16
|
+
self.short_desc = <<-DESC
|
|
17
|
+
SCENE: Sidewalk in front of 221B Baker Str.
|
|
18
|
+
DESC
|
|
19
|
+
|
|
20
|
+
player do
|
|
21
|
+
|
|
22
|
+
item(:pipe, 'pipe', 'clay', 'empty') do
|
|
23
|
+
self.open = true
|
|
24
|
+
self.desc = <<-DESC
|
|
25
|
+
A clay pipe for times when extraordinary concentration of thought is needed. Used with tobacco and matches.
|
|
26
|
+
DESC
|
|
27
|
+
self.short_desc = <<-DESC
|
|
28
|
+
A clay pipe.
|
|
29
|
+
DESC
|
|
30
|
+
self.script_accept = <<-SCRIPT
|
|
31
|
+
if [:tobacco].include?(args[0].tag) && children.empty?
|
|
32
|
+
return true
|
|
33
|
+
elsif !children.empty?
|
|
34
|
+
puts "The pipe is already filled with tobacco..."
|
|
35
|
+
return false
|
|
36
|
+
else
|
|
37
|
+
puts "You can't put that in the pipe..."
|
|
38
|
+
return false
|
|
39
|
+
end
|
|
40
|
+
SCRIPT
|
|
41
|
+
end
|
|
42
|
+
item(:tobacco, 'tobacco', 'strong', 'dry') do
|
|
43
|
+
self.desc = <<-DESC
|
|
44
|
+
Dry tobacco used to fill a pipe.
|
|
45
|
+
DESC
|
|
46
|
+
self.short_desc = <<-DESC
|
|
47
|
+
Dry tobacco.
|
|
48
|
+
DESC
|
|
49
|
+
end
|
|
50
|
+
item(:matches, 'matches', 'dry') do
|
|
51
|
+
self.desc = <<-DESC
|
|
52
|
+
These matches can be used on multiple items, when a flame is needed.
|
|
53
|
+
DESC
|
|
54
|
+
self.short_desc = <<-DESC
|
|
55
|
+
Box of matches.
|
|
56
|
+
DESC
|
|
57
|
+
self.script_use = <<-SCRIPT
|
|
58
|
+
if args[0].tag == :pipe
|
|
59
|
+
if !args[0].children.empty?
|
|
60
|
+
puts "You lit your pipe"
|
|
61
|
+
return
|
|
62
|
+
else
|
|
63
|
+
puts "Put tobacco in your pipe before lighting it"
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
puts "You can't use matches on that"
|
|
67
|
+
return
|
|
68
|
+
end
|
|
69
|
+
SCRIPT
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end # End Of Player
|
|
73
|
+
|
|
74
|
+
end # End Of Scene 'Sidewalk'
|
|
75
|
+
|
|
76
|
+
scene(:hall_way_ground_floor) do
|
|
77
|
+
self.exit_east = :side_walk
|
|
78
|
+
self.exit_up = :hall_way_first_floor
|
|
79
|
+
self.desc = <<-DESC
|
|
80
|
+
You are in the hallway on the ground floor of 221B Baker Str. Your chambers are up the stairs, on the first and
|
|
81
|
+
second floor. The front door leading to the sidewalk outside is east of you.
|
|
82
|
+
DESC
|
|
83
|
+
self.short_desc = <<-DESC
|
|
84
|
+
SCENE: Ground floor hallway of 221B Baker Str.
|
|
85
|
+
DESC
|
|
86
|
+
item(:table, 'table') do
|
|
87
|
+
self.desc = <<-DESC
|
|
88
|
+
A small table in the hallway on the ground floor. Any mail or telegrams recieved when you are not at home is usually
|
|
89
|
+
put on this table.
|
|
90
|
+
DESC
|
|
91
|
+
self.short_desc = <<-DESC
|
|
92
|
+
A small table.
|
|
93
|
+
DESC
|
|
94
|
+
self.presence = <<-PRES
|
|
95
|
+
You see a small table placed against the wall.
|
|
96
|
+
PRES
|
|
97
|
+
item(:telegram_1, 'telegram_1') do
|
|
98
|
+
self.desc = <<-DESC
|
|
99
|
+
TELEGRAM: Mysterious case - stop - Lauriston Gardens nr. 3 - stop - come as soon as possible - stop - Lestrade
|
|
100
|
+
DESC
|
|
101
|
+
self.short_desc = <<-DESC
|
|
102
|
+
A Telegram from detective inspector Lestrade.
|
|
103
|
+
DESC
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end # End Of Scene 'Hallway Grd. Floor'
|
|
107
|
+
|
|
108
|
+
scene(:hall_way_first_floor) do
|
|
109
|
+
self.exit_north = :sitting_room_first_floor
|
|
110
|
+
self.exit_down = :hall_way_ground_floor
|
|
111
|
+
self.desc = <<-DESC
|
|
112
|
+
You find yourself in the hallway on the first floor of 221B Baker Str. North of you is the door to your sitting room. Down the stairs
|
|
113
|
+
you will find the ground floor hallway.
|
|
114
|
+
DESC
|
|
115
|
+
self.short_desc = <<-DESC
|
|
116
|
+
SCENE: First floor hallway of 221B Baker Str.
|
|
117
|
+
DESC
|
|
118
|
+
end # End of Scene 'Hallway First Floor'
|
|
119
|
+
|
|
120
|
+
scene(:sitting_room_first_floor) do
|
|
121
|
+
self.exit_south = :hall_way_first_floor
|
|
122
|
+
self.desc = <<-DESC
|
|
123
|
+
You are in your sitting room on the first floor of 221B Baker Str. The windows to your east provide a view
|
|
124
|
+
of Baker Str. itself, and to your south is the door to the first floor stairwell.
|
|
125
|
+
DESC
|
|
126
|
+
self.short_desc = <<-DESC
|
|
127
|
+
SCENE: Sitting room at 221B Baker Str.
|
|
128
|
+
DESC
|
|
129
|
+
end # End Of Scene 'Sitting Room First Floor'
|
|
130
|
+
|
|
131
|
+
end # End of Location 'Baker Street'
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
require "yaml"
|
|
2
|
+
require "ostruct"
|
|
3
|
+
require "mr_holmes/string"
|
|
4
|
+
|
|
5
|
+
class Node < OpenStruct
|
|
6
|
+
|
|
7
|
+
# Method to fix YAML conversions and handling
|
|
8
|
+
def init_with(c)
|
|
9
|
+
c.map.keys.each do|k|
|
|
10
|
+
instance_variable_set("@#{k}", c.map[k])
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
@table.keys.each do|k|
|
|
14
|
+
new_ostruct_member(k)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Save node structure to YAML
|
|
19
|
+
def self.save(node, file='save.yaml')
|
|
20
|
+
File.open(file, 'w+') do|f|
|
|
21
|
+
f.puts node.to_yaml
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Load node structure from YAML file
|
|
26
|
+
def self.load(file='save.yaml')
|
|
27
|
+
yaml = YAML::load_file(file)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Override 'puts' method for scene descriptions
|
|
31
|
+
def puts(*s)
|
|
32
|
+
STDOUT.puts( s.join(' ').word_wrap )
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Define possible node types
|
|
36
|
+
DEFAULTS = {
|
|
37
|
+
:root => { :open => true },
|
|
38
|
+
:location => { :open => true },
|
|
39
|
+
:scene => { :open => true },
|
|
40
|
+
:item => { :open => false, },
|
|
41
|
+
:player => { :open => true }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# Initialize node
|
|
45
|
+
def initialize(parent=nil, tag=nil, defaults={}, &block)
|
|
46
|
+
super()
|
|
47
|
+
defaults.each { |k,v| send("#{k}=", v) }
|
|
48
|
+
self.parent = parent
|
|
49
|
+
self.parent.children << self unless parent.nil?
|
|
50
|
+
self.tag = tag
|
|
51
|
+
self.children = []
|
|
52
|
+
instance_eval(&block) unless block.nil?
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Create root
|
|
56
|
+
def self.root(&block)
|
|
57
|
+
Node.new(nil, :root, &block)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Create location
|
|
61
|
+
def location(tag, &block)
|
|
62
|
+
Node.new(self, tag, DEFAULTS[:location], &block)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Create scene
|
|
66
|
+
def scene(tag, &block)
|
|
67
|
+
Node.new(self, tag, DEFAULTS[:scene], &block)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Create item
|
|
71
|
+
def item(tag, name, *words, &block)
|
|
72
|
+
i = Node.new(self, tag, DEFAULTS[:item])
|
|
73
|
+
i.name = name
|
|
74
|
+
i.words = words
|
|
75
|
+
i.instance_eval(&block) if block_given?
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Create player
|
|
79
|
+
def player(&block)
|
|
80
|
+
Player.new(self, :player, DEFAULTS[:player], &block)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# ----------------------------------------------------------------- Finding Nodes
|
|
84
|
+
|
|
85
|
+
# Method to find node
|
|
86
|
+
def find(node_data)
|
|
87
|
+
case node_data
|
|
88
|
+
when Symbol
|
|
89
|
+
find_by_tag(node_data)
|
|
90
|
+
when String
|
|
91
|
+
find_by_string(node_data)
|
|
92
|
+
when Array
|
|
93
|
+
find_by_string(node_data)
|
|
94
|
+
when Node
|
|
95
|
+
node_data
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Find node by tag
|
|
100
|
+
def find_by_tag(tag)
|
|
101
|
+
return self if self.tag == tag
|
|
102
|
+
children.each do |c|
|
|
103
|
+
result = c.find_by_tag(tag)
|
|
104
|
+
return result unless result.nil?
|
|
105
|
+
end
|
|
106
|
+
return nil
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Find node by name
|
|
110
|
+
def find_by_name(words, nodes=[])
|
|
111
|
+
words = words.split unless words.is_a?(Array)
|
|
112
|
+
nodes << self if words.include?(name)
|
|
113
|
+
children.each do |c|
|
|
114
|
+
c.find_by_name(words, nodes)
|
|
115
|
+
end
|
|
116
|
+
return nodes
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Find node by string
|
|
120
|
+
def find_by_string(words)
|
|
121
|
+
words = words.split unless words.is_a?(Array)
|
|
122
|
+
nodes = find_by_name(words)
|
|
123
|
+
if nodes.empty?
|
|
124
|
+
puts "I don't see that here"
|
|
125
|
+
return nil
|
|
126
|
+
end
|
|
127
|
+
# Score nodes by number of matching adjectives
|
|
128
|
+
nodes.each do |i|
|
|
129
|
+
i.search_score = (words & i.words).length
|
|
130
|
+
end
|
|
131
|
+
# Sort highest scoring nodes to beginning of list
|
|
132
|
+
nodes.sort! do |a,b|
|
|
133
|
+
a.search_score <=> b.search_score
|
|
134
|
+
end
|
|
135
|
+
# Remove nodes with a lower score than the first node in the list
|
|
136
|
+
nodes.delete_if do |i|
|
|
137
|
+
i.search_score < nodes.first.search_score
|
|
138
|
+
end
|
|
139
|
+
# Interpret the results
|
|
140
|
+
if nodes.length == 1
|
|
141
|
+
return nodes.first
|
|
142
|
+
else
|
|
143
|
+
puts "Which item do you mean?"
|
|
144
|
+
nodes.each do |i|
|
|
145
|
+
puts " * #{i.name} (#{i.words.join(', ')})"
|
|
146
|
+
end
|
|
147
|
+
return nil
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# ----------------------------------------------------------------- Traversing Upwards
|
|
152
|
+
|
|
153
|
+
# Get scene
|
|
154
|
+
def get_scene
|
|
155
|
+
if parent.parent.tag == :root
|
|
156
|
+
return self
|
|
157
|
+
else
|
|
158
|
+
return parent.get_scene
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Get location
|
|
163
|
+
def get_location
|
|
164
|
+
if parent.tag == :root
|
|
165
|
+
return self
|
|
166
|
+
else
|
|
167
|
+
return parent.get_location
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Get root
|
|
172
|
+
def get_root
|
|
173
|
+
if tag == :root || parent.nil?
|
|
174
|
+
return self
|
|
175
|
+
else
|
|
176
|
+
return parent.get_root
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def ancestors(list=[])
|
|
181
|
+
if parent.nil?
|
|
182
|
+
return list
|
|
183
|
+
else
|
|
184
|
+
list << parent
|
|
185
|
+
return parent.ancestors(list)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# ----------------------------------------------------------------- Hidden Nodes
|
|
190
|
+
|
|
191
|
+
# Check if node is hidden
|
|
192
|
+
def hidden?
|
|
193
|
+
if parent.tag == :root || parent.tag == :location
|
|
194
|
+
return false
|
|
195
|
+
elsif parent.open == false
|
|
196
|
+
return true
|
|
197
|
+
else
|
|
198
|
+
return parent.hidden?
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# ----------------------------------------------------------------- Moving Nodes
|
|
203
|
+
|
|
204
|
+
# Move node
|
|
205
|
+
def move(object, to, check=true)
|
|
206
|
+
item = find(object)
|
|
207
|
+
dest = find(to)
|
|
208
|
+
return if item.nil?
|
|
209
|
+
if check && item.hidden?
|
|
210
|
+
puts "You can't get to that right now"
|
|
211
|
+
return
|
|
212
|
+
end
|
|
213
|
+
return if dest.nil?
|
|
214
|
+
if check && dest.hidden? || dest.open == false
|
|
215
|
+
puts "You can't put that there"
|
|
216
|
+
return
|
|
217
|
+
end
|
|
218
|
+
if dest.ancestors.include?(item)
|
|
219
|
+
puts "Are you trying to destroy the universe?"
|
|
220
|
+
return
|
|
221
|
+
end
|
|
222
|
+
item.parent.children.delete(item)
|
|
223
|
+
dest.children << item
|
|
224
|
+
item.parent = dest
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# ----------------------------------------------------------------- Executing Script
|
|
228
|
+
|
|
229
|
+
def script(key, *args)
|
|
230
|
+
if respond_to?("script_#{key}")
|
|
231
|
+
return eval(self.send("script_#{key}"))
|
|
232
|
+
else
|
|
233
|
+
return true
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# ----------------------------------------------------------------- Descriptions
|
|
238
|
+
|
|
239
|
+
def described?
|
|
240
|
+
if respond_to?(:described)
|
|
241
|
+
self.described
|
|
242
|
+
else
|
|
243
|
+
false
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def describe
|
|
248
|
+
base = ""
|
|
249
|
+
if !described? && respond_to?(:desc)
|
|
250
|
+
self.described = true
|
|
251
|
+
base << desc
|
|
252
|
+
elsif respond_to?(:short_desc)
|
|
253
|
+
base << short_desc
|
|
254
|
+
else
|
|
255
|
+
base << "You are in #{tag}"
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Append presence of children nodes if open
|
|
259
|
+
if open
|
|
260
|
+
children.each do|c|
|
|
261
|
+
base << (c.presence || '')
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
puts
|
|
266
|
+
puts base
|
|
267
|
+
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def short_description
|
|
271
|
+
if respond_to?(:short_desc)
|
|
272
|
+
short_desc
|
|
273
|
+
else
|
|
274
|
+
tag.to_s
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def long_description
|
|
279
|
+
if respond_to?(:desc)
|
|
280
|
+
desc
|
|
281
|
+
else
|
|
282
|
+
tag.to_s
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# ----------------------------------------------------------------- Rendering Nodes
|
|
287
|
+
|
|
288
|
+
# Render node structure
|
|
289
|
+
def to_s(verbose=false, indent='')
|
|
290
|
+
bullet = if parent && parent.tag == :root
|
|
291
|
+
'#'
|
|
292
|
+
elsif parent && parent.parent.tag == :root
|
|
293
|
+
'*'
|
|
294
|
+
elsif tag == :player
|
|
295
|
+
'@'
|
|
296
|
+
elsif tag == :root
|
|
297
|
+
'>'
|
|
298
|
+
elsif open == true
|
|
299
|
+
'O'
|
|
300
|
+
else
|
|
301
|
+
'-'
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
str = "#{indent}#{bullet} #{tag}\n"
|
|
305
|
+
|
|
306
|
+
if verbose
|
|
307
|
+
self.table.each do|k,v|
|
|
308
|
+
if k == :children
|
|
309
|
+
str << "#{indent+' '}#{k}=#{v.map(&:tag)}\n"
|
|
310
|
+
elsif v.is_a?(Node)
|
|
311
|
+
str << "#{indent+' '}#{k}=#{v.tag}\n"
|
|
312
|
+
else
|
|
313
|
+
str << "#{indent+' '}#{k}=#{v}\n"
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
children.each do|c|
|
|
319
|
+
str << c.to_s(verbose, indent + ' ')
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
return str
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
end
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
require "yaml"
|
|
2
|
+
|
|
3
|
+
class Player < Node
|
|
4
|
+
|
|
5
|
+
# ----------------------------------------------------------------- Basics
|
|
6
|
+
|
|
7
|
+
# Main command interpreter
|
|
8
|
+
def command(words)
|
|
9
|
+
verb, *words = words.split(" ")
|
|
10
|
+
verb = "do_#{verb}"
|
|
11
|
+
if respond_to?(verb)
|
|
12
|
+
send(verb, *words)
|
|
13
|
+
puts
|
|
14
|
+
else
|
|
15
|
+
puts "I don't know how to do that."
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Provide command shortcuts
|
|
20
|
+
%w{ north south east west up down }.each do|dir|
|
|
21
|
+
define_method("do_#{dir}") do
|
|
22
|
+
do_go(dir)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
define_method("do_#{dir[0]}") do
|
|
26
|
+
do_go(dir)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# ----------------------------------------------------------------- Actions
|
|
31
|
+
|
|
32
|
+
# Move the player around between scenes
|
|
33
|
+
def do_go(direction, *a)
|
|
34
|
+
dest = get_scene.send("exit_#{direction}")
|
|
35
|
+
if dest.nil?
|
|
36
|
+
puts "You can't go that way."
|
|
37
|
+
else
|
|
38
|
+
dest = get_location.find(dest)
|
|
39
|
+
if dest.script("enter", direction)
|
|
40
|
+
get_location.move(self, dest)
|
|
41
|
+
end
|
|
42
|
+
get_location.describe
|
|
43
|
+
get_scene.describe
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Display current scene information
|
|
48
|
+
def do_look(*a)
|
|
49
|
+
puts
|
|
50
|
+
puts get_scene.long_description
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Display the items currently in the player's inventory
|
|
54
|
+
def do_inventory(*a)
|
|
55
|
+
if children.empty?
|
|
56
|
+
puts
|
|
57
|
+
puts "INVENTORY"
|
|
58
|
+
puts
|
|
59
|
+
puts "You have nothing in your inventory..."
|
|
60
|
+
else
|
|
61
|
+
puts
|
|
62
|
+
puts "INVENTORY"
|
|
63
|
+
puts
|
|
64
|
+
children.each do |c|
|
|
65
|
+
puts " - #{c.name}"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Move an item from the current scene to your inventory
|
|
71
|
+
def do_take(*thing)
|
|
72
|
+
thing = get_scene.find(thing)
|
|
73
|
+
return if thing.nil?
|
|
74
|
+
if thing.script("take")
|
|
75
|
+
puts "Taken. " if get_location.move(thing, self)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Move an item from your inventory to the current scene
|
|
80
|
+
def do_drop(*thing)
|
|
81
|
+
move(thing.join(" "), get_scene)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Set the value of an item's "open" attribute
|
|
85
|
+
def open_close(thing, state)
|
|
86
|
+
container = get_scene.find(thing)
|
|
87
|
+
return if container.nil?
|
|
88
|
+
if container.open == state
|
|
89
|
+
puts "It's already #{state ? 'open' : 'closed'}"
|
|
90
|
+
else
|
|
91
|
+
container.open = state
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Open an item in the current scene
|
|
96
|
+
def do_open(*thing)
|
|
97
|
+
open_close(thing, true)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Close an item in the current scene
|
|
101
|
+
def do_close(*thing)
|
|
102
|
+
open_close(thing, false)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Put an item in or on another item
|
|
106
|
+
def do_put(*words)
|
|
107
|
+
prepositions = [' in ', ' on ']
|
|
108
|
+
prep_regex = Regexp.new("(#{prepositions.join('|')})")
|
|
109
|
+
item_words, _, cont_words = words.join(' ').split(prep_regex)
|
|
110
|
+
if cont_words.nil?
|
|
111
|
+
puts "You want to put what where?"
|
|
112
|
+
return
|
|
113
|
+
end
|
|
114
|
+
item = get_scene.find(item_words)
|
|
115
|
+
container = get_scene.find(cont_words)
|
|
116
|
+
return if item.nil? || container.nil?
|
|
117
|
+
if container.script("accept", item)
|
|
118
|
+
get_scene.move(item, container)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Use an item on another item
|
|
123
|
+
def do_use(*words)
|
|
124
|
+
prepositions = %w{ in on with }
|
|
125
|
+
prepositions.map!{|p| " #{p} " }
|
|
126
|
+
prep_regex = Regexp.new("(#{prepositions.join('|')})")
|
|
127
|
+
item1_words, _, item2_words = words.join(' ').split(prep_regex)
|
|
128
|
+
if item2_words.nil?
|
|
129
|
+
puts "I don't quite understand you."
|
|
130
|
+
return
|
|
131
|
+
end
|
|
132
|
+
item1 = get_scene.find(item1_words)
|
|
133
|
+
item2 = get_scene.find(item2_words)
|
|
134
|
+
return if item1.nil? || item2.nil?
|
|
135
|
+
item1.script('use', item2)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Examine an item closely
|
|
139
|
+
def do_examine(*thing)
|
|
140
|
+
item = get_scene.find(thing)
|
|
141
|
+
return if item.nil?
|
|
142
|
+
item.described = false
|
|
143
|
+
item.describe
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# ----------------------------------------------------------------- Alias methods
|
|
147
|
+
|
|
148
|
+
alias_method :do_get, :do_take
|
|
149
|
+
alias_method :do_i, :do_inventory
|
|
150
|
+
alias_method :do_inv, :do_inventory
|
|
151
|
+
|
|
152
|
+
# ----------------------------------------------------------------- Debugging
|
|
153
|
+
|
|
154
|
+
def do_root(*a)
|
|
155
|
+
STDOUT.puts get_root
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Display the complete node structure
|
|
159
|
+
def do_map(*a)
|
|
160
|
+
STDOUT.puts get_root
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Display the complete node structure in detail
|
|
164
|
+
def do_map_detailed(*a)
|
|
165
|
+
STDOUT.puts get_root.to_s(true)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class String
|
|
2
|
+
def word_wrap(width=80)
|
|
3
|
+
# Replace newlines with spaces
|
|
4
|
+
gsub(/\n/, ' ').
|
|
5
|
+
|
|
6
|
+
# Replace more than one space with a single space
|
|
7
|
+
gsub(/\s+/, ' ').
|
|
8
|
+
|
|
9
|
+
# Replace spaces at the beginning of the
|
|
10
|
+
# string with nothing
|
|
11
|
+
gsub(/^\s+/, '').
|
|
12
|
+
|
|
13
|
+
# This one is hard to read. Replace with any amount
|
|
14
|
+
# of space after it with that punctuation and two
|
|
15
|
+
# spaces
|
|
16
|
+
gsub(/([\.\!\?]+)(\s+)?/, '\1 ').
|
|
17
|
+
|
|
18
|
+
# Similar to the call above, except replace commas
|
|
19
|
+
# with a comma and one space
|
|
20
|
+
gsub(/\,(\s+)?/, ', ').
|
|
21
|
+
|
|
22
|
+
# The meat of the method, replace between 1 and width
|
|
23
|
+
# characters followed by whitespace or the end of the
|
|
24
|
+
# line with that string and a newline. This works
|
|
25
|
+
# because regular expression engines are greedy,
|
|
26
|
+
# they'll take as many characters as they can.
|
|
27
|
+
gsub(%r[(.{1,#{width}})(?:\s|\z)], "\\1\n")
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/mr_holmes.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
require 'mr_holmes/node'
|
|
4
|
+
require 'mr_holmes/player'
|
|
5
|
+
|
|
6
|
+
require 'yaml'
|
|
7
|
+
|
|
8
|
+
class Sherlock
|
|
9
|
+
|
|
10
|
+
VERSION = "0.0.1"
|
|
11
|
+
|
|
12
|
+
end # End Of Class
|
|
13
|
+
|
|
14
|
+
@root = Node.root
|
|
15
|
+
|
|
16
|
+
require 'locations/baker_street'
|
|
17
|
+
|
|
18
|
+
@root.find(:player).get_location.describe
|
|
19
|
+
@root.find(:player).get_scene.describe
|
|
20
|
+
puts
|
|
21
|
+
|
|
22
|
+
loop do
|
|
23
|
+
player = @root.find(:player)
|
|
24
|
+
|
|
25
|
+
print "What now? "
|
|
26
|
+
|
|
27
|
+
input = gets.chomp
|
|
28
|
+
verb = input.split(' ').first
|
|
29
|
+
|
|
30
|
+
case verb
|
|
31
|
+
when "load"
|
|
32
|
+
@root = Node.load
|
|
33
|
+
puts "Loaded"
|
|
34
|
+
when "save"
|
|
35
|
+
Node.save(@root)
|
|
36
|
+
puts "Saved current game progression... "
|
|
37
|
+
when "quit"
|
|
38
|
+
puts "Goodbye! "
|
|
39
|
+
exit
|
|
40
|
+
else
|
|
41
|
+
player.command(input)
|
|
42
|
+
end
|
|
43
|
+
end
|
data/mr_holmes.gemspec
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = 'mr_holmes'
|
|
3
|
+
s.version = '0.0.1'
|
|
4
|
+
s.date = '2014-11-26'
|
|
5
|
+
s.summary = "Mr Holmes is a text-based game based on the magnificent works of Sir Arthur Conan Doyle."
|
|
6
|
+
s.description = "Mr Holmes is a text-based game based on the magnificent works of Sir Arthur Conan Doyle. Release your inner sleuth as you work your way through a wide variaty of criminal mysteries. With the help of your loyal friend Dr. Watson, you'll have to solve complex puzzles whilst playing a dangerous game of chess with your arch-enemy: Moriarty."
|
|
7
|
+
s.authors = ["Stefan Hagen"]
|
|
8
|
+
s.email = 'stefan@stefanhagen.nl'
|
|
9
|
+
s.files = `git ls-files`.split("\n")
|
|
10
|
+
s.executables << 'mr_holmes'
|
|
11
|
+
s.homepage = 'https://github.com/StefanHagen/mr_holmes'
|
|
12
|
+
s.license = 'Creative Commons Attribution-NonCommercial'
|
|
13
|
+
end
|
data/save.yaml
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
--- &1 !ruby/object:Node
|
|
2
|
+
table:
|
|
3
|
+
:parent:
|
|
4
|
+
:tag: :root
|
|
5
|
+
:children:
|
|
6
|
+
- &2 !ruby/object:Node
|
|
7
|
+
table:
|
|
8
|
+
:open: true
|
|
9
|
+
:parent: *1
|
|
10
|
+
:tag: :baker_street
|
|
11
|
+
:children:
|
|
12
|
+
- !ruby/object:Node
|
|
13
|
+
table:
|
|
14
|
+
:open: true
|
|
15
|
+
:parent: *2
|
|
16
|
+
:tag: :side_walk
|
|
17
|
+
:children: []
|
|
18
|
+
:exit_west: :hall_way_ground_floor
|
|
19
|
+
:desc: |2
|
|
20
|
+
You are standing on the sidewalk in front of 221B Baker Str. You are facing north, with the front door of your chambers to your west.
|
|
21
|
+
:short_desc: |2
|
|
22
|
+
SCENE: Sidewalk in front of 221B Baker Str.
|
|
23
|
+
:described: true
|
|
24
|
+
modifiable: true
|
|
25
|
+
- &3 !ruby/object:Node
|
|
26
|
+
table:
|
|
27
|
+
:open: true
|
|
28
|
+
:parent: *2
|
|
29
|
+
:tag: :hall_way_ground_floor
|
|
30
|
+
:children:
|
|
31
|
+
- &4 !ruby/object:Node
|
|
32
|
+
table:
|
|
33
|
+
:open: false
|
|
34
|
+
:parent: *3
|
|
35
|
+
:tag: :table
|
|
36
|
+
:children:
|
|
37
|
+
- !ruby/object:Node
|
|
38
|
+
table:
|
|
39
|
+
:open: false
|
|
40
|
+
:parent: *4
|
|
41
|
+
:tag: :telegram_1
|
|
42
|
+
:children: []
|
|
43
|
+
:name: telegram_1
|
|
44
|
+
:words: []
|
|
45
|
+
:desc: |2
|
|
46
|
+
TELEGRAM: Mysterious case - stop - Lauriston Gardens nr. 3 - stop - come as soon as possible - stop - Lestrade
|
|
47
|
+
:short_desc: |2
|
|
48
|
+
A Telegram from detective inspector Lestrade.
|
|
49
|
+
modifiable: true
|
|
50
|
+
:name: table
|
|
51
|
+
:words: []
|
|
52
|
+
:desc: |2
|
|
53
|
+
A small table in the hallway on the ground floor. Any mail or telegrams recieved when you are not at home is usually
|
|
54
|
+
put on this table.
|
|
55
|
+
:short_desc: |2
|
|
56
|
+
A small table.
|
|
57
|
+
:presence: |2
|
|
58
|
+
You see a small table placed against the wall.
|
|
59
|
+
modifiable: true
|
|
60
|
+
- &5 !ruby/object:Player
|
|
61
|
+
table:
|
|
62
|
+
:open: true
|
|
63
|
+
:parent: *3
|
|
64
|
+
:tag: :player
|
|
65
|
+
:children:
|
|
66
|
+
- !ruby/object:Node
|
|
67
|
+
table:
|
|
68
|
+
:open: true
|
|
69
|
+
:parent: *5
|
|
70
|
+
:tag: :pipe
|
|
71
|
+
:children: []
|
|
72
|
+
:name: pipe
|
|
73
|
+
:words:
|
|
74
|
+
- clay
|
|
75
|
+
- empty
|
|
76
|
+
:desc: |2
|
|
77
|
+
A clay pipe for times when extraordinary concentration of thought is needed. Used with tobacco and matches.
|
|
78
|
+
:short_desc: |2
|
|
79
|
+
A clay pipe.
|
|
80
|
+
:script_accept: |2
|
|
81
|
+
if [:tobacco].include?(args[0].tag) && children.empty?
|
|
82
|
+
return true
|
|
83
|
+
elsif !children.empty?
|
|
84
|
+
puts "The pipe is already filled with tobacco..."
|
|
85
|
+
return false
|
|
86
|
+
else
|
|
87
|
+
puts "You can't put that in the pipe..."
|
|
88
|
+
return false
|
|
89
|
+
end
|
|
90
|
+
modifiable: true
|
|
91
|
+
- !ruby/object:Node
|
|
92
|
+
table:
|
|
93
|
+
:open: false
|
|
94
|
+
:parent: *5
|
|
95
|
+
:tag: :tobacco
|
|
96
|
+
:children: []
|
|
97
|
+
:name: tobacco
|
|
98
|
+
:words:
|
|
99
|
+
- strong
|
|
100
|
+
- dry
|
|
101
|
+
:desc: |2
|
|
102
|
+
Dry tobacco used to fill a pipe.
|
|
103
|
+
:short_desc: |2
|
|
104
|
+
Dry tobacco.
|
|
105
|
+
modifiable: true
|
|
106
|
+
- !ruby/object:Node
|
|
107
|
+
table:
|
|
108
|
+
:open: false
|
|
109
|
+
:parent: *5
|
|
110
|
+
:tag: :matches
|
|
111
|
+
:children: []
|
|
112
|
+
:name: matches
|
|
113
|
+
:words:
|
|
114
|
+
- dry
|
|
115
|
+
:desc: |2
|
|
116
|
+
These matches can be used on multiple items, when a flame is needed.
|
|
117
|
+
:short_desc: |2
|
|
118
|
+
Box of matches.
|
|
119
|
+
:script_use: |2
|
|
120
|
+
if args[0].tag == :pipe
|
|
121
|
+
if !args[0].children.empty?
|
|
122
|
+
puts "You lit your pipe"
|
|
123
|
+
return
|
|
124
|
+
else
|
|
125
|
+
puts "Put tobacco in your pipe before lighting it"
|
|
126
|
+
end
|
|
127
|
+
else
|
|
128
|
+
puts "You can't use matches on that"
|
|
129
|
+
return
|
|
130
|
+
end
|
|
131
|
+
modifiable: true
|
|
132
|
+
modifiable: true
|
|
133
|
+
:exit_east: :side_walk
|
|
134
|
+
:exit_up: :hall_way_first_floor
|
|
135
|
+
:desc: |2
|
|
136
|
+
You are in the hallway on the ground floor of 221B Baker Str. Your chambers are up the stairs, on the first and
|
|
137
|
+
second floor. The front door leading to the sidewalk outside is east of you.
|
|
138
|
+
:short_desc: |2
|
|
139
|
+
SCENE: Ground floor hallway of 221B Baker Str.
|
|
140
|
+
:described: true
|
|
141
|
+
modifiable: true
|
|
142
|
+
- !ruby/object:Node
|
|
143
|
+
table:
|
|
144
|
+
:open: true
|
|
145
|
+
:parent: *2
|
|
146
|
+
:tag: :hall_way_first_floor
|
|
147
|
+
:children: []
|
|
148
|
+
:exit_north: :sitting_room_first_floor
|
|
149
|
+
:exit_down: :hall_way_ground_floor
|
|
150
|
+
:desc: |2
|
|
151
|
+
You find yourself in the hallway on the first floor of 221B Baker Str. North of you is the door to your sitting room. Down the stairs
|
|
152
|
+
you will find the ground floor hallway.
|
|
153
|
+
:short_desc: |2
|
|
154
|
+
SCENE: First floor hallway of 221B Baker Str.
|
|
155
|
+
modifiable: true
|
|
156
|
+
- !ruby/object:Node
|
|
157
|
+
table:
|
|
158
|
+
:open: true
|
|
159
|
+
:parent: *2
|
|
160
|
+
:tag: :sitting_room_first_floor
|
|
161
|
+
:children: []
|
|
162
|
+
:exit_south: :hall_way_first_floor
|
|
163
|
+
:desc: |2
|
|
164
|
+
You are in your sitting room on the first floor of 221B Baker Str. The windows to your east provide a view
|
|
165
|
+
of Baker Str. itself, and to your south is the door to the first floor stairwell.
|
|
166
|
+
:short_desc: |2
|
|
167
|
+
SCENE: Sitting room at 221B Baker Str.
|
|
168
|
+
modifiable: true
|
|
169
|
+
:desc: |2
|
|
170
|
+
Your current location is Baker Street, London. It's the street that you call home, and where your chambers are. You share your
|
|
171
|
+
rooms with dr. Watson, on the first and second floor of 221B. The landlady is a kind, older woman called Mrs. Hudson.
|
|
172
|
+
:short_desc: |2
|
|
173
|
+
LOCATION: Baker Street
|
|
174
|
+
:described: true
|
|
175
|
+
modifiable: true
|
|
176
|
+
modifiable: true
|
metadata
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mr_holmes
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Stefan Hagen
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: 'Mr Holmes is a text-based game based on the magnificent works of Sir
|
|
14
|
+
Arthur Conan Doyle. Release your inner sleuth as you work your way through a wide
|
|
15
|
+
variaty of criminal mysteries. With the help of your loyal friend Dr. Watson, you''ll
|
|
16
|
+
have to solve complex puzzles whilst playing a dangerous game of chess with your
|
|
17
|
+
arch-enemy: Moriarty.'
|
|
18
|
+
email: stefan@stefanhagen.nl
|
|
19
|
+
executables:
|
|
20
|
+
- mr_holmes
|
|
21
|
+
extensions: []
|
|
22
|
+
extra_rdoc_files: []
|
|
23
|
+
files:
|
|
24
|
+
- ".DS_Store"
|
|
25
|
+
- ".autotest"
|
|
26
|
+
- Changelog.md
|
|
27
|
+
- LICENSE.md
|
|
28
|
+
- Manifest.md
|
|
29
|
+
- README.md
|
|
30
|
+
- bin/mr_holmes
|
|
31
|
+
- lib/.DS_Store
|
|
32
|
+
- lib/locations/.DS_Store
|
|
33
|
+
- lib/locations/baker_street.rb
|
|
34
|
+
- lib/mr_holmes.rb
|
|
35
|
+
- lib/mr_holmes/node.rb
|
|
36
|
+
- lib/mr_holmes/player.rb
|
|
37
|
+
- lib/mr_holmes/string.rb
|
|
38
|
+
- mr_holmes.gemspec
|
|
39
|
+
- save.yaml
|
|
40
|
+
- test/test_mr_holmes.rb
|
|
41
|
+
homepage: https://github.com/StefanHagen/mr_holmes
|
|
42
|
+
licenses:
|
|
43
|
+
- Creative Commons Attribution-NonCommercial
|
|
44
|
+
metadata: {}
|
|
45
|
+
post_install_message:
|
|
46
|
+
rdoc_options: []
|
|
47
|
+
require_paths:
|
|
48
|
+
- lib
|
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '0'
|
|
59
|
+
requirements: []
|
|
60
|
+
rubyforge_project:
|
|
61
|
+
rubygems_version: 2.2.2
|
|
62
|
+
signing_key:
|
|
63
|
+
specification_version: 4
|
|
64
|
+
summary: Mr Holmes is a text-based game based on the magnificent works of Sir Arthur
|
|
65
|
+
Conan Doyle.
|
|
66
|
+
test_files: []
|