diff --git a/.gitignore b/.gitignore index b512c09..e13c8ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -node_modules \ No newline at end of file +node_modules +build +dist \ No newline at end of file diff --git a/Gulpfile.js b/Gulpfile.js index e69de29..2dcde9a 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -0,0 +1,132 @@ +'use strict'; + +/* Raconteur Gulpfile scaffold. */ +/* Includes code adapted from Gulp documentation, among other sources. */ + +/* Imports */ +var 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'), + less = require('gulp-less'), + minifyCSS = require('gulp-minify-css'), + uglify = require('gulp-uglify'), + buffer = require('vinyl-buffer'), + _ = require('lodash'); + +var reload = browserSync.reload; + +/* Tasks */ + +/* Trivial file copies */ + +function html (target) { + return function () { + return gulp.src('html/index.html') + .pipe(gulp.dest(target)); + }; +} + +function img (target) { + return function () { + return gulp.src(['img/*.png', 'img/*.jpeg', 'img/*.jpg']) + .pipe(gulp.dest(target)); + }; +} + +gulp.task('html', html('./build')); +gulp.task('img', img('./build/img')); + +/* Less */ + +gulp.task('less', function () { + gulp.src('less/main.less') + .pipe(less()) + .pipe(gulp.dest('./build/css')); +}); + +/* Generate JavaScript with browser sync. */ + +var customOpts = { + entries: ['./game/main.coffee'], + debug: true, + transform: [coffeify] +}; + +var opts = _.assign({}, watchify.args, customOpts); +var bundler = watchify(browserify(opts)); + +gulp.task('coffee', bundle); // `gulp coffee` will generate bundle +bundler.on('update', bundle); // Re-bundle on dep updates +bundler.on('log', gutil.log); // Output build logs to terminal + +function bundle () { + return bundler.bundle() + .on('error', gutil.log.bind(gutil, 'Browserify Error')) + .pipe(source('bundle.js')) + .pipe(gulp.dest('./build/game')); +}; + +/* Make a development build */ + +gulp.task('build', ['html', 'img', 'less', 'coffee'], function () { + +}); + +/* Start a development server */ + +gulp.task('serve', ['build'], function () { + browserSync({ + server: { + baseDir: 'build' + } + }); + + var lessListener = function () { + reload('./build/css/main.css'); + } + + gulp.watch(['./html/*.html'], ['html']); + gulp.watch(['./less/*.less'], ['less']); + gulp.watch(['./img/*.png', './img/*.jpeg', './img/*.jpg'], ['img']); + + gulp.watch(['./build/css/main.css'], lessListener); + gulp.watch( + ['./build/game/bundle.js', './build/img/*', './build/index.html'], + browserSync.reload); +}); + +/* Distribution tasks */ + +gulp.task('html-dist', html('./dist')); +gulp.task('img-dist', img('./dist/img')); + +gulp.task('less-dist', function () { + return gulp.src('./less/main.less') + .pipe(less()) + .pipe(minifyCSS()) + .pipe(gulp.dest('./dist/css')); +}); + +var distBundler = browserify({ + debug: false, + entries: ['./game/main.coffee'], + transform: ['coffeeify'] +}); + +gulp.task('coffee-dist', function () { + return distBundler.bundle() + .pipe(source('bundle.js')) + .pipe(buffer()) + .pipe(uglify()) + .on('error', gutil.log) + .pipe(gulp.dest('./dist/game')); +}); + +gulp.task('dist', ['html-dist', 'img-dist', 'less-dist', 'coffee-dist'], + function () { + return; +}); \ No newline at end of file diff --git a/game/main.coffee b/game/main.coffee index 0d60376..81e861a 100644 --- a/game/main.coffee +++ b/game/main.coffee @@ -1,12 +1,11 @@ # Require the libraries we rely on +situation = require('raconteur/lib/situation.js') +situation.exportUndum() # Ensures our Undum object is the same as Raconteur's $ = require('jquery') -undum = require('undum-commonjs') - -situation = require('raconteur/situation.js') -oneOf = require('raconteur/oneOf.js') -elements = require('raconteur/elements.js') -qualities = require('raconteur/qualities.js') +oneOf = require('raconteur/lib/oneOf.js') +elements = require('raconteur/lib/elements.js') +qualities = require('raconteur/lib/qualities.js') a = elements.a span = elements.span @@ -23,18 +22,55 @@ undum.game.version = "0.1" situation 'start', content: """ - # Welcome to raconteur + ![a storyteller](img/storyteller.jpg) + + # Welcome to Raconteur If you're seeing this, you've successfully installed the Raconteur game - scaffold. Get writing! + scaffold. Get writing! + + Raconteur lives at a [Github Repository], where you can report issues or + send feedback. + + [Github Repository]: https://github.com/sequitur/raconteur """ +# ---------------------------------------------------------------------------- +# Qualities + +qualities + stats: + name: 'Statistics', + strength: qualities.integer('Strength', {priority: '001'}), + dexterity: qualities.integer('Dexterity', {priority: '002'}), + constitution: qualities.integer('Constitution', {priority: '003'}), + intelligence: qualities.integer('Intelligence', {priority: '004'}), + perception: qualities.integer('Perception', {priority: '005'}), + charisma: qualities.integer('Charisma', {priority: '006'}) + possessions: + name: 'Possessions', + gold: qualities.integer('Gold'), + sword: qualities.wordScale('Sword', ['dull', 'sharp']), + shield: qualities.yesNo('Shield') + options: + extraClasses: ["possessions"] + + #----------------------------------------------------------------------------- # Initialise Undum undum.game.init = (character, system) -> # Add initialisation code here + character.qualities.strength = 10 + character.qualities.dexterity = 12 + character.qualities.constitution = 10 + character.qualities.perception = 14 + character.qualities.intelligence = 16 + character.qualities.charisma = 8 + character.qualities.gold = 100 + character.qualities.sword = 1 + character.qualities.shield = 1 # Get the party started when the DOM is ready. -$(undum.begin) \ No newline at end of file +$(-> undum.begin()) \ No newline at end of file diff --git a/html/index.html b/html/index.html index d2c85bc..5679fda 100644 --- a/html/index.html +++ b/html/index.html @@ -5,10 +5,10 @@ - Raconteur Game Template + Raconteur Scaffold - + diff --git a/img/storyteller.jpg b/img/storyteller.jpg new file mode 100644 index 0000000..386cdc1 Binary files /dev/null and b/img/storyteller.jpg differ diff --git a/less/main.less b/less/main.less index c7c55b5..9e8566c 100644 --- a/less/main.less +++ b/less/main.less @@ -292,14 +292,15 @@ a { transition: color 0.1s ease-in; } a.raw { - padding-right: 14px; - background: transparent url("../img/external_link.png") no-repeat right 4px; + // External link + border-bottom: 1px dashed @anchor-colour; } a:hover { color: lighten(@anchor-colour, 10%); } -img.float_right { +img { + .material_shadow(); float: right; margin: 1.1em 0 1.1em 1.1em; } diff --git a/package.json b/package.json index 7af374e..e9715d0 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,12 @@ "babelify": "^6.0.2", "browser-sync": "^2.6.0", "browserify": "^9.0.8", + "coffeeify": "^1.0.0", "gulp": "^3.8.11", + "gulp-gzip": "^1.1.0", "gulp-less": "^3.0.2", - "gulp-sourcemaps": "^1.5.1", + "gulp-minify-css": "^1.0.0", + "gulp-uglify": "^1.2.0", "gulp-util": "^3.0.4", "lodash": "^3.6.0", "vinyl-buffer": "^1.0.0",