/*
Hurry Curry! - a game about cooking
Copyright 2024 metamuffin
Copyright 2024 nokoe
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License only.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
pub mod demands;
pub mod index;
use crate::entity::{construct_entity, Entities, EntityDecl};
use anyhow::{anyhow, bail, Result};
use demands::generate_demands;
use hurrycurry_bot::algos::ALGO_CONSTRUCTORS;
use hurrycurry_protocol::{
glam::{IVec2, Vec2},
Gamedata, ItemIndex, MapMetadata, Recipe, TileIndex,
};
use serde::{Deserialize, Serialize};
use std::{
collections::{HashMap, HashSet},
fs::File,
path::PathBuf,
str::FromStr,
sync::{Mutex, RwLock},
time::Duration,
};
use tokio::fs::read_to_string;
#[derive(Debug, Deserialize, Serialize, Clone, Copy, Default)]
#[serde(rename_all = "snake_case")]
pub enum RecipeDeclAction {
#[default]
Never,
Passive,
Active,
Instant,
Demand,
}
#[rustfmt::skip]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RecipeDecl {
#[serde(default)] tile: Option,
#[serde(default)] inputs: Vec,
#[serde(default)] outputs: Vec,
#[serde(default)] action: RecipeDeclAction,
#[serde(default)] warn: bool,
#[serde(default)] revert_duration: Option,
#[serde(default)] duration: Option,
#[serde(default)] points: Option,
}
#[rustfmt::skip]
#[derive(Debug, Clone, Deserialize)]
pub struct MapDecl {
#[serde(default)] recipes: Option,
map: Vec,
tiles: HashMap,
#[serde(default)] items: HashMap,
collider: Vec,
walkable: Vec,
chef_spawn: char,
customer_spawn: char,
#[serde(default)] entities: Vec,
#[serde(default)] tile_entities: HashMap,
#[serde(default)] score_baseline: i64,
#[serde(default)] default_timer: Option,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DemandDecl {
from: String,
to: Option,
duration: f32,
points: i64,
}
#[derive(Debug,Clone, Default)]
#[rustfmt::skip]
pub struct Serverdata {
pub initial_map: HashMap)>,
pub chef_spawn: Vec2,
pub customer_spawn: Vec2,
pub score_baseline: i64,
pub default_timer: Option
}
#[derive(Debug, Deserialize, Default)]
pub struct DataIndex {
pub maps: HashMap,
pub recipes: HashSet,
}
pub static DATA_DIR: Mutex