Optimizations WIP
This commit is contained in:
parent
b84b45b0f1
commit
d3581a6eb4
|
@ -0,0 +1,3 @@
|
|||
[submodule "game/improv"]
|
||||
path = game/improv
|
||||
url = https://gitlab.com/Oreolek/improv-salet.git
|
142
Gulpfile.coffee
142
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"))
|
||||
)
|
||||
|
||||
gulp.task('sass-dist', () ->
|
||||
return gulp.src('./sass/main.scss')
|
||||
.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/**')
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 968acca766468927ce546dadb2f068b3cd6f45d6
|
|
@ -1,4 +1,4 @@
|
|||
module.exports =
|
||||
en_lang =
|
||||
intro: """
|
||||
# Stowaway tragedy
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports =
|
||||
ru_lang =
|
||||
no_local_storage: "Локальное хранилище недоступно."
|
||||
erase_message: "Это навсегда удалит вашего персонажа и немедленно вернёт вас на старт игры. Вы уверены?"
|
||||
back: "Обратно"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js" integrity="sha384-QXBtGc4014gU26HdCwzgy8TVO+FHSSE4+EvPPiSTpdE9w0KyJy1ocfiIbBl1HLq7" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js" crossorigin="anonymous"></script>
|
||||
|
||||
<script type="text/javascript" src="game/bundle.js"></script>
|
||||
<script type="text/javascript" src="game/main.js"></script>
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js" crossorigin="anonymous"></script>
|
||||
<!-- <audio id="bgsound" preload="auto" loop="loop"><source src="audio/bgr.mp3" type='audio/mpeg; codecs="mp3"'></audio> -->
|
||||
|
||||
<script type="text/javascript" src="game/bundle.js"></script>
|
||||
<script type="text/javascript" src="game/main.js"></script>
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.3.3.css">
|
||||
<style>#page{display: none}</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class='ways'>
|
||||
<ul class="nav nav-pills" id="ways">
|
||||
</ul>
|
||||
</div>
|
||||
</div> <!-- End of div.tools_wrapper -->
|
||||
<div id="content_wrapper">
|
||||
<div id="content" class="content narrow">
|
||||
<noscript>This game requires Javascript.</noscript>
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
<div class="ui">
|
||||
<a href="#" id="storytab" class="tab active"></a>
|
||||
<a href="inventory" id="chartab" class="tab"></a>
|
||||
<a href="map" id="maptab" class="tab"></a>
|
||||
</div>
|
||||
<div class="action">
|
||||
<div class="verb" data-verb="examine">Examine</div>
|
||||
<ul class="objects" id="examinelist" data-verb="examine">
|
||||
</ul>
|
||||
<div class="verb" data-verb="take">Take</div>
|
||||
<ul class="objects" id="takelist" data-verb="take">
|
||||
</ul>
|
||||
<div class="verb" data-verb="drop">Drop</div>
|
||||
<ul class="objects" id="droplist" data-verb="drop">
|
||||
</ul>
|
||||
<div class="verb" data-verb="wear">Wear</div>
|
||||
<ul class="objects" id="wearlist" data-verb="wear">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<a name="end_of_content"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- End of div.page -->
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
|
||||
<!-- Dependency JS Libraries -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sigma.js/1.2.0/sigma.min.js"></script>
|
||||
<script src="https://code.jquery.com/qunit/qunit-2.3.3.js"></script>
|
||||
|
||||
<script src="game/salet.min.js"></script>
|
||||
<script src="game/main.js"></script>
|
||||
|
||||
<script defer="defer" src="test/main.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -21,5 +21,3 @@ dialogue = (title, startTag, endTag, text, effect) ->
|
|||
retval.before = (character, system) ->
|
||||
eval(effect)
|
||||
return retval
|
||||
|
||||
module.exports = dialogue
|
||||
|
|
|
@ -165,5 +165,3 @@ Array.prototype.oneOf = () ->
|
|||
oneOf.apply(null, this)
|
||||
String.prototype.oneOf = () ->
|
||||
return this
|
||||
|
||||
module.exports = oneOf
|
||||
|
|
|
@ -24,5 +24,3 @@ phrase = (title, tag, text, effect) ->
|
|||
retval.before = (character, system) ->
|
||||
eval(effect)
|
||||
return retval
|
||||
|
||||
module.exports = phrase
|
||||
|
|
17
package.json
17
package.json
|
@ -1,28 +1,21 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"cson": "^4.1.0",
|
||||
"glob": "^7.1.2",
|
||||
"improv": "^1.0.0",
|
||||
"salet": "^2.0.0"
|
||||
},
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"cson": "^4.1.0",
|
||||
"glob": "^7.1.2",
|
||||
"salet": "^2.0.0",
|
||||
"bootstrap": "^4.0.0-alpha.2",
|
||||
"browser-sync": "^2.18.13",
|
||||
"browserify": "^14.5.0",
|
||||
"browserify-shim": "^3.8.14",
|
||||
"coffeescript": "^2.0.0",
|
||||
"coffeeify": "^3.0.1",
|
||||
"gulp": "^3.8.11",
|
||||
"gulp-coffee": "^2.3.4",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-sass": "^3.1.0",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"gulp-util": "^3.0.8",
|
||||
"gulp-zip": "^4.0.0",
|
||||
"vinyl-buffer": "^1.0.0",
|
||||
"vinyl-source-stream": "^1.1.0",
|
||||
"watchify": "^3.9.0"
|
||||
"gulp-zip": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
salet.autosave = false;
|
||||
salet.autoload = false;
|
||||
|
||||
$(document).ready(function() {
|
||||
QUnit.test("The game starts okay.", function(assert) {
|
||||
assert.notEqual(salet, void 0, "Salet is initialized");
|
||||
return assert.equal(salet.current, "start", "Salet is in the room called 'start'");
|
||||
});
|
||||
QUnit.test("There are no game-breaking bugs when entering rooms.", function(assert) {
|
||||
for (var key in salet.rooms) {
|
||||
// skip loop if the property is from prototype
|
||||
if (!salet.rooms.hasOwnProperty(key)) continue;
|
||||
|
||||
var room = salet.rooms[key];
|
||||
|
||||
assert.ok(salet.goTo(room.name), "Entered room "+room.name);
|
||||
}
|
||||
});
|
||||
QUnit.test("There are no game-breaking bugs in all actions.", function(assert) {
|
||||
for (var key in salet.rooms) {
|
||||
// skip loop if the property is from prototype
|
||||
if (!salet.rooms.hasOwnProperty(key)) continue;
|
||||
var room = salet.rooms[key];
|
||||
|
||||
salet.goTo(room.name);
|
||||
for (var act in room.actions) {
|
||||
if (!room.actions.hasOwnProperty(act)) continue;
|
||||
assert.ok(act.fcall(room), "Executed action "+act);
|
||||
}
|
||||
for (var act in room.writers) {
|
||||
if (!room.writers.hasOwnProperty(act)) continue;
|
||||
assert.ok(act.fcall(room), "Executed action "+act);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue