Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predicting exobiology species on planets #15

Merged
merged 91 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
a710eff
✨ Added `check_for_planet` function
Somfic May 15, 2024
db42580
➕ Added `strum` to iterate over enum values
Somfic May 15, 2024
0159063
✨ Added `get_spawnable_species` function
Somfic May 15, 2024
a8a1a61
♻️ Moved `get_spawnable_species` to `SpawnSource`
Somfic May 15, 2024
328db2b
🏷️ Add `Debug` derive to `SpawnCondition`
Somfic May 15, 2024
76313b3
♻️ Use `Option` for `SpawnSource` fields
Somfic May 15, 2024
3e07437
🧪 Added tests for `get_spawnable_species` function
Somfic May 15, 2024
e1fdfa8
🏷️ Derive `Hash` and `Eq` for `Species`
Somfic May 16, 2024
7014ba3
🧪 Print all failing conditions instead of failing quickly
Somfic May 16, 2024
aeb51c2
🐛 Fix gravity being used wrongly
Somfic May 16, 2024
5faeb95
🏷️ Added `Gravity` type
Somfic May 16, 2024
94f92cc
🚨 Actually import the `Gravity` type
Somfic May 16, 2024
701a356
♻️ Refactor `Gravity` to be a struct that wraps a `f32`
Somfic May 16, 2024
0e5f883
Merge remote-tracking branch 'upstream/master' into exobiology-species
Somfic May 16, 2024
a7f5ee9
🏷️ Added `Distance` type
Somfic May 17, 2024
e525391
🏷️ Derive `Hash` and `Eq` for `PlanetClass`
Somfic May 17, 2024
365471c
♻️ Moved some fields from `TargetPlanet` to `SpawnSource`
Somfic May 17, 2024
29c37bd
✨ Added `feed_fss_body_signals_event`
Somfic May 17, 2024
07da856
✨ Created `exobioligy_state`
Somfic May 17, 2024
ffc20ac
🧪 Revert using `println` instead of `assert` in test
Somfic May 17, 2024
a9f6172
♻️ Renamed `distance_from_arrival_ls` to `distance_from_arrival`
Somfic May 17, 2024
6c9a31d
🐛 Fix rename `distance_from_arrival_ls` to `distance_from_arrival`
Somfic May 17, 2024
0f09830
🐛 Added numbers to `StarLuminosity` enum for comparing against intself
Somfic May 17, 2024
fe179a5
🧪 Added `test_star_luminosity_comparison` test
Somfic May 17, 2024
c69569f
🏷️ Added `SpawnCondition::MaterialPresence`
Somfic May 17, 2024
870cdfc
🏷️ Added `SpawnCondition::RockyComposition`
Somfic May 17, 2024
4e9a016
🏷️ Added `SpawnCondition::IcyComposition`
Somfic May 17, 2024
3f7ad49
🏷️ Added `SpawnCondition::MetalComposition`
Somfic May 17, 2024
0f3ebfd
🏷️ Derive `Hash` and `Eq` for `Material`
Somfic May 17, 2024
83d3beb
♻️ Use `SpawnCondition::RockyComposition` instead of ` SpawnCondition…
Somfic May 17, 2024
cf3372c
🐛 Fixed some spawn conditions
Somfic May 17, 2024
747bb96
🏷️ Implemented `Debug` implementation for `DistanceLs`
Somfic May 17, 2024
808d225
🏷️ Implemented `Debug` implementation for `Gravity`
Somfic May 17, 2024
6336b8f
♻️ Updated imports
Somfic May 17, 2024
b7ef2b5
♻️ Allow for multiple parents in `SpawnSource`
Somfic May 17, 2024
cbcec01
♻️ Made `body_name` public on `SpawnSource`
Somfic May 17, 2024
7b10ca9
✨ Implemented `SpawnCondition::MaterialPresence`
Somfic May 17, 2024
dd096db
✨ Implemented `SpawnCondition:: RockyComposition`
Somfic May 17, 2024
45aba16
✨ Implemented `SpawnCondition::IcyComposition`
Somfic May 17, 2024
c0ddaef
✨ Implemented `SpawnCondition::MetalComposition`
Somfic May 17, 2024
30fb0d5
🏷️ Added `PlanetComposition`
Somfic May 17, 2024
533cba3
♻️ Track the `body_id` of each `Star`
Somfic May 17, 2024
d48fb1c
♻️ Track `materials` on `TargetPlanet`
Somfic May 17, 2024
3cd8e43
♻️ Refactored `SpawnSource` functions
Somfic May 17, 2024
f7bb256
🧪 Updated `SpawnSource` tests
Somfic May 17, 2024
45f528b
🧪 Optimised tests
Somfic May 17, 2024
1928aef
Merge remote-tracking branch 'upstream/master' into exobiology-species
Somfic May 17, 2024
2e2d6aa
🔀 Re-added fixed conditions after merge
Somfic May 17, 2024
e6fb633
🔀 Fixed merge conflict
Somfic May 17, 2024
9a7d0b4
🔀 Fixed merge conflict
Somfic May 17, 2024
4e4284f
🔀 Fixed merge conflict
Somfic May 17, 2024
934e335
🔀 Fixed merge conflict
Somfic May 17, 2024
a3e7150
♻️ Use `HashSet` for `parent_stars_ids`
Somfic May 17, 2024
a31d99c
🧪 Rename test to `spawnable_species_no_false_negatives`
Somfic May 17, 2024
333795c
✨ Added `star_system_position`
Somfic May 17, 2024
461af6f
Merge remote-tracking branch 'upstream/master' into exobiology-species
Somfic May 17, 2024
5244295
✨ Added lightyears to `DistanceLs`
Somfic May 17, 2024
0caf078
🏷️ Derive `EnumIter` for `Nebula`
Somfic May 17, 2024
816de18
🏷️ Derive `Hash` and `Eq` for `StarClass`
Somfic May 17, 2024
48dd058
🏷️ Derive `Hash` for `StarLuminosity`
Somfic May 17, 2024
abd888b
♻️ Use `HashSet` for `stars_in_system`
Somfic May 17, 2024
2141074
✨ Implemented `SpawnCondition::WithinNebulaRange`
Somfic May 17, 2024
49c845d
💡 Updated `WithinNebulaRange` comment to include unit
Somfic May 17, 2024
763d533
💡 Removed fixed fixme
Somfic May 17, 2024
bb0f865
🐛 Fixed wrong light year to light second conversion
Somfic May 17, 2024
43838f8
🐛 Fixed wrong `Debug` implement for `Distance`
Somfic May 17, 2024
3ea1947
📝 Start working on adding a lot more doc comments
rster2002 May 17, 2024
7ed7e68
✨ Added `feed_location_event` and `feed_fsd_jump_event`
Somfic May 17, 2024
055f9f7
🧪 Added blacklisted bodies
Somfic May 17, 2024
f57a2fb
🧪 Print all failing tests, instead of immediately panicking
Somfic May 17, 2024
003fd5f
🐛 Fixed spawn conditions for Fumerola Extremus
Somfic May 17, 2024
b18e8cc
🧪 Added missing `#[cfg(test)]` on test modules
Somfic May 17, 2024
474b2bb
♻️ Renamed `Star` to `SpawnSourceStar`
Somfic May 17, 2024
4a58564
⚰️ Removed unused `Body` struct
Somfic May 17, 2024
dc9f7ea
♻️ Moved `PlanetComposition` to `models::galaxy`
Somfic May 17, 2024
b7206e4
♻️ Use `PlanetComposition` instead of `ScanEventPlanetComposition`
Somfic May 17, 2024
7f4c449
Merge remote-tracking branch 'upstream/master' into exobiology-species
Somfic May 18, 2024
5befa55
🚚 Move modules out of the models module
rster2002 May 18, 2024
9b7f79b
🚚 Update imports
rster2002 May 18, 2024
0da1ded
📝 Continue working on documentation
rster2002 May 18, 2024
9cc98be
Merge remote-tracking branch 'origin/master' into documentation
rster2002 May 18, 2024
b597677
📝 Continue working on documentation
rster2002 May 19, 2024
97fe266
✅ Fix tests blocking indefinitely
rster2002 May 19, 2024
138cac8
👷 Update workflows to have a lower timeout
rster2002 May 19, 2024
72c16cb
🏷️ Derive `Serialize` for `SpawnSource` (and children)
Somfic May 19, 2024
b5bc798
♻️ Moved `SpawnSource` construction to `ExobiologyState`
Somfic May 19, 2024
04d68a2
✨ Added `ExobiologyState` to `SystemState`
Somfic May 19, 2024
183ae5e
🔀 Merge pull request #34 from rster2002/documentation
rster2002 May 19, 2024
eb1de54
♻️ Access `SpawnSource` through `system.exobioligy.for_body()`
Somfic May 19, 2024
a4747eb
♻️ Moved distance calculations for nebulas to `Nebula`
Somfic May 19, 2024
d041b66
🔀 Merge
rster2002 May 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ env:

jobs:
build:

runs-on: ubuntu-latest

timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: Build
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-no-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ env:

jobs:
build:

runs-on: ubuntu-latest

timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: Build
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-strict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ env:

jobs:
build:

runs-on: ubuntu-latest

timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: Build
Expand Down
32 changes: 25 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,45 @@
//! > **Warning** this project is currently in beta, which means that it is very much work in progress. Breaking
//! > changes are likely to happen.
//!
//! ## Getting started
//! ## Where to start
//!
//! Currently, the only files that are parsed are the log files. Models for working `Market.json`
//! and `Status.json` etc will be added in the future. Best place to get started is the [JournalDir]
//! model.
//! This library contains quite a large number of modules that each cover a different part of the
//! game, but there are a couple of modules that are important to point out:
//!
//! * The [logs] module contains readers and models for reading the `Journal.log` files that are
//! stored in the games journal directory.
//! * [State](state) can be used to turn the logs from the `Journal.log` files into a single state that can
//! then be queried and used to figure out the current or previous state of the game.
//! * The [journal] module can be used to interact with the whole journal directory and can watch
//! the directory as a whole for changes.

mod modules;

pub use modules::logs;
pub use modules::models;
pub use modules::journal;
pub use modules::state;

pub use modules::status;
pub use modules::state;
pub use modules::exobiology;
pub use modules::exploration;
pub use modules::outfitting;
pub use modules::shipyard;
pub use modules::market;
pub use modules::nav_route;
pub use modules::modules_info;
pub use modules::backpack;
pub use modules::cargo;
pub use modules::ship_locker;
pub use modules::galaxy;
pub use modules::civilization;
pub use modules::commander;
pub use modules::materials;
pub use modules::trading;
pub use modules::odyssey;
pub use modules::ship;
pub use modules::station;
pub use modules::thargoid;
pub use modules::small;
pub use modules::mixed;

#[cfg(test)]
mod tests {
Expand Down
93 changes: 89 additions & 4 deletions src/modules.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,111 @@
/// Contains modules for working with journal log files providing readers for individual files or
/// all files at once.
pub mod logs;

/// Allows for tracking journal directory as a whole, firing events for when logs change but also
/// for when `.json` files are updated.
pub mod journal;

/// Utilities for working with the `Status.json` file. The `Status.json` file contains information
/// about the current status of the player and their ship. Things like if the player is docked
/// or landed or the location of the player on a planet.
pub mod status;

/// Used to construct a state by feeding it events from the journal logs which can then be used
/// to create relations between events and create a history.
pub mod state;

/// Contains models for genuses, species and variants and utilities for predicting possible
/// biological scans for planets
pub mod exobiology;

/// Contains functions for exploration related things, like calculating estimated exploration value
/// for stars and planets and for analysing scans for unusual data.
pub mod exploration;

/// Utilities for working with the `Outfitting.json` file. Is updated when opening the outfitting
/// menu on stations and includes all the modules that are available for purchase at that market.
/// Is reset every time the player opens the outfitting menu.
pub mod outfitting;

/// Utilities for working with the `Shipyard.json` file. Is updated when opening the shipyard menu
/// on stations and lists all the ships that are available to buy at that location. Resets every
/// time the player opens the shipyard menu.
pub mod shipyard;

/// Utilities for working with the `Market.json` file. Includes a list of commodities that are being
/// sold/requested at the current location. Resets every time the player opens the commodity market.
pub mod market;

/// Utilities for working with the `NavRoute.json` file. Provides the current plotted nav route for
/// the player. Resets if the player selects a new route destination or when clearing the route.
pub mod nav_route;

/// Utilities for working with the `ModulesInfo.json` file. This file provides information about
/// the current state of the modules of the player's ship.
pub mod modules_info;

/// Utilities for working with the `Backpack.json` file. Contains all the items that the player
/// currently has in their backpack. This is only filled if the player has the Odyssey expansion.
/// Updates when there are changes to the player's backpack.
pub mod backpack;

/// Utilities for working with the `Cargo.json` file. Includes a list of all the commodities that
/// the player currently has in their inventory. This is updated for both the player's ship and
/// an SRV, so at one time it might show the inventory of the player's ship and the next it shows
/// the inventory of the SRV, but never both at once. Is updated when there are changes to the
/// cargo hold or when switching between ship and SRV and vise versa.
pub mod cargo;
pub mod ship_locker;

/// Contains structs and enums which are used in multiple places. Things like commodity and material
/// names, ship types, exobiology data etc. can be found here.
pub mod models;
/// Utilities for working with the `ShipLocker.json` file. This file includes all the Odyssey items
/// the player has stored on their ship. Is updated when there are changes.
pub mod ship_locker;

/// Provides some utility functions and macros that are used internally.
mod utils;

/// Module for shared internal code.
mod shared;

/// Provides models for bodies like stars and planets.
pub mod galaxy;

/// This module contains models for things that have to do with civilisation and populated systems.
/// Things like the different superpowers or economies.
pub mod civilization;

/// Contains models for models for commander ranks.
pub mod commander;

/// Models and data for materials that are used for ship engineering. For materials that are used
/// for suit engineering, check the [odyssey] module.
pub mod materials;

/// Includes the commodity enum, which is used in various places in the library and contains all
/// the different commodities that can be bought/acquired.
pub mod trading;

/// Contains models and utilities for things that have been added in the Odyssey expansion of the
/// game. Note that [exobiology] is its own separate module.
pub mod odyssey;

/// Contains everything that has to do with ships, including the different types of ships, but also
/// the different modules that can be equipped.
pub mod ship;

/// Models related to stations and markets. Also contains some models that are used for fleet
/// carriers.
pub mod station;

/// Includes models related to Thargoids. Most importantly: the different types of Thargoids that
/// player can encounter.
pub mod thargoid;

/// This module contains 'small' models that are used to create representations for certain things
/// without needing to include all the information as it can differ quite a bit between the
/// different events of the game.
pub mod small;

/// Sometimes the game reuses certain events and instead of 'ship' data it sets Odyssey related
/// data. These mixed data types handle these differences.
pub mod mixed;
2 changes: 1 addition & 1 deletion src/modules/backpack/models/backpack_entry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::Deserialize;
use crate::models::odyssey::item::Item;
use crate::modules::odyssey::Item;

#[derive(Debug, Deserialize, PartialEq)]
#[serde(rename_all = "PascalCase")]
Expand Down
2 changes: 1 addition & 1 deletion src/modules/cargo/models/cargo_entry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::Deserialize;
use crate::models::trading::commodity::Commodity;
use crate::modules::trading::Commodity;

#[derive(Debug, Deserialize, PartialEq)]
#[serde(rename_all = "PascalCase")]
Expand Down
16 changes: 16 additions & 0 deletions src/modules/civilization/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mod models;

pub use models::conflict::Conflict;
pub use models::conflict::ConflictFaction;
pub use models::conflict::ConflictWarType;
pub use models::economy::Economy;
pub use models::faction::Faction;
pub use models::faction::FactionActiveState;
pub use models::faction_happiness::FactionHappiness;
pub use models::faction_state::FactionState;
pub use models::government::Government;
pub use models::superpower::Superpower;
pub use models::location_info::LocationInfo;
pub use models::system_security::SystemSecurity;
pub use models::thargoid_war::ThargoidWar;
pub use models::thargoid_war::ThargoidWarState;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ pub mod conflict;
pub mod economy;
pub mod faction;
pub mod faction_state;
pub mod faction_happiness;
pub mod government;
pub mod superpower;
pub mod system_info;
pub mod location_info;
pub mod system_security;
pub mod thargoid_war;
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
use serde::{Serialize, Deserialize};

use crate::modules::models::civilization::faction::faction_happiness::FactionHappiness;
use crate::modules::models::civilization::faction_state::FactionState;
use crate::modules::models::civilization::government::Government;
use crate::modules::models::civilization::superpower::Superpower;

mod faction_happiness;
use crate::modules::civilization::{FactionHappiness, FactionState, Government, Superpower};

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
use serde::{Serialize, Deserialize};

use crate::modules::models::civilization::conflict::Conflict;
use crate::modules::models::civilization::economy::Economy;
use crate::modules::models::civilization::faction::Faction;
use crate::modules::models::civilization::government::Government;
use crate::modules::models::civilization::superpower::Superpower;
use crate::modules::models::civilization::system_security::SystemSecurity;
use crate::modules::models::civilization::thargoid_war::ThargoidWar;
use crate::modules::models::galaxy::body_type::BodyType;
use crate::modules::civilization::{Conflict, Economy, Faction, Government, Superpower, SystemSecurity, ThargoidWar};
use crate::modules::galaxy::BodyType;

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct SystemInfo {
pub struct LocationInfo {
/// The name of the star system that is displayed to the player.
pub star_system: String,

Expand Down
16 changes: 16 additions & 0 deletions src/modules/commander/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mod models;

pub use models::combat_rank::CombatRank;
pub use models::combat_rank::CombatRankError;
pub use models::empire_rank::EmpireRank;
pub use models::empire_rank::EmpireRankError;
pub use models::exobiology_rank::ExobiologyRank;
pub use models::exobiology_rank::ExobiologyRankError;
pub use models::exploration_rank::ExplorationRank;
pub use models::exploration_rank::ExplorationRankError;
pub use models::federation_rank::FederationRank;
pub use models::federation_rank::FederationRankError;
pub use models::mercenary_rank::MercenaryRank;
pub use models::mercenary_rank::MercenaryRankError;
pub use models::trade_rank::TradeRank;
pub use models::trade_rank::TradeRankError;
File renamed without changes.
17 changes: 15 additions & 2 deletions src/modules/exobiology/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
pub mod models;
pub(crate) mod r#static;
mod models;
mod r#static;

pub use models::genus::Genus;
pub use models::spawn_condition::SpawnCondition;
pub use models::spawn_source::SpawnSource;
pub use models::spawn_source::SpawnSourceStar;
pub use models::spawn_source::TargetPlanet;
pub use models::species::Species;
pub use models::variant::Variant;
pub use models::variant::VariantError;
pub use models::variant_color::VariantColor;
pub use models::variant_color::VariantColorError;
pub use models::variant_source::VariantSource;
pub use models::variant_source::VariantSourceError;
5 changes: 5 additions & 0 deletions src/modules/exobiology/models.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
pub mod spawn_condition;
pub mod spawn_source;
pub mod genus;
pub mod species;
pub mod variant;
pub mod variant_color;
pub mod variant_source;
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::fmt::{Display, Formatter};

use serde::{Serialize, Deserialize};

use crate::modules::models::exploration::species::Species;
use crate::modules::exobiology::Species;

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum Genus {
Expand Down
17 changes: 12 additions & 5 deletions src/modules/exobiology/models/spawn_condition.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use crate::modules::models::galaxy::atmosphere_type::AtmosphereType;
use crate::modules::models::galaxy::planet_class::PlanetClass;
use crate::modules::models::galaxy::star_class::StarClass;
use crate::modules::models::galaxy::star_luminosity::StarLuminosity;
use crate::modules::models::galaxy::volcanism_type::VolcanismType;
use crate::materials::Material;
use crate::modules::galaxy::{AtmosphereType, PlanetClass, StarClass, StarLuminosity, VolcanismType};

#[derive(Debug)]
pub enum SpawnCondition {
MinMeanTemperature(f32),
MaxMeanTemperature(f32),
NoAtmosphere,
AnyThinAtmosphere,
ThinAtmosphere(AtmosphereType),
/// The minimum gravity the planet must have, in G
MinGravity(f32),
/// The maximum gravity the planet must have, in G
MaxGravity(f32),
PlanetClass(PlanetClass),
ParentStarClass(StarClass),
Expand All @@ -22,11 +22,18 @@ pub enum SpawnCondition {
MinDistanceFromParentSun(f32),
AnyVolcanism,

/// The maximum distance the planet needs to be from the center of a nebula in Ly
WithinNebulaRange(f32),

/// The target planet must have at least one geological signal present.
GeologicalSignalsPresent,

MaterialPresence(Material),

RockyComposition,
IcyComposition,
MetalComposition,

Any(Vec<SpawnCondition>),
All(Vec<SpawnCondition>),
}
Loading
Loading