diff --git a/Gulpfile.coffee b/Gulpfile.coffee index a0f310e..57fd7c1 100644 --- a/Gulpfile.coffee +++ b/Gulpfile.coffee @@ -44,7 +44,8 @@ gulp.task('sass', () -> ) gulp.task('concatCoffee', () -> - fs.mkdir('./build/game/translations') + if !fs.existsSync('./build/game/translations') + fs.mkdirSync('./build/game/translations') for language in ['ru', 'en'] data = CSON.parseCSONFile('game/translations/'+language+'.cson') json = JSON.stringify(data) + '\n' @@ -105,7 +106,8 @@ gulp.task('sass-dist', () -> ) 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'] data = CSON.parseCSONFile('game/translations/'+language+'.cson') json = JSON.stringify(data) + '\n' diff --git a/game/begin.coffee b/game/begin.coffee index 331f5ee..323815c 100644 --- a/game/begin.coffee +++ b/game/begin.coffee @@ -1,13 +1,6 @@ salet.game_id = "being-astrid-is-hard-enough-but-try-living-as-one" salet.game_version = "1.0" 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 ) $.getJSON('game/translations/'+i18n.lang+'.json', (data) -> @@ -44,6 +37,12 @@ $(document).ready(() -> 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") 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. # For accessibility reasons the text is provided in HTML, not here. 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() choices: "#start" button = unit "button", colors: ["red", "blue", "green", "yellow", "orange", "violet"] color: 0 - dsc: () -> "{"+"color_"+@colors[@color].l()+"}" + dsc: () -> "
{{"+("color_"+@colors[@color]).l()+"}}
" act: () -> - index = @colors.indexOf(@color) - index = index + 1 - if index > @colors.length - index = 0 - @color = @colors[index] + @color = @color + 1 + if @color >= @colors.length + @color = 0 salet.rooms["entry"].canChoose = true + salet.view.clearContent() + salet.here().entering(salet.currentRoom) + return "" room "instance", dsc: () -> "instance".l() tags: ["start"] + choices: "#instance" optionText: () -> "begin_game".l() - enter: () -> - for u in @units - u.color = salet.rnd.randomInt(u.colors.length) - units: [ - button "first", - button "second" - ] + exit: () -> + client.record.listen('presence.*', (match, isSubscribed, response) => + if (isSubscribed) + response.accept() + else + # stop publishing data, client disconnected + client.record.getRecord(match).discard() + ) -croom "entry", - canChoose: false - optionText: () -> "entry_option".l() - title: () -> "entry_title".l() - ways: ["corridor"] - desc: () -> "entry_dsc".l() +salet.rooms["instance"].take(button) croom = (name, options) -> options.enter = () -> @@ -121,3 +113,11 @@ croom = (name, options) -> options.dsc = () -> "### #{@title()}\n" + @desc() return room(name,options) + +croom "entry", + canChoose: false + tags: ["instance"] + optionText: () -> "entry_option".l() + title: () -> "entry_title".l() + ways: ["corridor"] + desc: () -> "entry_dsc".l() diff --git a/game/translations/ru.cson b/game/translations/ru.cson index 7df72fd..e33997b 100644 --- a/game/translations/ru.cson +++ b/game/translations/ru.cson @@ -7,7 +7,7 @@ intro: """ instance: """ Вы стоите в круглой комнате перед круглой дверью. - *Наберите двуцветный код мира и войдите в дверь. + *Выберите цветной код мира и войдите в дверь. В одном мире не может быть больше четырёх Астрид.* Рядом с дверью есть цветная кнопка. @@ -18,6 +18,7 @@ color_blue: "Синяя." color_yellow: "Жёлтая." color_orange: "Оранжевая." color_violet: "Фиолетовая." +entry_option: "Войти в дверь" no_local_storage: "Локальное хранилище недоступно." erase_message: "Это навсегда удалит вашего персонажа и немедленно вернёт вас на старт игры. Вы уверены?" room_enter: "В комнату входит "