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 round;
pub(crate) mod zombies;
pub(crate) mod xd;

View file

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

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::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");

View file

@ -1,43 +1,144 @@
use crate::commands::zombies::zombies::*;
struct Wave {
hordes: Vec<Horde>,
}
struct Round {
waves: Vec<Wave>,
}
pub type Wave = Vec<Horde>;
pub type Round = Vec<Wave>;
fn get_bb_r1() -> Vec<Wave> {
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<Wave>) {
for wave in waves {
let hordes:Vec<Horde> = 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)
}
}
}

View file

@ -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,
};

View file

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