Resolves #20 - proper inventory, list of carried things
This commit is contained in:
parent
b621ef2643
commit
6dd06d2b89
|
@ -34,3 +34,22 @@ room "start", salet,
|
|||
dsc: """
|
||||
""",
|
||||
choices: "#start"
|
||||
|
||||
# This is a special inventory room.
|
||||
# The inventory button is a regular link to this room.
|
||||
# You may alter these as much as you like or scrap it along with the button.
|
||||
room "inventory", salet,
|
||||
enter: () ->
|
||||
$("#inventory").hide()
|
||||
exit: () ->
|
||||
$("#inventory").show()
|
||||
dsc: (salet) ->
|
||||
if salet.character.inventory.length == 0
|
||||
text = "You are carrying nothing."
|
||||
else
|
||||
text = "You are carrying:\n\n"
|
||||
for thing in salet.character.inventory
|
||||
text += "* #{salet.character.listinv(thing.name)}\n"
|
||||
return text+"\n\n"+"""
|
||||
<div class="center"><a href="plaza"><button class="btn btn-lg btn-outline-primary">Go to plaza</button></a></div>
|
||||
"""
|
||||
|
|
|
@ -58,20 +58,19 @@
|
|||
</div>
|
||||
</div> <!-- End of div.tools_wrapper -->
|
||||
|
||||
<div class="row">
|
||||
<div id="legal">
|
||||
<div id="footleft">
|
||||
<p>The game was written by <em>(you should put your name here)</em></p>
|
||||
<p>Approximate play time: not measured.</p>
|
||||
<p>Written using <a href="http://git.oreolek.ru/oreolek/salet" target="_blank">Salet</a>.</p>
|
||||
<p>Betatesting credit: none yet</p>
|
||||
</div>
|
||||
<div id="footright">
|
||||
<p class='buttons'>
|
||||
<button id="erase" class="btn btn-outline-danger">Restart</button>
|
||||
</p>
|
||||
<p><a href="./LICENSE.txt"><img src="img/mit.png" alt="This program is licensed under MIT license."></a></p>
|
||||
</div>
|
||||
<div id="legal" class="row">
|
||||
<div id="footleft">
|
||||
<p>The game was written by <em>(you should put your name here)</em></p>
|
||||
<p>Approximate play time: not measured.</p>
|
||||
<p>Written using <a href="http://git.oreolek.ru/oreolek/salet" target="_blank">Salet</a>.</p>
|
||||
<p>Betatesting credit: none yet</p>
|
||||
</div>
|
||||
<div id="footright">
|
||||
<p id='buttons'>
|
||||
<a href="inventory"><button id="inventory" class="btn btn-outline-primary">Inventory</button></a>
|
||||
<button id="erase" class="btn btn-outline-danger">Restart</button>
|
||||
</p>
|
||||
<p><a href="./LICENSE.txt"><img src="img/mit.png" alt="This program is licensed under MIT license."></a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- End of div.page -->
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
invlink = (content, ref) ->
|
||||
return "<a href='./_inv_#{ref}' class='once'>#{content}</a>"
|
||||
|
||||
class Character
|
||||
constructor: (spec) ->
|
||||
@inventory = []
|
||||
|
@ -16,6 +19,16 @@ class Character
|
|||
return true
|
||||
return false
|
||||
|
||||
@listinv = (thing) =>
|
||||
for i in @inventory
|
||||
if i.name == thing
|
||||
return invlink(i.name, i.name)
|
||||
|
||||
@inv = (thing) =>
|
||||
for i in @inventory
|
||||
if i.name == thing
|
||||
return i.inv.fcall(i)
|
||||
|
||||
for index, value of spec
|
||||
this[index] = value
|
||||
return this
|
||||
|
|
|
@ -32,7 +32,7 @@ class SaletObj
|
|||
@take = (system) => "You take the #{@name}." # taking to inventory
|
||||
@act = (system) => "You don't find anything extraordinary about the #{@name}." # object action
|
||||
@dsc = (system) => "You see a {{#{@name}}} here." # object description
|
||||
@inv = (system) => "It's a {{#{@name}.}}" # inventory description
|
||||
@inv = (system) => "It's a #{@name}." # inventory description
|
||||
@location = ""
|
||||
@put = (salet, location) =>
|
||||
@level = 0 # this is scenery
|
||||
|
|
|
@ -155,7 +155,9 @@ class SaletRoom
|
|||
You could interpret this as an EXAMINE verb or USE one, it's your call.
|
||||
###
|
||||
@act = (system, action) =>
|
||||
if (link = action.match(/^_(act|cycle)_(.+)$/)) #object action
|
||||
if (link = action.match(/^_(act|cycle|inv)_(.+)$/)) #object action
|
||||
if link[1] == "inv"
|
||||
return system.view.write system.character.inv(link[2])
|
||||
for thing in @objects
|
||||
if thing.name == link[2]
|
||||
if link[1] == "act"
|
||||
|
|
|
@ -235,7 +235,7 @@ class Salet
|
|||
@linkStack = []
|
||||
|
||||
# Handle each link in turn.
|
||||
@processOneLink(code);
|
||||
@processOneLink(code)
|
||||
while (@linkStack.length > 0)
|
||||
code = @linkStack.shift()
|
||||
@processOneLink(code)
|
||||
|
@ -260,7 +260,9 @@ class Salet
|
|||
###
|
||||
@processOneLink = (code) =>
|
||||
match = code.match(@linkRe)
|
||||
assert(match, "link_not_valid".l({link:code}))
|
||||
if not match
|
||||
console.error "link_not_valid".l()
|
||||
console.error code
|
||||
|
||||
situation = match[1]
|
||||
action = match[3]
|
||||
|
@ -295,6 +297,11 @@ class Salet
|
|||
@progress.sequence.push({link:code, when:@time})
|
||||
@processLink(code)
|
||||
|
||||
# Presumably, the last action is the one that fired goBack, so we go to the
|
||||
# one before it.
|
||||
@goBack = (steps = 2) =>
|
||||
@processClick(@progress.sequence[@progress.sequence.length - steps].link)
|
||||
|
||||
# Transition between rooms.
|
||||
@doTransitionTo = (newRoomId) =>
|
||||
oldRoomId = @current
|
||||
|
|
|
@ -26,7 +26,7 @@ addClass = (element, className) ->
|
|||
|
||||
class SaletView
|
||||
init: (salet) =>
|
||||
$("#content, #ways").on("click", "a", (event) ->
|
||||
$("#content, #ways, #buttons").on("click", "a", (event) ->
|
||||
event.preventDefault()
|
||||
a = $(this)
|
||||
href = a.attr('href')
|
||||
|
|
|
@ -29,7 +29,6 @@ body {
|
|||
@media (min-width: breakpoint-min(sm)) {
|
||||
@include make-col-offset(1);
|
||||
}
|
||||
cursor: pointer; // Until we click to start.
|
||||
.label {
|
||||
overflow: hidden;
|
||||
margin: auto;
|
||||
|
@ -143,16 +142,13 @@ body {
|
|||
}
|
||||
}
|
||||
#legal {
|
||||
@include col(10,12);
|
||||
@media (min-width: breakpoint-min(sm)) {
|
||||
@include make-col-offset(1);
|
||||
}
|
||||
margin-top: 1em;
|
||||
color: darken($body-color, 10%);
|
||||
font-size: smaller;
|
||||
#footleft {
|
||||
@media (min-width: breakpoint-min(sm)) {
|
||||
@include make-col(10);
|
||||
@include make-col-offset(2);
|
||||
@include make-col(5);
|
||||
}
|
||||
@media (max-width: breakpoint-max(xs)) {
|
||||
@include make-col(12);
|
||||
|
@ -161,7 +157,7 @@ body {
|
|||
#footright {
|
||||
text-align: right;
|
||||
@media (min-width: breakpoint-min(sm)) {
|
||||
@include make-col(2);
|
||||
@include make-col(4);
|
||||
}
|
||||
@media (max-width: breakpoint-max(xs)) {
|
||||
@include make-col(12);
|
||||
|
@ -170,11 +166,6 @@ body {
|
|||
}
|
||||
}
|
||||
|
||||
#content_library,
|
||||
#ui_library {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.way {
|
||||
color: $waycolor;
|
||||
margin-right: 1em;
|
||||
|
@ -215,3 +206,7 @@ hr {
|
|||
.fadeIn {
|
||||
animation-name: fadeIn;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue