mapgen/game/4_plot.coffee

101 lines
3.2 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.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')])
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()
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>"