Compare commits
2 Commits
d16cfd2494
...
0e70a0bb48
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e70a0bb48 | ||
|
|
448bbe5bda |
@@ -4,4 +4,5 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
paste = "1.0.15"
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
|
|||||||
@@ -1 +1,70 @@
|
|||||||
// TODO
|
#![allow(unused)]
|
||||||
|
|
||||||
|
use crate::types::{
|
||||||
|
CharacterDetail, CharacterFull, CharacterMini, CharacterSearch, Id, ItemMini, ItemSearch,
|
||||||
|
LightconeDetail, LightconeFull, LightconeMini, LightconeSearch, RelicMini, RelicSearch,
|
||||||
|
};
|
||||||
|
use paste::paste;
|
||||||
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
|
macro_rules! define_data_store {
|
||||||
|
($base:ident, full) => {
|
||||||
|
paste::item! {
|
||||||
|
pub static [<$base:upper _DETAIL>]: OnceLock<[<$base Detail>]> = OnceLock::new();
|
||||||
|
pub static [<$base:upper _SEARCH>]: OnceLock<[<$base Search>]> = OnceLock::new();
|
||||||
|
|
||||||
|
pub fn [<get_ $base:lower _detail>]() -> &'static [<$base Detail>] {
|
||||||
|
[<$base:upper _DETAIL>]
|
||||||
|
.get()
|
||||||
|
.expect(concat!(stringify!([<$base:upper _DETAIL>]), " not initialized"))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn [<get_ $base:lower _search>]() -> &'static [<$base Search>] {
|
||||||
|
[<$base:upper _SEARCH>]
|
||||||
|
.get()
|
||||||
|
.expect(concat!(stringify!([<$base:upper _SEARCH>]), " not initialized"))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn [<get_ $base:lower full_by_id>](id: &Id) -> Option<&[<$base Full>]> {
|
||||||
|
[<get_ $base:lower _detail>]().0.get(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn [<get_ $base:lower _mini_by_id>](id: &Id) -> Option<&[<$base Mini>]> {
|
||||||
|
[<get_ $base:lower _search>]().0.get(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn [<set_ $base:lower _detail>](data: [<$base Detail>]) -> Result<(), [<$base Detail>]> {
|
||||||
|
[<$base:upper _DETAIL>].set(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn [<set_ $base:lower _search>](data: [<$base Search>]) -> Result<(), [<$base Search>]> {
|
||||||
|
[<$base:upper _SEARCH>].set(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
($base:ident, mini) => {
|
||||||
|
paste::item! {
|
||||||
|
pub static [<$base:upper _SEARCH>]: OnceLock<[<$base Search>]> = OnceLock::new();
|
||||||
|
|
||||||
|
pub fn [<get_ $base:lower _search>]() -> &'static [<$base Search>] {
|
||||||
|
[<$base:upper _SEARCH>]
|
||||||
|
.get()
|
||||||
|
.expect(concat!(stringify!([<$base:upper _SEARCH>]), " not initialized"))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn [<get_ $base:lower _mini_by_id>](id: &Id) -> Option<&[<$base Mini>]> {
|
||||||
|
[<get_ $base:lower _search>]().0.get(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn [<set_ $base:lower _search>](data: [<$base Search>]) -> Result<(), [<$base Search>]> {
|
||||||
|
[<$base:upper _SEARCH>].set(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
define_data_store!(Character, full);
|
||||||
|
define_data_store!(Lightcone, full);
|
||||||
|
define_data_store!(Relic, mini);
|
||||||
|
define_data_store!(Item, mini);
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ pub type Count = i32;
|
|||||||
pub type Desc = String;
|
pub type Desc = String;
|
||||||
pub type Uri = String;
|
pub type Uri = String;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
|
||||||
pub enum StatValue {
|
pub enum StatValue {
|
||||||
Flat(f32),
|
Flat(f32),
|
||||||
Percent(f32),
|
Percent(f32),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum StatType {
|
pub enum StatType {
|
||||||
Aggro = 1,
|
Aggro = 1,
|
||||||
@@ -42,7 +42,7 @@ pub enum StatType {
|
|||||||
Vulnerability = 25,
|
Vulnerability = 25,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Ascension {
|
pub enum Ascension {
|
||||||
A2 = 1,
|
A2 = 1,
|
||||||
@@ -50,7 +50,7 @@ pub enum Ascension {
|
|||||||
A6 = 3,
|
A6 = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Path {
|
pub enum Path {
|
||||||
Destruction = 1,
|
Destruction = 1,
|
||||||
@@ -64,7 +64,7 @@ pub enum Path {
|
|||||||
Elation = 9,
|
Elation = 9,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Rarity {
|
pub enum Rarity {
|
||||||
ThreeStar = 3,
|
ThreeStar = 3,
|
||||||
@@ -72,7 +72,7 @@ pub enum Rarity {
|
|||||||
FiveStar = 5,
|
FiveStar = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Element {
|
pub enum Element {
|
||||||
Physical = 1,
|
Physical = 1,
|
||||||
@@ -84,7 +84,7 @@ pub enum Element {
|
|||||||
Imaginary = 7,
|
Imaginary = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum RelicType {
|
pub enum RelicType {
|
||||||
Relic = 1,
|
Relic = 1,
|
||||||
|
|||||||
@@ -10,16 +10,7 @@ pub struct RelicMini {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub r#type: RelicType,
|
pub r#type: RelicType,
|
||||||
pub img_url: String,
|
pub img_url: String,
|
||||||
}
|
// lets just display these in the search page
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct RelicDetail(pub HashMap<Id, RelicFull>);
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct RelicFull {
|
|
||||||
pub name: String,
|
|
||||||
pub r#type: RelicType,
|
|
||||||
pub img_url: Uri,
|
|
||||||
pub two_pc: Desc,
|
pub two_pc: Desc,
|
||||||
pub four_pc: Option<Desc>,
|
pub four_pc: Option<Desc>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user