Skip to content

Commit

Permalink
Revive research card swiping rework (#6714)
Browse files Browse the repository at this point in the history
# About the pull request

This PR revives #6625 

# Explain why it's good for the game

More intuitive credit reward for research getting a survivor to swipe
their card so there isn't a meta strategy for the best utilization of
credits. Now at most 47 credits can be awarded (for a manager survivor's
card; only allowed to be swiped by them) regardless of whatever the
current research clearance is at.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl: Drathek iloveloopers
del: Removed ability to buy clearance papers.
balance: Clearance cards now give their equivalent clearance in credits.
balance: Clearance cards no longer lose their value when scanned by the
wrong person.
/:cl:

---------

Co-authored-by: iloveloopers <[email protected]>
Co-authored-by: iloveloopers <[email protected]>
  • Loading branch information
3 people authored Aug 5, 2024
1 parent 10ea9b2 commit 5b886ae
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 115 deletions.
56 changes: 10 additions & 46 deletions code/game/machinery/computer/research.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,24 @@
GLOB.chemical_data.update_credits(cred.credit_value)
visible_message(SPAN_NOTICE("[user] inserts [cred] in [src], collecting [cred.credit_value] points from sales."))
qdel(cred)
//Clearance Updating
//Clearance Card Updating
if(!istype(B, /obj/item/card/id))
return
var/obj/item/card/id/silver/clearance_badge/card = B
if(!istype(card))
visible_message(SPAN_NOTICE("[user] swipes their ID card on \the [src], but it is refused."))
visible_message(SPAN_NOTICE("[user] swipes their ID card on [src], but it is refused."))
return
if(card.clearance_access <= GLOB.chemical_data.clearance_level || (card.clearance_access == 6 && GLOB.chemical_data.clearance_level >= 5 && GLOB.chemical_data.clearance_x_access))
visible_message(SPAN_NOTICE("[user] swipes the clearance card on [src], but nothing happens."))
if(!card.check_biometrics(user))
visible_message(SPAN_WARNING("WARNING: ILLEGAL CLEARANCE USER DETECTED. ABORTING."))
return
if(user.real_name != card.registered_name)
visible_message(SPAN_WARNING("WARNING: ILLEGAL CLEARANCE USER DETECTED. CARD DATA HAS BEEN WIPED."))
card.clearance_access = 0
return

var/give_level
var/give_x = FALSE
if(card.clearance_access == 6)
give_level = 5
give_x = TRUE
else
give_level = card.clearance_access

GLOB.chemical_data.clearance_level = give_level
if(give_x)
GLOB.chemical_data.clearance_x_access = TRUE
GLOB.chemical_data.reached_x_access = TRUE
var/credits_to_add = max(card.credits_to_give - GLOB.chemical_data.credits_gained, 0)
if(credits_to_add)
GLOB.chemical_data.update_credits(credits_to_add)
GLOB.chemical_data.credits_gained += credits_to_add

visible_message(SPAN_NOTICE("[user] swipes their ID card on \the [src], updating the clearance to level [give_level][give_x ? "X" : ""]."))
msg_admin_niche("[key_name(user)] has updated the research clearance to level [give_level][give_x ? "X" : ""].")
visible_message(SPAN_NOTICE("[user] swipes their ID card on [src], granting [credits_to_add] credits."))
msg_admin_niche("[key_name(user)] has swiped a clearance card to give [credits_to_add] credits to research.")
return

/obj/structure/machinery/computer/research/ui_state(mob/user)
Expand Down Expand Up @@ -181,30 +169,6 @@
if(5)
new /obj/item/paper/research_notes/unique/tier_five/(photocopier.loc)
max_clearance = 5
if("purchase_document")
if(!photocopier)
return
var/purchase_tier = floor(text2num(params["purchase_document"]))
if(purchase_tier <= 0 || purchase_tier > 5)
return
if(purchase_tier > GLOB.chemical_data.clearance_level)
return
var/purchase_cost = base_purchase_cost + purchase_tier * 2
if(purchase_cost <= GLOB.chemical_data.rsc_credits)
GLOB.chemical_data.update_credits(purchase_cost * -1)
var/obj/item/paper/research_notes/unique/N
switch(purchase_tier)
if(1)
N = new /obj/item/paper/research_notes/unique/tier_one/(photocopier.loc)
if(2)
N = new /obj/item/paper/research_notes/unique/tier_two/(photocopier.loc)
if(3)
N = new /obj/item/paper/research_notes/unique/tier_three/(photocopier.loc)
if(4)
N = new /obj/item/paper/research_notes/unique/tier_four/(photocopier.loc)
else
N = new /obj/item/paper/research_notes/unique/tier_five/(photocopier.loc)
visible_message(SPAN_NOTICE("Research report for [N.data.name] has been purchased."))
if("publish_document")
var/print_type = params["print_type"]
var/print_title = params["print_title"]
Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/items/cards_ids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,24 @@
name = "corporate doctor badge"
desc = "A corporate holo-badge. It is fingerprint locked with clearance level 3 access. It is commonly held by corporate doctors."
icon_state = "clearance"
var/clearance_access = 3
var/credits_to_give = 15 //gives the equivalent clearance access in credits

/obj/item/card/id/silver/clearance_badge/scientist
name = "corporate scientist badge"
desc = "A corporate holo-badge. It is fingerprint locked with clearance level 4 access. It is commonly held by corporate scientists."
clearance_access = 4
credits_to_give = 27

/obj/item/card/id/silver/clearance_badge/cl
name = "corporate liaison badge"
desc = "A corporate holo-badge in unique corporate orange and white. It is fingerprint locked with clearance level 5 access. It is commonly held by corporate liaisons."
icon_state = "cl"
clearance_access = 5
credits_to_give = 42

/obj/item/card/id/silver/clearance_badge/manager
name = "corporate manager badge"
desc = "A corporate holo-badge in standard corporate orange and white. It has a unique uncapped bottom. It is fingerprint locked with 5-X clearance level. Commonly held by corporate managers."
icon_state = "pmc"
clearance_access = 6
credits_to_give = 47

/obj/item/card/id/pizza
name = "pizza guy badge"
Expand Down
2 changes: 2 additions & 0 deletions code/modules/reagents/chemical_research/Chemical-Research.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ GLOBAL_DATUM_INIT(chemical_data, /datum/chemical_data, new)
/datum/chemical_data
var/rsc_credits = 0
var/clearance_level = 1
///credits gained from survivor clearance cards
var/credits_gained = 0
var/clearance_x_access = FALSE
var/reached_x_access = FALSE
var/has_new_properties = FALSE
Expand Down
65 changes: 0 additions & 65 deletions tgui/packages/tgui/interfaces/ResearchTerminal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState } from 'react';

import { classes } from '../../common/react';
import { useBackend } from '../backend';
import { Box, Button, Flex, Section, Stack, Tabs } from '../components';
import { BoxProps } from '../components/Box';
Expand Down Expand Up @@ -32,69 +31,6 @@ interface TerminalProps {
printer_toner: number;
}

const PurchaseDocs = () => {
const { data, act } = useBackend<TerminalProps>();
const [purchaseSelection, setPurchaseSelection] = useState('0');
const clearance_level = data.clearance_level;
const all_levels = ['1', '2', '3', '4', '5'];
const costs = { '1': 7, '2': 9, '3': 11, '4': 13, '5': 15 };
const available_levels = Array.from(Array(clearance_level).keys()).map((x) =>
(x + 1).toString(),
);

return (
<Stack vertical>
<Stack.Item>
<span>Purchase Reports</span>
<hr />
</Stack.Item>

<Stack.Item>
<Flex justify="space-between" fill={1} className="purchase-flex">
{all_levels.map((x) => {
const isDisabled =
!available_levels.includes(x) || costs[x] > data.rsc_credits;
return (
<Flex.Item key={x}>
<Button
className={classes([
!available_levels.includes(x) && 'HiddenButton',
])}
disabled={isDisabled}
onClick={() => setPurchaseSelection(x)}
>
Level {x} {costs[x]}CR
</Button>
</Flex.Item>
);
})}
</Flex>
</Stack.Item>
<hr />
{purchaseSelection !== '0' && (
<Flex.Item>
<ConfirmationDialogue
onConfirm={() => {
act('purchase_document', {
purchase_document: purchaseSelection,
});
setPurchaseSelection('0');
}}
onCancel={() => setPurchaseSelection('0')}
>
<span>
Are you sure you want to purchase a level{' '}
<u>{purchaseSelection}</u> document?
<br />
It will cost <u>{costs[purchaseSelection]}</u> credits.
</span>
</ConfirmationDialogue>
</Flex.Item>
)}
</Stack>
);
};

interface ConfirmationProps extends BoxProps {
readonly onConfirm: () => any;
readonly onCancel: () => any;
Expand Down Expand Up @@ -486,7 +422,6 @@ const ResearchManager = (props: {
</Stack.Item>
</Stack>
<hr />
<PurchaseDocs />
<ImproveClearanceConfirmation
isConfirm={isConfirm}
setConfirm={setConfirm}
Expand Down

0 comments on commit 5b886ae

Please sign in to comment.