N-S-E-W "compass" links
This commit is contained in:
parent
b4fdd63e6b
commit
9497297a7b
|
@ -77,7 +77,9 @@ class Maze
|
|||
describe: (x, y, improv) ->
|
||||
model = @data[x][y]
|
||||
model = setAdjacent(model)
|
||||
return '<h4>'+model.loctitle+"</h4>\n"+improv.gen('description', model)+"\n\n"+improv.gen('directions', model)
|
||||
return '<h4>'+model.loctitle+"</h4>\n"+improv.gen('description', model)+"\n\n"#+improv.gen('directions', model)
|
||||
# Я хотел сделать дополнительные ссылки в тексте, но это жутко муторно
|
||||
# писать кучу кода для Improv на разбор, какие направления доступны.
|
||||
isEast: (x, y) -> return (x+1) <= (@width - 1)
|
||||
isWest: (x, y) -> return (x-1) >= 0
|
||||
isNorth: (x, y) -> return (y-1) >= 0
|
||||
|
@ -98,6 +100,13 @@ class Maze
|
|||
if @isSouth(x, y)
|
||||
return @at(x+1, y+1)
|
||||
return false
|
||||
getDirection: (direction, x, y) ->
|
||||
switch direction
|
||||
when "north" then return @getNorth(x,y)
|
||||
when "south" then return @getSouth(x,y)
|
||||
when "east" then return @getEast(x,y)
|
||||
when "west" then return @getWest(x,y)
|
||||
else return false
|
||||
log: () ->
|
||||
map = ""
|
||||
for y in [0..(@height-1)]
|
||||
|
|
|
@ -44,11 +44,11 @@ croom = (name, spec) ->
|
|||
spec.optionText ?= () ->
|
||||
retval = """
|
||||
<div class="#{spec.optionColor}">
|
||||
<div class="title">#{spec.title.fcall()}</div>
|
||||
<div class="title">#{spec.title.fcall(spec)}</div>
|
||||
"""
|
||||
if (spec.subtitle?)
|
||||
if spec.subtitle?
|
||||
retval += """
|
||||
<div class="subtitle">#{spec.subtitle.fcall()}</div>
|
||||
<div class="subtitle">#{spec.subtitle.fcall(spec)}</div>
|
||||
"""
|
||||
retval += '</div>'
|
||||
spec.dsc ?= () -> name.l()
|
||||
|
@ -168,6 +168,7 @@ window.set_volume = (value) ->
|
|||
else
|
||||
volume.css('background-position', '0 -75px')
|
||||
|
||||
###
|
||||
update_paths = (character) ->
|
||||
x = character.x
|
||||
y = character.y
|
||||
|
@ -209,6 +210,7 @@ update_paths = (character) ->
|
|||
else
|
||||
$("#south").html("")
|
||||
return
|
||||
###
|
||||
|
||||
typeIsArray = ( value ) ->
|
||||
value and
|
||||
|
@ -264,10 +266,14 @@ setAdjacent = (model) ->
|
|||
if adjacent.indexOf(type) != -1 # уже есть сосед этого типа
|
||||
continue
|
||||
adjacent.push(type)
|
||||
model.loctitle_north = cells["north"].loctitle
|
||||
model.loctitle_east = cells["east"].loctitle
|
||||
model.loctitle_west = cells["west"].loctitle
|
||||
model.loctitle_south = cells["south"].loctitle
|
||||
if cells["north"]?
|
||||
model.loctitle_north = cells["north"].loctitle
|
||||
if cells["east"]?
|
||||
model.loctitle_east = cells["east"].loctitle
|
||||
if cells["west"]?
|
||||
model.loctitle_west = cells["west"].loctitle
|
||||
if cells["south"]?
|
||||
model.loctitle_south = cells["south"].loctitle
|
||||
model.tags.push(["adjacent", adjacent])
|
||||
return model
|
||||
|
||||
|
|
|
@ -150,9 +150,26 @@ $(document).on('init', () ->
|
|||
)
|
||||
|
||||
direction_room = (name, varname, plus) ->
|
||||
room(name,
|
||||
return croom(name,
|
||||
# I'm sure it can be optimized but not now
|
||||
title: () ->
|
||||
cell = salet.character.maze.getDirection(@name, salet.character.x, salet.character.y)
|
||||
if cell != false and cell != undefined and cell.loctitle != undefined
|
||||
return cell.loctitle
|
||||
else
|
||||
return "no_direction".l()
|
||||
canView: () ->
|
||||
cell = salet.character.maze.getDirection(name, salet.character.x, salet.character.y)
|
||||
if cell != false and cell != undefined and cell.loctitle != undefined
|
||||
return true
|
||||
else
|
||||
return false
|
||||
subtitle: () ->
|
||||
return "#{name}_direction".l()
|
||||
varname: varname,
|
||||
add: plus
|
||||
tags: ["direction"]
|
||||
dsc: false
|
||||
enter: () ->
|
||||
salet.character[@varname] = salet.character[@varname] + @add
|
||||
salet.goTo("maze")
|
||||
|
|
|
@ -20,6 +20,7 @@ room "maze",
|
|||
clear: false
|
||||
priority: -10
|
||||
showTransition: true
|
||||
choices: '#direction'
|
||||
before: (from) ->
|
||||
if @showTransition == false
|
||||
@showTransition = true
|
||||
|
@ -50,7 +51,7 @@ room "maze",
|
|||
salet.character.past_y = salet.character.y
|
||||
return salet.character.improv.gen('transition', model)
|
||||
dsc: () ->
|
||||
update_paths(salet.character)
|
||||
#update_paths(salet.character)
|
||||
salet.character.describe()
|
||||
canExit: (to) ->
|
||||
model = []
|
||||
|
|
|
@ -18,5 +18,10 @@ strings =
|
|||
night: "Ночной режим"
|
||||
multiplayer: "Режим мультиплеера"
|
||||
erase_message: "Вы точно хотите стереть сохранение и начать игру заново?"
|
||||
no_direction: "Конец города"
|
||||
north_direction: "Идти на север"
|
||||
south_direction: "Идти на юг"
|
||||
west_direction: "Идти на запад"
|
||||
east_direction: "Идти на восток"
|
||||
|
||||
window.i18n.push("ru", strings)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
<div id="content" class="content">
|
||||
<noscript>Эта игра требует включённого Javascript.</noscript>
|
||||
</div>
|
||||
<div id="actions"></div>
|
||||
<a name="end_of_content"></a>
|
||||
</div>
|
||||
<div class="footer">
|
||||
|
|
Loading…
Reference in a new issue