added deploy script and updated readme

This commit is contained in:
Rudis Muiznieks 2021-09-06 09:51:23 -05:00
parent 829404ba53
commit c983a687eb
6 changed files with 60 additions and 37 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
public/js/irreligious.js public/js/irreligious.js
node_modules/* node_modules/*
.env

View File

@ -4,9 +4,15 @@ An incremental game in which you start a cult and must grow it into the dominant
## Current State ## Current State
It can be run and played through a not-very-pretty debugging interface. To make testing easier, default configuration is massively sped up from what the final game will use, and the relationships between resources have not been play-tested or balanced in any meaningful way. Playable, but lightyears from complete and not very pretty or fun yet.
## Build and Run ## Play Online
[https://irreligio.us/](https://irreligio.us)
The online version may be behind what's in the repository.
## Build and Run Locally
``` ```
npm install npm install

View File

@ -1,7 +1,8 @@
{ {
"scripts": { "scripts": {
"build": "eslint src/ && tsc", "lint": "eslint src/",
"lint": "eslint src/" "build": "npm run lint && tsc",
"deploy": "aws s3 sync --delete public/ \"$(grep AWS_S3_BUCKET .env | cut -d '=' -f2)\" && aws cloudfront create-invalidation --distribution-id \"$(grep AWS_CLOUDFRONT_ID .env | cut -d '=' -f2)\" --paths=/*"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/eslint-plugin": "^4.30.0",

View File

@ -77,6 +77,7 @@ class GameConfig {
public cfgPastorTitheCollectionFollowerMax = 100; public cfgPastorTitheCollectionFollowerMax = 100;
public cfgTimeBetweenTithes = 30000; public cfgTimeBetweenTithes = 30000;
public cfgTitheAmount = 10; public cfgTitheAmount = 10;
public cfgTitheCredibilityHitFactor = 3;
public generateState (): GameState { public generateState (): GameState {
const state = new GameState(this); const state = new GameState(this);

View File

@ -1,22 +1,36 @@
/// <reference path="./Purchasable.ts" /> /// <reference path="./Purchasable.ts" />
class Money extends Purchasable { class Money implements IResource {
public readonly resourceType = ResourceType.consumable; public readonly resourceType = ResourceType.consumable;
public readonly label = 'Money';
public readonly singularName = '${}';
public readonly pluralName = '${}';
public readonly description = 'Used to purchase goods and services.';
public readonly valueInWholeNumbers = false;
public userActions: ResourceAction[] = [
{
name: 'Collect Tithes',
description: 'Voluntary contributions from followers.',
isEnabled: (state: GameState): boolean =>
this.value <= this.max(state)
&& (state.resource.followers?.value ?? 0) >= 1,
performAction: (state: GameState): void => {
this._collectTithes(state);
},
},
];
private _lastCollectionTime = 0; private _lastCollectionTime = 0;
constructor ( constructor (
public value: number public value: number
) { ) {}
super(
'Money', public isUnlocked = (_state: GameState): boolean => true;
'${}',
'${}', public addValue (amount: number, _state: GameState): void {
'Used to purchase goods and services.', this.value += amount;
'Collect Tithes',
'Voluntary contributions from followers.');
this.valueInWholeNumbers = false;
this._isUnlocked = true;
} }
public max: (state: GameState) => number = (state: GameState) => { public max: (state: GameState) => number = (state: GameState) => {
@ -40,20 +54,27 @@ class Money extends Purchasable {
return inc; return inc;
}; };
protected _purchaseAmount (state: GameState): number { protected _collectTithes (state: GameState): void {
const plorg = state.resource.followers; if (this.value >= this.max(state)) return;
if (plorg === undefined || plorg.value === 0) {
state.log('You have no followers to collect from!'); const followers = state.resource.followers?.value ?? 0;
return 0; if (followers <= 0) return;
}
// collecting too frequently hurts credibility
const diff = state.now - this._lastCollectionTime; const diff = state.now - this._lastCollectionTime;
if (diff < state.config.cfgTimeBetweenTithes) { if (diff < state.config.cfgTimeBetweenTithes) {
const lost = state.config.cfgTimeBetweenTithes / diff / 3; const lost = state.config.cfgTimeBetweenTithes
/ diff / state.config.cfgTitheCredibilityHitFactor;
state.resource.credibility?.addValue(lost * -1, state); state.resource.credibility?.addValue(lost * -1, state);
} }
const tithings = plorg.value * state.config.cfgTitheAmount;
const tithings = followers * state.config.cfgTitheAmount;
this._lastCollectionTime = state.now; this._lastCollectionTime = state.now;
return tithings;
if (tithings > 0) {
this.addValue(tithings, state);
this._purchaseLog(tithings, state);
}
} }
protected _purchaseLog (amount: number, state: GameState): string { protected _purchaseLog (amount: number, state: GameState): string {

View File

@ -49,10 +49,6 @@ abstract class Purchasable implements IResource {
return; return;
} }
protected _purchaseAmount (_state: GameState): number {
return 1;
}
protected _purchaseLog (amount: number, _state: GameState): string { protected _purchaseLog (amount: number, _state: GameState): string {
return `You purchased ${amount} ${amount > 1 ? this.pluralName : this.singularName}.`; return `You purchased ${amount} ${amount > 1 ? this.pluralName : this.singularName}.`;
} }
@ -60,15 +56,12 @@ abstract class Purchasable implements IResource {
private _purchase (state: GameState): void { private _purchase (state: GameState): void {
if (this.max !== undefined && this.value >= this.max(state)) return; if (this.max !== undefined && this.value >= this.max(state)) return;
if (state.deductCost(this.cost)) { if (state.deductCost(this.cost)) {
const amount = this._purchaseAmount(state); this.value += 1;
if (amount > 0) { state.log(this._purchaseLog(1, state));
this.value += amount; for (const key in this._costMultiplier) {
state.log(this._purchaseLog(amount, state)); const rkey = <ResourceKey>key;
for (const key in this._costMultiplier) { this.cost[rkey] =
const rkey = <ResourceKey>key; (this.cost[rkey] ?? 0) * (this._costMultiplier[rkey] ?? 1);
this.cost[rkey] =
(this.cost[rkey] ?? 0) * (this._costMultiplier[rkey] ?? 1);
}
} }
} }
} }