diff --git a/Gulpfile.js b/Gulpfile.js index 02e90d9..7beaec9 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -89,7 +89,12 @@ gulp.task('copyTranslations', [], function() { }); gulp.task('concatCoffee', ['copyTranslations'], function() { - return gulp.src('./game/*.coffee') + return gulp.src([ + './game/begin.coffee', + './game/gameplay.coffee', + './game/story.coffee', + './game/end.coffee', + ]) .pipe(concat('./main.coffee')) .pipe(gulp.dest('./build/game')); }); diff --git a/game/00begin.coffee b/game/00begin.coffee deleted file mode 100644 index ed23446..0000000 --- a/game/00begin.coffee +++ /dev/null @@ -1,19 +0,0 @@ -# copyright (c) Alexander Yakovlev 2015. -# This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. -# To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0 - -situation = require('raconteur') -undum = require('undum-commonjs') -oneOf = require('raconteur/lib/oneOf.js') -qualities = require('raconteur/lib/qualities.js') - -undumloc = require("./translations/ru.coffee").language -undum.language["ru"] = undumloc -undumloc = require("./translations/en.coffee").language -undum.language["en"] = undumloc -$ = require("jquery") -Array.prototype.oneOf = () -> - oneOf.apply(null, this) - -undum.game.id = "7a1aba32-f0fd-4e3b-ba5a-59e3fa9e6012" -undum.game.version = "2.0" diff --git a/game/begin.coffee b/game/begin.coffee new file mode 100644 index 0000000..48bf105 --- /dev/null +++ b/game/begin.coffee @@ -0,0 +1,43 @@ +# copyright (c) Alexander Yakovlev 2015. +# This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. +# To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0 + +situation = require('raconteur') +undum = require('undum-commonjs') +oneOf = require('raconteur/lib/oneOf.js') +qualities = require('raconteur/lib/qualities.js') + +undumloc = require("./translations/ru.coffee").language +undum.language["ru"] = undumloc +undumloc = require("./translations/en.coffee").language +undum.language["en"] = undumloc +$ = require("jquery") +Array.prototype.oneOf = () -> + oneOf.apply(null, this) + +undum.game.id = "7a1aba32-f0fd-4e3b-ba5a-59e3fa9e6012" +undum.game.version = "2.0" + +a = require('raconteur/lib/elements.js').a +way_to = (content, ref) -> a(content).class('way').ref(ref) +textlink = (content, ref) -> a(content).once().writer(ref) +textcycle = (content, ref) -> a(content).replacer(ref).class("cycle").id(ref).toString() +writemd = (system, text) -> + if typeof text is Function + text = text() + system.write(markdown.render(text)) + +situation "start", + content: () -> + return "start".l()(this.writers.smell) + choices: ["#start"], + writers: + smell: textcycle("пахнет сладким мёдом", "look") + look: textcycle("смотрит вдаль, о чём-то задумавшись", "touch") + touch: textcycle("крепко обнимает меня, впиваясь ногтями в плечо", "smell") + +is_visited = (situation) -> + situations = undum.game.situations[situation] + if situations + return Boolean situations.visited + return 0 diff --git a/game/99end.coffee b/game/end.coffee similarity index 90% rename from game/99end.coffee rename to game/end.coffee index 987fae8..ef6a107 100644 --- a/game/99end.coffee +++ b/game/end.coffee @@ -1,3 +1,4 @@ + qualities head: bullets: qualities.integer("bullets".l()), @@ -18,7 +19,6 @@ undum.game.init = (character, system) -> character.sandbox.killed = 0 character.sandbox.seen_pacifist = 0 character.sandbox.shot_pacifist = undefined - window.is_visited = (situation) -> undum.game.situations[situation].visited == 1 $("#title").click(() -> $("#clip").fadeIn() ) diff --git a/game/gameplay.coffee b/game/gameplay.coffee index 8f922d4..a214263 100644 --- a/game/gameplay.coffee +++ b/game/gameplay.coffee @@ -1,20 +1,3 @@ -situation = require('raconteur') -$ = require("jquery") -md = require('markdown-it') -markdown = new md({ - typographer: true, - html: true -}) - -a = require('raconteur/lib/elements.js').a -way_to = (content, ref) -> a(content).class('way').ref(ref) -textlink = (content, ref) -> a(content).once().writer(ref) -textcycle = (content, ref) -> a(content).replacer(ref).class("cycle").id(ref) -writemd = (system, text) -> - if typeof text is Function - text = text() - system.write(markdown.render(text)) - # This is an easy game. # I'm thinking if you want more harder approach, you can: # a) remove bullet counter (you don't know how many bullets left in a clip) diff --git a/game/story.coffee b/game/story.coffee index 5688cfc..8d825a2 100644 --- a/game/story.coffee +++ b/game/story.coffee @@ -1,14 +1,3 @@ -situation = require('raconteur') - -a = require('raconteur/lib/elements.js').a -way_to = (content, ref) -> a(content).class('way').ref(ref) -textlink = (content, ref) -> a(content).once().writer(ref) -textcycle = (content, ref) -> a(content).replacer(ref).class("cycle").id(ref).toString() -writemd = (system, text) -> - if typeof text is Function - text = text() - system.write(markdown.render(text)) - ### --- Intro dialogue --- I believe a dialogue is always a mini-game in itself. @@ -16,20 +5,11 @@ Undum's implicit choice system is perfect for "floating modules"-type of dialogu BUT it also means that every phrase should be a separate situation. ### -situation "start", - content: () -> - return "start".l()(this.writers.smell) - choices: ["#start"], - writers: - smell: textcycle("пахнет сладким мёдом", "look") - look: textcycle("смотрит вдаль, о чём-то задумавшись", "touch") - touch: textcycle("крепко обнимает меня, впиваясь ногтями в плечо", "smell") - situation 'answer1', optionText: "Милая, я просто за тебя беспокоюсь.", choices: ['#answer1'], tags: "start", - canView: true, + canView: () -> !is_visited(this.name), content: """ -- Милая, я просто за тебя беспокоюсь. @@ -43,7 +23,7 @@ situation 'branch1-a', optionText: "Защиты недостаточно.", choices: ['#start'], tags: "answer1", - canView: true, + canView: () -> !is_visited(this.name), content: """ -- Защиты недостаточно. -- я кладу руку на рукоять пистолета. @@ -54,7 +34,7 @@ situation 'branch1-b', optionText: "Я всегда держу его при себе.", choices: ['#start'], tags: "answer1", - canView: true, + canView: () -> !is_visited(this.name), content: """ -- Я всегда держу его при себе. Это нормально. @@ -67,7 +47,7 @@ situation 'dlg-intro-finale1', optionText: "Я и так расслаблен.", choices: ['#stage3'], tags: "answer2", - canView: true, + canView: () -> !is_visited(this.name), content: () -> """ -- О чём ты говоришь? Я и так расслаблен. @@ -85,6 +65,7 @@ situation 'answer2', optionText: "Я его даже не трогаю.", choices: ['#answer2', "#stage2"], tags: "start", + canView: () -> !is_visited(this.name), content: """ -- Я его даже не трогаю. @@ -95,6 +76,7 @@ situation 'answer2', situation 'lazy', optionText: "Я просто не вынимал его из кобуры.", choices: ['#lazy', "#stage2"], + canView: () -> !is_visited(this.name), tags: "start", content: """ -- Я просто не вынимал его из кобуры. @@ -107,6 +89,7 @@ situation 'lazy2', optionText: "Конечно, он на предохранителе.", choices: ['#stage2'], tags: "lazy", + canView: () -> !is_visited(this.name), content: """ -- Конечно, он на предохранителе. Видишь, ничего страшного. -- я вытащил пистолет, чтобы показать ей. @@ -122,6 +105,7 @@ situation 'lazy3', optionText: "Я не собираюсь стрелять.", choices: ['#stage3'], tags: "stage2", + canView: () -> !is_visited(this.name), content: """ -- Я не собираюсь стрелять. @@ -132,6 +116,7 @@ situation 'dlg-intro-finale2', optionText: "Это просто мой пистолет.", choices: ['#intro'], tags: "stage3", + canView: () -> !is_visited(this.name), content: """ -- Это просто мой пистолет. Лучше посмотри на эти розовые облака в небе.