@@ -16,6 +16,7 @@ import { setMyAgent } from "../../spaceTraderAPI/redux/agentSlice";
1616import { selectAgentSymbol } from "../../spaceTraderAPI/redux/configSlice" ;
1717import { putContract } from "../../spaceTraderAPI/redux/contractSlice" ;
1818import {
19+ deleteShip ,
1920 setShip ,
2021 setShipCargo ,
2122 setShipCooldown ,
@@ -27,7 +28,10 @@ import {
2728 pruneSurveys ,
2829} from "../../spaceTraderAPI/redux/surveySlice" ;
2930import { selectSystem } from "../../spaceTraderAPI/redux/systemSlice" ;
30- import { addMarketTransaction } from "../../spaceTraderAPI/redux/tansactionSlice" ;
31+ import {
32+ addMarketTransaction ,
33+ addScrapTransaction ,
34+ } from "../../spaceTraderAPI/redux/tansactionSlice" ;
3135import {
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 ) ;
0 commit comments