framework rounds, round-command

This commit is contained in:
Moritz Roßbacher 2023-10-27 18:26:49 +02:00
parent c99ff53ee3
commit 2f547b95a4
7 changed files with 362 additions and 97 deletions

View file

@ -1,3 +1,4 @@
pub(crate) mod lfg; pub(crate) mod lfg;
pub(crate) mod round; pub(crate) mod round;
pub(crate) mod zombies; pub(crate) mod zombies;
pub(crate) mod xd;

View file

@ -1,8 +1,28 @@
use crate::commands::zombies::zombies::*;
use crate::{Context, Error}; use crate::{Context, Error};
use std::convert::Into; use crate::commands::{
lfg::{
*,
Map::{*}
},
zombies::{
rounds
}
};
#[poise::command(slash_command)] #[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(()) Ok(())
} }

11
src/commands/xd.rs Normal file
View file

@ -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(())
}

View file

@ -1,53 +1,87 @@
use crate::commands::zombies::gear::ArmorMaterial::Leather; use crate::commands::zombies::gear::{
use crate::commands::zombies::gear::ArmorPiece::Leggings; Weapon::{*},
use crate::commands::zombies::gear::Weapon::{Axe, Sword}; WeaponMaterial::{*}
use crate::commands::zombies::gear::WeaponMaterial::{Diamond, Gold, Wood}; };
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)] #[derive(Debug)]
pub enum ArmorPiece { pub enum ArmorPiece {
None, None(ArmorValue),
Helmet(HelmetType), Helmet(ArmorValue, Enchanted, ArmorMaterial),
Chestplate(ArmorMaterial, Enchanted), Head(ArmorValue, Enchanted, SkinId),
Leggings(ArmorMaterial, Enchanted), Chestplate(ArmorValue, Enchanted, ArmorMaterial),
Boots(ArmorMaterial, Enchanted), 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)] #[derive(Debug)]
pub enum WeaponMaterial { pub enum WeaponMaterial {
Wood, Wood,
Stone, Stone,
Gold, Gold,
Iron, Iron,
Diamond, Diamond
}
#[derive(Debug)]
pub enum HelmetType {
Head(u32),
Helmet(ArmorMaterial, Enchanted),
} }
#[derive(Debug)] #[derive(Debug)]
pub enum ArmorMaterial { pub enum ArmorMaterial {
Leather(u32), Leather(LeatherColor),
Gold, Gold,
Chainmail, Chainmail,
Iron, Iron,
Diamond, Diamond
} }
#[derive(Debug)] #[derive(Debug)]
pub enum Weapon { pub enum Weapon {
None, None(Damage),
Axe(WeaponMaterial, Enchanted), Axe(Damage, Enchanted, WeaponMaterial),
Sword(WeaponMaterial, Enchanted), 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; impl Weapon {
pub const NO_CHESTPLATE: ArmorPiece = ArmorPiece::None; pub fn damage(&self) -> &Damage {
pub const NO_LEGGINGS: ArmorPiece = ArmorPiece::None; match self {
pub const NO_BOOTS: ArmorPiece = ArmorPiece::None; 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");

View file

@ -1,43 +1,144 @@
use crate::commands::zombies::zombies::*; use crate::commands::zombies::zombies::*;
struct Wave { pub type Wave = Vec<Horde>;
hordes: Vec<Horde>, pub type Round = Vec<Wave>;
}
struct Round {
waves: Vec<Wave>,
}
fn get_bb_r1() -> Vec<Wave> { pub(crate) struct BadBlood;
impl BadBlood {
fn round1() -> Round {
vec![
//wave 1
vec![ vec![
Wave {
hordes: vec![
Horde { Horde {
zombie: BB_Z_1, zombie: BB_Z_1,
count: 4, count: 4,
} }
] ],
}, //wave 2
Wave { vec![
hordes: vec![
Horde { Horde {
zombie: BB_Z_1, zombie: BB_Z_1,
count: 5, count: 5,
} }
] ]
]
}
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,
} }
] ]
} ]
pub(crate) fn get_bb_by_round(round: u8) { }
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 { match round {
1 => t(get_bb_r1()), 1 => Self::round1(),
_ => {} 2 => Self::round2(),
}; 3 => Self::round3(),
} 4 => Self::round4(),
fn t(waves:Vec<Wave>) { _ => panic!("Round {} not found", round)
for wave in waves {
let hordes:Vec<Horde> = wave.hordes;
for horde in hordes {
println!("{:?} x {}", horde.zombie, horde.count);
} }
} }
} }

View file

@ -1,45 +1,142 @@
use crate::commands::zombies::gear::ArmorMaterial::Leather; use crate::commands::zombies::gear::{
use crate::commands::zombies::gear::HelmetType::Head; *,
use crate::commands::zombies::gear::*; ArmorMaterial::*,
use crate::{Context, Error}; ArmorPiece::*,
use ArmorPiece::Leggings; 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)] #[derive(Debug)]
pub struct Zombie { pub struct Zombie {
pub(crate) id: u16, family: Family,
pub(crate) damage: u8, pub tier: u8,
pub(crate) health: u16,
pub(crate) speed: f32, pub speed: f32,
pub(crate) armor: [ArmorPiece; 4], armor: Armor,
pub(crate) weapon: Weapon, weapon: Weapon,
pub(crate) follow_range: u8,
}
#[derive(Debug)]
pub struct Horde {
pub(crate) zombie: Zombie,
pub(crate) count: u8,
} }
pub const BB_Z_1: Zombie = Zombie { impl Zombie {
id: 1, 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, damage: 3,
health: 20, health: 22,
speed: 0.25,
armor: [NO_HELMET, NO_CHESTPLATE, NO_LEGGINGS, NO_BOOTS],
weapon: WOODEN_AXE,
follow_range: 35, follow_range: 35,
base_armor: 2,
}; };
pub const BB_S_1: Zombie = Zombie { pub const BB_SLIME_ZOMBIE: Family = Family {
id: 2, family: "slime_zombie",
damage: 4, damage: 3,
health: 25, 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, speed: 0.25,
armor: [ armor: [
ArmorPiece::Helmet(Head(3)), NO_HELMET,
ArmorPiece::Chestplate(Leather(3), false), NO_CHESTPLATE,
Leggings(Leather(3), false), NO_LEGGINGS,
ArmorPiece::Boots(Leather(3), false), 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, 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,
}; };

View file

@ -1,6 +1,5 @@
mod commands; mod commands;
use crate::commands::round::round;
use poise::{async_trait, serenity_prelude as serenity, Event}; use poise::{async_trait, serenity_prelude as serenity, Event};
use serenity::client::EventHandler; use serenity::client::EventHandler;
use serenity::model::id::UserId; use serenity::model::id::UserId;
@ -35,7 +34,9 @@ async fn poise(
COMMANDS: COMMANDS:
*/ */
commands: vec![ commands: vec![
commands::lfg::lfg() commands::lfg::lfg(),
commands::round::round(),
commands::xd::xd(),
], ],
prefix_options: poise::PrefixFrameworkOptions { prefix_options: poise::PrefixFrameworkOptions {
prefix: Some("~".into()), prefix: Some("~".into()),