ability framework, some more rounds

This commit is contained in:
Moritz Roßbacher 2023-10-27 21:04:59 +02:00
parent 2f547b95a4
commit a867fc77c2
3 changed files with 324 additions and 31 deletions

View file

@ -1,6 +1,8 @@
use crate::commands::zombies::gear::{ use crate::commands::zombies::gear::{
Weapon::{*}, Weapon::{*},
WeaponMaterial::{*} WeaponMaterial::{Wood, Stone},
ArmorPiece::{*},
ArmorMaterial::{Chainmail, Leather},
}; };
pub type Enchanted = bool; pub type Enchanted = bool;
@ -23,11 +25,11 @@ impl ArmorPiece {
pub fn armor_value(&self) -> &ArmorValue { pub fn armor_value(&self) -> &ArmorValue {
match self { match self {
ArmorPiece::None(value) => value, ArmorPiece::None(value) => value,
ArmorPiece::Helmet(value, _, _) => value, Helmet(value, _, _) => value,
ArmorPiece::Head(value, _, _) => value, Head(value, _, _) => value,
ArmorPiece::Chestplate(value, _, _) => value, Chestplate(value, _, _) => value,
ArmorPiece::Leggings(value, _, _) => value, Leggings(value, _, _) => value,
ArmorPiece::Boots(value, _, _) => value Boots(value, _, _) => value
} }
} }
} }
@ -50,7 +52,7 @@ pub enum ArmorMaterial {
} }
#[derive(Debug)] #[derive(Debug)]
pub enum Weapon { pub enum Weapon {
None(Damage), None,
Axe(Damage, Enchanted, WeaponMaterial), Axe(Damage, Enchanted, WeaponMaterial),
Sword(Damage, Enchanted, WeaponMaterial), Sword(Damage, Enchanted, WeaponMaterial),
@ -60,7 +62,7 @@ pub enum Weapon {
impl Weapon { impl Weapon {
pub fn damage(&self) -> &Damage { pub fn damage(&self) -> &Damage {
match self { match self {
None(damage) => damage, Weapon::None => &0_u8,
Axe(damage, _, _) => damage, Axe(damage, _, _) => damage,
Sword(damage, _, _) => damage, Sword(damage, _, _) => damage,
Other(damage, _, _) => damage Other(damage, _, _) => damage
@ -74,14 +76,21 @@ pub const NO_HELMET: ArmorPiece = ArmorPiece::None(0);
pub const NO_CHESTPLATE: ArmorPiece = ArmorPiece::None(0); pub const NO_CHESTPLATE: ArmorPiece = ArmorPiece::None(0);
pub const NO_LEGGINGS: ArmorPiece = ArmorPiece::None(0); pub const NO_LEGGINGS: ArmorPiece = ArmorPiece::None(0);
pub const NO_BOOTS: ArmorPiece = ArmorPiece::None(0); pub const NO_BOOTS: ArmorPiece = ArmorPiece::None(0);
pub const SLIME_HEAD: ArmorPiece = ArmorPiece::Head(0,false,0); pub const CHAIN_CHESTPLATE: ArmorPiece = Chestplate(5,false,Chainmail);
pub const CHAIN_LEGGINGS: ArmorPiece = Leggings(4,false,Chainmail);
pub const CHAIN_BOOTS: ArmorPiece = Boots(1, false, Chainmail);
pub const SLIME_HEAD: ArmorPiece = Head(0,false,0);
pub const WERE_HEAD: ArmorPiece = Head(0,false,1);
pub const LILY_HEAD: ArmorPiece = Head(0,false,2);
//Weapons //Weapons
pub const NO_WEAPON: Weapon = Weapon::None(0); pub const NO_WEAPON: Weapon = Weapon::None;
pub const WOODEN_AXE: Weapon = Axe(3,false,Wood); pub const WOODEN_AXE: Weapon = Axe(3,false,Wood);
pub const DIAMOND_AXE: Weapon = Axe(6,false,Diamond); pub const DIAMOND_AXE: Weapon = Axe(6,false,WeaponMaterial::Diamond);
pub const GOLD_SWORD: Weapon = Sword(4,false,Gold); pub const GOLD_SWORD: Weapon = Sword(4,false,WeaponMaterial::Gold);
pub const DIAMOND_SWORD: Weapon = Sword(7,false,Diamond); pub const STONE_SWORD: Weapon = Sword(5,false,Stone);
pub const IRON_SWORD: Weapon = Sword(6,false,WeaponMaterial::Iron);
pub const DIAMOND_SWORD: Weapon = Sword(7,false,WeaponMaterial::Diamond);
pub const SLIME_BALL: Weapon = Other(0, true, "Slime Ball"); pub const SLIME_BALL: Weapon = Other(0, true, "Slime Ball");

View file

@ -89,38 +89,38 @@ impl BadBlood {
//wave 1 //wave 1
vec![ vec![
Horde { Horde {
zombie: BB_Z_2, zombie: BB_Z_3,
count: 4, count: 4,
}, },
Horde { Horde {
zombie: BB_SZ_1, zombie: BB_SZ_1,
count: 2, count: 2,
}, }
], ],
//wave 2 //wave 2
vec![ vec![
Horde { Horde {
zombie: BB_Z_2, zombie: BB_Z_3,
count: 3, count: 3,
}, },
Horde { Horde {
zombie: BB_SZ_1, zombie: BB_SZ_1,
count: 2, count: 1,
}, },
Horde { Horde {
zombie: BB_S_1, zombie: BB_WI_1,
count: 2, count: 2,
} }
], ],
//wave 3 //wave 3
vec![ vec![
Horde { Horde {
zombie: BB_Z_2, zombie: BB_Z_3,
count: 3, count: 3,
}, },
Horde { Horde {
zombie: BB_SZ_1, zombie: BB_SZ_1,
count: 2, count: 1,
}, },
Horde { Horde {
zombie: BB_S_1, zombie: BB_S_1,
@ -129,16 +129,138 @@ impl BadBlood {
] ]
] ]
} }
/*fn round5() -> Round { fn round5() -> Round {
vec![
//wave 1
vec![
Horde {
zombie: BB_WO_1,
count: 3,
},
Horde {
zombie: BB_WW_1,
count: 1,
}
],
//wave 2
vec![
Horde {
zombie: BB_WO_1,
count: 3,
},
Horde {
zombie: BB_WW_1,
count: 1,
}
],
//wave 3
vec![
Horde {
zombie: BB_WO_1,
count: 2,
},
Horde {
zombie: BB_WW_1,
count: 1,
},
Horde {
zombie: BB_LILY,
count: 1,
},
Horde {
zombie: BB_ELLIE,
count: 1,
}
]
]
}
fn round6() -> Round {
vec![
//wave 1
vec![
Horde {
zombie: BB_Z_4,
count: 4,
},
Horde {
zombie: BB_WI_1,
count: 3,
}
],
//wave 2
vec![
Horde {
zombie: BB_Z_4,
count: 3,
},
Horde {
zombie: BB_WI_1,
count: 2,
}
],
//wave 3
vec![
Horde {
zombie: BB_Z_4,
count: 3,
},
Horde {
zombie: BB_WI_1,
count: 2,
},
]
]
}
fn round7() -> Round {
vec![
//wave 1
vec![
Horde {
zombie: BB_S_1,
count: 3,
},
Horde {
zombie: BB_WI_1,
count: 3,
}
],
//wave 2
vec![
Horde {
zombie: BB_S_1,
count: 3,
},
Horde {
zombie: BB_WI_1,
count: 3,
}
],
//wave 3
vec![
Horde {
zombie: BB_S_1,
count: 3,
},
Horde {
zombie: BB_WI_1,
count: 3,
},
]
]
}
/*fn round8() -> Round {
}*/ }*/
pub(crate) fn get_round(round: u8) -> Round { pub(crate) fn get_round(round: u8) -> Option<Round> {
match round { match round {
1 => Self::round1(), 1 => Some(Self::round1()),
2 => Self::round2(), 2 => Some(Self::round2()),
3 => Self::round3(), 3 => Some(Self::round3()),
4 => Self::round4(), 4 => Some(Self::round4()),
_ => panic!("Round {} not found", round) 5 => Some(Self::round5()),
6 => Some(Self::round6()),
7 => Some(Self::round7()),
_ => None
} }
} }
} }

View file

@ -4,8 +4,9 @@ use crate::commands::zombies::gear::{
ArmorPiece::*, ArmorPiece::*,
Weapon::* Weapon::*
}; };
use crate::commands::zombies::rounds::{Round, Wave};
type ChildrenCount = u8;
type RespawningChildren = bool;
#[derive(Debug)] #[derive(Debug)]
pub struct Family { pub struct Family {
family: *const str, family: *const str,
@ -22,14 +23,34 @@ pub struct Zombie {
pub speed: f32, pub speed: f32,
armor: Armor, armor: Armor,
weapon: Weapon, weapon: Weapon,
children: Children,
damage_type: DamageType,
}
#[derive(Debug)]
pub enum Children {
None,
Single(&'static Horde, RespawningChildren),
}
#[derive(Debug)]
pub enum Ability {
Single(*const str),
Double(*const str, *const str),
}
#[derive(Debug)]
pub enum DamageType {
Melee,
Ranged,
Ability(Ability),
MeleeRanged,
MeleeAbility(Ability),
RangedAbility(Ability),
} }
impl Zombie { impl Zombie {
pub fn health(&self) -> u16 { pub fn health(&self) -> u16 {
self.family.health self.family.health
} }
pub fn damage(&self) -> Damage { pub fn damage(&self) -> (&DamageType, Damage) {
self.family.damage+ self.weapon.damage() (&self.damage_type, self.family.damage + self.weapon.damage())
} }
pub fn follow_range(&self) -> u8 { pub fn follow_range(&self) -> u8 {
self.family.follow_range self.family.follow_range
@ -73,6 +94,27 @@ pub const BB_SLIME: Family = Family {
follow_range: 16, follow_range: 16,
base_armor: 2, base_armor: 2,
}; };
pub const BB_WITCH: Family = Family {
family: "witch",
damage: 2,
health: 20,
follow_range: 16,
base_armor: 0,
};
pub const BB_WOLF: Family = Family {
family: "wolf",
damage: 4,
health: 16,
follow_range: 16,
base_armor: 0,
};
pub const BB_WEREWOLF: Family = Family {
family: "werewolf",
damage: 3,
health: 32,
follow_range: 35,
base_armor: 2,
};
pub const BB_Z_1: Zombie = Zombie { pub const BB_Z_1: Zombie = Zombie {
family: BB_BASIC, family: BB_BASIC,
@ -86,6 +128,8 @@ pub const BB_Z_1: Zombie = Zombie {
NO_BOOTS, NO_BOOTS,
], ],
weapon: NO_WEAPON, weapon: NO_WEAPON,
children: Children::None,
damage_type: DamageType::Melee,
}; };
pub const BB_Z_2: Zombie = Zombie { pub const BB_Z_2: Zombie = Zombie {
family: BB_BASIC, family: BB_BASIC,
@ -99,6 +143,8 @@ pub const BB_Z_2: Zombie = Zombie {
NO_BOOTS, NO_BOOTS,
], ],
weapon: NO_WEAPON, weapon: NO_WEAPON,
children: Children::None,
damage_type: DamageType::Melee,
}; };
pub const BB_Z_3: Zombie = Zombie { pub const BB_Z_3: Zombie = Zombie {
family: BB_BASIC, family: BB_BASIC,
@ -112,6 +158,23 @@ pub const BB_Z_3: Zombie = Zombie {
NO_BOOTS, NO_BOOTS,
], ],
weapon: WOODEN_AXE, weapon: WOODEN_AXE,
children: Children::None,
damage_type: DamageType::Melee,
};
pub const BB_Z_4: Zombie = Zombie {
family: BB_BASIC,
tier: 4,
speed: 0.25,
armor: [
NO_HELMET,
Chestplate(3,false,Leather(0x000000)),
Leggings(2,false,Leather(0x000000)),
NO_BOOTS,
],
weapon: WOODEN_AXE,
children: Children::None,
damage_type: DamageType::Melee,
}; };
pub const BB_SZ_1: Zombie = Zombie { pub const BB_SZ_1: Zombie = Zombie {
@ -126,7 +189,10 @@ pub const BB_SZ_1: Zombie = Zombie {
Boots(1,false,Leather(0x000000)), Boots(1,false,Leather(0x000000)),
], ],
weapon: SLIME_BALL, weapon: SLIME_BALL,
children: Children::None,
damage_type: DamageType::Melee,
}; };
pub const BB_S_1: Zombie = Zombie { pub const BB_S_1: Zombie = Zombie {
family: BB_SLIME, family: BB_SLIME,
tier: 1, tier: 1,
@ -139,4 +205,100 @@ pub const BB_S_1: Zombie = Zombie {
NO_BOOTS, NO_BOOTS,
], ],
weapon: NO_WEAPON, weapon: NO_WEAPON,
children: Children::None,
damage_type: DamageType::Melee,
};
pub const BB_WI_1: Zombie = Zombie {
family: BB_WITCH,
tier: 1,
speed: 0.25,
armor: [
NO_HELMET,
NO_CHESTPLATE,
NO_LEGGINGS,
NO_BOOTS,
],
weapon: NO_WEAPON,
children: Children::None,
damage_type: DamageType::Ability(Ability::Double("splash potion of Harming", "splash potion of Poison")),
};
pub const BB_WO_1: Zombie = Zombie {
family: BB_WOLF,
tier: 1,
speed: 0.36,
armor: [
NO_HELMET,
NO_CHESTPLATE,
NO_LEGGINGS,
NO_BOOTS,
],
weapon: NO_WEAPON,
children: Children::None,
damage_type: DamageType::Melee,
};
pub const BB_WW_1: Zombie = Zombie {
family: BB_WEREWOLF,
tier: 1,
speed: 0.3,
armor: [
WERE_HEAD,
Chestplate(3,false,Leather(0x555555)),
Leggings(2,false,Leather(0x555555)),
Boots(1,false,Leather(0x555555)),
],
weapon: STONE_SWORD,
children: Children::None,
damage_type: DamageType::Melee,
};
pub const BB_LILY: Zombie = Zombie {
family: Family {
family: "bb_lore",
damage: 3,
health: 55,
follow_range: 35,
base_armor: 2,
},
tier: 1,
speed: 0.3,
armor: [
LILY_HEAD,
CHAIN_CHESTPLATE,
CHAIN_LEGGINGS,
CHAIN_BOOTS
],
weapon: STONE_SWORD,
children: Children::Single(&Horde {
zombie: BB_ELLIE,
count: 1,
}, false),
damage_type: DamageType::Melee,
};
pub const BB_ELLIE: Zombie = Zombie {
family: Family {
family: "bb_lore",
damage: 4,
health: 30,
follow_range: 16,
base_armor: 0,
},
tier: 0,
speed: 0.38,
armor: [
NO_HELMET,
NO_CHESTPLATE,
NO_LEGGINGS,
NO_BOOTS,
],
weapon: NO_WEAPON,
children: Children::None,
damage_type: DamageType::MeleeAbility(Ability::Single("poop")),
}; };