Skip to main content

rakata_core/
game.rs

1//! Which of the two games something belongs to.
2
3use std::fmt;
4
5/// Which game an install, a mount or a rule belongs to.
6///
7/// The games share a resource system and most of their formats, and differ in
8/// what an install mounts and how some files are laid out. Anything that has to
9/// behave differently takes this as an input instead of working it out from the
10/// files in front of it. Finding out which game a directory holds is
11/// `rakata-install`'s job, and it can fail to say.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
13pub enum Game {
14    /// Knights of the Old Republic.
15    KOTOR1,
16    /// Knights of the Old Republic II.
17    KOTOR2,
18}
19
20impl fmt::Display for Game {
21    /// Names the game the way somebody modding it would.
22    ///
23    /// `KOTOR1` is the spelling the series uses rather than the one the variant
24    /// does.
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        f.write_str(match self {
27            Self::KOTOR1 => "KotOR",
28            Self::KOTOR2 => "KotOR II",
29        })
30    }
31}