Skip to content

Commit

Permalink
cryoing now correctly opens a job slot
Browse files Browse the repository at this point in the history
players can no longer open job slots
  • Loading branch information
ZephyrTFA committed Mar 9, 2024
1 parent e6a2bfe commit 238d8e0
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 28 deletions.
28 changes: 19 additions & 9 deletions code/game/machinery/cryopod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,25 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/computer/cryopod/retro, 17)
/obj/machinery/cryopod/proc/despawn_occupant()
var/mob/living/mob_occupant = occupant

if(linked_ship)
if(mob_occupant.job in linked_ship.current_ship.job_slots)
linked_ship.current_ship.job_slots[mob_occupant.job]++

if(mob_occupant.mind && mob_occupant.mind.assigned_role)
//Handle job slot/tater cleanup.
if(LAZYLEN(mob_occupant.mind.objectives))
mob_occupant.mind.objectives.Cut()
mob_occupant.mind.special_role = null
if(linked_ship && mob_occupant.mind.original_ship == WEAKREF(linked_ship.current_ship))
var/job_identifier = mob_occupant.job

var/datum/job/crew_job
for(var/datum/job/job as anything in linked_ship.current_ship.job_slots)
if(job.name == job_identifier)
crew_job = job
break

if(isnull(crew_job))
message_admins(span_warning("Failed to identify the job of [key_name_admin(mob_occupant)] on [linked_ship] at [loc_name(src)]."))
else
linked_ship.current_ship.job_slots[crew_job]++

if(mob_occupant.mind && mob_occupant.mind.assigned_role)
//Handle job slot/tater cleanup.
if(LAZYLEN(mob_occupant.mind.objectives))
mob_occupant.mind.objectives.Cut()
mob_occupant.mind.special_role = null

// Delete them from datacore.
var/announce_rank = null
Expand Down
20 changes: 12 additions & 8 deletions code/modules/overmap/ships/owner_action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
.["pending"] = FALSE
.["joinMode"] = parent_ship.join_mode
.["cooldown"] = COOLDOWN_TIMELEFT(parent_ship, job_slot_adjustment_cooldown)
.["isAdmin"] = !!user.client?.holder
.["applications"] = list()
for(var/a_key as anything in parent_ship.applications)
var/datum/ship_application/app = parent_ship.applications[a_key]
Expand Down Expand Up @@ -197,18 +198,21 @@
if(!target_job || target_job.officer || !COOLDOWN_FINISHED(parent_ship, job_slot_adjustment_cooldown))
return TRUE

var/change_amount = params["delta"]
if(change_amount > 0)
if(!user.client.holder)
to_chat(user, span_warning("You cannot increase the number of slots for a job."))
return TRUE
message_admins("[key_name_admin(user)] has increased the number of slots for [target_job.name] on [parent_ship.name] by [change_amount].")

var/new_amount = parent_ship.job_slots[target_job] + change_amount
var/job_default_slots = parent_ship.source_template.job_slots[target_job]
var/job_max_slots = min(job_default_slots * 2, job_default_slots + 3)
var/new_slots = parent_ship.job_slots[target_job] + params["delta"]
if(new_slots < 0 || new_slots > job_max_slots)
if(new_amount < 0 || new_amount > job_max_slots)
return TRUE

var/cooldown_time = 5 SECONDS
if(params["delta"] > 0 && new_slots > job_default_slots)
cooldown_time = 2 MINUTES
COOLDOWN_START(parent_ship, job_slot_adjustment_cooldown, cooldown_time * cooldown_coeff)

parent_ship.job_slots[target_job] = new_slots
COOLDOWN_START(parent_ship, job_slot_adjustment_cooldown, (5 SECONDS) * cooldown_coeff)
parent_ship.job_slots[target_job] = new_amount
update_static_data(user)
return TRUE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@ import {
} from '../components';
import { Window } from '../layouts';

type ShipOwnerData = {
crew: [CrewData];
jobs: [JobData];
memo: string;
pending: boolean;
joinMode: string;
cooldown: number;
applications: [ApplicationData];
isAdmin: boolean;
};

type ApplicationData = {
ref: string;
key: string;
name: string;
text: string;
status: string;
};

type CrewData = {
ref: string;
name: string;
allowed: boolean;
};

type JobData = {
ref: string;
name: string;
slots: number;
max: number;
def: number;
};

export const ShipOwner = (props, context) => {
return (
<Window width={620} height={620} resizable>
Expand All @@ -19,8 +52,8 @@ export const ShipOwner = (props, context) => {
);
};

const ShipOwnerContent = (props, context) => {
const { act, data } = useBackend(context);
const ShipOwnerContent = (_, context: any) => {
const { act, data } = useBackend<ShipOwnerData>(context);
const [tab, setTab] = useLocalState(context, 'tab', 1);
const {
crew = [],
Expand All @@ -30,6 +63,7 @@ const ShipOwnerContent = (props, context) => {
joinMode,
cooldown = 1,
applications = [],
isAdmin,
} = data;
return (
<Section
Expand Down Expand Up @@ -85,7 +119,7 @@ const ShipOwnerContent = (props, context) => {
<Table.Cell>Message</Table.Cell>
<Table.Cell>Status</Table.Cell>
</Table.Row>
{applications.map((app) => (
{applications.map((app: ApplicationData) => (
<Table.Row key={app.ref}>
<Table.Cell>{app.key}</Table.Cell>
<Table.Cell>{app.name}</Table.Cell>
Expand Down Expand Up @@ -144,16 +178,16 @@ const ShipOwnerContent = (props, context) => {
<Table.Cell>Can be owner</Table.Cell>
<Table.Cell>Transfer Ownership</Table.Cell>
</Table.Row>
{crew.map((mind) => (
<Table.Row key={mind.name}>
<Table.Cell>{mind.name}</Table.Cell>
{crew.map((crew_data: CrewData) => (
<Table.Row key={crew_data.name}>
<Table.Cell>{crew_data.name}</Table.Cell>
<Table.Cell>
<Button.Checkbox
content="Candidate"
checked={mind.allowed}
checked={crew_data.allowed}
onClick={() =>
act('toggleCandidate', {
ref: mind.ref,
ref: crew_data.ref,
})
}
/>
Expand All @@ -163,7 +197,7 @@ const ShipOwnerContent = (props, context) => {
content="Transfer Owner"
onClick={() =>
act('transferOwner', {
ref: mind.ref,
ref: crew_data.ref,
})
}
/>
Expand All @@ -184,13 +218,18 @@ const ShipOwnerContent = (props, context) => {
<Table.Cell>Job Name</Table.Cell>
<Table.Cell>Slots</Table.Cell>
</Table.Row>
{jobs.map((job) => (
{jobs.map((job: JobData) => (
<Table.Row key={job.name}>
<Table.Cell>{job.name}</Table.Cell>
<Table.Cell>
<Button
content="+"
disabled={cooldown > 0 || job.slots >= job.max}
disabled={!isAdmin || cooldown > 0 || job.slots >= job.max}
tooltip={
!isAdmin
? 'You must be an admin to increase job slots'
: undefined
}
color={job.slots >= job.def ? 'average' : 'default'}
onClick={() =>
act('adjustJobSlot', {
Expand Down

0 comments on commit 238d8e0

Please sign in to comment.