1
0
Fork 0

Colored button

This commit is contained in:
Alexander Yakovlev 2017-01-27 23:28:59 +07:00
parent 4eeb9d15a1
commit 945bb02bb6
3 changed files with 37 additions and 34 deletions

View File

@ -44,7 +44,8 @@ gulp.task('sass', () ->
) )
gulp.task('concatCoffee', () -> gulp.task('concatCoffee', () ->
fs.mkdir('./build/game/translations') if !fs.existsSync('./build/game/translations')
fs.mkdirSync('./build/game/translations')
for language in ['ru', 'en'] for language in ['ru', 'en']
data = CSON.parseCSONFile('game/translations/'+language+'.cson') data = CSON.parseCSONFile('game/translations/'+language+'.cson')
json = JSON.stringify(data) + '\n' json = JSON.stringify(data) + '\n'
@ -105,7 +106,8 @@ gulp.task('sass-dist', () ->
) )
gulp.task('coffee-dist', ['concatCoffee'], () -> gulp.task('coffee-dist', ['concatCoffee'], () ->
fs.mkdir('./dist/game/translations') if !fs.existsSync('./dist/game/translations')
fs.mkdirSync('./dist/game/translations')
for language in ['ru', 'en'] for language in ['ru', 'en']
data = CSON.parseCSONFile('game/translations/'+language+'.cson') data = CSON.parseCSONFile('game/translations/'+language+'.cson')
json = JSON.stringify(data) + '\n' json = JSON.stringify(data) + '\n'

View File

@ -1,13 +1,6 @@
salet.game_id = "being-astrid-is-hard-enough-but-try-living-as-one" salet.game_id = "being-astrid-is-hard-enough-but-try-living-as-one"
salet.game_version = "1.0" salet.game_version = "1.0"
client = deepstream('localhost:6020').login() client = deepstream('localhost:6020').login()
client.record.listen('presence.*', (match, isSubscribed, response) =>
if (isSubscribed)
response.accept()
else
# stop publishing data, client disconnected
client.record.getRecord(match).discard()
)
$.holdReady( true ) $.holdReady( true )
$.getJSON('game/translations/'+i18n.lang+'.json', (data) -> $.getJSON('game/translations/'+i18n.lang+'.json', (data) ->
@ -44,6 +37,12 @@ $(document).ready(() ->
salet.beginGame() salet.beginGame()
) )
salet.initGame = () ->
names = "names".l()
salet.character.name = names[salet.rnd.randomInt(names.length)]
salet.character.id = salet.rnd.randn()
button.color = salet.rnd.randomInt(button.colors.length)
### ###
Element helpers. There is no real need to build monsters like a().id("hello") Element helpers. There is no real need to build monsters like a().id("hello")
because you won't use them as is. It does not make sense in context, the because you won't use them as is. It does not make sense in context, the
@ -59,44 +58,37 @@ actlink = (content, ref) ->
# The first room of the game. # The first room of the game.
# For accessibility reasons the text is provided in HTML, not here. # For accessibility reasons the text is provided in HTML, not here.
room "start", room "start",
enter: () ->
if (salet.character.name == undefined)
names = "names".l()
salet.character.name = names[salet.rnd.randomInt(names.length)]
salet.character.id = salet.rnd.randn()
dsc: () -> "intro".l() dsc: () -> "intro".l()
choices: "#start" choices: "#start"
button = unit "button", button = unit "button",
colors: ["red", "blue", "green", "yellow", "orange", "violet"] colors: ["red", "blue", "green", "yellow", "orange", "violet"]
color: 0 color: 0
dsc: () -> "{"+"color_"+@colors[@color].l()+"}" dsc: () -> "<center><b>{{"+("color_"+@colors[@color]).l()+"}}</b></center>"
act: () -> act: () ->
index = @colors.indexOf(@color) @color = @color + 1
index = index + 1 if @color >= @colors.length
if index > @colors.length @color = 0
index = 0
@color = @colors[index]
salet.rooms["entry"].canChoose = true salet.rooms["entry"].canChoose = true
salet.view.clearContent()
salet.here().entering(salet.currentRoom)
return ""
room "instance", room "instance",
dsc: () -> "instance".l() dsc: () -> "instance".l()
tags: ["start"] tags: ["start"]
choices: "#instance"
optionText: () -> "begin_game".l() optionText: () -> "begin_game".l()
enter: () -> exit: () ->
for u in @units client.record.listen('presence.*', (match, isSubscribed, response) =>
u.color = salet.rnd.randomInt(u.colors.length) if (isSubscribed)
units: [ response.accept()
button "first", else
button "second" # stop publishing data, client disconnected
] client.record.getRecord(match).discard()
)
croom "entry", salet.rooms["instance"].take(button)
canChoose: false
optionText: () -> "entry_option".l()
title: () -> "entry_title".l()
ways: ["corridor"]
desc: () -> "entry_dsc".l()
croom = (name, options) -> croom = (name, options) ->
options.enter = () -> options.enter = () ->
@ -121,3 +113,11 @@ croom = (name, options) ->
options.dsc = () -> options.dsc = () ->
"### #{@title()}\n" + @desc() "### #{@title()}\n" + @desc()
return room(name,options) return room(name,options)
croom "entry",
canChoose: false
tags: ["instance"]
optionText: () -> "entry_option".l()
title: () -> "entry_title".l()
ways: ["corridor"]
desc: () -> "entry_dsc".l()

View File

@ -7,7 +7,7 @@ intro: """
instance: """ instance: """
Вы стоите в круглой комнате перед круглой дверью. Вы стоите в круглой комнате перед круглой дверью.
*Наберите двуцветный код мира и войдите в дверь. *Выберите цветной код мира и войдите в дверь.
В одном мире не может быть больше четырёх Астрид.* В одном мире не может быть больше четырёх Астрид.*
Рядом с дверью есть цветная кнопка. Рядом с дверью есть цветная кнопка.
@ -18,6 +18,7 @@ color_blue: "Синяя."
color_yellow: "Жёлтая." color_yellow: "Жёлтая."
color_orange: "Оранжевая." color_orange: "Оранжевая."
color_violet: "Фиолетовая." color_violet: "Фиолетовая."
entry_option: "Войти в дверь"
no_local_storage: "Локальное хранилище недоступно." no_local_storage: "Локальное хранилище недоступно."
erase_message: "Это навсегда удалит вашего персонажа и немедленно вернёт вас на старт игры. Вы уверены?" erase_message: "Это навсегда удалит вашего персонажа и немедленно вернёт вас на старт игры. Вы уверены?"
room_enter: "В комнату входит " room_enter: "В комнату входит "