Adrià Vilanova Martínez | 67b0b25 | 2024-05-18 00:35:51 +0200 | [diff] [blame] | 1 | import { OptionCodename } from '../../optionsPrototype'; |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 2 | import Script, { ConcreteScript } from '../scripts/Script'; |
| 3 | |
| 4 | export default abstract class Feature { |
| 5 | /** |
| 6 | * Internal codename used for the feature. |
| 7 | * |
| 8 | * It will be used for i18n translations, shown in log messages, etc. |
| 9 | */ |
| 10 | abstract readonly codename: string; |
| 11 | |
| 12 | /** |
| 13 | * Options which control the behavior of this feature. |
| 14 | */ |
Adrià Vilanova Martínez | 67b0b25 | 2024-05-18 00:35:51 +0200 | [diff] [blame] | 15 | abstract readonly relatedOptions: OptionCodename[]; |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * Uninitialized scripts which are associated with the feature. |
| 19 | */ |
| 20 | abstract readonly scripts: ConcreteScript[]; |
| 21 | |
| 22 | private initializedScripts: Script[]; |
| 23 | |
| 24 | public getScripts() { |
| 25 | if (this.initializedScripts === undefined) { |
| 26 | this.initializedScripts = this.scripts.map((script) => new script()); |
| 27 | } |
| 28 | return this.initializedScripts; |
| 29 | } |
| 30 | } |