-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmaterial-template.ts
59 lines (51 loc) · 1.84 KB
/
material-template.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Type } from 'class-transformer';
import { IsNumber, Max, Min, ValidateNested } from 'class-validator';
import { maxTreatmentRange } from '../state-helpers/max-treatment-range';
import { IsLiteralUnion, IsValue } from '../utils/validators';
import { CanCaterFor, getCreate, ImageProperties } from './utils';
import { MaterialType, materialTypeAllowedValues } from './utils/material-type';
export class MaterialTemplate {
@IsValue('materialTemplate' as const)
public readonly type = 'materialTemplate';
@IsLiteralUnion(materialTypeAllowedValues)
public readonly materialType: MaterialType;
@ValidateNested()
@Type(() => CanCaterFor)
public readonly canCaterFor: CanCaterFor;
/**
* Patients in this range are preferred over patients farther away (even if they are less injured).
* Guaranteed to be <= {@link maxTreatmentRange}.
*/
@IsNumber()
@Min(0)
@Max(maxTreatmentRange)
public readonly overrideTreatmentRange: number;
/**
* Only patients in this range around the material's position can be treated.
* Guaranteed to be <= {@link maxTreatmentRange}.
*/
@IsNumber()
@Min(0)
@Max(maxTreatmentRange)
public readonly treatmentRange: number;
@ValidateNested()
@Type(() => ImageProperties)
public readonly image: ImageProperties;
/**
* @deprecated Use {@link create} instead
*/
constructor(
materialType: MaterialType,
image: ImageProperties,
canCaterFor: CanCaterFor,
overrideTreatmentRange: number,
treatmentRange: number
) {
this.materialType = materialType;
this.image = image;
this.canCaterFor = canCaterFor;
this.overrideTreatmentRange = overrideTreatmentRange;
this.treatmentRange = treatmentRange;
}
static readonly create = getCreate(this);
}