Implement a diner where food can be bought.
This commit is contained in:
parent
704b760c52
commit
8461f36fa6
@ -63,6 +63,7 @@ pub mod say;
|
||||
mod score;
|
||||
mod sign;
|
||||
pub mod sit;
|
||||
mod staff_show;
|
||||
pub mod stand;
|
||||
mod status;
|
||||
mod uninstall;
|
||||
@ -248,6 +249,7 @@ static REGISTERED_COMMANDS: UserVerbRegistry = phf_map! {
|
||||
|
||||
static STAFF_COMMANDS: UserVerbRegistry = phf_map! {
|
||||
"staff_reset_spawns" => reset_spawns::VERB,
|
||||
"staff_show" => staff_show::VERB,
|
||||
};
|
||||
|
||||
fn resolve_handler(ctx: &VerbContext, cmd: &str) -> Option<&'static UserVerbRef> {
|
||||
|
@ -0,0 +1,52 @@
|
||||
use super::{
|
||||
get_player_item_or_fail, user_error, UResult, UserError, UserVerb, UserVerbRef, VerbContext,
|
||||
};
|
||||
use crate::static_content::room;
|
||||
use async_trait::async_trait;
|
||||
|
||||
pub struct Verb;
|
||||
#[async_trait]
|
||||
impl UserVerb for Verb {
|
||||
async fn handle(
|
||||
self: &Self,
|
||||
ctx: &mut VerbContext,
|
||||
_verb: &str,
|
||||
remaining: &str,
|
||||
) -> UResult<()> {
|
||||
let requester = get_player_item_or_fail(ctx).await?;
|
||||
let mut resp: String = String::new();
|
||||
if remaining == "loc" {
|
||||
let (loc_type, loc_code) = requester
|
||||
.location
|
||||
.split_once("/")
|
||||
.ok_or_else(|| UserError("Invalid current location string".to_owned()))?;
|
||||
resp.push_str(&format!("Location code: {}\n", loc_code));
|
||||
if loc_type == "room" {
|
||||
resp.push_str("You're in an ordinary room.\n");
|
||||
let room = room::room_map_by_code().get(loc_code).ok_or_else(|| {
|
||||
UserError("Can't find your current room in static data".to_owned())
|
||||
})?;
|
||||
resp.push_str(&format!(
|
||||
"Grid coords: x={}, y={}, z={}. Coordinates get lower as you go \
|
||||
north, west, down.\n",
|
||||
room.grid_coords.x, room.grid_coords.y, room.grid_coords.z
|
||||
));
|
||||
} else if loc_type == "dynroom" {
|
||||
resp.push_str("You're in a dynamic room.\n");
|
||||
} else {
|
||||
resp.push_str(&format!(
|
||||
"Weird - you're in a location of type {}.\n",
|
||||
loc_type
|
||||
));
|
||||
}
|
||||
} else {
|
||||
user_error("Unknown subcommand.".to_owned())?;
|
||||
}
|
||||
ctx.trans
|
||||
.queue_for_session(&ctx.session, Some(&resp))
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
static VERB_INT: Verb = Verb;
|
||||
pub static VERB: UserVerbRef = &VERB_INT as UserVerbRef;
|
@ -21,6 +21,7 @@ mod books;
|
||||
mod bottles;
|
||||
mod corp_licence;
|
||||
mod fangs;
|
||||
mod food;
|
||||
pub mod head_armour;
|
||||
mod lock;
|
||||
pub mod lower_armour;
|
||||
@ -424,6 +425,7 @@ pub enum PossessionType {
|
||||
Scanlock,
|
||||
// Food
|
||||
GrilledSteak,
|
||||
GreasyBurger,
|
||||
// Crafting inputs
|
||||
Steak,
|
||||
AnimalSkin,
|
||||
@ -516,6 +518,7 @@ pub fn possession_data() -> &'static BTreeMap<PossessionType, &'static Possessio
|
||||
)
|
||||
.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)))
|
||||
.chain(
|
||||
head_armour::data()
|
||||
.iter()
|
||||
|
47
blastmud_game/src/static_content/possession_type/food.rs
Normal file
47
blastmud_game/src/static_content/possession_type/food.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use crate::static_content::possession_type::EatData;
|
||||
|
||||
use super::{ChargeData, PossessionData, PossessionType};
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
pub fn data() -> &'static Vec<(PossessionType, PossessionData)> {
|
||||
static D: OnceCell<Vec<(PossessionType, PossessionData)>> = OnceCell::new();
|
||||
&D.get_or_init(|| vec!(
|
||||
(
|
||||
PossessionType::GrilledSteak,
|
||||
PossessionData {
|
||||
display: "grilled steak",
|
||||
details: "A mouth-wateringly grilled steak, its outer brown surface a perfect demonstration of the Maillard reaction, with a thin bit of fat adjoining the lean protein",
|
||||
weight: 250,
|
||||
eat_data: Some(EatData {
|
||||
hunger_impact: -600,
|
||||
thirst_impact: 0,
|
||||
}),
|
||||
charge_data: Some(ChargeData {
|
||||
max_charges: 20,
|
||||
charge_name_prefix: "bite",
|
||||
charge_name_suffix: "of food",
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
),
|
||||
(
|
||||
PossessionType::GreasyBurger,
|
||||
PossessionData {
|
||||
display: "greasy burger",
|
||||
aliases: vec!("burger"),
|
||||
details: "A burger with an egg, some bacon, and a comparatively small looking slice of tomato, between two plain white soft burger buns, and slathered in mayonaise",
|
||||
weight: 250,
|
||||
eat_data: Some(EatData {
|
||||
hunger_impact: -300,
|
||||
thirst_impact: 0,
|
||||
}),
|
||||
charge_data: Some(ChargeData {
|
||||
max_charges: 20,
|
||||
charge_name_prefix: "bite",
|
||||
charge_name_suffix: "of food",
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
),
|
||||
))
|
||||
}
|
@ -43,23 +43,5 @@ pub fn data() -> &'static Vec<(PossessionType, PossessionData)> {
|
||||
..Default::default()
|
||||
}
|
||||
),
|
||||
(
|
||||
PossessionType::GrilledSteak,
|
||||
PossessionData {
|
||||
display: "grilled steak",
|
||||
details: "A mouth-wateringly grilled steak, its outer brown surface a perfect demonstration of the Maillard reaction, with a thin bit of fat adjoining the lean protein",
|
||||
weight: 250,
|
||||
eat_data: Some(EatData {
|
||||
hunger_impact: -600,
|
||||
thirst_impact: 0,
|
||||
}),
|
||||
charge_data: Some(ChargeData {
|
||||
max_charges: 20,
|
||||
charge_name_prefix: "bite",
|
||||
charge_name_suffix: "of food",
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
),
|
||||
))
|
||||
}
|
||||
|
@ -90,10 +90,39 @@ pub fn room_list() -> Vec<Room> {
|
||||
direction: Direction::SOUTH,
|
||||
..Default::default()
|
||||
},
|
||||
Exit {
|
||||
direction: Direction::EAST,
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
should_caption: false,
|
||||
..Default::default()
|
||||
},
|
||||
Room {
|
||||
zone: "melbs",
|
||||
secondary_zones: vec!(),
|
||||
code: "melbs_jills_diner",
|
||||
name: "Jill's Diner",
|
||||
short: ansi!("<bgblue><white>JD<reset>"),
|
||||
description: "A dated looking eatery that looks like it has existed long before the collapse. Inside the diner is speckled white linoleum floors that run up to the walls. The smell of bacon grease pervades the air, reminding you of the purpose of this venue with every breath you take. Tables of various sizes are set out for diners to sit at, and at the back is a kitchen. The kitchen whirs with stainless steel exhaust pans, as cooks appear to do nothing but frying. Separating the kitchen from the dining area, and running the width of the restaurant, runs a counter. Hanging signs convey a menu in hand-painted black on white. A middle-aged woman sits behind the counter, looking eager to take your order.",
|
||||
description_less_explicit: None,
|
||||
grid_coords: GridCoords { x: 2, y: -2, z: 0 },
|
||||
exits: vec!(
|
||||
Exit {
|
||||
direction: Direction::WEST,
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
stock_list: vec![
|
||||
RoomStock {
|
||||
possession_type: PossessionType::GreasyBurger,
|
||||
list_price: 5,
|
||||
..Default::default()
|
||||
}
|
||||
],
|
||||
should_caption: false,
|
||||
..Default::default()
|
||||
},
|
||||
Room {
|
||||
zone: "melbs",
|
||||
secondary_zones: vec!(),
|
||||
|
Loading…
Reference in New Issue
Block a user