diff --git a/src/commands/mod.rs b/src/commands/mod.rs index b488167..aaf7aa8 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,3 +1,4 @@ pub(crate) mod lfg; pub(crate) mod round; pub(crate) mod zombies; +pub(crate) mod xd; diff --git a/src/commands/round.rs b/src/commands/round.rs index de4dd04..d55af82 100644 --- a/src/commands/round.rs +++ b/src/commands/round.rs @@ -1,8 +1,28 @@ -use crate::commands::zombies::zombies::*; use crate::{Context, Error}; -use std::convert::Into; +use crate::commands::{ + lfg::{ + *, + Map::{*} + }, + zombies::{ + rounds + } +}; #[poise::command(slash_command)] -pub(crate) async fn round(ctx: Context<'_>) -> Result<(), Error> { +pub(crate) async fn round( + ctx: Context<'_>, + map: Map, + + #[min = 1_u8] + #[max = 105_u8] + round: u8 +) -> Result<(), Error> { + match map { + DeadEnd => {} + BadBlood => {rounds::BadBlood::get_round(round);} + AlienArcadium => {} + } + ctx.say(format!("hi")).await?; Ok(()) } diff --git a/src/commands/xd.rs b/src/commands/xd.rs new file mode 100644 index 0000000..be55ce2 --- /dev/null +++ b/src/commands/xd.rs @@ -0,0 +1,11 @@ +use crate::{Context, Error}; + +const XD:&str = "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n⣿⣿⣿⡿⠿⠿⠿⠿⠿⠿⠿⢿⣿⣿⣿⣿⡿⠿⠿⠿⠿⠿⠿⠿⢿⡿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n⣿⣿⣿⣧⣄⡀⠀⠀⠀⢀⣠⣼⣿⣿⣿⣿⣧⣄⡀⠀⠀⠀⣀⣤⣼⣷⣦⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢿⣿⣿⣿⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⠟⠀⠀⢀⣼⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⣶⣦⣄⡀⠀⠀⠙⢿⣿⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠙⣿⣿⣿⣿⠋⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠈⢿⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠈⢿⡿⠁⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⢸⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡗⠀⠀⠀⠐⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⣠⡀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠀⠀⣰⣿⣷⡄⠀⠀⠘⢿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⣾⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⡟⠁⠀⢀⣼⣿⣿⣿⣿⣆⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⢀⣼⣿⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⠋⠀⠀⢠⣾⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠙⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⣿⠿⠛⠁⠀⠀⣠⣾⣿⣿⣿⣿⣿\n⣿⣿⣿⠿⠛⠁⠀⠀⠀⠙⠻⣿⣿⣿⣿⣿⡿⠟⠋⠀⠀⠀⠈⠛⠻⡿⠟⠛⠁⠀⠀⠈⠉⠉⠉⠉⠀⠀⠀⠀⣀⣴⣾⣿⣿⣿⣿⣿⣿⣿\n⣿⣿⣿⣶⣶⣶⣶⣶⣶⣶⣶⣿⣿⣿⣿⣿⣷⣶⣶⣶⣶⣶⣶⣶⣶⣷⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿\n"; + +#[poise::command(slash_command)] +pub(crate) async fn xd( + ctx: Context<'_>, +) -> Result<(), Error> { + ctx.say(XD).await?; + Ok(()) +} \ No newline at end of file diff --git a/src/commands/zombies/gear.rs b/src/commands/zombies/gear.rs index be60d92..c94a48b 100644 --- a/src/commands/zombies/gear.rs +++ b/src/commands/zombies/gear.rs @@ -1,53 +1,87 @@ -use crate::commands::zombies::gear::ArmorMaterial::Leather; -use crate::commands::zombies::gear::ArmorPiece::Leggings; -use crate::commands::zombies::gear::Weapon::{Axe, Sword}; -use crate::commands::zombies::gear::WeaponMaterial::{Diamond, Gold, Wood}; +use crate::commands::zombies::gear::{ + Weapon::{*}, + WeaponMaterial::{*} +}; + +pub type Enchanted = bool; +pub type Armor = [ArmorPiece; 4]; +pub type Damage = u8; +pub type ArmorValue = u8; +pub type SkinId = u8; +pub type LeatherColor = u32; #[derive(Debug)] pub enum ArmorPiece { - None, - Helmet(HelmetType), - Chestplate(ArmorMaterial, Enchanted), - Leggings(ArmorMaterial, Enchanted), - Boots(ArmorMaterial, Enchanted), + None(ArmorValue), + Helmet(ArmorValue, Enchanted, ArmorMaterial), + Head(ArmorValue, Enchanted, SkinId), + Chestplate(ArmorValue, Enchanted, ArmorMaterial), + Leggings(ArmorValue, Enchanted, ArmorMaterial), + Boots(ArmorValue, Enchanted, ArmorMaterial) } + +impl ArmorPiece { + pub fn armor_value(&self) -> &ArmorValue { + match self { + ArmorPiece::None(value) => value, + ArmorPiece::Helmet(value, _, _) => value, + ArmorPiece::Head(value, _, _) => value, + ArmorPiece::Chestplate(value, _, _) => value, + ArmorPiece::Leggings(value, _, _) => value, + ArmorPiece::Boots(value, _, _) => value + } + } +} + #[derive(Debug)] pub enum WeaponMaterial { Wood, Stone, Gold, Iron, - Diamond, -} -#[derive(Debug)] -pub enum HelmetType { - Head(u32), - Helmet(ArmorMaterial, Enchanted), + Diamond } #[derive(Debug)] pub enum ArmorMaterial { - Leather(u32), + Leather(LeatherColor), Gold, Chainmail, Iron, - Diamond, + Diamond } #[derive(Debug)] pub enum Weapon { - None, - Axe(WeaponMaterial, Enchanted), - Sword(WeaponMaterial, Enchanted), + None(Damage), + Axe(Damage, Enchanted, WeaponMaterial), + Sword(Damage, Enchanted, WeaponMaterial), - SlimeBall(Enchanted), + Other(Damage, Enchanted, *const str) } -pub type Enchanted = bool; -pub const NO_WEAPON: Weapon = Weapon::None; -pub const WOODEN_AXE: Weapon = Axe(Wood, false); -pub const DIAMOND_AXE: Weapon = Axe(Diamond, false); -pub const GOLD_SWORD: Weapon = Sword(Gold, false); -pub const DIAMOND_SWORD: Weapon = Sword(Diamond, false); -pub const SLIME_BALL: Weapon = Weapon::SlimeBall(true); -pub const NO_HELMET: ArmorPiece = ArmorPiece::None; -pub const NO_CHESTPLATE: ArmorPiece = ArmorPiece::None; -pub const NO_LEGGINGS: ArmorPiece = ArmorPiece::None; -pub const NO_BOOTS: ArmorPiece = ArmorPiece::None; +impl Weapon { + pub fn damage(&self) -> &Damage { + match self { + None(damage) => damage, + Axe(damage, _, _) => damage, + Sword(damage, _, _) => damage, + Other(damage, _, _) => damage + } + } +} + + +//No Gear +pub const NO_HELMET: ArmorPiece = ArmorPiece::None(0); +pub const NO_CHESTPLATE: ArmorPiece = ArmorPiece::None(0); +pub const NO_LEGGINGS: ArmorPiece = ArmorPiece::None(0); +pub const NO_BOOTS: ArmorPiece = ArmorPiece::None(0); +pub const SLIME_HEAD: ArmorPiece = ArmorPiece::Head(0,false,0); + + +//Weapons +pub const NO_WEAPON: Weapon = Weapon::None(0); +pub const WOODEN_AXE: Weapon = Axe(3,false,Wood); +pub const DIAMOND_AXE: Weapon = Axe(6,false,Diamond); +pub const GOLD_SWORD: Weapon = Sword(4,false,Gold); +pub const DIAMOND_SWORD: Weapon = Sword(7,false,Diamond); +pub const SLIME_BALL: Weapon = Other(0, true, "Slime Ball"); + diff --git a/src/commands/zombies/rounds.rs b/src/commands/zombies/rounds.rs index d9b0420..cf6dc92 100644 --- a/src/commands/zombies/rounds.rs +++ b/src/commands/zombies/rounds.rs @@ -1,43 +1,144 @@ use crate::commands::zombies::zombies::*; -struct Wave { - hordes: Vec, -} -struct Round { - waves: Vec, -} +pub type Wave = Vec; +pub type Round = Vec; -fn get_bb_r1() -> Vec { - vec![ - Wave { - hordes: vec![ +pub(crate) struct BadBlood; + +impl BadBlood { + fn round1() -> Round { + vec![ + //wave 1 + vec![ Horde { zombie: BB_Z_1, count: 4, } - ] - }, - Wave { - hordes: vec![ + ], + //wave 2 + vec![ Horde { zombie: BB_Z_1, count: 5, } ] - } - ] -} -pub(crate) fn get_bb_by_round(round: u8) { - match round { - 1 => t(get_bb_r1()), - _ => {} - }; -} -fn t(waves:Vec) { - for wave in waves { - let hordes:Vec = wave.hordes; - for horde in hordes { - println!("{:?} x {}", horde.zombie, horde.count); + ] + } + fn round2() -> Round { + vec![ + //wave 1 + vec![ + Horde { + zombie: BB_Z_1, + count: 4, + }, + Horde { + zombie: BB_SZ_1, + count: 1, + } + ], + //wave 2 + vec![ + Horde { + zombie: BB_Z_2, + count: 4, + }, + Horde { + zombie: BB_SZ_1, + count: 2, + } + ] + ] + } + fn round3() -> Round { + vec![ + //wave 1 + vec![ + Horde { + zombie: BB_Z_2, + count: 4, + }, + Horde { + zombie: BB_SZ_1, + count: 3, + }, + Horde { + zombie: BB_S_1, + count: 2, + } + ], + //wave 2 + vec![ + Horde { + zombie: BB_Z_2, + count: 3, + }, + Horde { + zombie: BB_SZ_1, + count: 2, + }, + Horde { + zombie: BB_S_1, + count: 2, + } + ] + ] + } + fn round4() -> Round { + vec![ + //wave 1 + vec![ + Horde { + zombie: BB_Z_2, + count: 4, + }, + Horde { + zombie: BB_SZ_1, + count: 2, + }, + ], + //wave 2 + vec![ + Horde { + zombie: BB_Z_2, + count: 3, + }, + Horde { + zombie: BB_SZ_1, + count: 2, + }, + Horde { + zombie: BB_S_1, + count: 2, + } + ], + //wave 3 + vec![ + Horde { + zombie: BB_Z_2, + count: 3, + }, + Horde { + zombie: BB_SZ_1, + count: 2, + }, + Horde { + zombie: BB_S_1, + count: 2, + } + ] + ] + } + /*fn round5() -> Round { + + }*/ + pub(crate) fn get_round(round: u8) -> Round { + match round { + 1 => Self::round1(), + 2 => Self::round2(), + 3 => Self::round3(), + 4 => Self::round4(), + _ => panic!("Round {} not found", round) } } } \ No newline at end of file diff --git a/src/commands/zombies/zombies.rs b/src/commands/zombies/zombies.rs index 71736de..253fd53 100644 --- a/src/commands/zombies/zombies.rs +++ b/src/commands/zombies/zombies.rs @@ -1,45 +1,142 @@ -use crate::commands::zombies::gear::ArmorMaterial::Leather; -use crate::commands::zombies::gear::HelmetType::Head; -use crate::commands::zombies::gear::*; -use crate::{Context, Error}; -use ArmorPiece::Leggings; +use crate::commands::zombies::gear::{ + *, + ArmorMaterial::*, + ArmorPiece::*, + Weapon::* +}; +use crate::commands::zombies::rounds::{Round, Wave}; +#[derive(Debug)] +pub struct Family { + family: *const str, + damage: u8, + health: u16, + follow_range: u8, + base_armor: u8, +} #[derive(Debug)] pub struct Zombie { - pub(crate) id: u16, - pub(crate) damage: u8, - pub(crate) health: u16, - pub(crate) speed: f32, - pub(crate) armor: [ArmorPiece; 4], - pub(crate) weapon: Weapon, - pub(crate) follow_range: u8, -} -#[derive(Debug)] -pub struct Horde { - pub(crate) zombie: Zombie, - pub(crate) count: u8, + family: Family, + pub tier: u8, + + pub speed: f32, + armor: Armor, + weapon: Weapon, } -pub const BB_Z_1: Zombie = Zombie { - id: 1, +impl Zombie { + pub fn health(&self) -> u16 { + self.family.health + } + pub fn damage(&self) -> Damage { + self.family.damage+ self.weapon.damage() + } + pub fn follow_range(&self) -> u8 { + self.family.follow_range + } + pub fn armor_value(&self) -> ArmorValue { + let mut armor = self.family.base_armor; + for piece in &self.armor { + armor += piece.armor_value(); + } + armor + } + pub fn family(&self) -> *const str { + self.family.family + } +} + +#[derive(Debug)] +pub struct Horde { + pub zombie: Zombie, + pub count: u8, +} + +pub const BB_BASIC: Family = Family { + family: "basic", damage: 3, - health: 20, - speed: 0.25, - armor: [NO_HELMET, NO_CHESTPLATE, NO_LEGGINGS, NO_BOOTS], - weapon: WOODEN_AXE, + health: 22, follow_range: 35, + base_armor: 2, }; -pub const BB_S_1: Zombie = Zombie { - id: 2, - damage: 4, - health: 25, +pub const BB_SLIME_ZOMBIE: Family = Family { + family: "slime_zombie", + damage: 3, + health: 22, + follow_range: 35, + base_armor: 2, +}; +pub const BB_SLIME: Family = Family { + family: "slime", + damage: 0, + health: 4, + follow_range: 16, + base_armor: 2, +}; + +pub const BB_Z_1: Zombie = Zombie { + family: BB_BASIC, + tier: 1, + speed: 0.25, armor: [ - ArmorPiece::Helmet(Head(3)), - ArmorPiece::Chestplate(Leather(3), false), - Leggings(Leather(3), false), - ArmorPiece::Boots(Leather(3), false), + NO_HELMET, + NO_CHESTPLATE, + NO_LEGGINGS, + NO_BOOTS, + ], + weapon: NO_WEAPON, +}; +pub const BB_Z_2: Zombie = Zombie { + family: BB_BASIC, + tier: 2, + + speed: 0.25, + armor: [ + NO_HELMET, + NO_CHESTPLATE, + Leggings(2,false,Leather(0x000000)), + NO_BOOTS, + ], + weapon: NO_WEAPON, +}; +pub const BB_Z_3: Zombie = Zombie { + family: BB_BASIC, + tier: 3, + + speed: 0.25, + armor: [ + NO_HELMET, + NO_CHESTPLATE, + Leggings(2,false,Leather(0x000000)), + NO_BOOTS, + ], + weapon: WOODEN_AXE, +}; + +pub const BB_SZ_1: Zombie = Zombie { + family: BB_SLIME_ZOMBIE, + tier: 1, + + speed: 0.3, + armor: [ + SLIME_HEAD, + Chestplate(3,false,Leather(0x000000)), + Leggings(2,false,Leather(0x000000)), + Boots(1,false,Leather(0x000000)), ], weapon: SLIME_BALL, - follow_range: 35, +}; +pub const BB_S_1: Zombie = Zombie { + family: BB_SLIME, + tier: 1, + + speed: 0.36, + armor: [ + NO_HELMET, + NO_CHESTPLATE, + NO_LEGGINGS, + NO_BOOTS, + ], + weapon: NO_WEAPON, }; diff --git a/src/main.rs b/src/main.rs index e799e6a..1c2576d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ mod commands; -use crate::commands::round::round; use poise::{async_trait, serenity_prelude as serenity, Event}; use serenity::client::EventHandler; use serenity::model::id::UserId; @@ -35,7 +34,9 @@ async fn poise( COMMANDS: */ commands: vec![ - commands::lfg::lfg() + commands::lfg::lfg(), + commands::round::round(), + commands::xd::xd(), ], prefix_options: poise::PrefixFrameworkOptions { prefix: Some("~".into()),