Initial commit

This commit is contained in:
Dmitry Popov
2024-09-18 01:55:30 +04:00
parent 6a96a5f56e
commit 4136aaad76
1675 changed files with 124664 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
import { SolarSystemConnection } from '@/hooks/Mapper/types/connection.ts';
export const convertConnection2Edge = (conn: SolarSystemConnection) => {
return {
sourceHandle: 'c',
targetHandle: 'a',
type: 'floating',
label: 'updatable edge',
id: conn.id,
source: conn.source,
target: conn.target,
data: conn,
};
};

View File

@@ -0,0 +1,14 @@
import { SolarSystemRawType } from '@/hooks/Mapper/types/system.ts';
import { Node } from 'reactflow';
export const convertSystem2Node = (sys: SolarSystemRawType): Node => {
return {
type: 'custom',
width: 130,
height: 34,
id: sys.id,
position: sys.position,
data: sys,
draggable: !sys.locked,
};
};

View File

@@ -0,0 +1,20 @@
import { isZarzakhSpace } from '@/hooks/Mapper/components/map/helpers/isZarzakhSpace.ts';
import {
SECURITY_BACKGROUND_CLASSES,
SYSTEM_CLASS_BACKGROUND_CLASSES,
WORMHOLE_CLASS_BACKGROUND_CLASSES,
} from '@/hooks/Mapper/components/map/constants.ts';
import { isKnownSpace } from '@/hooks/Mapper/components/map/helpers/isKnownSpace.ts';
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace.ts';
export const getBackgroundClass = (systemClass: number, security: string) => {
if (isZarzakhSpace(systemClass)) {
return SYSTEM_CLASS_BACKGROUND_CLASSES[systemClass];
} else if (isKnownSpace(systemClass)) {
return SECURITY_BACKGROUND_CLASSES[security];
} else if (isWormholeSpace(systemClass)) {
return WORMHOLE_CLASS_BACKGROUND_CLASSES[systemClass];
} else {
return SYSTEM_CLASS_BACKGROUND_CLASSES[systemClass];
}
};

View File

@@ -0,0 +1,16 @@
import { isKnownSpace } from './isKnownSpace.ts';
import { isWormholeSpace } from './isWormholeSpace.ts';
import { isPochvenSpace } from './isPochvenSpace.ts';
import { isTriglavianInvasion } from './isTriglavianInvasion.ts';
export const getShapeClass = (systemClass: number, triglavianInvasionStatus: string) => {
if (isPochvenSpace(systemClass) || (isKnownSpace(systemClass) && isTriglavianInvasion(triglavianInvasionStatus))) {
return 'wd-route-system-shape-triangle';
}
if (isWormholeSpace(systemClass)) {
return 'wd-route-system-shape-circle';
}
return '';
};

View File

@@ -0,0 +1,23 @@
import { isKnownSpace } from '@/hooks/Mapper/components/map/helpers/isKnownSpace.ts';
import {
SECURITY_FOREGROUND_CLASSES,
SYSTEM_CLASS_STYLES,
WORMHOLE_CLASS_STYLES,
} from '@/hooks/Mapper/components/map/constants.ts';
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace.ts';
import { SolarSystemStaticInfo } from '@/hooks/Mapper/types';
type SystemClassStylesProps = Pick<SolarSystemStaticInfo, 'systemClass' | 'security'>;
export const getSystemClassStyles = ({ systemClass, security }: SystemClassStylesProps) => {
if (isKnownSpace(systemClass)) {
return SECURITY_FOREGROUND_CLASSES[security];
}
if (isWormholeSpace(systemClass)) {
return WORMHOLE_CLASS_STYLES[systemClass];
}
return SYSTEM_CLASS_STYLES[systemClass];
};

View File

@@ -0,0 +1,5 @@
export * from './convertConnection2Edge';
export * from './convertSystem2Node';
export * from './getSystemClassStyles';
export * from './getShapeClass';
export * from './getBackgroundClass';

View File

@@ -0,0 +1,13 @@
import { SOLAR_SYSTEM_CLASS_IDS } from '@/hooks/Mapper/components/map/constants.ts';
export const isKnownSpace = (wormholeClassID: number) => {
switch (wormholeClassID) {
case SOLAR_SYSTEM_CLASS_IDS.hs:
case SOLAR_SYSTEM_CLASS_IDS.ls:
case SOLAR_SYSTEM_CLASS_IDS.ns:
case SOLAR_SYSTEM_CLASS_IDS.zarzakh:
return true;
}
return false;
};

View File

@@ -0,0 +1,10 @@
import { SOLAR_SYSTEM_CLASS_IDS } from '@/hooks/Mapper/components/map/constants.ts';
export const isPochvenSpace = (wormholeClassID: number) => {
switch (wormholeClassID) {
case SOLAR_SYSTEM_CLASS_IDS.pochven:
return true;
}
return false;
};

View File

@@ -0,0 +1,10 @@
export const isTriglavianInvasion = (triglavianInvasionStatus: string) => {
switch (triglavianInvasionStatus) {
case 'Normal':
return false;
case 'Final':
case 'Edencom':
case 'Triglavian':
return true;
}
};

View File

@@ -0,0 +1,22 @@
import { SOLAR_SYSTEM_CLASS_IDS } from '@/hooks/Mapper/components/map/constants.ts';
export const isWormholeSpace = (wormholeClassID: number) => {
switch (wormholeClassID) {
case SOLAR_SYSTEM_CLASS_IDS.c1:
case SOLAR_SYSTEM_CLASS_IDS.c2:
case SOLAR_SYSTEM_CLASS_IDS.c3:
case SOLAR_SYSTEM_CLASS_IDS.c4:
case SOLAR_SYSTEM_CLASS_IDS.c5:
case SOLAR_SYSTEM_CLASS_IDS.c6:
case SOLAR_SYSTEM_CLASS_IDS.c13:
case SOLAR_SYSTEM_CLASS_IDS.thera:
case SOLAR_SYSTEM_CLASS_IDS.baribican:
case SOLAR_SYSTEM_CLASS_IDS.vidette:
case SOLAR_SYSTEM_CLASS_IDS.conflux:
case SOLAR_SYSTEM_CLASS_IDS.redoubt:
case SOLAR_SYSTEM_CLASS_IDS.sentinel:
return true;
}
return false;
};

View File

@@ -0,0 +1,10 @@
import { SOLAR_SYSTEM_CLASS_IDS } from '@/hooks/Mapper/components/map/constants.ts';
export const isZarzakhSpace = (wormholeClassID: number) => {
switch (wormholeClassID) {
case SOLAR_SYSTEM_CLASS_IDS.zarzakh:
return true;
}
return false;
};