2024-04-01 16:43:51 +02:00
|
|
|
import { tags } from "typia";
|
|
|
|
|
|
|
|
|
2024-04-01 18:35:26 +02:00
|
|
|
/* messages ***************************************************************************************/
|
2024-04-01 16:43:51 +02:00
|
|
|
|
2024-04-04 11:14:57 +02:00
|
|
|
export type SimToCmMessage = {
|
2024-04-30 16:37:51 +02:00
|
|
|
message?: Message,
|
|
|
|
stressLevel?: Range<0, 1>,
|
2024-04-04 11:14:57 +02:00
|
|
|
};
|
|
|
|
|
2024-05-29 14:40:55 +02:00
|
|
|
export type Message = ThreatDetected | RequestApprovalToAttack | AcaFuelLow | MissileToOwnshipDetected | AcaDefect | AcaHeadingToBase;
|
2024-04-01 16:43:51 +02:00
|
|
|
|
|
|
|
export type BaseMessage<TKind extends string, TData extends object> = {
|
2024-05-13 15:06:29 +02:00
|
|
|
id: Uuid,
|
|
|
|
conversationId: Uuid,
|
2024-04-01 16:43:51 +02:00
|
|
|
priority: Priority,
|
2024-05-22 10:14:27 +02:00
|
|
|
tags: Array<string>,
|
2024-04-01 16:43:51 +02:00
|
|
|
kind: TKind,
|
|
|
|
data: TData,
|
|
|
|
};
|
|
|
|
|
2024-05-29 14:40:55 +02:00
|
|
|
export type ThreatDetected = BaseMessage<"ThreatDetected", {
|
2024-04-01 16:43:51 +02:00
|
|
|
target: Target,
|
|
|
|
detectedByAca?: Id,
|
2024-05-29 14:40:55 +02:00
|
|
|
}>;
|
|
|
|
|
|
|
|
export type RequestApprovalToAttack = BaseMessage<"RequestApprovalToAttack", {
|
2024-05-31 14:19:05 +02:00
|
|
|
target: Target,
|
|
|
|
detectedByAca?: Id,
|
2024-05-29 14:40:55 +02:00
|
|
|
collateralDamage: "none" | "simple" | "complex",
|
2024-04-01 16:43:51 +02:00
|
|
|
attackWeapon: Weapon,
|
|
|
|
choiceWeight: Range<-1, 1>, // specifies which choice option to prefer, -1: deny, 1: approve
|
|
|
|
}>;
|
|
|
|
|
|
|
|
export type MissileToOwnshipDetected = BaseMessage<"MissileToOwnshipDetected", {
|
2024-05-13 14:49:32 +02:00
|
|
|
missileLocation: Point,
|
2024-04-01 16:43:51 +02:00
|
|
|
survivability: Range<0, 1>,
|
|
|
|
detectedByAca?: Id,
|
|
|
|
acaAttackWeapon?: Weapon,
|
|
|
|
choiceWeight: Range<-1, 1>, // specifies which choice option to prefer, -1: avoid, 1: intervene
|
2024-04-01 18:35:26 +02:00
|
|
|
}>;
|
2024-04-01 16:43:51 +02:00
|
|
|
|
|
|
|
export type AcaFuelLow = BaseMessage<"AcaFuelLow", {
|
|
|
|
acaId: Id,
|
|
|
|
fuelLevel: Range<0, 1>,
|
|
|
|
}>;
|
|
|
|
|
|
|
|
export type AcaDefect = BaseMessage<"AcaDefect", {
|
|
|
|
acaId: Id,
|
|
|
|
message: string,
|
2024-04-01 18:35:26 +02:00
|
|
|
}>;
|
2024-04-01 16:43:51 +02:00
|
|
|
|
|
|
|
export type AcaHeadingToBase = BaseMessage<"AcaHeadingToBase", {
|
|
|
|
acaId: Id,
|
|
|
|
reason?: "fuelLow" | "weaponsLow",
|
2024-04-01 18:35:26 +02:00
|
|
|
}>;
|
2024-04-01 16:43:51 +02:00
|
|
|
|
|
|
|
|
2024-04-01 18:35:26 +02:00
|
|
|
/* utility types **********************************************************************************/
|
2024-04-01 16:43:51 +02:00
|
|
|
|
2024-04-09 19:02:51 +02:00
|
|
|
export type Id = number & tags.Type<"uint64">;
|
2024-05-13 15:06:29 +02:00
|
|
|
export type Uuid = string & tags.Format<"uuid">;
|
2024-05-13 14:49:32 +02:00
|
|
|
export type Priority = DiscreteRange<0, 10>;
|
2024-04-01 16:43:51 +02:00
|
|
|
export type Range<From extends number, To extends number> = number & tags.Type<"float"> & tags.Minimum<From> & tags.Maximum<To>;
|
2024-05-13 14:49:32 +02:00
|
|
|
export type DiscreteRange<From extends number, To extends number> = number & tags.Type<"int64"> & tags.Minimum<From> & tags.Maximum<To>;
|
2024-04-01 16:43:51 +02:00
|
|
|
|
|
|
|
export type Target = {
|
2024-05-13 14:49:32 +02:00
|
|
|
location: Point,
|
2024-04-01 16:43:51 +02:00
|
|
|
threatLevel: Range<0, 1>,
|
2024-05-13 15:05:25 +02:00
|
|
|
type: "airDefense" | "artillery" | "radar",
|
2024-04-01 16:43:51 +02:00
|
|
|
};
|
|
|
|
|
2024-05-13 14:49:32 +02:00
|
|
|
export type Point = {
|
|
|
|
x: DiscreteRange<0, 1920>,
|
|
|
|
y: DiscreteRange<0, 1080>,
|
2024-04-01 16:43:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export type Weapon = {
|
|
|
|
type: string,
|
|
|
|
load: Range<0, 1>,
|
|
|
|
};
|