Skip to content

Commit 0d35db0

Browse files
committed
Change module + systems map
1 parent 22b9d65 commit 0d35db0

13 files changed

Lines changed: 1115 additions & 112 deletions

File tree

src/MyApp.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Fleet from "./app/sites/fleet/Fleet";
1313
import ShipInfo from "./app/sites/fleet/ShipInfo";
1414
import Help from "./app/sites/help/help";
1515
import Main from "./app/sites/main/Main";
16+
import { SystemMap } from "./app/sites/map/SystemMap";
1617
import MapConfig from "./app/sites/map/waypoint/mapConfig";
1718
import WpMap from "./app/sites/map/waypoint/wpMap";
1819
import NewAgent from "./app/sites/newAgent/NewAgent";
@@ -100,6 +101,10 @@ function MyApp() {
100101
path="/system/map/:systemID"
101102
element={<WpMap></WpMap>}
102103
/>
104+
<Route
105+
path="/system/map"
106+
element={<SystemMap></SystemMap>}
107+
/>
103108
<Route
104109
path="/system/wpConfig"
105110
element={<MapConfig></MapConfig>}

src/app/features/Shipinfo/ShipCargoInfo.tsx

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import {
1111
} from "antd";
1212
import { useState } from "react";
1313
import { useAppDispatch, useAppSelector } from "../../hooks";
14-
import type { Ship, ShipCargoItem } from "../../spaceTraderAPI/api";
14+
import {
15+
ShipModuleSymbolEnum,
16+
ShipMountSymbolEnum,
17+
type Ship,
18+
type ShipCargoItem,
19+
} from "../../spaceTraderAPI/api";
1520
import { selectAgent, setMyAgent } from "../../spaceTraderAPI/redux/agentSlice";
1621
import { selectAgentSymbol } from "../../spaceTraderAPI/redux/configSlice";
1722
import {
@@ -22,8 +27,13 @@ import {
2227
selectShips,
2328
setShipCargo,
2429
setShipFuel,
30+
setShipModules,
31+
setShipMounts,
2532
} from "../../spaceTraderAPI/redux/fleetSlice";
26-
import { addMarketTransaction } from "../../spaceTraderAPI/redux/tansactionSlice";
33+
import {
34+
addMarketTransaction,
35+
addShipModificationTransaction,
36+
} from "../../spaceTraderAPI/redux/tansactionSlice";
2737
import spaceTraderClient from "../../spaceTraderAPI/spaceTraderClient";
2838

2939
function ShipCargoInfo({ ship }: { ship: Ship }) {
@@ -214,6 +224,68 @@ function ShipCargoInfo({ ship }: { ship: Ship }) {
214224
);
215225
});
216226
}}
227+
onInstallModule={(item) => {
228+
console.log("Install Module", item);
229+
spaceTraderClient.FleetClient.installShipModule(
230+
ship.symbol,
231+
{
232+
symbol: item,
233+
},
234+
).then((resp) => {
235+
message.success(
236+
`${item} installed on ${ship.symbol} cost ${resp.data.data.transaction.totalPrice}`,
237+
);
238+
dispatch(
239+
setShipCargo({
240+
symbol: ship.symbol,
241+
cargo: resp.data.data.cargo,
242+
}),
243+
);
244+
245+
dispatch(
246+
setShipModules({
247+
symbol: ship.symbol,
248+
modules: resp.data.data.modules,
249+
}),
250+
);
251+
dispatch(
252+
addShipModificationTransaction(
253+
resp.data.data.transaction,
254+
),
255+
);
256+
dispatch(setMyAgent(resp.data.data.agent));
257+
});
258+
}}
259+
onInstallMount={(item) => {
260+
console.log("Install Mount", item);
261+
spaceTraderClient.FleetClient.installMount(ship.symbol, {
262+
symbol: item,
263+
}).then((resp) => {
264+
message.success(
265+
`${item} installed on ${ship.symbol} cost ${resp.data.data.transaction.totalPrice}`,
266+
);
267+
268+
dispatch(
269+
setShipCargo({
270+
symbol: ship.symbol,
271+
cargo: resp.data.data.cargo,
272+
}),
273+
);
274+
275+
dispatch(
276+
setShipMounts({
277+
symbol: ship.symbol,
278+
mounts: resp.data.data.mounts,
279+
}),
280+
);
281+
dispatch(
282+
addShipModificationTransaction(
283+
resp.data.data.transaction,
284+
),
285+
);
286+
dispatch(setMyAgent(resp.data.data.agent));
287+
});
288+
}}
217289
></CargoActions>
218290
);
219291
},
@@ -245,6 +317,8 @@ function CargoActions({
245317
onFulfill,
246318
onRefuel,
247319
onSupply,
320+
onInstallModule,
321+
onInstallMount,
248322
}: {
249323
item: ShipCargoItem;
250324
onJettison: (count: number, item: string) => void;
@@ -253,6 +327,8 @@ function CargoActions({
253327
onFulfill: (count: number, item: string, contractID: string) => void;
254328
onRefuel: (count: number) => void;
255329
onSupply: (count: number, item: string) => void;
330+
onInstallMount: (item: string) => void;
331+
onInstallModule: (item: string) => void;
256332
}) {
257333
const [count, setCount] = useState(1);
258334
const agentSymbol = useAppSelector(selectAgentSymbol);
@@ -318,6 +394,16 @@ function CargoActions({
318394
)}
319395

320396
<Button onClick={() => onSupply(count, item.symbol)}>Supply Const</Button>
397+
{Object.values(ShipMountSymbolEnum).find((w) => w === item.symbol) && (
398+
<Button onClick={() => onInstallMount(item.symbol)}>
399+
Install Mount
400+
</Button>
401+
)}
402+
{Object.values(ShipModuleSymbolEnum).find((w) => w === item.symbol) && (
403+
<Button onClick={() => onInstallModule(item.symbol)}>
404+
Install Module
405+
</Button>
406+
)}
321407
</Space>
322408
);
323409
}

src/app/features/Shipinfo/ShipControlCenter.tsx

Lines changed: 143 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { setMyAgent } from "../../spaceTraderAPI/redux/agentSlice";
1616
import { selectAgentSymbol } from "../../spaceTraderAPI/redux/configSlice";
1717
import { putContract } from "../../spaceTraderAPI/redux/contractSlice";
1818
import {
19+
deleteShip,
1920
setShip,
2021
setShipCargo,
2122
setShipCooldown,
@@ -27,7 +28,10 @@ import {
2728
pruneSurveys,
2829
} from "../../spaceTraderAPI/redux/surveySlice";
2930
import { selectSystem } from "../../spaceTraderAPI/redux/systemSlice";
30-
import { addMarketTransaction } from "../../spaceTraderAPI/redux/tansactionSlice";
31+
import {
32+
addMarketTransaction,
33+
addScrapTransaction,
34+
} from "../../spaceTraderAPI/redux/tansactionSlice";
3135
import {
3236
putWaypoints,
3337
selectSystemWaypoints,
@@ -98,6 +102,8 @@ function ShipControlCenter({
98102
selectSystem(state, ship.nav.systemSymbol),
99103
);
100104

105+
const [shiftKey, setShiftKey] = useState(false);
106+
101107
const wayPoint = system?.waypoints.find(
102108
(x) => x.symbol === ship?.nav.waypointSymbol,
103109
);
@@ -124,6 +130,7 @@ function ShipControlCenter({
124130
value={new Date(ship.nav.route.arrival).getTime()}
125131
/>
126132
)}
133+
127134
<Button
128135
onClick={() => {
129136
spaceTraderClient.FleetClient.getMyShip(ship.symbol).then(
@@ -550,6 +557,141 @@ function ShipControlCenter({
550557
</>
551558
)}
552559
</Space>
560+
<Space size="large">
561+
<span>Shipyard</span>
562+
563+
<Button
564+
onMouseOver={(e) => {
565+
setShiftKey(e.shiftKey);
566+
}}
567+
onMouseMove={(e) => {
568+
setShiftKey(e.shiftKey);
569+
}}
570+
onMouseLeave={(e) => {
571+
setShiftKey(false);
572+
}}
573+
type={shiftKey ? "primary" : "default"}
574+
danger={shiftKey}
575+
onClick={(e) => {
576+
if (e.shiftKey) {
577+
spaceTraderClient.FleetClient.scrapShip(ship.symbol).then(
578+
(response) => {
579+
message.success(
580+
`Ship Scraped: ${response.data.data.transaction.totalPrice} at waypoint ${response.data.data.transaction.waypointSymbol}`,
581+
);
582+
dispatch(
583+
addScrapTransaction(response.data.data.transaction),
584+
);
585+
dispatch(setMyAgent(response.data.data.agent));
586+
dispatch(
587+
deleteShip(response.data.data.transaction.shipSymbol),
588+
);
589+
},
590+
);
591+
} else {
592+
spaceTraderClient.FleetClient.getScrapShip(ship.symbol).then(
593+
(response) => {
594+
message.success(
595+
`Scrap Value: ${response.data.data.transaction.totalPrice} at waypoint ${response.data.data.transaction.waypointSymbol}`,
596+
);
597+
},
598+
);
599+
}
600+
}}
601+
>
602+
{shiftKey ? "Scrap" : "Scrap Value"}
603+
</Button>
604+
<Button>Repair Ship</Button>
605+
</Space>
606+
<Space size="large">
607+
<span>Scan</span>
608+
{ship.mounts.some(
609+
(value) =>
610+
value.symbol === "MOUNT_SENSOR_ARRAY_I" ||
611+
value.symbol === "MOUNT_SENSOR_ARRAY_II" ||
612+
value.symbol === "MOUNT_SENSOR_ARRAY_III",
613+
) && (
614+
<Button
615+
onClick={(e) => {
616+
spaceTraderClient.FleetClient.createShipSystemScan(
617+
ship.symbol,
618+
).then((response) => {
619+
message.success(
620+
`Scanned ${response.data.data.systems.length} systems`,
621+
);
622+
623+
dispatch(
624+
setShipCooldown({
625+
symbol: ship.symbol,
626+
cooldown: response.data.data.cooldown,
627+
}),
628+
);
629+
console.log("systems", response.data.data.systems);
630+
});
631+
}}
632+
>
633+
Scan Systems
634+
</Button>
635+
)}
636+
{ship.mounts.some(
637+
(value) =>
638+
value.symbol === "MOUNT_SENSOR_ARRAY_I" ||
639+
value.symbol === "MOUNT_SENSOR_ARRAY_II" ||
640+
value.symbol === "MOUNT_SENSOR_ARRAY_III",
641+
) && (
642+
<Button
643+
onClick={(e) => {
644+
spaceTraderClient.FleetClient.createShipWaypointScan(
645+
ship.symbol,
646+
).then((response) => {
647+
message.success(
648+
`Scanned ${response.data.data.waypoints.length} waypoints`,
649+
);
650+
dispatch(
651+
setShipCooldown({
652+
symbol: ship.symbol,
653+
cooldown: response.data.data.cooldown,
654+
}),
655+
);
656+
// response.data.data.waypoints.forEach((waypoint) => {
657+
// waypoint.
658+
// })
659+
console.log("waypoints", response.data.data.waypoints);
660+
});
661+
}}
662+
>
663+
Scan Waypoints
664+
</Button>
665+
)}
666+
{ship.mounts.some(
667+
(value) =>
668+
value.symbol === "MOUNT_SENSOR_ARRAY_I" ||
669+
value.symbol === "MOUNT_SENSOR_ARRAY_II" ||
670+
value.symbol === "MOUNT_SENSOR_ARRAY_III",
671+
) && (
672+
<Button
673+
onClick={(e) => {
674+
spaceTraderClient.FleetClient.createShipShipScan(
675+
ship.symbol,
676+
).then((response) => {
677+
message.success(
678+
`Scanned ${response.data.data.ships.length} ships`,
679+
);
680+
dispatch(
681+
setShipCooldown({
682+
symbol: ship.symbol,
683+
cooldown: response.data.data.cooldown,
684+
}),
685+
);
686+
687+
console.log("ships", response.data.data.ships);
688+
});
689+
}}
690+
>
691+
Scan Ships
692+
</Button>
693+
)}
694+
</Space>
553695
</Flex>
554696
</Card>
555697
);

src/app/features/Shipinfo/ShipModuleInfo.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ import type {
66
ShipModule,
77
ShipRefineRequestProduceEnum,
88
} from "../../spaceTraderAPI/api";
9+
import { setMyAgent } from "../../spaceTraderAPI/redux/agentSlice";
910
import {
1011
setShipCargo,
1112
setShipCooldown,
13+
setShipModules,
1214
} from "../../spaceTraderAPI/redux/fleetSlice";
15+
import { addShipModificationTransaction } from "../../spaceTraderAPI/redux/tansactionSlice";
1316
import spaceTraderClient from "../../spaceTraderAPI/spaceTraderClient";
1417
import { message } from "../../utils/antdMessage";
1518

@@ -93,6 +96,43 @@ function ShipModuleInfo({ value, ship }: { value: ShipModule; ship: Ship }) {
9396
) : (
9497
""
9598
)}
99+
<span>
100+
<Button
101+
onClick={() => {
102+
spaceTraderClient.FleetClient.removeShipModule(
103+
ship.symbol,
104+
{
105+
symbol: value.symbol,
106+
},
107+
).then((resp) => {
108+
message.success(
109+
`Removed ${value.symbol} ${resp.data.data.transaction.shipSymbol} cost ${resp.data.data.transaction.totalPrice}`,
110+
);
111+
dispatch(
112+
setShipCargo({
113+
symbol: ship.symbol,
114+
cargo: resp.data.data.cargo,
115+
}),
116+
);
117+
118+
dispatch(
119+
setShipModules({
120+
symbol: ship.symbol,
121+
modules: resp.data.data.modules,
122+
}),
123+
);
124+
dispatch(
125+
addShipModificationTransaction(
126+
resp.data.data.transaction,
127+
),
128+
);
129+
dispatch(setMyAgent(resp.data.data.agent));
130+
});
131+
}}
132+
>
133+
Remove Module
134+
</Button>
135+
</span>
96136
</Flex>
97137
),
98138
span: 3,

0 commit comments

Comments
 (0)