fish_lib/game/
interface.rs

1use crate::data::item_data::ItemData;
2use crate::data::location_data::LocationData;
3use crate::data::species_data::SpeciesData;
4use crate::dto::inventory::Inventory;
5use crate::dto::user_location_unlock::UserLocationUnlock;
6use crate::game::errors::GameResult;
7use crate::game::systems::weather_system::weather::Weather;
8use crate::models::fishing_history_entry::FishingHistoryEntry;
9use crate::models::item::Item;
10use crate::models::specimen::Specimen;
11use crate::models::user::User;
12use std::sync::Arc;
13
14/// # Game Interface
15///
16/// The trait defining all available game operations. This interface is implemented
17/// by the [`crate::game::Game`] struct to provide the actual game functionality. It serves as a
18/// contract to ensure all required functionality is implemented and to prevent
19/// accidental breaking changes.
20pub trait GameInterface: Send + Sync {
21    fn item_find(&self, item_id: i32) -> GameResult<Arc<ItemData>>;
22    fn location_find(&self, location_id: i32) -> GameResult<Arc<LocationData>>;
23    fn location_weather_current(&self, location: Arc<LocationData>) -> GameResult<Weather>;
24    fn species_find(&self, species_id: i32) -> GameResult<Arc<SpeciesData>>;
25    fn user_catch_specific_specimen(
26        &self,
27        user: &User,
28        species: Arc<SpeciesData>,
29    ) -> GameResult<(Specimen, FishingHistoryEntry)>;
30    fn user_get_fishing_history(
31        &self,
32        user: &User,
33        species: Arc<SpeciesData>,
34    ) -> GameResult<FishingHistoryEntry>;
35    fn user_find(&self, external_id: i64) -> GameResult<User>;
36    fn user_get_unlocked_locations(&self, user: &User) -> GameResult<Vec<UserLocationUnlock>>;
37    fn user_inventory(&self, user: &User) -> GameResult<Inventory>;
38    fn user_item_give(&self, user: &User, item: Arc<ItemData>, count: u64) -> GameResult<Item>;
39    fn user_register(&self, external_id: i64) -> GameResult<User>;
40    fn user_save(&self, user: User) -> GameResult<User>;
41    fn user_unlock_location(
42        &self,
43        user: &User,
44        location: Arc<LocationData>,
45    ) -> GameResult<UserLocationUnlock>;
46}