mapgen/game/4_plot.coffee

98 lines
3.1 KiB
CoffeeScript
Raw Normal View History

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)
2018-07-14 11:23:27 +03:00
room "maze",
clear: false
priority: -10
showTransition: true
before: (from) ->
if @showTransition == false
@showTransition = true
return ""
currentCell = salet.character.getCell()
if currentCell.hasTag('special')
salet.character.past_x = salet.character.x
salet.character.past_y = salet.character.y
salet.saveGame()
return salet.specials[currentCell.getTag('special')]()
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')])
else
model.tags.push(['from', 'outside'])
model.tags.push(['to', currentCell.getTag('type')])
# Piwik analytics: terrain type
2018-08-12 18:07:52 +03:00
if _paq?
_paq.push(['setCustomDimension', 1, currentCell.getTag('type')])
2018-07-14 11:23:27 +03:00
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()
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
## Встреча 1
plotscene "meet1",
enter: () ->
hideSidebar()
beforeChoices: () ->
$("#content").on("submit", "form", (event) ->
event.preventDefault()
input = $("#name").val()
# _paq.push(['setCustomDimension', 2, input]) # record the name
salet.character.name = input
if input.length > 0
salet.processClick("meet1_cont")
return false
)
plotscene "meet1_noname",
tags: ["meet1"]
choices: "#meet1_cont"
dsc: "meet1_cont".l()
plotscene "meet1_cont",
tags: ["meet1"]
choices: "#meet1_cont"
canChoose: () -> return false
optionText: () ->
return "meet1_cont_option".l()+" <form class='inline'><input name='keyword' class='form-control' type='text' id='name' placeholder='#{"enter_name".l()}'></input><button class='btn' type='submit'>#{"say".l()}</button></form>"