Change location field to region during scene creation

This commit is contained in:
projectmoon 2024-01-12 22:00:14 +01:00
parent d5fb204df4
commit 8cdd20c2aa
6 changed files with 35 additions and 33 deletions

View File

@ -245,7 +245,7 @@ impl AiLogic {
let mut scene = Scene {
_key: Some(new_uuid_string()),
name: scene_seed.name,
location: scene_seed.location,
region: scene_seed.region,
description: scene_seed.description,
props: scene_seed.props.drain(0..).map_into().collect(),
is_stub: false,

View File

@ -136,7 +136,7 @@ fn stage_info(stage: &Stage) -> String {
info.push_str("\n");
info.push_str(" - Location: ");
info.push_str(&stage.scene.location);
info.push_str(&stage.scene.region);
info.push_str("\n");
let people: String = stage
@ -182,7 +182,7 @@ fn stage_info(stage: &Stage) -> String {
.replacen("{EXIT_NAME}", &e.name, 1)
.replacen("{DIRECTION}", &e.direction, 1)
.replacen("{SCENE_KEY}", &e.scene_key, 1)
.replacen("{EXIT_LOCATION}", &e.location, 1)
.replacen("{EXIT_LOCATION}", &e.region, 1)
})
.collect::<Vec<_>>()
.join("\n\n");

View File

@ -10,13 +10,13 @@ const SCENE_BNF: &'static str = r#"
root ::= Scene
Prop ::= "{" ws "\"name\":" ws string "," ws "\"description\":" ws string "," ws "\"features\":" ws stringlist "," ws "\"possible_interactions\":" ws stringlist "}"
Proplist ::= "[]" | "[" ws Prop ("," ws Prop)* "]"
Exit ::= "{" ws "\"name\":" ws string "," ws "\"direction\":" ws string "," "\"location\":" ws string "}"
Exit ::= "{" ws "\"name\":" ws string "," ws "\"direction\":" ws string "," "\"region\":" ws string "}"
Exitlist ::= "[]" | "[" ws Exit ("," ws Exit)* "]"
Item ::= "{" ws "\"name\":" ws string "," ws "\"category\":" ws string "," ws "\"rarity\":" ws string "}"
Itemlist ::= "[]" | "[" ws Item ("," ws Item)* "]"
Person ::= "{" ws "\"name\":" ws string "," ws "\"occupation\":" ws string "," ws "\"race\":" ws string "}"
Personlist ::= "[]" | "[" ws Person ("," ws Person)* "]"
Scene ::= "{" ws "\"name\":" ws string "," ws "\"location\":" ws string "," ws "\"description\":" ws string "," ws "\"people\":" ws Personlist "," ws "\"items\":" ws Itemlist "," ws "\"props\":" ws Proplist "," "\"exits\":" ws Exitlist "}"
Scene ::= "{" ws "\"name\":" ws string "," ws "\"region\":" ws string "," ws "\"description\":" ws string "," ws "\"people\":" ws Personlist "," ws "\"items\":" ws Itemlist "," ws "\"props\":" ws Proplist "," "\"exits\":" ws Exitlist "}"
Scenelist ::= "[]" | "[" ws Scene ("," ws Scene)* "]"
string ::= "\"" ([^"]*) "\""
boolean ::= "true" | "false"
@ -28,7 +28,7 @@ numberlist ::= "[" ws "]" | "[" ws string ("," ws number)* ws
const EXIT_SEED_BNF: &'static str = r#"
root ::= ExitSeed
ExitSeed ::= "{" ws "\"name\":" ws string "," ws "\"direction\":" ws string "," ws "\"location\":" ws string "}"
ExitSeed ::= "{" ws "\"name\":" ws string "," ws "\"direction\":" ws string "," ws "\"region\":" ws string "}"
ExitSeedlist ::= "[]" | "[" ws ExitSeed ("," ws ExitSeed)* "]"
string ::= "\"" ([^"]*) "\""
boolean ::= "true" | "false"
@ -64,21 +64,21 @@ The scene must be created with a certain level of fantasticalness:
The scene has the following information:
- `name`: The name of the scene, or location where the scene takes place.
- `location`: The greater enclosing location of the scene.
- The location should be specific, like the name of the city, state/province, kingdom, or geographical region.
- The location should not be a description of where the scene is located. It must be a specifically named place.
- `region`: The greater enclosing region of the scene.
- The region should be specific, like the name of the city, state/province, kingdom, or geographical area.
- The are should not be a description of where the scene is located. It must be a specifically named place.
- `description`: A description of the scene, directed at the player.
- `exits`: A handful of cardinal directions or new scenes to which the player can use to move to a new scene, either in the same location, or a completely different location. Exits have their own fields.
- `exits`: A handful of cardinal directions or new scenes to which the player can use to move to a new scene, either in the same region, or a completely different region. Exits have their own fields.
- `direction`: This must be cardinal or relative direction of the exit. Examples: `north`, `south`, `east`, `west`, `up`, `down`, `nearby`, `in`, `out`.
- `name`: This should be the name name of the new scene that the exit leads to. This must NOT be a direction (like `north`, `south`, `up`, `down`, `in`, `out`, etc).
- `location`: This should be the greater enclosing region of the scene that this exit leads to.
- `region`: This should be the greater enclosing region of the scene that this exit leads to.
More instructions for the `exits` field of a scene:
- The name of an exit must be thematically appropriate.
- All exit directions must be unique. Do not include the same direction twice.
- Make sure the `name` field does not have the direction in it, as that is already in the `direction` field.
- The `location` field for an exit should be same the `location` as the scene itself, if the exit leads somewhere else in the same general area.
- IF the exit leads to a different region, the `location` should be a different value, leading the player to a new region of the world.
- The `region` field for an exit should be same the `region` as the scene itself, if the exit leads somewhere else in the same general area.
- IF the exit leads to a different region, the `region` should be a different value, leading the player to a new region of the world.
The scene should also be populated with the following entities:
- People: Interesting people (not including the player themselves)
@ -108,7 +108,7 @@ const SCENE_FROM_STUB_PROMPT: &'static str = r#"
## Creation of THIS scene
Create the scene and determine its fantasticalness (`low`, `medium`, or `high`) from the provided name and location.
Create the scene and determine its fantasticalness (`low`, `medium`, or `high`) from the provided name and region.
- The scene connected to this one is provided for contextual information.
- The player arrived from the Connected Scene.
- The newly created scene MUST include the Connected Scene as an exit, in the opposite direction the player entered this new scene.
@ -121,7 +121,7 @@ Create the scene and determine its fantasticalness (`low`, `medium`, or `high`)
Name of scene to create: `{SCENE_NAME}`
Location of scene to create: `{SCENE_LOCATION}`
Region of scene to create: `{SCENE_REGION}`
## Connected Scene Information
@ -131,6 +131,7 @@ Basic Connected Scene Information:
- Connected Scene ID: `{CONNECTED_SCENE_ID}`
- Connected Scene Key: `{CONNECTED_SCENE_KEY}`
- Connected Scene Name: `{CONNECTED_SCENE_NAME}`
- Connected Scene Region: `{CONNECTED_SCENE_REGION}`
- Connected Scene Direction: `{CONNECTED_SCENE_DIRECTION}`
### Connected Scene Description
@ -178,7 +179,7 @@ Fill in the details of the person below. This person is a character in a text-ba
const SCENE_INFO_FOR_PERSON: &'static str = r#"
Basic scene information:
- Scene Name: {NAME}
- Scene Location: {LOCATION}
- Scene REGION: {REGION}
Extended scene description:
@ -224,7 +225,7 @@ Do **NOT** use this Scene Name as a `name` for the new exit.
fn scene_info_for_person(scene: &SceneSeed) -> String {
SCENE_INFO_FOR_PERSON
.replacen("{NAME}", &scene.name, 1)
.replacen("{LOCATION}", &scene.location, 1)
.replacen("{REGION}", &scene.region, 1)
.replacen("{DESCRIPTION}", &scene.description, 1)
}
@ -273,6 +274,7 @@ pub fn scene_from_stub_prompt(connected_scene: &Scene, stub: &SceneStub) -> AiPr
&SCENE_FROM_STUB_PROMPT
.replacen("{SCENE_INSTRUCTIONS}", SCENE_INSTRUCTIONS, 1)
.replacen("{CONNECTED_SCENE_NAME}", &connected_scene.name, 1)
.replacen("{CONNECTED_SCENE_REGION}", &connected_scene.region, 1)
.replacen("{CONNECTED_SCENE_DIRECTION}", &connected_direction, 1)
.replacen("{CONNECTED_SCENE_KEY}", connected_scene_key, 1)
.replacen("{CONNECTED_SCENE_ID}", connected_scene_id, 1)
@ -282,7 +284,7 @@ pub fn scene_from_stub_prompt(connected_scene: &Scene, stub: &SceneStub) -> AiPr
1,
)
.replacen("{SCENE_NAME}", &stub.name, 1)
.replacen("{SCENE_LOCATION}", &stub.location, 1),
.replacen("{SCENE_REGION}", &stub.region, 1),
SCENE_BNF,
1024,
)

View File

@ -28,7 +28,7 @@ enum CollectionType {
// Document Collections
const CMD_COLLECTION: &'static str = "command_cache";
const SCENE_COLLECTION: &'static str = "scenes";
const LOCATION_COLLECTION: &'static str = "locations";
const REGION_COLLECTION: &'static str = "regions";
const PEOPLE_COLLECTION: &'static str = "people";
const ITEMS_COLLECTION: &'static str = "items";
const PROPS_COLLECTION: &'static str = "props";
@ -45,7 +45,7 @@ const GAME_WORLD_GRAPH: &'static str = "world";
const DOC_COLLECTIONS: &'static [&str] = &[
CMD_COLLECTION,
SCENE_COLLECTION,
LOCATION_COLLECTION,
REGION_COLLECTION,
PEOPLE_COLLECTION,
ITEMS_COLLECTION,
PROPS_COLLECTION,
@ -226,7 +226,7 @@ impl Database {
from: vec![SCENE_COLLECTION.to_string()],
to: vec![
ITEMS_COLLECTION.to_string(),
LOCATION_COLLECTION.to_string(),
REGION_COLLECTION.to_string(),
OCCUPATIONS_COLLECTION.to_string(),
PEOPLE_COLLECTION.to_string(),
PROPS_COLLECTION.to_string(),

View File

@ -15,7 +15,7 @@ pub struct World {
#[derive(Serialize, Deserialize, Debug)]
pub struct SceneSeed {
pub name: String,
pub location: String,
pub region: String,
pub description: String,
pub people: Vec<PersonSeed>,
pub items: Vec<ItemSeed>,
@ -26,7 +26,7 @@ pub struct SceneSeed {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ExitSeed {
pub name: String,
pub location: String,
pub region: String,
pub direction: String,
}

View File

@ -23,7 +23,7 @@ pub struct Scene {
pub _id: Option<String>,
pub name: String,
pub location: String,
pub region: String,
#[serde(default)]
pub description: String,
@ -46,7 +46,7 @@ impl Default for Scene {
_key: Some(new_uuid_string()),
_id: None,
name: "".to_string(),
location: "".to_string(),
region: "".to_string(),
description: "".to_string(),
is_stub: false,
props: vec![],
@ -67,7 +67,7 @@ pub struct SceneStub {
pub _id: Option<String>,
pub name: String,
pub location: String,
pub region: String,
#[serde(default)]
pub is_stub: bool,
@ -81,7 +81,7 @@ impl Default for SceneStub {
_key: None,
_id: None,
name: "".to_string(),
location: "".to_string(),
region: "".to_string(),
is_stub: true,
}
}
@ -92,7 +92,7 @@ impl From<&Exit> for SceneStub {
Self {
_key: Some(exit.scene_key.clone()),
name: exit.name.clone(),
location: exit.location.clone(),
region: exit.region.clone(),
is_stub: true,
..Default::default()
}
@ -190,7 +190,7 @@ impl std::fmt::Display for Stage {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct Exit {
pub name: String,
pub location: String,
pub region: String,
pub direction: String,
pub scene_key: String,
@ -204,7 +204,7 @@ impl Exit {
pub fn from_connected_scene(scene: &Scene, direction_from: &str) -> Exit {
Exit {
name: scene.name.clone(),
location: scene.location.clone(),
region: scene.region.clone(),
direction: direction_from.to_string(),
scene_key: scene._key.as_ref().cloned().unwrap(),
scene_id: scene._id.clone(),
@ -217,7 +217,7 @@ impl From<ExitSeed> for Exit {
Self {
direction: seed.direction,
name: seed.name,
location: seed.location,
region: seed.region,
scene_key: new_uuid_string(),
scene_id: None, // it will be set by the database.
}
@ -229,7 +229,7 @@ impl From<&ExitSeed> for Exit {
Self {
direction: seed.direction.clone(),
name: seed.name.clone(),
location: seed.location.clone(),
region: seed.region.clone(),
scene_key: new_uuid_string(),
scene_id: None, // it will be set by the database.
}
@ -241,7 +241,7 @@ impl From<&mut ExitSeed> for Exit {
Self {
direction: seed.direction.clone(),
name: seed.name.clone(),
location: seed.location.clone(),
region: seed.region.clone(),
scene_key: new_uuid_string(),
scene_id: None, // it will be set by the database.
}