Added readline function, started work on shops, added some comments, made main menu and a bit of the start.

This commit is contained in:
Raktbastr 2025-02-25 10:04:03 -06:00
parent 455a867719
commit e413a5dea4
17 changed files with 3889 additions and 17 deletions

View file

@ -1,4 +1,3 @@
# Lonesome Road # Lonesome Road
## Story ## Run "npm install readline-sync" before running! It is needed for user input!
You are a loyal Enclave Soldier and the worst has just happened, Control Station Enclave is gone. You must make your way across the country to Raven Rock in the Capital Wasteland where President Eden is waiting for your imminent return. Be careful and remember "Dont feed the yao guai!"

19
TODO.md
View file

@ -1,8 +1,8 @@
## Basic ## Basic
* See if we can split things across multiple files for readability * See if we can split things across multiple files for readability
* Graphics * Graphics
* Dialogue * Dialogue, make in function
* Story * __Story__
## Game Mechanics ## Game Mechanics
* Scavenging (random num 1-100, items based on that) * Scavenging (random num 1-100, items based on that)
@ -16,4 +16,17 @@
* Hunting minigame (only if we can make the terminal blankout and not just add lines) * Hunting minigame (only if we can make the terminal blankout and not just add lines)
## Misc ## Misc
* Credit Bethesda if needed * Credit Bethesda if needed
## Locations (Please Read)
* Raven Rock to Whitespring, tutorial ghoul encounters
* Whitespring to Delta, Easy raider encounters, Missisippi crossing
* Delta to Vault 0, Medium raider encounters, rare chance of enclave base
* Vault 0 to New Vegas, medium Legion encounters, garunteed location encounter
* Lower Path, medium NCR encounters, garunteed location encounters
* Upper Path, bad NCR+encounter, garunteed location encounters, disguise doesnt work in shady sands
### Other Location notes
* MODUS at the Whitespring directs you to the Midwest Brotherhood
* Bunker gamma directs you to Delta but it is overrun with raiders, hence the medium encounter
* The legion inst directly hostile with you, however you can still have bad encounters

View file

@ -1,5 +1,7 @@
// Program is started from here, runs functions from other files. // Program is started from here, runs functions from other files.
const variables = require("./variables.js"); const variables = require("./variables.js");
const shops = require("./shops");
const readline = require('node:readline');
console.clear(); console.clear();
@ -9,5 +11,39 @@ console.log(" / ' / / /
console.log("---/__-------__---/---/----__---------_/_---------/-------__----__----__---__----__---_--_----__-------/___ /----__----__----__-/-"); console.log("---/__-------__---/---/----__---------_/_---------/-------__----__----__---__----__---_--_----__-------/___ /----__----__----__-/-");
console.log(" / / ) / / / ) / / / o / / ) / ) /___) (_ ` / ) / / ) /___) / | / ) / ) / / "); console.log(" / / ) / / / ) / / / o / / ) / ) /___) (_ ` / ) / / ) /___) / | / ) / ) / / ");
console.log("_/________(___(_/___/___(___/_(___(__(_ __o_____/____/_(___/_/___/_(___ _(__)_(___/_/_/__/_(___ _____/_____|__(___/_(___(_(___/___"); console.log("_/________(___(_/___/___(___/_(___(__(_ __o_____/____/_(___/_/___/_(___ _(__)_(___/_/_/__/_(___ _____/_____|__(___/_(___(_(___/___");
console.log("Credits: Bethesda Game Studio") console.log("Credits: Bethesda Game Studio");
variables.sleep(1000); variables.sleep(1000);
console.log("What would you like to do?");
console.log("--------------------------");
console.log("1) Start new game");
console.log("2) Learn How to play");
console.log("3) Quit Game");
var mainMenuInput = variables.userInput("Enter: ")
switch(mainMenuInput) {
case "1":
startGame();
case "2":
showManual();
case "3":
console.log("Quitting Game...");
variables.sleep(1000);
}
function startGame() { // So far what I have is filler and testing, feel free to change.
console.clear();
variables.sleep(1000);
variables.name = variables.userInput("What is your name? ");
console.log(variables.name+" Is now your name...")
variables.sleep(2000);
console.clear();
console.log("Intro:");
console.log("You are an ordinary loyal Enclave Soldier working at Raven Rock. \nYou are typing away at your terminal, entering reports of recovered materials when a message flashes on it.\n\nDear "+variables.name+" ,\n\n This is a direct order from the Enclave High Command. \nIgnore all previous directives. Proceed to Camp Navarro immediately. \nSeek safe passage through the Brotherhood and NCR territories. \nDo not disclose your mission to anyone but Enclave Personel with \nsecurity clearance 5 or higher. Reqisition supplies before departure. \n\n Signed, President John Henry Eden\n\n");
variables.userInput("[Enter to open shop]")
console.clear();
variables.prewarmoney = 500;
}

16
files/node_modules/.package-lock.json generated vendored Normal file
View file

@ -0,0 +1,16 @@
{
"name": "files",
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/readline-sync": {
"version": "1.4.10",
"resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz",
"integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==",
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
}
}
}
}

21
files/node_modules/readline-sync/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 anseki
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

89
files/node_modules/readline-sync/README-Deprecated.md generated vendored Normal file
View file

@ -0,0 +1,89 @@
# readlineSync
## <a name="deprecated_methods_and_options"></a>Deprecated Methods and Options
The readlineSync current version is fully compatible with older version.
The following methods and options are deprecated.
### <a name="deprecated_methods_and_options-setprint_method"></a>`setPrint` method
Use the [`print`](README.md#basic_options-print) option.
For the [Default Options](README.md#basic_options), use:
```js
readlineSync.setDefaultOptions({print: value});
```
instead of:
```js
readlineSync.setPrint(value);
```
### <a name="deprecated_methods_and_options-setprompt_method"></a>`setPrompt` method
Use the [`prompt`](README.md#basic_options-prompt) option.
For the [Default Options](README.md#basic_options), use:
```js
readlineSync.setDefaultOptions({prompt: value});
```
instead of:
```js
readlineSync.setPrompt(value);
```
### <a name="deprecated_methods_and_options-setencoding_method"></a>`setEncoding` method
Use the [`encoding`](README.md#basic_options-encoding) option.
For the [Default Options](README.md#basic_options), use:
```js
readlineSync.setDefaultOptions({encoding: value});
```
instead of:
```js
readlineSync.setEncoding(value);
```
### <a name="deprecated_methods_and_options-setmask_method"></a>`setMask` method
Use the [`mask`](README.md#basic_options-mask) option.
For the [Default Options](README.md#basic_options), use:
```js
readlineSync.setDefaultOptions({mask: value});
```
instead of:
```js
readlineSync.setMask(value);
```
### <a name="deprecated_methods_and_options-setbuffersize_method"></a>`setBufferSize` method
Use the [`bufferSize`](README.md#basic_options-buffersize) option.
For the [Default Options](README.md#basic_options), use:
```js
readlineSync.setDefaultOptions({bufferSize: value});
```
instead of:
```js
readlineSync.setBufferSize(value);
```
### <a name="deprecated_methods_and_options-noechoback_option"></a>`noEchoBack` option
Use [`hideEchoBack`](README.md#basic_options-hideechoback) option instead of it.
### <a name="deprecated_methods_and_options-notrim_option"></a>`noTrim` option
Use [`keepWhitespace`](README.md#basic_options-keepwhitespace) option instead of it.

1836
files/node_modules/readline-sync/README.md generated vendored Normal file

File diff suppressed because it is too large Load diff

24
files/node_modules/readline-sync/lib/encrypt.js generated vendored Normal file
View file

@ -0,0 +1,24 @@
/*
* readlineSync
* https://github.com/anseki/readline-sync
*
* Copyright (c) 2019 anseki
* Licensed under the MIT license.
*/
var cipher = require('crypto').createCipher(
process.argv[2] /*algorithm*/, process.argv[3] /*password*/),
stdin = process.stdin,
stdout = process.stdout,
crypted = '';
stdin.resume();
stdin.setEncoding('utf8');
stdin.on('data', function(d) {
crypted += cipher.update(d, 'utf8', 'hex');
});
stdin.on('end', function() {
stdout.write(crypted + cipher.final('hex'), 'binary', function() {
process.exit(0);
});
});

123
files/node_modules/readline-sync/lib/read.cs.js generated vendored Normal file
View file

@ -0,0 +1,123 @@
/* jshint wsh:true */
/*
* readlineSync
* https://github.com/anseki/readline-sync
*
* Copyright (c) 2019 anseki
* Licensed under the MIT license.
*/
var
FSO_ForReading = 1, FSO_ForWriting = 2,
PS_MSG = 'Microsoft Windows PowerShell is required.' +
' https://technet.microsoft.com/en-us/library/hh847837.aspx',
input = '', fso, tty,
options = (function(conf) {
var options = {}, arg, args =// Array.prototype.slice.call(WScript.Arguments),
(function() {
var args = [], i, iLen;
for (i = 0, iLen = WScript.Arguments.length; i < iLen; i++)
{ args.push(WScript.Arguments(i)); }
return args;
})(),
confLc = {}, key;
function decodeArg(arg) {
return arg.replace(/#(\d+);/g, function(str, charCode) {
return String.fromCharCode(+charCode);
});
}
for (key in conf) {
if (conf.hasOwnProperty(key))
{ confLc[key.toLowerCase()] = {key: key, type: conf[key]}; }
}
while (typeof(arg = args.shift()) === 'string') {
if (!(arg = (arg.match(/^\-+(.+)$/) || [])[1])) { continue; }
arg = arg.toLowerCase();
if (confLc[arg]) {
options[confLc[arg].key] =
confLc[arg].type === 'boolean' ? true :
confLc[arg].type === 'string' ? args.shift() : null;
}
}
for (key in conf) {
if (conf.hasOwnProperty(key) && conf[key] === 'string') {
if (typeof options[key] !== 'string') { options[key] = ''; }
else { options[key] = decodeArg(options[key]); }
}
}
return options;
})({
display: 'string',
displayOnly: 'boolean',
keyIn: 'boolean',
hideEchoBack: 'boolean',
mask: 'string'
});
if (!options.hideEchoBack && !options.keyIn) {
if (options.display) { writeTTY(options.display); }
if (!options.displayOnly) { input = readByFSO(); }
} else if (options.hideEchoBack && !options.keyIn && !options.mask) {
if (options.display) { writeTTY(options.display); }
if (!options.displayOnly) { input = readByPW(); }
} else {
WScript.StdErr.WriteLine(PS_MSG);
WScript.Quit(1);
}
WScript.StdOut.Write('\'' + input + '\'');
WScript.Quit();
function writeTTY(text) {
try {
tty = tty || getFso().OpenTextFile('CONOUT$', FSO_ForWriting, true);
tty.Write(text);
} catch (e) {
WScript.StdErr.WriteLine('TTY Write Error: ' + e.number +
'\n' + e.description + '\n' + PS_MSG);
WScript.Quit(e.number || 1);
}
}
function readByFSO() {
var text;
try {
text = getFso().OpenTextFile('CONIN$', FSO_ForReading).ReadLine();
} catch (e) {
WScript.StdErr.WriteLine('TTY Read Error: ' + e.number +
'\n' + e.description + '\n' + PS_MSG);
WScript.Quit(e.number || 1);
}
return text;
}
// TTY must be STDIN that is not redirected and not piped.
function readByPW() {
var text;
try {
text = WScript.CreateObject('ScriptPW.Password').GetPassword()
// Bug? Illegal data may be returned when user types before initializing.
.replace(/[\u4000-\u40FF]/g, function(chr) {
var charCode = chr.charCodeAt(0);
return charCode >= 0x4020 && charCode <= 0x407F ?
String.fromCharCode(charCode - 0x4000) : '';
});
} catch (e) {
WScript.StdErr.WriteLine('ScriptPW.Password Error: ' + e.number +
'\n' + e.description + '\n' + PS_MSG);
WScript.Quit(e.number || 1);
}
writeTTY('\n');
return text;
}
function getFso() {
if (!fso) { fso = new ActiveXObject('Scripting.FileSystemObject'); }
return fso;
}

128
files/node_modules/readline-sync/lib/read.ps1 generated vendored Normal file
View file

@ -0,0 +1,128 @@
# readlineSync
# https://github.com/anseki/readline-sync
#
# Copyright (c) 2019 anseki
# Licensed under the MIT license.
Param(
[string] $display,
[switch] $displayOnly,
[switch] $keyIn,
[switch] $hideEchoBack,
[string] $mask,
[string] $limit,
[switch] $caseSensitive
)
$ErrorActionPreference = 'Stop' # for cmdlet
trap {
# `throw $_` and `Write-Error $_` return exit-code 0
$Host.UI.WriteErrorLine($_)
exit 1
}
function decodeArg ($arg) {
[Regex]::Replace($arg, '#(\d+);', { [char][int] $args[0].Groups[1].Value })
}
$options = @{}
foreach ($arg in @('display', 'displayOnly', 'keyIn', 'hideEchoBack', 'mask', 'limit', 'caseSensitive')) {
$options.Add($arg, (Get-Variable $arg -ValueOnly))
}
$argList = New-Object string[] $options.Keys.Count
$options.Keys.CopyTo($argList, 0)
foreach ($arg in $argList) {
if ($options[$arg] -is [string] -and $options[$arg])
{ $options[$arg] = decodeArg $options[$arg] }
}
[string] $inputTTY = ''
[bool] $silent = -not $options.display -and
$options.keyIn -and $options.hideEchoBack -and -not $options.mask
[bool] $isCooked = -not $options.hideEchoBack -and -not $options.keyIn
# Instant method that opens TTY without CreateFile via P/Invoke in .NET Framework
# **NOTE** Don't include special characters of DOS in $command when $getRes is True.
# [string] $cmdPath = $Env:ComSpec
# [string] $psPath = 'powershell.exe'
function execWithTTY ($command, $getRes = $False, $throwError = $False) {
if ($getRes) {
$res = (cmd.exe /C "<CON powershell.exe -Command $command")
if ($LastExitCode -ne 0) {
if ($throwError) { throw $LastExitCode }
else { exit $LastExitCode }
}
return $res
} else {
$command | cmd.exe /C ">CON powershell.exe -Command -"
if ($LastExitCode -ne 0) {
if ($throwError) { throw $LastExitCode }
else { exit $LastExitCode }
}
}
}
function writeTTY ($text) {
execWithTTY ('Write-Host (''' +
(($text -replace '''', '''''') -replace '[\r\n]', '''+"`n"+''') + ''') -NoNewline')
}
if ($options.display) {
writeTTY $options.display
}
if ($options.displayOnly) { return "''" }
if (-not $options.keyIn -and $options.hideEchoBack -and $options.mask -eq '*') {
# It fails when it's not ready.
try {
$inputTTY = execWithTTY ('$text = Read-Host -AsSecureString;' +
'$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($text);' +
'[Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)') $True $True
return '''' + $inputTTY + ''''
} catch {} # ignore
}
if ($options.keyIn) { $reqSize = 1 }
if ($options.keyIn -and $options.limit) {
$limitPtn = '[^' + $options.limit + ']'
}
while ($True) {
if (-not $isCooked) {
$chunk = [char][int] (execWithTTY '[int] [Console]::ReadKey($True).KeyChar' $True)
} else {
$chunk = execWithTTY 'Read-Host' $True
$chunk += "`n"
}
if ($chunk -and $chunk -match '^(.*?)[\r\n]') {
$chunk = $Matches[1]
$atEol = $True
} else { $atEol = $False }
# other ctrl-chars
if ($chunk) { $chunk = $chunk -replace '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]', '' }
if ($chunk -and $limitPtn) {
if ($options.caseSensitive) { $chunk = $chunk -creplace $limitPtn, '' }
else { $chunk = $chunk -ireplace $limitPtn, '' }
}
if ($chunk) {
if (-not $isCooked) {
if (-not $options.hideEchoBack) {
writeTTY $chunk
} elseif ($options.mask) {
writeTTY ($options.mask * $chunk.Length)
}
}
$inputTTY += $chunk
}
if ((-not $options.keyIn -and $atEol) -or
($options.keyIn -and $inputTTY.Length -ge $reqSize)) { break }
}
if (-not $isCooked -and -not $silent) { execWithTTY 'Write-Host ''''' } # new line
return "'$inputTTY'"

137
files/node_modules/readline-sync/lib/read.sh generated vendored Normal file
View file

@ -0,0 +1,137 @@
# readlineSync
# https://github.com/anseki/readline-sync
#
# Copyright (c) 2019 anseki
# Licensed under the MIT license.
# Use perl for compatibility of sed/awk of GNU / POSIX, BSD. (and tr)
# Hide "\n" from shell by "\fNL"
decode_arg() {
printf '%s' "$(printf '%s' "$1" | perl -pe 's/#(\d+);/sprintf("%c", $1)/ge; s/[\r\n]/\fNL/g')"
}
# getopt(s)
while [ $# -ge 1 ]; do
arg="$(printf '%s' "$1" | grep -E '^-+[^-]+$' | tr '[A-Z]' '[a-z]' | tr -d '-')"
case "$arg" in
'display') shift; options_display="$(decode_arg "$1")";;
'displayonly') options_displayOnly=true;;
'keyin') options_keyIn=true;;
'hideechoback') options_hideEchoBack=true;;
'mask') shift; options_mask="$(decode_arg "$1")";;
'limit') shift; options_limit="$(decode_arg "$1")";;
'casesensitive') options_caseSensitive=true;;
esac
shift
done
reset_tty() {
if [ -n "$save_tty" ]; then
stty --file=/dev/tty "$save_tty" 2>/dev/null || \
stty -F /dev/tty "$save_tty" 2>/dev/null || \
stty -f /dev/tty "$save_tty" || exit $?
fi
}
trap 'reset_tty' EXIT
save_tty="$(stty --file=/dev/tty -g 2>/dev/null || stty -F /dev/tty -g 2>/dev/null || stty -f /dev/tty -g || exit $?)"
[ -z "$options_display" ] && [ "$options_keyIn" = true ] && \
[ "$options_hideEchoBack" = true ] && [ -z "$options_mask" ] && silent=true
[ "$options_hideEchoBack" != true ] && [ "$options_keyIn" != true ] && is_cooked=true
write_tty() {
# if [ "$2" = true ]; then
# printf '%b' "$1" >/dev/tty
# else
# printf '%s' "$1" >/dev/tty
# fi
printf '%s' "$1" | perl -pe 's/\fNL/\r\n/g' >/dev/tty
}
replace_allchars() { (
text=''
for i in $(seq 1 ${#1})
do
text="$text$2"
done
printf '%s' "$text"
) }
if [ -n "$options_display" ]; then
write_tty "$options_display"
fi
if [ "$options_displayOnly" = true ]; then
printf "'%s'" ''
exit 0
fi
if [ "$is_cooked" = true ]; then
stty --file=/dev/tty cooked 2>/dev/null || \
stty -F /dev/tty cooked 2>/dev/null || \
stty -f /dev/tty cooked || exit $?
else
stty --file=/dev/tty raw -echo 2>/dev/null || \
stty -F /dev/tty raw -echo 2>/dev/null || \
stty -f /dev/tty raw -echo || exit $?
fi
[ "$options_keyIn" = true ] && req_size=1
if [ "$options_keyIn" = true ] && [ -n "$options_limit" ]; then
if [ "$options_caseSensitive" = true ]; then
limit_ptn="$options_limit"
else
# Safe list
# limit_ptn="$(printf '%s' "$options_limit" | sed 's/\([a-z]\)/\L\1\U\1/ig')"
limit_ptn="$(printf '%s' "$options_limit" | perl -pe 's/([a-z])/lc($1) . uc($1)/ige')"
fi
fi
while :
do
if [ "$is_cooked" != true ]; then
# chunk="$(dd if=/dev/tty bs=1 count=1 2>/dev/null)"
chunk="$(dd if=/dev/tty bs=1 count=1 2>/dev/null | perl -pe 's/[\r\n]/\fNL/g')"
else
IFS= read -r chunk </dev/tty || exit $?
chunk="$(printf '%s\fNL' "$chunk")"
fi
# if [ -n "$chunk" ] && [ "$(printf '%s' "$chunk" | tr '\r' '\n' | wc -l)" != "0" ]; then
# chunk="$(printf '%s' "$chunk" | tr '\r' '\n' | head -n 1)"
if [ -n "$chunk" ] && printf '%s' "$chunk" | perl -ne '/\fNL/ or exit 1'; then
chunk="$(printf '%s' "$chunk" | perl -pe 's/^(.*?)\fNL.*$/$1/')"
at_eol=true
fi
# other ctrl-chars
if [ -n "$chunk" ]; then
# chunk="$(printf '%s' "$chunk" | tr -d '\00-\10\13\14\16-\37\177')"
# for System V
chunk="$(printf '%s' "$chunk" | tr -d '\00\01\02\03\04\05\06\07\10\13\14\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177')"
fi
if [ -n "$chunk" ] && [ -n "$limit_ptn" ]; then
chunk="$(printf '%s' "$chunk" | tr -cd "$limit_ptn")"
fi
if [ -n "$chunk" ]; then
if [ "$is_cooked" != true ]; then
if [ "$options_hideEchoBack" != true ]; then
write_tty "$chunk"
elif [ -n "$options_mask" ]; then
write_tty "$(replace_allchars "$chunk" "$options_mask")"
fi
fi
input="$input$chunk"
fi
if ( [ "$options_keyIn" != true ] && [ "$at_eol" = true ] ) || \
( [ "$options_keyIn" = true ] && [ ${#input} -ge $req_size ] ); then break; fi
done
if [ "$is_cooked" != true ] && [ "$silent" != true ]; then write_tty "$(printf '%b' '\fNL')"; fi
printf "'%s'" "$input"
exit 0

1329
files/node_modules/readline-sync/lib/readline-sync.js generated vendored Normal file

File diff suppressed because it is too large Load diff

40
files/node_modules/readline-sync/package.json generated vendored Normal file
View file

@ -0,0 +1,40 @@
{
"name": "readline-sync",
"version": "1.4.10",
"title": "readlineSync",
"description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).",
"keywords": [
"readline",
"synchronous",
"interactive",
"prompt",
"question",
"password",
"cli",
"tty",
"command",
"repl",
"keyboard",
"wait",
"block"
],
"main": "./lib/readline-sync.js",
"files": [
"lib/*.@(js|ps1|sh)",
"README-Deprecated.md"
],
"engines": {
"node": ">= 0.8.0"
},
"homepage": "https://github.com/anseki/readline-sync",
"repository": {
"type": "git",
"url": "git://github.com/anseki/readline-sync.git"
},
"bugs": "https://github.com/anseki/readline-sync/issues",
"license": "MIT",
"author": {
"name": "anseki",
"url": "https://github.com/anseki"
}
}

21
files/package-lock.json generated Normal file
View file

@ -0,0 +1,21 @@
{
"name": "files",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"readline-sync": "^1.4.10"
}
},
"node_modules/readline-sync": {
"version": "1.4.10",
"resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz",
"integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==",
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
}
}
}
}

5
files/package.json Normal file
View file

@ -0,0 +1,5 @@
{
"dependencies": {
"readline-sync": "^1.4.10"
}
}

39
files/shops.js Normal file
View file

@ -0,0 +1,39 @@
const readline = require('readline-sync');
const variables = require("./variables");
module.exports = {
ravenRock,
vaultZero,
newVegas,
eureka,
trader,
}
// Inventories for the various shops
var rrInv = [];
var vt0Inv = [];
var vegasInv = []; // A mix of gunrunners, mick&ralphs, and followers
var eurInv = [];
var trader1Inv = [];
var trader2Inv = [];
var trader3Inv = [];
function ravenRock() {
// purchasing code
}
function vaultZero() {
// purchasing code
}
function newVegas() {
// purchasing code
}
function eureka() {
// purchasing code
}
function trader() { // One of the 3 trader inventories, chosen randomly
// purchasing code
}

View file

@ -1,7 +1,7 @@
// Holds the global variables, functions, and math operations such as the day counter and food eaten.. // Holds the global variables, functions, and math operations such as the day counter and food eaten..
const death = require("./deathscreens"); const readline = require('readline-sync');
module.exports = { module.exports = { // Lets variables and functions be used in other files
day, day,
location, location,
ammo, ammo,
@ -14,29 +14,39 @@ module.exports = {
isSick, isSick,
sickSeverity, sickSeverity,
inventory, inventory,
name,
prewarmoney,
caps,
eatfood, eatfood,
calcLocation, calcLocation,
calcSickPoints, calcSickPoints,
scavenge, scavenge,
sleep, sleep,
checkLose, checkLose,
userInput,
}; };
var name = '';
var prewarmoney = 0; // Used in Enclave Stores
var caps = 0; // Used everywhere
var day = 0; // Should we add a definite end? 365 Days? var day = 0; // Should we add a definite end? 365 Days?
var location = 0; // Location in the world, 0 is Control Station Enclave, 200 is Raven rock. var location = 0; // Location in the world, 0 is Raven Rock, 200 is CTE.
var ammo = 0; // No cap :) var ammo = 0; // Used in encounters and hunting, No cap :)
var food = 0; // Max: 200 var food = 0; // Max: 200
var foodAmt = 0; // Amt of food eaten per day, 3 levels, starting at 1 var foodAmt = 0; // Amt of food eaten per day, 3 levels, starting at 1
var health = 0; // Max: 100 var health = 0; // Max: 100
var travelSpeed = 0; // 3 levels, starting at 1 var travelSpeed = 0; // Location points per day, 3 levels, starting at 1
var isRadiated = false; var isRadiated = false;
var radSeverity = 0; // 3 levels, starting at 1 var radSeverity = 0; // Modifies many things, 3 levels, starting at 1
var isSick = false; var isSick = false;
var sickPoints = 0; // If you accumulate 50 sick points you lose var sickPoints = 0; // If you accumulate 50 sick points you lose
@ -44,7 +54,7 @@ var sickSeverity = 0; // 3 levls, starting at 1
var inventory = []; // Max of 5 items var inventory = []; // Max of 5 items
var lootTables = [[],[],[],[],[]] // 5 Loot tables per scavenge score, 3 items in each, first is best var lootTables = [[],[],[],[],[]] // Only small things like food and ammo, 5 Loot tables per scavenge score, 3 items in each, first is best
function eatfood() { function eatfood() {
if (food == 0) { health - 20 } if (food == 0) { health - 20 }
@ -59,7 +69,7 @@ function calcSickPoints() {
} }
} }
function scavenge() { function scavenge() { // Rolls a random number between 1 and 100 to see which loot table you get, then picks a random item from it. ADD COOLDOWN!
let luck = Math.random(1,100); let luck = Math.random(1,100);
if (luck <= 20) { if (luck <= 20) {
let group = 0; let group = 0;
@ -84,11 +94,11 @@ function scavenge() {
} }
} }
function sleep(time) { function sleep(time) { // Waits the inputed amt of miliseconds before proceeding
setTimeout(() => {}, time); setTimeout(() => {}, time);
} }
function checkLose() { function checkLose() { // Checks to see if any lose conditions have been met
if (health <= 0 || sickPoints >= 50) { if (health <= 0 || sickPoints >= 50) {
deathScreen(); deathScreen();
} }
@ -97,7 +107,8 @@ function checkLose() {
} }
} }
function calcLocation() { // You move your move speed per day, but 3/4 of it if you are sick function calcLocation() { // Calculates your location in the world using location points.
// You move your move speed per day, but 3/4 of it if you are sick
if (travelSpeed == 1) { if (travelSpeed == 1) {
if (isSick == true) { if (isSick == true) {
location = location+0.75; location = location+0.75;
@ -119,4 +130,9 @@ function calcLocation() { // You move your move speed per day, but 3/4 of it if
location = location+3; location = location+3;
} }
} }
}
function userInput(question) { // Basic user input functions, takes in the question to be asked.
let answer = readline.question(question);
return(answer);
} }