framework mapdata
This commit is contained in:
parent
b0a712bd6e
commit
05814dd0e7
9 changed files with 215 additions and 34 deletions
2
.idea/ZMP-bot.iml
generated
2
.idea/ZMP-bot.iml
generated
|
@ -3,6 +3,8 @@
|
|||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/commands/T/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/commands/T/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
|
|
@ -3,15 +3,13 @@ use crate::commands::lfg::Difficulty::Normal;
|
|||
use crate::commands::lfg::Map::*;
|
||||
use crate::commands::lfg::Mode::*;
|
||||
//from main.rs
|
||||
use crate::Context;
|
||||
use crate::Error;
|
||||
use crate::{Context, Error};
|
||||
//
|
||||
use serenity::model::id::RoleId;
|
||||
use serenity::model::id::{RoleId};
|
||||
use serenity::model::mention::Mention;
|
||||
use serenity::model::mention::Mention::Role;
|
||||
use serenity::prelude::Mentionable;
|
||||
use serenity::model::mention::Mention::{Role};
|
||||
|
||||
#[derive(Debug, poise::ChoiceParameter)]
|
||||
#[derive(Debug, poise::ChoiceParameter, PartialEq)]
|
||||
pub enum Map {
|
||||
#[name = "Dead End"]
|
||||
DeadEnd,
|
||||
|
@ -41,7 +39,9 @@ pub enum Difficulty {
|
|||
#[poise::command(slash_command)]
|
||||
pub(crate) async fn lfg(
|
||||
ctx: Context<'_>,
|
||||
#[rename = "map"] map: Map,
|
||||
|
||||
#[rename = "map"]
|
||||
map: Map,
|
||||
|
||||
#[description = "Normal"]
|
||||
#[rename = "difficulty"]
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
pub(crate) mod lfg;
|
||||
pub(crate) mod round;
|
||||
pub(crate) mod zombies;
|
||||
|
|
10
src/commands/round.rs
Normal file
10
src/commands/round.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
use std::convert::Into;
|
||||
use crate::{Context, Error};
|
||||
use crate::commands::zombies::zombies::*;
|
||||
|
||||
#[poise::command(slash_command)]
|
||||
pub(crate) async fn round(
|
||||
ctx: Context<'_>
|
||||
) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
46
src/commands/zombies/gear.rs
Normal file
46
src/commands/zombies/gear.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
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};
|
||||
#[derive(Debug)]
|
||||
pub enum ArmorPiece {
|
||||
None,
|
||||
Helmet(ArmorMaterial),
|
||||
Chestplate(ArmorMaterial),
|
||||
Leggings(ArmorMaterial),
|
||||
Boots(ArmorMaterial)
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub enum WeaponMaterial {
|
||||
Wood,
|
||||
Stone,
|
||||
Gold,
|
||||
Iron,
|
||||
Diamond
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub enum ArmorMaterial {
|
||||
Leather,
|
||||
Gold,
|
||||
Chainmail,
|
||||
Iron,
|
||||
Diamond
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub enum Weapon {
|
||||
None,
|
||||
Axe(WeaponMaterial),
|
||||
Sword(WeaponMaterial)
|
||||
}
|
||||
pub const NO_WEAPON:Weapon = Weapon::None;
|
||||
pub const WOODEN_AXE:Weapon = Axe(Wood);
|
||||
pub const DIAMOND_AXE:Weapon = Axe(Diamond);
|
||||
pub const GOLD_SWORD:Weapon = Sword(Gold);
|
||||
pub const DIAMOND_SWORD:Weapon = Sword(Diamond);
|
||||
|
||||
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;
|
||||
|
||||
pub const LEATHER_LEGGINGS:ArmorPiece = Leggings(Leather);
|
3
src/commands/zombies/mod.rs
Normal file
3
src/commands/zombies/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub mod zombies;
|
||||
pub mod gear;
|
||||
pub(crate) mod rounds;
|
53
src/commands/zombies/rounds.rs
Normal file
53
src/commands/zombies/rounds.rs
Normal file
|
@ -0,0 +1,53 @@
|
|||
use crate::commands::zombies::rounds::Round::*;
|
||||
use crate::commands::zombies::rounds::Wave::*;
|
||||
use crate::commands::zombies::zombies::*;
|
||||
/*type Wave = Vec<Horde>;
|
||||
type Round = Vec<Wave>;
|
||||
|
||||
fn bad_blood_round1() -> Round {
|
||||
let mut round:Round = Vec::with_capacity(2);
|
||||
let mut wave1:Wave = Vec::with_capacity(2);
|
||||
let mut wave2:Wave = Vec::with_capacity(1);
|
||||
wave1.push(Horde {
|
||||
zombie: BB_Z_1,
|
||||
count: 4
|
||||
});
|
||||
wave2.push(Horde {
|
||||
zombie: BB_Z_1,
|
||||
count: 5
|
||||
});
|
||||
round.push(wave1);
|
||||
round.push(wave2);
|
||||
round
|
||||
}*/
|
||||
|
||||
pub enum Wave {
|
||||
Wave1horde([Horde;1]),
|
||||
Wave2hordes([Horde;2]),
|
||||
Wave3hordes([Horde;3]),
|
||||
Wave4hordes([Horde;4]),
|
||||
Wave5hordes([Horde;5]),
|
||||
Wave6hordes([Horde;6]),
|
||||
Wave7hordes([Horde;7])
|
||||
}
|
||||
pub enum Round {
|
||||
Round2Waves([Wave;2]),
|
||||
Round3Waves([Wave;3]),
|
||||
Round4Waves([Wave;4]),
|
||||
Round5Waves([Wave;5]),
|
||||
Round6Waves([Wave;6]),
|
||||
Round7Waves([Wave;7])
|
||||
}
|
||||
const DE:[Round;30] = [
|
||||
Round2Waves([
|
||||
Wave1horde([
|
||||
Horde { zombie: BB_Z_1, count: 4 }
|
||||
]),
|
||||
Wave1horde([
|
||||
Horde { zombie: BB_Z_1, count: 5 }
|
||||
])
|
||||
]);30
|
||||
];
|
||||
/*fn t() {
|
||||
DE.get(2)
|
||||
}*/
|
27
src/commands/zombies/zombies.rs
Normal file
27
src/commands/zombies/zombies.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use crate::commands::zombies::gear::*;
|
||||
use crate::{Context, Error};
|
||||
#[derive(Debug)]
|
||||
pub struct Zombie {
|
||||
id: u16,
|
||||
damage: u8,
|
||||
health: u16,
|
||||
speed: f32,
|
||||
armor: [ArmorPiece;4],
|
||||
weapon: Weapon,
|
||||
follow_range: u8
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct Horde {
|
||||
pub zombie: Zombie,
|
||||
pub count: u8
|
||||
}
|
||||
|
||||
pub const BB_Z_1: Zombie = Zombie {
|
||||
id: 1,
|
||||
damage: 3,
|
||||
health: 20,
|
||||
speed: 0.25,
|
||||
armor: [NO_HELMET,NO_CHESTPLATE,LEATHER_LEGGINGS,NO_BOOTS],
|
||||
weapon: WOODEN_AXE,
|
||||
follow_range: 35
|
||||
};
|
56
src/main.rs
56
src/main.rs
|
@ -1,22 +1,31 @@
|
|||
mod commands;
|
||||
|
||||
use poise::serenity_prelude as serenity;
|
||||
use poise::{async_trait, Event, serenity_prelude as serenity};
|
||||
use serenity::model::id::UserId;
|
||||
use std::collections::HashSet;
|
||||
use std::convert::Into;
|
||||
use serenity::client::EventHandler;
|
||||
use crate::commands::round::round;
|
||||
|
||||
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||
// User data, which is stored and accessible in all command invocations
|
||||
pub struct Data {}
|
||||
struct ReadyHandler;
|
||||
|
||||
#[async_trait]
|
||||
impl EventHandler for ReadyHandler {
|
||||
async fn ready(&self, _: poise::serenity_prelude::Context, ready: poise::serenity_prelude::Ready) {
|
||||
println!("{} is connected!", ready.user.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let mut owners = HashSet::new();
|
||||
owners.insert(UserId(449579075531440128_u64));
|
||||
let framework = poise::Framework::builder()
|
||||
.options(poise::FrameworkOptions {
|
||||
commands: vec![commands::lfg::lfg()],
|
||||
let options = poise::FrameworkOptions {
|
||||
commands: vec![
|
||||
commands::lfg::lfg(),
|
||||
],
|
||||
prefix_options: poise::PrefixFrameworkOptions {
|
||||
prefix: Some("~".into()),
|
||||
..Default::default()
|
||||
|
@ -35,13 +44,28 @@ async fn main() {
|
|||
}
|
||||
})
|
||||
},
|
||||
owners,
|
||||
owners: {
|
||||
HashSet::from([UserId(449579075531440128_u64)])
|
||||
},
|
||||
event_handler: |_ctx, event, _framework, _data| {
|
||||
Box::pin(event_handler(_ctx, event, _framework, _data))
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
let framework = poise::Framework::builder()
|
||||
|
||||
.options(options)
|
||||
|
||||
.token(std::env::var("DISCORD_TOKEN").unwrap())
|
||||
|
||||
.intents(
|
||||
serenity::GatewayIntents::non_privileged() | serenity::GatewayIntents::MESSAGE_CONTENT,
|
||||
)
|
||||
|
||||
.setup(move |ctx, _ready, framework| {
|
||||
Box::pin(async move {
|
||||
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||
|
@ -51,3 +75,17 @@ async fn main() {
|
|||
|
||||
framework.run().await.unwrap();
|
||||
}
|
||||
async fn event_handler(
|
||||
_ctx: &serenity::Context,
|
||||
event: &Event<'_>,
|
||||
_framework: poise::FrameworkContext<'_, Data, Error>,
|
||||
_data: &Data,
|
||||
) -> Result<(), Error> {
|
||||
match event {
|
||||
Event::Ready { data_about_bot } => {
|
||||
println!("Logged in as {}", data_about_bot.user.name);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Reference in a new issue