diff --git a/Gulpfile.coffee b/Gulpfile.coffee
index ae4ca4d..7cb56e3 100644
--- a/Gulpfile.coffee
+++ b/Gulpfile.coffee
@@ -1,16 +1,32 @@
+watchify = require('watchify')
+browserify = require('browserify')
browserSync = require('browser-sync')
gulp = require('gulp')
gutil = require('gulp-util')
coffee = require("gulp-coffee")
+coffeify = require('coffeeify')
sass = require('gulp-sass')
uglify = require('gulp-uglify')
zip = require('gulp-zip')
concat = require('gulp-concat')
rename = require('gulp-rename')
+source = require('vinyl-source-stream')
fs = require 'fs'
reload = browserSync.reload
+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'))
+
html = (target, debug) ->
return () ->
sources = [
@@ -80,11 +96,10 @@ gulp.task('concatCoffee', () ->
.pipe(gulp.dest('./build/game'))
)
-gulp.task('coffee', ['concatCoffee'], () ->
- gulp.src('./build/game/main.coffee')
- .pipe(coffee({bare: true}))
- .pipe(gulp.dest('./build/game/'))
-)
+bundler.on('update', bundle)
+bundler.on('log', gutil.log)
+
+gulp.task('coffee', ['concatCoffee'], bundle)
gulp.task('build', [
'html'
diff --git a/game/engine.coffee b/game/engine.coffee
index 2c69417..db232e2 100644
--- a/game/engine.coffee
+++ b/game/engine.coffee
@@ -1,6 +1,7 @@
###
# This is the file with all thing *around* Salet.
###
+Improv = require('improv')
salet.game_id = "2868be0e-0011-4d94-87a9-1a80f65ff7f0"
salet.game_version = "1.0"
diff --git a/game/model.coffee b/game/model.coffee
index fa7ccc0..cf6db17 100644
--- a/game/model.coffee
+++ b/game/model.coffee
@@ -193,3 +193,141 @@ sysroom "map",
text: () -> """
Здесь будет карта
"""
+
+Array.prototype.remove = (args...) ->
+ output = []
+ for arg in args
+ index = @indexOf arg
+ output.push @splice(index, 1) if index isnt -1
+ output = output[0] if args.length is 1
+ output
+
+Array.prototype.shuffle = () ->
+ i = this.length
+ while --i > 0
+ j = ~~(salet.rnd.randf() * (i + 1))
+ t = this[j]
+ this[j] = this[i]
+ this[i] = t
+ this
+
+# Volume from 0 to 1
+get_volume = () ->
+ return ($('#slider').slider('value') - 1) / 100
+
+window.set_volume = (value) ->
+ document.getElementById("bgsound").volume = (value / 100)
+ volume = $('.voldisplay')
+ if value <= 5
+ volume.css('background-position', '0 0')
+ else if value <= 25
+ volume.css('background-position', '0 -25px')
+ else if value <= 75
+ volume.css('background-position', '0 -50px')
+ else
+ volume.css('background-position', '0 -75px')
+
+update_paths = (character) ->
+ x = character.x
+ y = character.y
+ maze = character.maze
+ if maze.isEast(x,y)
+ text = "east".l()
+ if not character.has("compass")
+ eastCell = character.getCell(x+1,y)
+ type = eastCell.getTag("type")
+ text = "#{type}".l()
+ $("#east").html("#{text}")
+ else
+ $("#east").html("")
+ if maze.isWest(x,y)
+ text = "west".l()
+ if not character.has("compass")
+ westCell = character.getCell(x-1,y)
+ type = westCell.getTag("type")
+ text = "#{type}".l()
+ $("#west").html("#{text}")
+ else
+ $("#west").html("")
+ if maze.isNorth(x,y)
+ text = "north".l()
+ if not character.has("compass")
+ northCell = character.getCell(x,y-1)
+ type = northCell.getTag("type")
+ text = "#{type}".l()
+ $("#north").html("#{text}")
+ else
+ $("#north").html("")
+ if maze.isSouth(x,y)
+ text = "south".l()
+ if not character.has("compass")
+ southCell = character.getCell(x,y+1)
+ type = southCell.getTag("type")
+ text = "#{type}".l()
+ $("#south").html("#{text}")
+ else
+ $("#south").html("")
+ return
+
+typeIsArray = ( value ) ->
+ value and
+ typeof value is 'object' and
+ value instanceof Array and
+ typeof value.length is 'number' and
+ typeof value.splice is 'function' and
+ not ( value.propertyIsEnumerable 'length' )
+
+###
+# Improv's mismatchFilter with tag options.
+# Ensures that the group and model don't have any mismatched tags.
+# Returns null if found a mismatch between model tag and the group.
+# Every match counts as +1 to the score offset.
+# Returns 0 if unsure.
+#
+# Unlike the default mismatchFilter, it allows tags like this:
+#
+# ['to', ['thickforest', 'rareforest', 'deepforest']]
+#
+###
+tagMismatchFilter = (group, model) ->
+ score = 0
+ if group.tags.length == 0
+ return 0
+ for groupTag in group.tags
+ for modelTag in model.tags
+ if modelTag[0] != groupTag[0]
+ continue
+ modelTag = modelTag[1]
+ groupTag = groupTag[1]
+ if typeIsArray(groupTag)
+ if groupTag.indexOf(modelTag) != -1
+ score = score + 1
+ else
+ return null
+ else
+ if modelTag != groupTag
+ return null
+ return score
+
+
+setAdjacent = (model) ->
+ cells = {}
+ cells["north"] = salet.character.maze.getNorth(salet.character.x, salet.character.y)
+ cells["west"] = salet.character.maze.getWest(salet.character.x, salet.character.y)
+ cells["east"] = salet.character.maze.getEast(salet.character.x, salet.character.y)
+ cells["south"] = salet.character.maze.getSouth(salet.character.x, salet.character.y)
+ adjacent = []
+ for direction, cell of cells
+ if cell == false
+ continue
+ type = cell.getTag('type')
+ if adjacent.indexOf(type) != -1 # уже есть сосед этого типа
+ continue
+ adjacent.push(type)
+ model["#{type}_direction"] = "#{direction}".l()
+ model["#{type}_direction_instrumental"] = "#{direction}_instrumental".l()
+ model["#{type}_direction_genitive"] = "#{direction}_genitive".l()
+ model["#{type}_direction_vocative"] = "#{direction}_vocative".l()
+ model["#{type}_direction_adverb"] = "#{direction}_adverb".l()
+ model.tags.push(["adjacent", adjacent])
+ return model
diff --git a/html/index.html b/html/index.html
index acf9108..9ef7462 100644
--- a/html/index.html
+++ b/html/index.html
@@ -47,13 +47,10 @@
-
-
-
-
+