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 {
#prompt: string;
constructor(prompt: string) {
this.#prompt = prompt || DEFAULT_PROMPT;
constructor(prompt: string = DEFAULT_PROMPT) {
this.#prompt = prompt;
}
ask(question: string): string {

View File

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

View File

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