Compare commits
No commits in common. "169e56dc84c9f9abd5b58fe6a28f8a06d146f75d" and "15b96c1b509e1f6bd77b51e414a9440a718f3634" have entirely different histories.
169e56dc84
...
15b96c1b50
@ -55,7 +55,6 @@ pub mod open;
|
|||||||
mod page;
|
mod page;
|
||||||
pub mod parsing;
|
pub mod parsing;
|
||||||
pub mod pay;
|
pub mod pay;
|
||||||
pub mod plug;
|
|
||||||
mod pow;
|
mod pow;
|
||||||
pub mod put;
|
pub mod put;
|
||||||
mod quit;
|
mod quit;
|
||||||
@ -199,8 +198,6 @@ static REGISTERED_COMMANDS: UserVerbRegistry = phf_map! {
|
|||||||
"l" => look::VERB,
|
"l" => look::VERB,
|
||||||
"look" => look::VERB,
|
"look" => look::VERB,
|
||||||
"read" => look::VERB,
|
"read" => look::VERB,
|
||||||
"examine" => look::VERB,
|
|
||||||
"ex" => look::VERB,
|
|
||||||
|
|
||||||
"feint" => feint::VERB,
|
"feint" => feint::VERB,
|
||||||
"list" => list::VERB,
|
"list" => list::VERB,
|
||||||
@ -224,7 +221,6 @@ static REGISTERED_COMMANDS: UserVerbRegistry = phf_map! {
|
|||||||
"reply" => page::VERB,
|
"reply" => page::VERB,
|
||||||
|
|
||||||
"pay" => pay::VERB,
|
"pay" => pay::VERB,
|
||||||
"plug" => plug::VERB,
|
|
||||||
|
|
||||||
"pow" => pow::VERB,
|
"pow" => pow::VERB,
|
||||||
"power" => pow::VERB,
|
"power" => pow::VERB,
|
||||||
|
@ -114,7 +114,6 @@ impl QueueCommandHandler for QueueHandler {
|
|||||||
&item.display_for_sentence(1, false)
|
&item.display_for_sentence(1, false)
|
||||||
))?
|
))?
|
||||||
}
|
}
|
||||||
ctx.trans.delete_task("ChargeItem", &item.refstr()).await?;
|
|
||||||
|
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"{} picks up {}\n",
|
"{} picks up {}\n",
|
||||||
|
@ -50,7 +50,7 @@ pub async fn announce_move(
|
|||||||
arriving: &Item,
|
arriving: &Item,
|
||||||
) -> DResult<()> {
|
) -> DResult<()> {
|
||||||
let msg_leaving = format!(
|
let msg_leaving = format!(
|
||||||
"{} departs towards {}.\n",
|
"{} departs towards {}\n",
|
||||||
&character.display_for_sentence(1, true),
|
&character.display_for_sentence(1, true),
|
||||||
&arriving.display
|
&arriving.display
|
||||||
);
|
);
|
||||||
@ -63,7 +63,7 @@ pub async fn announce_move(
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let msg_arriving = format!(
|
let msg_arriving = format!(
|
||||||
"{} arrives from {}.\n",
|
"{} arrives from {}\n",
|
||||||
&character.display_for_sentence(1, true),
|
&character.display_for_sentence(1, true),
|
||||||
&leaving.display
|
&leaving.display
|
||||||
);
|
);
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
use crate::{
|
|
||||||
db::ItemSearchParams,
|
|
||||||
models::{
|
|
||||||
item::ItemSpecialData,
|
|
||||||
task::{Task, TaskDetails, TaskMeta},
|
|
||||||
},
|
|
||||||
services::comms::broadcast_to_room,
|
|
||||||
static_content::{
|
|
||||||
dynzone::{dynzone_by_type, DynzoneType},
|
|
||||||
possession_type::possession_data,
|
|
||||||
room::room_map_by_code,
|
|
||||||
},
|
|
||||||
DResult,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
|
||||||
get_player_item_or_fail, search_item_for_user, user_error, CommandHandlingError, UResult,
|
|
||||||
UserError, UserVerb, UserVerbRef, VerbContext,
|
|
||||||
};
|
|
||||||
#[double]
|
|
||||||
use crate::db::DBTrans;
|
|
||||||
use ansi::ansi;
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use chrono::{Duration, Utc};
|
|
||||||
use mockall_double::double;
|
|
||||||
|
|
||||||
async fn place_has_power(trans: &DBTrans, place_type: &str, place_code: &str) -> DResult<bool> {
|
|
||||||
match place_type {
|
|
||||||
"room" => room_map_by_code()
|
|
||||||
.get(place_code)
|
|
||||||
.map(|r| Ok(r.has_power))
|
|
||||||
.unwrap_or(Ok(false)),
|
|
||||||
"dynroom" => trans
|
|
||||||
.find_item_by_type_code(place_type, place_code)
|
|
||||||
.await?
|
|
||||||
.and_then(|place| match place.special_data.as_ref() {
|
|
||||||
Some(ItemSpecialData::DynroomData {
|
|
||||||
dynzone_code,
|
|
||||||
dynroom_code,
|
|
||||||
}) => DynzoneType::from_str(&dynzone_code)
|
|
||||||
.and_then(|dzt| dynzone_by_type().get(&dzt))
|
|
||||||
.and_then(|dz| dz.dyn_rooms.get(dynroom_code.as_str()))
|
|
||||||
.map(|dr| Ok(dr.has_power)),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.unwrap_or(Ok(false)),
|
|
||||||
_ => Ok(false),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Verb;
|
|
||||||
#[async_trait]
|
|
||||||
impl UserVerb for Verb {
|
|
||||||
async fn handle(
|
|
||||||
self: &Self,
|
|
||||||
ctx: &mut VerbContext,
|
|
||||||
_verb: &str,
|
|
||||||
remaining: &str,
|
|
||||||
) -> UResult<()> {
|
|
||||||
let (word, remaining) = match remaining.split_once(" ") {
|
|
||||||
None => user_error(ansi!("Try <bold>plug in<reset> something").to_owned())?,
|
|
||||||
Some(v) => v,
|
|
||||||
};
|
|
||||||
if word.trim() != "in" {
|
|
||||||
user_error(ansi!("Try <bold>plug in<reset> something").to_owned())?;
|
|
||||||
}
|
|
||||||
let player_item = get_player_item_or_fail(ctx).await?;
|
|
||||||
if player_item.death_data.is_some() {
|
|
||||||
user_error("Plugging metal things in can make you dead, but being dead doesn't let you plug things in.".to_owned())?;
|
|
||||||
}
|
|
||||||
let remaining = remaining.trim();
|
|
||||||
let item = search_item_for_user(
|
|
||||||
ctx,
|
|
||||||
&ItemSearchParams {
|
|
||||||
limit: 1,
|
|
||||||
include_loc_contents: true,
|
|
||||||
item_type_only: Some("possession"),
|
|
||||||
..ItemSearchParams::base(&player_item, &remaining)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|e| match e {
|
|
||||||
CommandHandlingError::UserError(m) => CommandHandlingError::UserError(
|
|
||||||
m + " I only looked in the room - try dropping an item first.",
|
|
||||||
),
|
|
||||||
e => e,
|
|
||||||
})?;
|
|
||||||
let charge_data = match item
|
|
||||||
.possession_type
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|pt| possession_data().get(pt))
|
|
||||||
.and_then(|pd| pd.charge_data.as_ref())
|
|
||||||
{
|
|
||||||
Some(v) if v.electric_recharge => v,
|
|
||||||
_ => user_error("You can't recharge that!".to_owned())?,
|
|
||||||
};
|
|
||||||
|
|
||||||
let (place_type, place_code) = player_item
|
|
||||||
.location
|
|
||||||
.split_once("/")
|
|
||||||
.ok_or_else(|| UserError("Bad location".to_owned()))?;
|
|
||||||
if !place_has_power(&ctx.trans, place_type, place_code).await? {
|
|
||||||
user_error("You can't find any power sockets to plug in to.".to_owned())?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if item.charges >= charge_data.max_charges {
|
|
||||||
user_error("You realise it's already fully charged.".to_owned())?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let refstr = item.refstr();
|
|
||||||
if ctx
|
|
||||||
.trans
|
|
||||||
.check_task_by_type_code("ChargeItem", &refstr)
|
|
||||||
.await?
|
|
||||||
{
|
|
||||||
user_error("It's already charging!".to_owned())?;
|
|
||||||
}
|
|
||||||
ctx.trans
|
|
||||||
.upsert_task(&Task {
|
|
||||||
meta: TaskMeta {
|
|
||||||
task_code: refstr.clone(),
|
|
||||||
next_scheduled: Utc::now() + Duration::minutes(1),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
details: TaskDetails::ChargeItem { item: refstr },
|
|
||||||
})
|
|
||||||
.await?;
|
|
||||||
broadcast_to_room(
|
|
||||||
&ctx.trans,
|
|
||||||
&player_item.location,
|
|
||||||
None,
|
|
||||||
&format!(
|
|
||||||
"{} plugs in {}.\n",
|
|
||||||
&player_item.display_for_sentence(1, true),
|
|
||||||
&item.display_for_sentence(1, false)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static VERB_INT: Verb = Verb;
|
|
||||||
pub static VERB: UserVerbRef = &VERB_INT as UserVerbRef;
|
|
@ -155,7 +155,6 @@ pub struct ChargeData {
|
|||||||
pub max_charges: u8,
|
pub max_charges: u8,
|
||||||
pub charge_name_prefix: &'static str,
|
pub charge_name_prefix: &'static str,
|
||||||
pub charge_name_suffix: &'static str,
|
pub charge_name_suffix: &'static str,
|
||||||
pub electric_recharge: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ChargeData {
|
impl Default for ChargeData {
|
||||||
@ -164,7 +163,6 @@ impl Default for ChargeData {
|
|||||||
max_charges: 1,
|
max_charges: 1,
|
||||||
charge_name_prefix: "charge",
|
charge_name_prefix: "charge",
|
||||||
charge_name_suffix: "",
|
charge_name_suffix: "",
|
||||||
electric_recharge: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ pub fn data() -> &'static Vec<(PossessionType, PossessionData)> {
|
|||||||
max_charges: 20,
|
max_charges: 20,
|
||||||
charge_name_prefix: "bite",
|
charge_name_prefix: "bite",
|
||||||
charge_name_suffix: "of food",
|
charge_name_suffix: "of food",
|
||||||
..Default::default()
|
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
@ -40,7 +39,6 @@ pub fn data() -> &'static Vec<(PossessionType, PossessionData)> {
|
|||||||
max_charges: 20,
|
max_charges: 20,
|
||||||
charge_name_prefix: "bite",
|
charge_name_prefix: "bite",
|
||||||
charge_name_suffix: "of food",
|
charge_name_suffix: "of food",
|
||||||
..Default::default()
|
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -175,8 +175,6 @@ pub fn data() -> &'static Vec<(PossessionType, PossessionData)> {
|
|||||||
max_charges: 20,
|
max_charges: 20,
|
||||||
charge_name_prefix: "bar",
|
charge_name_prefix: "bar",
|
||||||
charge_name_suffix: "of power",
|
charge_name_suffix: "of power",
|
||||||
electric_recharge: true,
|
|
||||||
..ChargeData::default()
|
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})])
|
})])
|
||||||
|
@ -29,7 +29,6 @@ pub fn data() -> &'static Vec<(PossessionType, PossessionData)> {
|
|||||||
max_charges: 20,
|
max_charges: 20,
|
||||||
charge_name_prefix: "bite",
|
charge_name_prefix: "bite",
|
||||||
charge_name_suffix: "of food",
|
charge_name_suffix: "of food",
|
||||||
..Default::default()
|
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
y: 0
|
y: 0
|
||||||
z: 0
|
z: 0
|
||||||
description: "A sizeable lobby that looks like it is serves the dual purpose as the entrance to the residential condos and as a grand entrance to the linked Murlison Suites commercial building. It is tiled with sparkling clean bluestone tiles. Light green tinted tempered glass panels line the walls. You notice a set of sleek lifts, supervised by a friendly robot, and a passage to the attached Murlison commercial building to the east.\n\n\"Welcome to Condos on King!\", intones the bot, \"say <bold>in<reset> name\" with the name of the person you are here to see, and I'll guide you to their apartment. Or try <bold>rent studio<reset> to rent a studio apartment for $20 a day ($40 setup fee), and <bold>vacate studio<reset> to give notice to vacate"
|
description: "A sizeable lobby that looks like it is serves the dual purpose as the entrance to the residential condos and as a grand entrance to the linked Murlison Suites commercial building. It is tiled with sparkling clean bluestone tiles. Light green tinted tempered glass panels line the walls. You notice a set of sleek lifts, supervised by a friendly robot, and a passage to the attached Murlison commercial building to the east.\n\n\"Welcome to Condos on King!\", intones the bot, \"say <bold>in<reset> name\" with the name of the person you are here to see, and I'll guide you to their apartment. Or try <bold>rent studio<reset> to rent a studio apartment for $20 a day ($40 setup fee), and <bold>vacate studio<reset> to give notice to vacate"
|
||||||
has_power: true
|
|
||||||
exits:
|
exits:
|
||||||
- direction: west
|
- direction: west
|
||||||
target: !Custom room/melbs_kingst_80
|
target: !Custom room/melbs_kingst_80
|
||||||
@ -35,7 +34,6 @@
|
|||||||
y: 0
|
y: 0
|
||||||
z: 0
|
z: 0
|
||||||
description: "A sleek reception that could have been the bridge of a 2000s era sci-fi spaceship. Linished metal plates are lit up by ambient blue LEDs, while stone tiles cover the floor. You see a white android, complete with elegant rounded corners and glowing blue eyes.\n\n\"Welcome to Murlison Suites - the best a business can rent\", purs the bot pleasantly. \"Just say <bold>in<reset> corpname\" and I'll guide you to the suite for that corp before you can blink! Or if you hold a corp and would like to rent the best suite money can buy for it, just say <bold>rent deluxe for<reset> corpname, and I'll set you up\""
|
description: "A sleek reception that could have been the bridge of a 2000s era sci-fi spaceship. Linished metal plates are lit up by ambient blue LEDs, while stone tiles cover the floor. You see a white android, complete with elegant rounded corners and glowing blue eyes.\n\n\"Welcome to Murlison Suites - the best a business can rent\", purs the bot pleasantly. \"Just say <bold>in<reset> corpname\" and I'll guide you to the suite for that corp before you can blink! Or if you hold a corp and would like to rent the best suite money can buy for it, just say <bold>rent deluxe for<reset> corpname, and I'll set you up\""
|
||||||
has_power: true
|
|
||||||
exits:
|
exits:
|
||||||
- direction: west
|
- direction: west
|
||||||
rentable_dynzone:
|
rentable_dynzone:
|
||||||
|
@ -180,8 +180,6 @@
|
|||||||
- direction: north
|
- direction: north
|
||||||
- direction: south
|
- direction: south
|
||||||
- direction: east
|
- direction: east
|
||||||
- direction: down
|
|
||||||
target: !Custom room/melbs_sewers_1i
|
|
||||||
should_caption: false
|
should_caption: false
|
||||||
scavtable: CityStreet
|
scavtable: CityStreet
|
||||||
- zone: melbs
|
- zone: melbs
|
||||||
@ -304,8 +302,6 @@
|
|||||||
exits:
|
exits:
|
||||||
- direction: west
|
- direction: west
|
||||||
- direction: east
|
- direction: east
|
||||||
- direction: down
|
|
||||||
target: !Custom room/melbs_sewers_2o
|
|
||||||
should_caption: false
|
should_caption: false
|
||||||
scavtable: CityStreet
|
scavtable: CityStreet
|
||||||
- zone: melbs
|
- zone: melbs
|
||||||
@ -476,8 +472,6 @@
|
|||||||
- direction: north
|
- direction: north
|
||||||
- direction: west
|
- direction: west
|
||||||
- direction: east
|
- direction: east
|
||||||
- direction: down
|
|
||||||
target: !Custom room/melbs_sewers_9q
|
|
||||||
should_caption: false
|
should_caption: false
|
||||||
scavtable: CityStreet
|
scavtable: CityStreet
|
||||||
- zone: melbs
|
- zone: melbs
|
||||||
@ -591,8 +585,6 @@
|
|||||||
exits:
|
exits:
|
||||||
- direction: west
|
- direction: west
|
||||||
- direction: north
|
- direction: north
|
||||||
- direction: down
|
|
||||||
target: !Custom room/melbs_sewers_17q
|
|
||||||
should_caption: false
|
should_caption: false
|
||||||
scavtable: CityStreet
|
scavtable: CityStreet
|
||||||
- zone: melbs
|
- zone: melbs
|
||||||
@ -607,8 +599,6 @@
|
|||||||
exits:
|
exits:
|
||||||
- direction: south
|
- direction: south
|
||||||
- direction: west
|
- direction: west
|
||||||
- direction: down
|
|
||||||
target: !Custom room/melbs_sewers_17a
|
|
||||||
should_caption: false
|
should_caption: false
|
||||||
scavtable: CityStreet
|
scavtable: CityStreet
|
||||||
- zone: melbs
|
- zone: melbs
|
||||||
@ -723,8 +713,6 @@
|
|||||||
- direction: north
|
- direction: north
|
||||||
- direction: south
|
- direction: south
|
||||||
- direction: west
|
- direction: west
|
||||||
- direction: down
|
|
||||||
target: !Custom room/melbs_sewers_17i
|
|
||||||
should_caption: false
|
should_caption: false
|
||||||
scavtable: CityStreet
|
scavtable: CityStreet
|
||||||
- zone: melbs
|
- zone: melbs
|
||||||
@ -937,8 +925,6 @@
|
|||||||
- direction: south
|
- direction: south
|
||||||
- direction: west
|
- direction: west
|
||||||
- direction: east
|
- direction: east
|
||||||
- direction: down
|
|
||||||
target: !Custom room/melbs_sewers_9a
|
|
||||||
should_caption: false
|
should_caption: false
|
||||||
scavtable: CityStreet
|
scavtable: CityStreet
|
||||||
- zone: melbs
|
- zone: melbs
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 65 KiB |
Loading…
Reference in New Issue
Block a user