All checks were successful
E2E Testing / test (push) Successful in 1m19s
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import {Character} from "../characters/Character";
|
|
import {Condition} from "./condition/Condition";
|
|
import {ScriptAccountCondition} from "../gamesystems/conditions/ScriptAccountCondition";
|
|
import {InventoryCondition} from "./condition/InventoryCondition";
|
|
import {GamesystemCondition} from "./condition/GamesystemCondition";
|
|
import {Action} from "./actions/Action";
|
|
|
|
export abstract class AbstractInteraction {
|
|
|
|
sourceCharacter: Character
|
|
targetCharacter: Character | undefined
|
|
|
|
conditions: Condition[] = []
|
|
|
|
interactionLabel: string
|
|
|
|
|
|
constructor(sourceCharacter: Character, targetCharacter: Character | undefined, interactionLabel: string) {
|
|
this.sourceCharacter = sourceCharacter;
|
|
this.targetCharacter = targetCharacter;
|
|
this.interactionLabel = interactionLabel;
|
|
}
|
|
|
|
abstract equals(other: AbstractInteraction): boolean
|
|
abstract validate(requieredCharacter: Character): boolean
|
|
|
|
get scriptAccountConditions() {
|
|
return this.conditions.filter(condition => condition instanceof ScriptAccountCondition);
|
|
}
|
|
|
|
get inventoryConditions() {
|
|
return this.conditions.filter(condition => condition instanceof InventoryCondition).map(condition => condition as InventoryCondition)
|
|
}
|
|
|
|
get gamesystemConditions(): GamesystemCondition[] {
|
|
return this.conditions.filter(condition => condition instanceof GamesystemCondition).map(condition => condition as GamesystemCondition)
|
|
}
|
|
|
|
addConditon(addedCondition: Condition) {
|
|
this.conditions.push(addedCondition);
|
|
}
|
|
|
|
removeCondition(removedCondition: Condition) {
|
|
this.conditions = this.conditions.filter(condition => condition !== removedCondition);
|
|
}
|
|
}
|