Allow completing a test to get a rad permit.

This commit is contained in:
Condorra 2024-03-17 16:25:04 +11:00
parent f6cda9a0b8
commit 8769c8c6eb
8 changed files with 161 additions and 3 deletions

View File

@ -12,6 +12,7 @@ pub enum JournalType {
Died,
SharedWithPlayer,
BribedJosephineForRedCode,
GotRadPermit,
}
#[derive(Serialize, Deserialize, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]

View File

@ -72,6 +72,11 @@ pub fn journal_types() -> &'static BTreeMap<JournalType, JournalData> {
details: "got the red code off Josephine by selling lots of blades",
xp: 250,
}),
(JournalType::GotRadPermit, JournalData {
name: "Got rad permit",
details: "passed a test and all you got was a stinking permit",
xp: 200,
}),
).into_iter().collect());
}

View File

@ -33,6 +33,7 @@ pub mod lights;
pub mod lock;
pub mod lower_armour;
mod meat;
mod testpapers;
pub mod torso_armour;
mod trauma_kit;
mod whip;
@ -429,6 +430,8 @@ pub enum PossessionType {
// Corporate
NewCorpLicence,
CertificateOfIncorporation,
// Tests
RadSafetyTest,
// Storage
DuffelBag,
// Fluid containers
@ -555,6 +558,7 @@ pub fn possession_data() -> &'static BTreeMap<PossessionType, &'static Possessio
.iter()
.map(|v| ((*v).0.clone(), &(*v).1)),
)
.chain(testpapers::data().iter().map(|v| ((*v).0.clone(), &(*v).1)))
.chain(lock::data().iter().map(|v| ((*v).0.clone(), &(*v).1)))
.chain(meat::data().iter().map(|v| ((*v).0.clone(), &(*v).1)))
.chain(food::data().iter().map(|v| ((*v).0.clone(), &(*v).1)))

View File

@ -0,0 +1,129 @@
use crate::{
message_handler::user_commands::{user_error, UResult, VerbContext},
models::{item::Item, journal::JournalType},
static_content::{journals::award_journal_if_needed, room::ScanCode},
};
use ansi::ansi;
use async_trait::async_trait;
use once_cell::sync::OnceCell;
use super::{PossessionData, PossessionType, WriteHandler};
pub struct RadTestHandler {}
#[async_trait]
impl WriteHandler for RadTestHandler {
async fn write_cmd(
&self,
ctx: &mut VerbContext,
player: &Item,
on_what: &Item,
write_what: &str,
) -> UResult<()> {
let input = write_what.trim().to_uppercase();
if player.location != "room/oorans_testing" {
user_error(
"You realise you are probably supposed to do this in the testing centre."
.to_owned(),
)?;
}
if input.len() != 4 {
user_error(
"You realise you'll need to write 4 letters to complete the test.".to_owned(),
)?;
}
if input.chars().any(|x| !"ABCD".contains(x)) {
user_error("You realise you can only pick A, B, C or D for each answer.".to_owned())?;
}
let wrong = input
.chars()
.zip("BCAC".chars())
.filter(|(x, y)| x != y)
.count();
if wrong > 0 {
ctx.trans
.queue_for_session(
ctx.session,
Some(&format!(
"The pen makes a scratching sound as you mark the paper with it. An invigilator passes by, sees you have \
completed your test, and shakes her head. \"You got {} wrong!\", she says, \"Radiation safety is very \
important, so we'll have to fail you. Try visting the OORANS Training Centre before re-attempting the \
test\"! She takes the spoiled test off you.\n",
wrong
)),
)
.await?;
} else {
ctx.trans.queue_for_session(ctx.session,
Some("The pen makes a scratching sound as you mark the paper with it. An invigilator passes by, sees you have \
completed your test, and smiles at you. \"Congratulations\", she says, \"You got 100%, and so are eligible \
for a permit to travel to radiation contaminated areas! Be safe out there\"! She takes the completed test off you, and holds her wristpad up to yours, causing yours to beep and show a copy of the permit.\n")
).await?;
if let Some(user) = ctx.user_dat.as_mut() {
let mut player = (*player).clone();
let awarded_journal = award_journal_if_needed(
&ctx.trans,
user,
&mut player,
JournalType::GotRadPermit,
)
.await?;
if awarded_journal {
ctx.trans.save_item_model(&player).await?;
}
let added_permit = if !user.scan_codes.contains(&ScanCode::RadPermit) {
user.scan_codes.push(ScanCode::RadPermit);
true
} else {
false
};
if awarded_journal || added_permit {
ctx.trans.save_user_model(user).await?;
}
}
}
ctx.trans
.delete_item(&on_what.item_type, &on_what.item_code)
.await?;
Ok(())
}
}
static RADTEST_HANDLER: RadTestHandler = RadTestHandler {};
pub fn data() -> &'static Vec<(PossessionType, PossessionData)> {
static D: OnceCell<Vec<(PossessionType, PossessionData)>> = OnceCell::new();
&D.get_or_init(|| vec!(
(PossessionType::RadSafetyTest,
PossessionData {
display: "a radiation safety test paper",
details: ansi!("A test paper that looks like it is for a multiple choice test. The heading reads \"Radiation Safety Licence Test\". Bold text below it says: \"Test-takers beware! To ensure academic integrity, it is not possible to erase your answers once written - you'll only get one attempt and need to buy a new paper if you spoil it. Write your answers using the letter of your choice, in all caps, with no spaces. For example, to answer A for question 1, B for question 2, C for question 3, and D for question 4, you would <bold>write ABCD on test<reset>.\n\n\
Question 1: Suppose a person was to spend a long time walking in a heavily contaminated radfield with no special equipment. What would happen?\n\
A: Nothing would happen, as long as they didn't eat the contaminated dirt.\n\
B: They would not immediately feel any ill effects, but would eventually succomb to radiation poisoning.\n\
C: They would immediately feel a burning sensation from the ionising radiation, due to the area being radiologically hot.\n\
D: They would be able to tell the area is contaminated because it gives off a green glow.\n\
Question 2: What device can measure how much ionising radiation is in an area?\n\
A: A Dowsing Rod.\n\
B: A Colourimetric Radiation Detector.\n\
C: A Geiger Counter.\n\
D: A Schottky Power Detector.\n\
Question 3: How can you reduce your ionising radiation exposure while travelling in a contaminated area?\n\
A: Wear an OORANS certified radiation suit.\n\
B: Use a safety shower immediately after travelling.\n\
C: Eat a small amount of fallout dust daily to build up resistance.\n\
D: Move back and forwards within the contaminated area to ensure radiation misses you.\n\
Question 4: What should you do if you are accidentally exposed to ionising radiation?\n\
A: Walk backwards through the area you were exposed to reverse the effect.\n\
B: Go to the Melbs General Hospital.\n\
C: Find someone skilled as a medic and ask them to use a rad detox kit on you.\n\
D: Nothing, radiation isn't dangerous"),
aliases: vec!("test paper"),
weight: 10,
write_handler: Some(&RADTEST_HANDLER),
..Default::default()
}),
))
}

View File

@ -456,6 +456,7 @@ pub struct RoomStock {
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum ScanCode {
SewerAccess,
RadPermit,
RedImperialCode,
}

View File

@ -62,7 +62,7 @@ pub fn fixed_items() -> Vec<FixedItem> {
pin_sequence: "KINGSOFF".to_owned()
}),
..Default::default()
}
},
]
}

View File

@ -1618,12 +1618,11 @@
secondary_zones:
- zone: melbs
short: <bgblack><yellow>RN<reset>
name: OORANS
caption: OORANS
grid_coords:
x: 6
y: 6
z: 0
caption: Melbs
description: |-
A room, painted completely white. Navy blue carpet tiles cover the floor, their weave alternating in direction. On the wall, a white sign features a slick swirly logo, beneath which are the letters OORANS. Underneath this is the printed text "Office of Radiological and Nuclear Safety. By authority of the ". Someone has rubbed out the printed text at the end, although you can still see a faint remnant of the word Empire, and written "King" in some kind of marker pen
short: <bgblack><yellow>LO<reset>
@ -1634,6 +1633,7 @@
exits:
- direction: west
- direction: east
- direction: north
- zone: oorans
code: oorans_training
name: OORANS Training Centre
@ -1667,6 +1667,21 @@
z: 0
exits:
- direction: west
- zone: oorans
code: oorans_testing
name: OORANS Testing Centre
description: |-
A room, painted completely white. The room has rows of desks, each with a pen attached by a string. Stern looking invigilators pace up and down the room ensuring that no one cheats on the test. At the front, it looks like you can <bold>buy<reset> test papers from the head invigilator to sit the test for a permit to access fallout contaminated areas
short: <bgblack><yellow>TE<reset>
grid_coords:
x: 1
y: -1
z: 0
exits:
- direction: south
stock_list:
- possession_type: !RadSafetyTest
list_price: 1000
- zone: melbs
code: melbs_williamsst_collinsst
name: Williams St & Collins St

View File

@ -17,6 +17,9 @@
description: "The start of a deteriorating asphalt road that leads north through a barren dusty environment. The road is blocked by a barrier arm. The arm is attached to a box with a window in it, occupied by a guard in a fluorescent yellow high-visibility vest. The side of the box is painted with a symbol featuring three black wedges arranged circularly around a central black circle, on a yellow background. Beneath it is the text: <red>DANGER - FALLOUT - Ionising Radiation Hazard. Access to the radfields by permit only<reset>"
exits:
- direction: north
needs_scan:
need_scancode: !RadPermit
block_message: "The guard in the box bellows out: <blue>Stop right there and turn around! It's a fallout contaminated area past here, and your wristpad is scanning up as not having a permit. Unless you have a permit from OORANS near the King's Office, I can't let you access the radfields\"!<reset> The barrier arm remains firmly shut, blocking your way"
- direction: south
target: !Custom room/melbs_latrobest_140
- zone: northern_radfields