Skip to content

Commit

Permalink
feat: character sheet improvements (#477)
Browse files Browse the repository at this point in the history
Signed-off-by: hxtree <[email protected]>
  • Loading branch information
hxtree authored Oct 29, 2023
1 parent 0736bca commit 1359c1c
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 63 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Matthew Heroux
Copyright (c) 2021 Matthew Heroux

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
Expand Down
12 changes: 6 additions & 6 deletions services/character-sheet/openapi-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
"required": true,
"in": "path",
"schema": {
"default": "c63bd3b9-02a2-4f32-b836-9aac1665cc96",
"default": "1f0fb038-21f8-47ff-9de1-010502a010d3",
"type": "string"
}
}
Expand Down Expand Up @@ -586,11 +586,11 @@
"properties": {
"_id": {
"type": "string",
"default": "d8fba7e1-3bb2-4715-986e-1846209627a0"
"default": "de2e5e17-70ee-4c27-b01a-c38bc6c3e4e2"
},
"instanceId": {
"type": "string",
"default": "05f888f0-07ad-484f-9f73-33b828abc09e"
"default": "26be8bd5-5d6f-4bbd-8878-b14675fc8dd5"
},
"archetypeId": {
"type": "string",
Expand Down Expand Up @@ -647,11 +647,11 @@
"properties": {
"id": {
"type": "string",
"default": "712756ed-6b55-42c1-ba6d-2568729b2403"
"default": "be51385e-9c08-40ba-b92c-d6b3790db555"
},
"instanceId": {
"type": "string",
"default": "8445ffd3-4e7f-4d58-b2a9-620b0d3c4847"
"default": "2e308a56-a26d-4513-ba79-2a412f5c113b"
},
"place": {
"type": "string",
Expand All @@ -674,7 +674,7 @@
"properties": {
"characterSheetId": {
"type": "string",
"default": "ebfe4388-5a84-494a-9e55-b806b9719689"
"default": "8eddefd6-612c-421b-a033-ac5234a330e4"
},
"affiliationId": {
"type": "string",
Expand Down
30 changes: 19 additions & 11 deletions services/character-sheet/src/data/archetype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ export namespace Archetype {
export const MISCHIEVOUS_PIEBALD: Type = {
name: 'Mischievous',
surname: 'Piebald',
alias: ['Keeper of Law', 'Mischief'],
alias: ['Keeper of Law', 'Mischief', 'Tux'],
symbolizes: ['Law', 'Causality', 'Absolute'],
backstory:
'Governs the logical of this realm. '
+ 'He can choose whether a wall is hard or one can put their hand through it. '
+ 'He can choose whether the rain falls downward or upward. '
+ 'His power is based on speech, he must blink speak a rule and blink again in order to invoke it. '
+ 'He can change the rules but is not able to control the runtime of those rules. '
+ 'He is subspectable to time manipulation as it revert or deteriate his rule. ',
+ 'He is suspectable to time manipulation as it revert or deteriorate his rule. ',
affiliation: [Affiliation.THE_CATS],
description:
'A black and white cat. '
Expand Down Expand Up @@ -175,7 +175,7 @@ export namespace Archetype {
export const OUERN_ONI: Type = {
name: 'Ouren',
surname: 'Oni',
symbolizes: ['Destroyer of Time'],
symbolizes: ['Dad', 'Father', 'Destroyer of Time'],
alias: ['The Black Plague', 'Skyfall', 'Timestopper', 'Standstill'],
backstory:
'Often sang a song similar to Tumbalalaika to his sons when they were young. '
Expand All @@ -195,12 +195,8 @@ export namespace Archetype {
export const VALLON_ONI: Type = {
name: 'Vallon',
surname: 'Oni',
symbolizes: [
'Destroyer of Heart',
'Loveless Lover',
'Heartache',
'Heart Wrench',
],
alias: ['Boss', 'Heartache'],
symbolizes: ['Destroyer of Heart', 'Loveless Lover', 'Heart Wrench'],
description: 'White hair',
affiliation: [
Affiliation.THE_DESTROYERS,
Expand Down Expand Up @@ -270,6 +266,7 @@ export namespace Archetype {
name: 'Arinoth',
surname: 'Diyath',
symbolizes: ['Patience'],
alias: ['Tree'],
affiliation: [],
backstory: '',
potentialDisciplines: [],
Expand Down Expand Up @@ -454,6 +451,7 @@ export namespace Archetype {
*/
export const VOID: Type = {
name: 'Void',
alias: ['Empty'],
affiliation: [Affiliation.DEVILS],
backstory:
'Is one of the original seven demons.'
Expand Down Expand Up @@ -493,6 +491,7 @@ export namespace Archetype {

export const MADHI_TSIA: Type = {
name: 'Mahdi',
alias: ['Brother'],
surname: 'Tsia',
description: "Malace's brother",
backstory: 'When the world is about to end he is its savor',
Expand All @@ -516,6 +515,7 @@ export namespace Archetype {

export const WISP: Type = {
name: 'Wisp',
alias: ['Crackles'],
affiliation: [Affiliation.VALLONS_SEVEN],
symbolizes: ['Gluttony', 'Hyena'],
potentialDisciplines: [Discipline.MAGI_YELLOW],
Expand All @@ -524,6 +524,7 @@ export namespace Archetype {

export const ASMIN: Type = {
name: 'Asmin',
alias: ['Big Guy'],
affiliation: [Affiliation.VALLONS_SEVEN],
symbolizes: ['Pride', 'Ox'],
potentialDisciplines: [Discipline.MAGI_BROWN],
Expand All @@ -533,6 +534,7 @@ export namespace Archetype {

export const DIAG: Type = {
name: 'Diag',
alias: ['Poisonous Snake'],
affiliation: [Affiliation.VALLONS_SEVEN],
symbolizes: ['Envy', 'Snake'],
potentialDisciplines: [Discipline.MAGI_PURPLE],
Expand All @@ -558,6 +560,7 @@ export namespace Archetype {

export const WARLING: Type = {
name: 'Warling',
alias: ['Wind Bag'],
description: 'The embodiment of a traveling cyclone',
potentialDisciplines: [Discipline.WIZARD, Discipline.HISTORIAN],
gearSlots: HumanoidCreatureGearSlots,
Expand All @@ -568,33 +571,38 @@ export namespace Archetype {
*/
export const SPIDER: Type = {
name: 'Spider',
alias: ['Creepy Crawlers'],
description: 'A spider',
weaponCompatibility: [],
gearSlots: [],
};

export const SEA_HORSE: Type = {
name: 'Sea Horse',
alias: ['Legless Horse'],
description: 'A spider',
weaponCompatibility: [],
gearSlots: [],
};

export const SENSITIVE_PLANT: Type = {
name: 'Sensitive Plant',
alias: ['Weepers'],
description: 'A plant that drops when touched',
weaponCompatibility: [],
gearSlots: [],
};

export const DEEP_THINKER: Type = {
name: 'Deep Thinker',
alias: ['Fish Brains'],
description: 'A humanoid, fish, monster',
gearSlots: [],
};

export const GEL: Type = {
name: 'Gel',
alias: ['Blob', 'Jello', 'Squishy'],
description: 'A gel based creature',
gearSlots: AmorphousCreatureGearSlots,
};
Expand Down Expand Up @@ -626,8 +634,8 @@ export namespace Archetype {
gearSlots: [],
};

export const SNAKE_OF_WATER: Type = {
name: 'Snake of Water',
export const SNAKE_OF_THE_WATER: Type = {
name: 'Snake of the Water',
description: 'A type of dragon.',
gearSlots: SerpentineCreatureGearSlots,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { AffiliationId, AffiliationIds } from '../data/affiliations';
@Schema({ _id: false })
export class AffiliationEmbeddable {
@IsEnum(AffiliationIds)
@Prop()
@Prop({
type: String,
required: true,
enum: AffiliationIds,
})
public affiliationId!: AffiliationId;

@IsInt()
Expand Down
12 changes: 8 additions & 4 deletions services/character-sheet/src/models/character-sheet.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export class CharacterSheet {
public instanceId!: string;

@IsEnum(ArchetypeIds)
@Prop()
@Prop({
type: String,
required: true,
enum: ArchetypeIds,
})
public archetypeId!: ArchetypeId;

@IsString()
Expand Down Expand Up @@ -96,7 +100,7 @@ export class CharacterSheet {
@ArrayUnique()
@ArrayMinSize(0)
@ArrayMaxSize(5)
@Prop()
@Prop([])
public disciplines: DisciplineEmbeddable[];

@ValidateNested({ each: true })
Expand All @@ -105,14 +109,14 @@ export class CharacterSheet {
@ArrayUnique()
@ArrayMinSize(0)
@ArrayMaxSize(12)
@Prop()
@Prop([])
public equipment: EquipmentEmbeddable[];

@ValidateNested({ each: true })
@Type(() => AffiliationEmbeddable)
@IsArray()
@ArrayUnique()
@Prop()
@Prop([])
public affiliation: AffiliationEmbeddable[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { DisciplineId, DisciplineIds } from '../data/discipline';
@Schema()
export class DisciplineEmbeddable {
@IsEnum(DisciplineIds)
@Prop()
@Prop({
type: String,
required: true,
enum: DisciplineIds,
})
public disciplineId!: DisciplineId;

@IsInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import { EquipmentId, EquipmentIds } from '../data/gear/equipment.gear';
@Schema({ _id: false })
export class EquipmentEmbeddable {
@IsEnum(EquipmentIds)
@Prop()
@Prop({
type: String,
required: true,
enum: EquipmentIds,
})
public equipmentId!: EquipmentId;

@ArrayUnique()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from '@nestjs/common';
import { v4 } from 'uuid';
import { CharacterSheetRepository } from '../../models/character-sheet.repository';
import { CharacterSheetService } from './character-sheet.service';
import {
CharacterSheet,
TCharacterSheetDocument,
Expand All @@ -22,10 +21,7 @@ import { CreateCharacterSheetDto } from './create-character-sheet-dto';

@Controller({ path: 'character-sheets', version: [VERSION_NEUTRAL, '1'] })
export class CharacterSheetController {
constructor(
private _characterSheetService: CharacterSheetService,
private _characterSheetRepository: CharacterSheetRepository,
) {}
constructor(private _characterSheetRepository: CharacterSheetRepository) {}

@Get(':id')
async findOne(@Param('id', new ParseUUIDPipe()) id: string): Promise<any> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '@cats-cradle/nestjs-modules';
import { FakerFactory } from '@cats-cradle/faker-factory';
import { v4 } from 'uuid';
import { CharacterSheetService } from './character-sheet.service';
import {
CharacterSheetSchema,
CharacterSheet,
Expand All @@ -21,7 +20,6 @@ import { Archetype } from '../../data/archetype';

describe('/character-sheets', () => {
let app: INestApplication;
let characterSheetService: CharacterSheetService;
let characterSheetRepository: CharacterSheetRepository;
let placeService: PlaceService;

Expand All @@ -33,21 +31,14 @@ describe('/character-sheets', () => {
{ name: 'CharacterSheet', schema: CharacterSheetSchema },
]),
],
providers: [
PlaceService,
CharacterSheetRepository,
CharacterSheetService,
],
providers: [PlaceService, CharacterSheetRepository],
controllers: [CharacterSheetController],
}).compile();

app = moduleRef.createNestApplication();
characterSheetRepository = moduleRef.get<CharacterSheetRepository>(
CharacterSheetRepository,
);
characterSheetService = moduleRef.get<CharacterSheetService>(
CharacterSheetService,
);

placeService = moduleRef.get<PlaceService>(PlaceService);

Expand Down Expand Up @@ -75,7 +66,7 @@ describe('/character-sheets', () => {
const characterSheet = await FakerFactory.create<CharacterSheet>(
CharacterSheet,
{ archetypeId: 'MEEKU_ONI' },
{ optionals: false },
{ optionals: false, pojo: true },
);
await characterSheetRepository.create(characterSheet);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Module } from '@nestjs/common';
import { MongooseModule } from '@cats-cradle/nestjs-modules';
import { databaseModule } from '../../database.module';
import { CharacterSheetService } from './character-sheet.service';
import { CharacterSheetController } from './character-sheet.controller';
import { CharacterSheetRepository } from '../../models/character-sheet.repository';
import { CharacterSheetSchema } from '../../models/character-sheet.schema';
import { PlaceService } from '../place/place.service';

@Module({
controllers: [CharacterSheetController],
providers: [PlaceService, CharacterSheetService, CharacterSheetRepository],
providers: [PlaceService, CharacterSheetRepository],
imports: [
databaseModule(),
MongooseModule.forFeature([
Expand Down

This file was deleted.

Loading

0 comments on commit 1359c1c

Please sign in to comment.