Implement homeless shelter.

This commit is contained in:
Condorra 2023-01-08 00:18:56 +11:00
parent 1f3fbd28bf
commit 2efc309d78
5 changed files with 212 additions and 18 deletions

View File

@ -285,7 +285,7 @@ impl DBTrans {
// Only copy more permanent fields, others are supposed to change over time and shouldn't
// be reset on restart.
for to_copy in ["display", "display_less_explicit", "details", "details_less_explicit",
"total_xp", "total_stats", "total_skills", "pronouns"] {
"total_xp", "total_stats", "total_skills", "pronouns", "flags"] {
det_ex = format!("jsonb_set({}, '{{{}}}', ${})", det_ex, to_copy, var_id);
params.push(obj_map.get(to_copy).unwrap_or(&Value::Null));
var_id += 1;

View File

@ -3,7 +3,7 @@ use super::{VerbContext, UserVerb, UserVerbRef, UResult, UserError, user_error,
use async_trait::async_trait;
use ansi::{ansi, flow_around, word_wrap};
use crate::db::ItemSearchParams;
use crate::models::{item::{Item, LocationActionType, Subattack}};
use crate::models::{item::{Item, LocationActionType, Subattack, ItemFlag}};
use crate::static_content::room::{self, Direction};
use itertools::Itertools;
use std::sync::Arc;
@ -75,6 +75,9 @@ pub async fn describe_room(ctx: &VerbContext<'_>, item: &Item,
}
async fn list_item_contents<'l>(ctx: &'l VerbContext<'_>, item: &'l Item) -> UResult<String> {
if item.flags.contains(&ItemFlag::NoSeeContents) {
return Ok(" It is too foggy to see who or what else is here.".to_owned());
}
let mut buf = String::new();
let mut items = ctx.trans.find_items_by_location(&format!("{}/{}",
item.item_type, item.item_code)).await?;

View File

@ -108,7 +108,8 @@ pub enum Sex {
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub enum ItemFlag {
NoSay
NoSay,
NoSeeContents
}
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]

View File

@ -181,8 +181,8 @@ mod test {
for type_group in registry.iter() {
let iterator : Box<dyn Iterator<Item = StaticTask>> = (type_group.things)();
let duplicates: Vec<&'static str> = iterator
.group_by(|x| x.task_code)
let duplicates: Vec<String> = iterator
.group_by(|x| x.task_code.clone())
.into_iter()
.filter_map(|(k, v)| if v.count() <= 1 { None } else { Some(k) })
.collect();

File diff suppressed because it is too large Load Diff