Fix incorrect filtering of effect sources.

This commit is contained in:
2021-05-29 12:54:57 -07:00
parent e26747cc7c
commit b134f1849a
3 changed files with 11 additions and 12 deletions

View File

@ -7,8 +7,8 @@ const DEFAULT_PROMPT = ">";
export default class User { export default class User {
#prompt: string; #prompt: string;
constructor(prompt: string) { constructor(prompt: string = DEFAULT_PROMPT) {
this.#prompt = prompt || DEFAULT_PROMPT; this.#prompt = prompt;
} }
ask(question: string): string { ask(question: string): string {

View File

@ -35,15 +35,14 @@ export default class Vessel<T extends VesselProperties> {
activePlayerEffects: string[], activePlayerEffects: string[],
activeSceneEffects: string[] activeSceneEffects: string[]
): T { ): T {
const activeEffects = [...activePlayerEffects, ...activeSceneEffects]; const playerSet = new Set(activePlayerEffects);
const map = this._conditions.effects.reduce( const sceneSet = new Set(activeSceneEffects);
(map: { [name: string]: Effect<T> }, effect: Effect<T>) => {
map[effect.name] = effect; const effects = this._conditions.effects.filter(({ name, source }) => {
return map; const set = source === "player" ? playerSet : sceneSet;
}, return set.has(name);
{} });
);
const effects = activeEffects.map((e) => map[e]);
const appliedProperties = { ...this._properties }; const appliedProperties = { ...this._properties };
// for each effect, apply changed properties to the // for each effect, apply changed properties to the

View File

@ -35,7 +35,7 @@ export const hall: StoryScene<SceneProperties> = {
effect: "flashlight-on", effect: "flashlight-on",
// can be "player" or "scene" // can be "player" or "scene"
applyTo: "scene", applyTo: "player",
// When it's used, this is what should be reported back to // When it's used, this is what should be reported back to
// the user. // the user.