mapgen/game/4_plot.coffee
Alexander Yakovlev 6e4d10e8fe
All checks were successful
default/mapgen/master This commit looks good
Названия баней, площади на карте
2018-10-07 22:30:06 +07:00

99 lines
3.3 KiB
CoffeeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

plotscene = (title, options) ->
options ?= {}
options.clear ?= false
options.choices ?= "##{title}"
options.dsc ?= () ->
return "#{title}".l()
options.optionText ?= () ->
return "#{title}_option".l()
options.afterChoices ?= () ->
if salet.interactive
# Scroll to the text input
salet.view.scrollToBottom()
# Piwik analytics: room stats
if _paq?
_paq.push(['trackPageView', title])
return ""
return room(title, options)
room "maze",
clear: false
priority: -10
showTransition: true
choices: '#direction'
before: (from) ->
if @showTransition == false
@showTransition = true
return ""
currentCell = salet.character.getCell()
if currentCell == false
console.error "No cell found!"
salet.eraseSave()
model = new ImprovModel
if salet.character.past_x?
pastCell = salet.character.getCell(salet.character.past_x, salet.character.past_y)
model.tags.push(['from', pastCell.getTag('type')])
model.tags.push(['from_position', pastCell.getTag('position')])
else
model.tags.push(['from', 'outside'])
model.tags.push(['to', currentCell.getTag('type')])
model.tags.push(['to_position', currentCell.getTag('position')])
# Piwik analytics: terrain type
if _paq?
_paq.push(['setCustomDimension', 1, currentCell.getTag('type')])
model = setAdjacent(model)
salet.character.past_x = salet.character.x
salet.character.past_y = salet.character.y
return salet.character.improv.gen('transition', model)
dsc: () ->
#update_paths(salet.character)
salet.character.describe()
after: () ->
jQuery(document).trigger("maze_"+salet.character.x+"_"+salet.character.y)
return ''
canExit: (to) ->
model = []
model["x"] = salet.character.x
model["y"] = salet.character.y
model[to.varname] = model[to.varname] + to.add
# Определяем, может ли персонаж зайти на клетку.
# Некоторые типы клеток требуют особого навыка.
cell = salet.character.maze.at(model["x"], model["y"])
if cell.getTag("type") == "lake"
salet.view.append("*#{"lake_inaccessible".l()}*")
@showTransition = false
return false
if cell.getTag("type") == "rock"
salet.view.append("*#{"rock_inaccessible".l()}")
@showTransition = false
return false
return true
bathevent = () ->
# событие не вызывается дважды
unless salet.character.bathevent? and salet.character.bathevent == true
jQuery(".questline").html(marked("bath_questline".l({
workshopname: salet.character.workshopname
})))
salet.character.bathevent = true
salet.view.append "story2".l({
"workshopname": salet.character.workshopname
})
workshopevent = () ->
# событие работает только после посещения бани
if salet.character.bathevent? and salet.character.bathevent
# событие не вызывается дважды
unless salet.character.workshopevent? and salet.character.workshopevent
salet.character.workshopevent = true
jQuery(".questline").html(marked("end_questline".l()))
salet.view.append "story3".l({
})
plotscene "end",
clear: true