Merged both tables for resist & bp
This commit is contained in:
parent
46b8e35254
commit
37a6531ae4
|
|
@ -25,8 +25,7 @@ use config::monsters::MonsterConfig;
|
|||
use rusqlite::Connection;
|
||||
|
||||
use crate::monster_structs::{
|
||||
CreatureBodyParts, CreatureData, CreatureResistance, CreatureStats, FullMonster,
|
||||
MonsterAttacks, MonsterSingleAttack,
|
||||
CreatureBodyPart, CreatureData, CreatureStats, FullMonster, MonsterAttacks, MonsterSingleAttack,
|
||||
};
|
||||
|
||||
/// Deserialise a table row (or rows) into the given type and add a nice context message.
|
||||
|
|
@ -72,14 +71,7 @@ fn fetch_all_data(connection: Connection) -> Result<Vec<FullMonster>, anyhow::Er
|
|||
Some("phase, attack_group, attack_type, name")
|
||||
);
|
||||
let creature_resistances = fetch_from!(
|
||||
CreatureResistance,
|
||||
connection,
|
||||
creature,
|
||||
"creature_resistances",
|
||||
Some("body_part_name")
|
||||
);
|
||||
let creature_body_parts = fetch_from!(
|
||||
CreatureBodyParts,
|
||||
CreatureBodyPart,
|
||||
connection,
|
||||
creature,
|
||||
"creature_body_parts",
|
||||
|
|
@ -104,9 +96,8 @@ fn fetch_all_data(connection: Connection) -> Result<Vec<FullMonster>, anyhow::Er
|
|||
attacks: MonsterAttacks {
|
||||
attacks: creature_attacks,
|
||||
},
|
||||
creature_body_parts: todo!(),
|
||||
resistances: monster_structs::MonsterResistances {
|
||||
resistances: creature_resistances,
|
||||
body_parts: monster_structs::CreatureBodyParts {
|
||||
body_parts: creature_resistances,
|
||||
},
|
||||
data: creature.clone(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,14 +25,11 @@ pub struct FullMonster {
|
|||
/// Serialized generic data directly copied from the database table.
|
||||
pub data: CreatureData,
|
||||
|
||||
/// Creature body parts and their resists
|
||||
pub creature_body_parts: CreatureBodyParts,
|
||||
|
||||
/// Collection of attacks, wrapped in a helper that exposes useful functions.
|
||||
pub attacks: MonsterAttacks,
|
||||
|
||||
/// Collection of resistances, wrapped in a helper for convenient iteration.
|
||||
pub resistances: MonsterResistances,
|
||||
pub body_parts: CreatureBodyParts,
|
||||
|
||||
/// Serialized stats directly copied from the database table.
|
||||
pub stats: CreatureStats,
|
||||
|
|
@ -107,9 +104,9 @@ pub struct MonsterAttacks {
|
|||
/// The inner vector contains `MonsterSingleResistance` entries; methods
|
||||
/// on this struct can provide iterators or lookup functions that are
|
||||
/// easier to consume than raw rows.
|
||||
pub struct MonsterResistances {
|
||||
pub struct CreatureBodyParts {
|
||||
/// All resistance rows for the monster, as read from the database.
|
||||
pub resistances: Vec<CreatureResistance>,
|
||||
pub body_parts: Vec<CreatureBodyPart>,
|
||||
}
|
||||
|
||||
/// Represents a single attack entry as deserialized from the database.
|
||||
|
|
@ -164,13 +161,28 @@ pub struct MonsterSingleAttack {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
pub struct CreatureResistance {
|
||||
/// The id of the creature that owns these resistances (FOREIGN KEY to `creature_data.id`).
|
||||
/// All different body parts and their different resists
|
||||
pub struct CreatureBodyPart {
|
||||
#[INTEGER]
|
||||
pub creature_id: i64,
|
||||
/// Full name of the body part (e.g. “Head”, “Arm” …).
|
||||
#[TEXT]
|
||||
pub body_part_name: String,
|
||||
#[INTEGER]
|
||||
pub threshold_p1: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub threshold_p2: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub protection_p1: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub protection_p2: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub integrity_p1: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub integrity_p2: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub life_points_p1: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub life_points_p2: Option<i64>,
|
||||
#[TEXT]
|
||||
pub slash: Option<String>,
|
||||
#[TEXT]
|
||||
|
|
@ -199,31 +211,6 @@ pub struct CreatureResistance {
|
|||
pub thunder: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
/// All different body parts and their different resists
|
||||
pub struct CreatureBodyParts {
|
||||
#[INTEGER]
|
||||
pub creature_id: i64,
|
||||
#[TEXT]
|
||||
pub body_part_name: String,
|
||||
#[INTEGER]
|
||||
pub threshold_p1: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub threshold_p2: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub protection_p1: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub protection_p2: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub integrity_p1: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub integrity_p2: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub life_points_p1: Option<i64>,
|
||||
#[INTEGER]
|
||||
pub life_points_p2: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FieldsAsSlice)]
|
||||
/// All creature stats
|
||||
pub struct CreatureStats {
|
||||
|
|
|
|||
Loading…
Reference in New Issue