feat: Added API for web map in discord bot
- Bump version to 0.11.0 - Added data table to quests, accounts and rooms - Discord bot now adds "avatar" and "name" data to accounts on init - Added CLI "map data" command
This commit is contained in:
parent
0ab777d898
commit
c22787792d
18 changed files with 1161 additions and 224 deletions
|
|
@ -1,6 +1,6 @@
|
|||
//! User accounts
|
||||
|
||||
use std::{fs, io::Write, path::PathBuf};
|
||||
use std::{collections::HashMap, fs, io::Write, path::PathBuf};
|
||||
|
||||
use serde::{ Serialize, Deserialize };
|
||||
|
||||
|
|
@ -29,6 +29,9 @@ pub struct Account {
|
|||
|
||||
/// Vec of rooms unlocked by this user
|
||||
pub rooms_unlocked: Vec<u16>,
|
||||
|
||||
/// Additional implementation-defined data
|
||||
pub data: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
impl Default for Account {
|
||||
|
|
@ -39,6 +42,7 @@ impl Default for Account {
|
|||
location: u16::default(),
|
||||
quests_completed: Vec::new(),
|
||||
rooms_unlocked: Vec::new(),
|
||||
data: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||
use crate::{SquadObject, account::Account, error::Error, quest::Quest};
|
||||
|
||||
/// Struct for containing paths to other (de-)serializable things
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct Config {
|
||||
/// Path to config directory
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! Map, a.k.a. a graph of rooms
|
||||
|
||||
use std::{fs, io::Write, path::PathBuf};
|
||||
use std::{collections::HashMap, fs, io::Write, path::PathBuf};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ use crate::{SquadObject, account::Account, error::{Error, MapError}};
|
|||
#[serde(default)]
|
||||
pub struct Map {
|
||||
/// Rooms go here
|
||||
pub room: Vec<Room>
|
||||
pub room: Vec<Room>,
|
||||
}
|
||||
|
||||
impl Default for Map {
|
||||
|
|
@ -131,6 +131,8 @@ pub struct Room {
|
|||
pub name: String,
|
||||
/// Room description
|
||||
pub description: Option<String>,
|
||||
/// Additional implementation-based data
|
||||
pub data: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
fn default_name() -> String {
|
||||
|
|
@ -145,6 +147,7 @@ impl Default for Room {
|
|||
value: u32::default(),
|
||||
name: default_name(),
|
||||
description: None,
|
||||
data: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! Text-based quests and user solutions for them
|
||||
|
||||
use std::{fs, io::Write, path::PathBuf};
|
||||
use std::{collections::HashMap, fs, io::Write, path::PathBuf};
|
||||
|
||||
use serde::{ Serialize, Deserialize };
|
||||
use crate::{SquadObject, account::Account, error::{Error, QuestError}};
|
||||
|
|
@ -66,7 +66,10 @@ pub struct Quest {
|
|||
pub available_on: Option<Date>,
|
||||
|
||||
/// When quest expires
|
||||
pub deadline: Option<Date>
|
||||
pub deadline: Option<Date>,
|
||||
|
||||
/// Additional implementation-defined data
|
||||
pub data: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
impl Default for Quest {
|
||||
|
|
@ -80,7 +83,8 @@ impl Default for Quest {
|
|||
answer: default_answer(),
|
||||
public: false,
|
||||
available_on: None,
|
||||
deadline: None
|
||||
deadline: None,
|
||||
data: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue