-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alpha 9
- Loading branch information
Showing
144 changed files
with
4,278 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {t} from "@server/init/t"; | ||
import {pubsub} from "@server/init/pubsub"; | ||
import {z} from "zod"; | ||
|
||
export const alertLevel = t.router({ | ||
update: t.procedure | ||
.input(z.object({level: z.union([ | ||
z.literal("5"), | ||
z.literal("4"), | ||
z.literal("3"), | ||
z.literal("2"), | ||
z.literal("1"), | ||
z.literal("p") | ||
])})) | ||
.send(({ctx, input}) => { | ||
if (!ctx.ship) throw new Error("Ship not found"); | ||
|
||
ctx.ship.updateComponent('isShip', {alertLevel:input.level}); | ||
pubsub.publish.ship.get({shipId: ctx.ship.id}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import * as React from "react"; | ||
import {q} from "@client/context/AppContext"; | ||
import Button from "@thorium/ui/Button"; | ||
import { AlertLevel } from "@server/components/isShip"; | ||
|
||
const alertLevelText = [ | ||
{ | ||
number: 5, | ||
text: | ||
"This alert condition is used when the ship is at normal running status. The crew is on standard duty and the ship is in no danger.", | ||
}, | ||
{ | ||
number: 4, | ||
text: | ||
"This alert condition is used when the station has a minor problem. All crew except damage control is on standard duty.", | ||
}, | ||
{ | ||
number: 3, | ||
text: | ||
"This alert condition is used when the ship needs to be ready for a crisis. All off duty personnel are put on stand by status.", | ||
}, | ||
{ | ||
number: 2, | ||
text: | ||
"This alert condition is used when the ship is in a dangerous situation, but is safe for the moment. All crew members are put on duty.", | ||
}, | ||
{ | ||
number: 1, | ||
text: | ||
"This alert condition is used when the ship is in danger or under attack. All crew members are put on duty at battle stations.", | ||
}, | ||
]; | ||
|
||
export function AlertLevelCard() { | ||
const [ship] = q.ship.get.useNetRequest(); | ||
let [description, setDescription] = React.useState(""); | ||
|
||
const updateLevel = (newLevel: AlertLevel) => { | ||
q.alertLevel.update.netSend({ | ||
level: newLevel | ||
}); | ||
} | ||
const displayDesc = (level: number) => { | ||
alertLevelText.forEach((e) => { | ||
if (e.number === level) { | ||
setDescription(e.text); | ||
} | ||
}); | ||
} | ||
const clearDesc = () => { | ||
setDescription(""); | ||
} | ||
return ( | ||
<div className="flex flex-row h-full gap-4"> | ||
<div className="flex-1"> | ||
<div className="flex flex-col justify-between h-full gap-4"> | ||
<Button | ||
className="btn-primary flex-1" | ||
type="button" | ||
onClick={() => updateLevel("5")} | ||
onMouseEnter={() => displayDesc(5)} | ||
onMouseLeave={() => clearDesc()} | ||
> | ||
Alert Condition 5 | ||
</Button> | ||
<Button | ||
className="btn-success flex-1" | ||
type="button" | ||
onClick={() => updateLevel("4")} | ||
onMouseEnter={() => displayDesc(4)} | ||
onMouseLeave={() => clearDesc()} | ||
> | ||
Alert Condition 4 | ||
</Button> | ||
<Button | ||
className="btn-warning flex-1" | ||
type="button" | ||
onClick={() => updateLevel("3")} | ||
onMouseEnter={() => displayDesc(3)} | ||
onMouseLeave={() => clearDesc()} | ||
> | ||
Alert Condition 3 | ||
</Button> | ||
<Button | ||
className="btn-secondary flex-1" | ||
type="button" | ||
onClick={() => updateLevel("2")} | ||
onMouseEnter={() => displayDesc(2)} | ||
onMouseLeave={() => clearDesc()} | ||
> | ||
Alert Condition 2 | ||
</Button> | ||
<Button | ||
className="btn-error flex-1" | ||
type="button" | ||
onClick={() => updateLevel("1")} | ||
onMouseEnter={() => displayDesc(1)} | ||
onMouseLeave={() => clearDesc()} | ||
> | ||
Alert Condition 1 | ||
</Button> | ||
</div> | ||
</div> | ||
<div className="form-control flex flex-1 h-64"> | ||
<textarea className="textarea h-full w-full" value={description} disabled></textarea> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export function cargoSort([keyA]: [string, number], [keyB]: [string, number]) { | ||
export function cargoSort( | ||
[keyA]: [string, {count: number}], | ||
[keyB]: [string, {count: number}] | ||
) { | ||
return keyA.localeCompare(keyB); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.