| Crates.io | fish-lib |
| lib.rs | fish-lib |
| version | 0.2.3 |
| created_at | 2025-02-03 18:11:22.299867+00 |
| updated_at | 2025-02-15 23:37:33.847685+00 |
| description | A work-in-progress fishing game library containing the game/storage logic for a discord fishing game I'm working on. |
| homepage | |
| repository | https://github.com/Zitronenjoghurt/fish-lib |
| max_upload_size | |
| id | 1540853 |
| size | 292,879 |
THIS LIBRARY IS STILL IN DEVELOPMENT, ALL FEATURES ARE WORK-IN-PROGRESS AND MAY BE SUBJECT TO CHANGE
The game/storage logic for a highly customizable fishing game. This library is tailored to MMO-style fishing games for discord bots, etc.
These examples are not doc-tested. If you notice inaccuracies, please create an issue.
Doc-tested examples can be found in the Game struct's documentation.
This will show you how to interact with this library on a basic level.
use fish_lib::config::{Config, ConfigBuilderInterface};
use fish_lib::game::prelude::*;
use std::path::Path;
const POSTGRES_URL: &str = "...";
// For simplification all errors will be unwrapped, you can choose how you want to handle errors.
// Examples of error handling can be found in the documentation of the Game functions.
fn main() {
let locations_file_path: &Path = "...";
let settings_file_path: &Path = "...";
let species_file_path: &Path = "...";
let config = Config::builder()
.locations_file(locations_file_path).unwrap()
.settings_file(settings_file_path).unwrap()
.species_file(species_file_path).unwrap()
.build().unwrap();
// Will create a new game interface
// Fails if it's unable to connect to the database
let game = Game::new(POSTGRES_URL, Some(config)).unwrap();
// Register a user
let external_id: i64 = 1337; // That's the ID your system identifies this user with
let mut user = game.user_register(external_id).unwrap();
// Manipulate and save the user
user.credits = 10;
let updated_user = game.user_save(user).unwrap();
assert_eq!(updated_user.credits, 10);
}