diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..fb9c461
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "game/improv"]
+ path = game/improv
+ url = https://gitlab.com/Oreolek/improv-salet.git
diff --git a/Gulpfile.coffee b/Gulpfile.coffee
index 158ee37..6861cae 100644
--- a/Gulpfile.coffee
+++ b/Gulpfile.coffee
@@ -1,25 +1,30 @@
-watchify = require('watchify')
-browserify = require('browserify')
browserSync = require('browser-sync')
gulp = require('gulp')
-source = require('vinyl-source-stream')
gutil = require('gulp-util')
-coffeify = require('coffeeify')
coffee = require("gulp-coffee")
sass = require('gulp-sass')
uglify = require('gulp-uglify')
-buffer = require('vinyl-buffer')
zip = require('gulp-zip')
concat = require('gulp-concat')
+rename = require('gulp-rename')
fs = require 'fs'
-CSON = require 'cson'
-glob = require 'glob'
reload = browserSync.reload
-html = (target) ->
+html = (target, debug) ->
return () ->
- return gulp.src(['html/*.html']).pipe(gulp.dest(target))
+ sources = [
+ 'html/index.html'
+ 'html/ru.html'
+ ]
+ if (debug)
+ sources.push('html/test.html')
+ gulp.src(sources)
+ .pipe(gulp.dest(target))
+ #gulp.src(['game/gamepad.min.js']).pipe(gulp.dest(target+"/game"))
+ gulp.src(['node_modules/salet/lib/index.min.js'])
+ .pipe(rename('salet.min.js'))
+ .pipe(gulp.dest(target+"/game"))
# Images
img = (target) ->
@@ -31,68 +36,65 @@ audio = (target) ->
return () ->
return gulp.src(['audio/*.mp3']).pipe(gulp.dest(target))
-gulp.task('html', html('./build'))
+gulp.task('html', html('./build', true))
gulp.task('img', img('./build/img'))
gulp.task('audio', audio('./build/audio'))
+# SCSS styles
gulp.task('sass', () ->
gulp.src('sass/main.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('./build/css'))
)
-bundler = watchify(browserify({
- entries: ["./build/game/main.coffee"]
- debug: true
- transform: [coffeify]
-}))
-
-bundle = () ->
- return bundler.bundle()
- .on('error', gutil.log.bind(gutil, 'Browserify Error'))
- .pipe(source('bundle.js'))
- .pipe(gulp.dest('./build/game'))
-
-gulp.task('concatCoffee', () ->
- for language in ['ru', 'en']
- files = glob.sync('game/procgen/'+language+'/*.cson')
- spec = {}
- for file in files
- data = CSON.parseCSONFile(file)
- if not data.groups?
- data.groups = []
- if data.phrases?
- data.groups.push({
- tags: [],
- phrases: data.phrases
- })
- data.phrases = undefined
- key = file.substr(0, file.lastIndexOf('.')) || file
- key = key.replace('game/procgen/'+language+'/', '')
- spec[key] = data
-
- json = JSON.stringify(spec) + '\n'
- fs.writeFileSync("./build/game/procgen/"+language+".json", json)
-
- return gulp.src([
- './game/begin.coffee',
- './game/story.coffee',
- ]).pipe(concat('./main.coffee')).pipe(gulp.dest('./build/game'))
+# Autotests
+gulp.task('tests', () ->
+ gulp.src('test/*.js')
+ .pipe(gulp.dest('./build/test/'))
)
-gulp.task('coffee', ['concatCoffee'], bundle)
+gulp.task('concatCoffee', () ->
+ gulp.src([
+ # language
+ './game/language/ru.coffee'
+ './game/language/en.coffee'
+ # Improv
+ './game/improv/index.coffee'
+ './game/improv/filters.coffee'
+ './game/improv/template.coffee'
+ ## additional functions
+ "./lib/oneOf.coffee"
+ "./lib/phrase.coffee"
+ ## the actual game
+ './game/begin.coffee'
+ './game/story.coffee'
+ ]).pipe(concat('./main.coffee'))
+ .pipe(gulp.dest('./build/game'))
+)
-bundler.on('update', bundle)
-bundler.on('log', gutil.log)
+gulp.task('coffee', ['concatCoffee'], () ->
+ gulp.src('./build/game/main.coffee')
+ .pipe(coffee({bare: true}))
+ .pipe(gulp.dest('./build/game/'))
+)
-gulp.task('build', ['html', 'img', 'sass', 'coffee', 'audio'])
+gulp.task('build', [
+ 'html',
+ 'img',
+ 'sass',
+ 'coffee',
+ 'audio',
+ 'tests'
+])
gulp.task('serve', ['build'], () ->
browserSync({
server: {
baseDir: 'build'
}
+ online: true
browser: []
+ ghostMode: false
})
sassListener = () ->
@@ -101,8 +103,10 @@ gulp.task('serve', ['build'], () ->
gulp.watch(['./html/*.html'], ['html'])
gulp.watch(['./sass/*.scss'], ['sass'])
gulp.watch(['./img/*.png', './img/*.jpeg', './img/*.jpg'], ['img'])
- gulp.watch(['./game/*.coffee'], ['coffee']);
- gulp.watch(['./game/procgen/*/*.cson'], ['concatCoffee']);
+ gulp.watch([
+ './game/*.coffee'
+ './game/translations/*.cson'
+ ], ['coffee'])
gulp.watch(['./build/css/main.css'], sassListener)
gulp.watch(
@@ -110,47 +114,35 @@ gulp.task('serve', ['build'], () ->
browserSync.reload)
)
-gulp.task('html-dist', html('./dist'))
+gulp.task('html-dist', html('./dist', false))
gulp.task('img-dist', img('./dist/img'))
gulp.task('audio-dist', audio('./dist/audio'))
gulp.task('legal-dist', () ->
return gulp.src(['LICENSE.txt'])
- .pipe(gulp.dest("./dist"))
+ .pipe(gulp.dest("./dist"))
)
-
gulp.task('sass-dist', () ->
return gulp.src('./sass/main.scss')
- .pipe(sass({outputStyle: 'compressed'}))
+ .pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('./dist/css'))
)
-distBundler = browserify({
- debug: false,
- entries: ['./build/game/main.coffee'],
- transform: ['coffeeify']
-})
-
gulp.task('coffee-dist', ['concatCoffee'], () ->
- return distBundler.bundle()
- .pipe(source('bundle.js'))
- .pipe(buffer())
+ gulp.src('./build/game/main.coffee', {sourcemaps: false})
+ .pipe(coffee())
.pipe(uglify())
.on('error', gutil.log)
- .pipe(gulp.dest('./dist/game'))
+ .pipe(gulp.dest('./dist/game/'))
)
gulp.task('dist', [
- 'html-dist',
- 'img-dist',
- 'sass-dist',
- 'coffee-dist',
- 'audio-dist',
+ 'html-dist'
+ 'img-dist'
+ 'sass-dist'
+ 'coffee-dist'
+ 'audio-dist'
'legal-dist'
-], () ->
- return gulp.src([
- './build/game/procgen/*.json'
- ]).pipe(gulp.dest("./dist/game/procgen"))
-)
+])
gulp.task('zip', ['dist'], () ->
return gulp.src('dist/**')
diff --git a/game/begin.coffee b/game/begin.coffee
index dddbf5e..1b478f2 100644
--- a/game/begin.coffee
+++ b/game/begin.coffee
@@ -1,13 +1,8 @@
-require('babel-polyfill')
-require('salet')
-dialogue = require('../../lib/dialogue.coffee')
-phrase = require('../../lib/phrase.coffee')
-#oneOf = require('../../lib/oneOf.coffee')
-ImprovEngine = require('improv')
+ImprovEngine = new Improv
Improv = {}
-i18n.push("ru", require('../../game/language/ru.coffee'))
-i18n.push("en", require('../../game/language/en.coffee'))
+i18n.push("ru", ru_lang)
+i18n.push("en", en_lang)
salet.game_id = "0ee0825d-0c71-4a08-bfe5-730e575df26d"
salet.game_version = "1.0"
diff --git a/game/improv b/game/improv
new file mode 160000
index 0000000..968acca
--- /dev/null
+++ b/game/improv
@@ -0,0 +1 @@
+Subproject commit 968acca766468927ce546dadb2f068b3cd6f45d6
diff --git a/game/language/en.coffee b/game/language/en.coffee
index 594f9df..549d9d2 100644
--- a/game/language/en.coffee
+++ b/game/language/en.coffee
@@ -1,4 +1,4 @@
-module.exports =
+en_lang =
intro: """
# Stowaway tragedy
diff --git a/game/language/ru.coffee b/game/language/ru.coffee
index 5f8dc99..685e434 100644
--- a/game/language/ru.coffee
+++ b/game/language/ru.coffee
@@ -1,4 +1,4 @@
-module.exports =
+ru_lang =
no_local_storage: "Локальное хранилище недоступно."
erase_message: "Это навсегда удалит вашего персонажа и немедленно вернёт вас на старт игры. Вы уверены?"
back: "Обратно"
diff --git a/html/index.html b/html/index.html
index 4366d44..a3e63c5 100644
--- a/html/index.html
+++ b/html/index.html
@@ -40,7 +40,7 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+