Skip to content

Commit

Permalink
Added more backend code for CoC.
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgul committed Oct 4, 2024
1 parent 4e691d4 commit 79ae291
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 0 deletions.
96 changes: 96 additions & 0 deletions src/common/interfaces/systems/coc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//----------------------------------------------------------------------------------------------------------------------
// Call of Cthulhu Models
//----------------------------------------------------------------------------------------------------------------------

export interface CocBackstory
{
description : string;
ideology : string;
significantPeople : string;
meaningfulLocations : string;
treasuredPossession : string;
traits : string;
injuries : string;
phobias : string;
arcaneTomes : string;
encounters : string;
}

export interface CoCSkill
{
name : string;
defaultValue : number;
value : number;
}

export interface CoCCharacteristics
{
strength : number;
constitution : number;
size : number;
dexterity : number;
appearance : number;
intelligence : number;
power : number;
education : number;
}

export interface CoCStat
{
value : number;
max : number;
starting ?: number;
}

export interface CocBiography
{
age : number;
birthplace : string;
name : string;
occupation : string;
pronouns : string;
residence : string;
}

export interface CoCWeapon
{
name : string;
damage : string;
range : string;
attacks : number;
ammo : number;
malfunctions : number;
skill : string; // TODO: This is a skill name, should be a reference to a skill
}

export interface CoCWealth
{
cash : number;
assets : string;
spendingLevel : string;
}

export interface CoCSystemDetails
{
biography : CocBiography;
characteristics : CoCCharacteristics;
skills : CoCSkill[];
movement : number;
luck : CoCStat;
sanity : CoCStat;
hitPoints : CoCStat;
magicPoints : CoCStat;
status : {
temporaryInsanity : boolean;
indefiniteInsanity : boolean;
majorWound : boolean;
unconscious : boolean;
dying : boolean;
}
weapons : CoCWeapon[];
backstory : CocBackstory;
gear : string[];
wealth : CoCWealth;
}

//----------------------------------------------------------------------------------------------------------------------
32 changes: 32 additions & 0 deletions src/server/knex/migrations/20241004005326_coc_system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//----------------------------------------------------------------------------------------------------------------------
// Call of Cthulhu DB Tables
//----------------------------------------------------------------------------------------------------------------------

import type { Knex } from 'knex';

//----------------------------------------------------------------------------------------------------------------------

export async function up(knex : Knex) : Promise<Knex.QueryBuilder>
{
await knex.schema.createTable('coc_weapons', (table) =>
{
table.increments('id').primary();
table.string('name').notNullable();
table.string('damage').notNullable();
table.string('range').notNullable();
table.integer('attacks').notNullable();
table.integer('ammo').notNullable();
table.integer('malfunction').notNullable();
table.string('notes').notNullable();
});
}

//----------------------------------------------------------------------------------------------------------------------

export async function down(knex: Knex): Promise<Knex.QueryBuilder>
{
await knex.schema.dropTable('coc_weapons');
}

//----------------------------------------------------------------------------------------------------------------------

2 changes: 2 additions & 0 deletions src/server/resource-access/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//----------------------------------------------------------------------------------------------------------------------

// Systems
import CoC from '../systems/coc/system';
import Risus from '../systems/risus/system';
import Fate from '../systems/fate/system';
import Wfrp from '../systems/wfrp/system';
Expand All @@ -21,6 +22,7 @@ class SystemManager
constructor()
{
this.systems = [
CoC,
Risus,
Fate,
Genesys,
Expand Down
10 changes: 10 additions & 0 deletions src/server/systems/coc/defaults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//----------------------------------------------------------------------------------------------------------------------
// Fate Model Defaults
//----------------------------------------------------------------------------------------------------------------------

export default {
character: {
}
};

//----------------------------------------------------------------------------------------------------------------------
42 changes: 42 additions & 0 deletions src/server/systems/coc/system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//----------------------------------------------------------------------------------------------------------------------
// Call of Cthulhu System
//----------------------------------------------------------------------------------------------------------------------

// BaseClass
import { BaseSystem } from '../base';

// Defaults
import defaults from './defaults';

// Logger
import logging from '@strata-js/util-logging';
import { SupportStatus } from '../../../common/interfaces/models/system';

const logger = logging.getLogger('fate-system');

//----------------------------------------------------------------------------------------------------------------------
// System definition
//----------------------------------------------------------------------------------------------------------------------

const id = 'coc';
const name = 'Call of Cthulhu';
const description = 'In Call of Cthulhu, you take on the role of everyday people who become investigators of the '
+ 'unknown—whether they are prepared or not. The mysterious places, people, and situations you encounter are '
+ 'often not what they seem—you and your friends are the only thing standing in the way of diabolical cults and '
+ 'cosmic monsters from beyond space!';

class FATESystem extends BaseSystem
{
constructor()
{
super(id, name, description, defaults.character, SupportStatus.InDevelopment);

logger.info(`Loaded '${ name }' system.`);
}
}

//----------------------------------------------------------------------------------------------------------------------

export default new FATESystem();

//----------------------------------------------------------------------------------------------------------------------

0 comments on commit 79ae291

Please sign in to comment.