From 0c32acd500447c66ff8242ca44a6c2195d378605 Mon Sep 17 00:00:00 2001 From: Oreolek Date: Tue, 1 Dec 2015 16:43:51 +0700 Subject: [PATCH] Version 0.5 - the minimal playable version. --- Gulpfile.js | 4 +- game/main.coffee | 148 +++++++++++++++++++++++++++++++++++++++-------- game/ru.coffee | 21 +++++++ html/en.html | 95 ++++++++++++++++++++++++++++++ html/index.html | 3 +- less/layout.less | 3 + 6 files changed, 247 insertions(+), 27 deletions(-) create mode 100644 game/ru.coffee create mode 100644 html/en.html diff --git a/Gulpfile.js b/Gulpfile.js index b06e959..321ca0c 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -26,7 +26,7 @@ var reload = browserSync.reload; function html (target) { return function () { - return gulp.src('html/index.html') + return gulp.src(['html/index.html','html/en.html']) .pipe(gulp.dest(target)); }; } @@ -158,4 +158,4 @@ gulp.task('zip', ['dist'], function () { return gulp.src('dist/**') .pipe(zip('dist.zip')) .pipe(gulp.dest('.')); -}); \ No newline at end of file +}); diff --git a/game/main.coffee b/game/main.coffee index 3516649..0c06c16 100644 --- a/game/main.coffee +++ b/game/main.coffee @@ -1,5 +1,6 @@ # copyright (c) Alexander Yakovlev 2015. -# Distributed under the MIT license. See LICENSE for information. +# 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') @@ -13,13 +14,15 @@ markdown = new md({ typographer: true, html: true }) +undumloc = require("./ru.coffee").language +undum.language["ru"] = undumloc a = elements.a span = elements.span img = elements.img undum.game.id = "7a1aba32-f0fd-4e3b-ba5a-59e3fa9e6012" -undum.game.version = "0.1" +undum.game.version = "0.5" way_to = (content, ref) -> a(content).class('way').ref(ref) textlink = (content, ref) -> a(content).once().writer(ref) @@ -31,6 +34,11 @@ writemd = (system, text) -> link_colour = "#B68000" +# 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) +# b) remove canChoose restriction (you can shoot any time you want, but if you have no bullets - nothing comes out and you've lost a turn) + spend_bullet = (character, system) -> bullets = character.sandbox.clips[character.sandbox.current_clip] if bullets >= 1 @@ -38,21 +46,25 @@ spend_bullet = (character, system) -> system.setQuality("bullets", bullets - 1) spend_clip = (character, system) -> - clips = character.sandbox.clips.length bullets = character.sandbox.clips[character.sandbox.current_clip] - if clips == 0 + clips = character.sandbox.clips.length + if clips < 2 return if bullets == 0 character.sandbox.clips.splice(character.sandbox.current_clip, 1) - system.setQuality("bullets", character.sandbox.clips[character.sandbox.current_clip]) - system.setQuality("clips", clips - 1) + clips = character.sandbox.clips.length writemd(system, "Я выбрасываю пустой картридж.") + system.setQuality("clips", clips) + if character.sandbox.current_clip < clips - 1 + character.sandbox.current_clip++ else - if character.sandbox.current_clip < clips - 1 - character.sandbox.current_clip++ - else - character.sandbox.current_clip == 0 - system.setQuality("bullets", character.sandbox.clips[character.sandbox.current_clip]) + character.sandbox.current_clip = 0 + system.setQuality("bullets", character.sandbox.clips[character.sandbox.current_clip]) + +check_distance = (character, system) -> + if character.sandbox.distance == 0 + system.setQuality("health", character.qualities.health - 1) + system.writemd("Один из андроидов доходит до меня и кусает!") situation 'start', content: """ @@ -60,6 +72,9 @@ situation 'start', Узкий коридор, я и непрекращающаяся очередь сверкающих белоснежной кожей андроидов. Я уверен, что я представлял этот Новый Год совершенно не так. + + Один ящик андроидов содержит тридцать пять машин. + Это будет длинная битва. """, choices: ["#shoot"], @@ -72,8 +87,11 @@ situation "hit", return response() choices: ["#shoot"] before: (character, system, from) -> - system.setQuality("enemies", character.qualities.enemies - 1) character.sandbox.nicked = 0 + if character.qualities.enemies > 1 + system.setQuality("enemies", character.qualities.enemies - 1) + if character.qualities.enemies == 0 + system.doLink("finale") choices: ["#shoot"] situation "nicked", @@ -108,25 +126,41 @@ situation "miss", situation "shoot", tags: ["shoot"], optionText: (character, system, from) -> - response = oneOf( + return oneOf( "Выстрел", + "Бдыщь!", + "Выстрелить", + "Нажать на курок", + "Атака", + "Стрельба", "СТРЕЛЯТЬ!", "УБИТЬ ИХ ИЗ ПИСТОЛЕТА", - "НЕНАВИЖУ АНДРОИДОВ" - ).stopping(system) - return response() + "НЕНАВИЖУ АНДРОИДОВ", + "АННИГИЛЯЦИЯ МЕХАНОИДОВ", + "Уничтожить механоидов", + "Отправить пулю в андроида", + "Послать пулю взрывом", + "Нажать на курок во имя ЧЕЛОВЕЧЕСТВА", + "Прыгнуть к стене и выстрелить из пистолета в полёте", + "Присесть и выстрелить с колена", + "Взять пистолет в обе руки и нажать на курок", + "Не спеша прицелиться и выстрелить" + ).randomly(system) canChoose: (character, system) -> return character.qualities.bullets > 0 before: (character, system, from) -> spend_bullet(character, system) + character.sandbox.distance = 3 system.clearContent() after: (character, system, from) -> - # d20 roll - # 1-14 - hit, 15-18 - nicked, 19-20 = miss - roll = system.rnd.randomInt(1,20) + roll = system.rnd.dice(1,20) # d20 roll + hit_threshold = 15 + miss_threshold = 18 + if character.qualities.health < 2 + hit_threshold = 18 switch - when roll < 15 then system.doLink("hit") - when roll > 18 then system.doLink("miss") + when roll < hit_threshold then system.doLink("hit") + when roll > miss_threshold then system.doLink("miss") else system.doLink("nicked") situation "reload", @@ -134,18 +168,79 @@ situation "reload", choices: ["#shoot"], optionText: "Перезарядить пистолет", canView: (character, system) -> - return character.qualities.bullets < 6 + return character.sandbox.seen_reload || character.qualities.bullets < 6 + canChoose: (character, system) -> + return character.qualities.bullets < 6 and character.sandbox.clips.length > 1 before: (character, system) -> + character.sandbox.seen_reload = 1 system.clearContent() + character.sandbox.distance-- after: (character, system) -> spend_clip(character, system) writemd(system, "Я вставляю другой картридж в пистолет. Надеюсь, в нём есть патроны.") return true -# А теперь plot twist: у пистолета есть шанс осечки и промаха. Ты теряешь патрон. Всего патронов у тебя 36, а врагов 35. +situation "search", + tags: ["shoot"], + optionText: "Искать чужие картриджи", + canView: (character, system) -> + return character.sandbox.seen_search || character.qualities.clips < 5 + canChoose: (character, system) -> + return character.qualities.clips < 5 + before: (character, system) -> + system.clearContent() + character.sandbox.seen_search = 1 + character.sandbox.distance-- + after: (character, system) -> + response = oneOf( + "Я в спешке шарю по полу, пытаясь найти хотя бы один целый картридж.", + "Я быстро оглядываюсь в поисках картриджей на полу." + ).randomly(system) + writemd(system, response()) + roll = system.rnd.dice(1,20) # d20 roll + find_threshold = 10 + if character.qualities.health < 2 + find_threshold += 2 + if character.sandbox.distance < 2 + find_threshold += 2 + if roll < find_threshold + system.doLink("found") + else + system.doLink("not_found") + +situation "found", + choices: ["#shoot"], + before: (character, system, from) -> + bullets = system.rnd.randomInt(2,4) + character.sandbox.clips[character.sandbox.clips.length] = bullets + system.setQuality("clips", character.sandbox.clips.length) + content: (character, system, from) -> + response = oneOf( + "Ага! Есть один. Надеюсь, в нём есть патроны.", + "А, вот какой-то. На вес тяжёлый -- надеюсь, в нём есть патроны." + ).randomly(system) + return response() + +situation "not_found", + choices: ["#shoot"], + content: (character, system, from) -> + response = oneOf( + "Нет, ничего нет.", + "Ну хотя бы один! Нет, не нашёл." + ).randomly(system) + return response() situation "finale", content: """ + Ба-бах! + + Последний андроид внезапно взрывается, как будто нашпигованный взрывчаткой. + А, впрочем, с этими машинами никогда не знаешь наверняка. + Я отворачиваюсь и ухожу прочь, не обращая внимания на взрыв. + + Моя работа сделана. + +

КОНЕЦ

""", qualities @@ -153,13 +248,18 @@ qualities bullets: qualities.integer('Патронов в картридже'), clips: qualities.integer('Картриджей с патронами'), enemies: qualities.integer('Врагов впереди'), + health: qualities.fudgeAdjectives('Здоровье'), undum.game.init = (character, system) -> system.setQuality("bullets", 6) system.setQuality("clips", 6) system.setQuality("enemies", 35) - character.sandbox.clips = [6,6,6,6] + system.setQuality("health", 3) + character.sandbox.clips = [5,5]#[6,6,6,6,6,6] character.sandbox.current_clip = 0 character.sandbox.nicked = 0 + character.sandbox.distance = 3 + character.sandbox.seen_reload = 0 + character.sandbox.seen_search = 0 window.onload = undum.begin diff --git a/game/ru.coffee b/game/ru.coffee new file mode 100644 index 0000000..966bb26 --- /dev/null +++ b/game/ru.coffee @@ -0,0 +1,21 @@ +module.exports.language = + terrible: "ужасно", + poor: "бедно", + mediocre: "средне", + fair: "нормально" + good: "хорошо" + great: "прекрасно" + superb: "идеально" + yes: "да" + no: "нет" + no_group_definition: "Невозможно найти определение группы {id}." + link_not_valid: "Ссылка '{link}' не выглядит правильной." + link_no_action: "Ссылка с ситуацией '.' должна иметь действие." + unknown_situation: "Вы не можете переместиться в неизвестную ситуацию {id}." + erase_message: "Это навсегда удалит вашего персонажа и немедленно вернёт вас к началу игры. Вы уверены?" + no_current_situation: "Я не могу отобразить, потому что у нас нет текущей ситуации." + no_local_storage: "Локальное хранилище недоступно." + random_seed_error: "Вы должны задать верное случайное зерно." + random_error: "Проинициализируйте Random с непустым зерном перед использованием." + dice_string_error: "не могу интерпретировать вашу cтроку кубиков: '{string}'." + erase_message: "Это навсегда удалит вашего персонажа и немедленно вернёт вас на старт игры. Вы уверены?" diff --git a/html/en.html b/html/en.html new file mode 100644 index 0000000..b9c9b0f --- /dev/null +++ b/html/en.html @@ -0,0 +1,95 @@ + + + + + + Thirty five shots + + + + + +
+

Thirty five shots

+ +
+ + +
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+ +

Thirty five shots

+ +

click to play

+
+
+ +
+
+
+ +
+ + +
+
+ +
+
+ + +
+ +
+

+
+
+
+ +
+ + +
+
+
+
+ + +
+ +
+
+ +
+ + + + diff --git a/html/index.html b/html/index.html index a922816..48e956c 100644 --- a/html/index.html +++ b/html/index.html @@ -55,7 +55,8 @@ diff --git a/less/layout.less b/less/layout.less index d2e64dd..62126d9 100644 --- a/less/layout.less +++ b/less/layout.less @@ -458,3 +458,6 @@ img.left { .center-block { margin: 0 auto; } +.footright { + float: right; +}