Skip to content

Commit

Permalink
Merge pull request #241 from red-life-project/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Nereuxofficial authored Dec 8, 2022
2 parents 03d7ff8 + 173c804 commit 01c9212
Show file tree
Hide file tree
Showing 21 changed files with 363 additions and 255 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,27 @@ jobs:
if : ${{ runner.os == 'Linux' }}
run: strip target/release/game

- name: Copy binary Linux
if: ${{ runner.os == 'Linux' }}
run: cp target/release/game game

- name: Copy binary Windows
if: ${{ runner.os == 'Windows' }}
run: cp target/release/game.exe game.exe

- name: Zip Release
if : ${{ runner.os == 'Windows' }}
uses: vimtor/action-zip@v1
with:
files: assets target/release/game.exe
recursive: false
files: assets game.exe
dest: game_windows.zip

- name: Zip Release Linux
if : ${{ runner.os == 'Linux' }}
uses: vimtor/action-zip@v1
with:
files: assets target/release/game
files: assets game
recursive: false
dest: game_linux.zip

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
Binary file modified assets/basis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/mainmenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 35 additions & 58 deletions game/src/backend/constants.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Contains all constants that are necessary for the game to played.
use crate::backend::rlcolor::RLColor;
use crate::backend::utils::gen_inventory;
use crate::game_core::player::gen_inventory;
use crate::game_core::resources::Resources;
use crate::languages::german::MACHINE_NAMES;
use crate::machines::machine::State;
use crate::machines::trade::Trade;
use ggez::graphics::{Color, Rect};
Expand Down Expand Up @@ -36,12 +37,6 @@ pub const MOVEMENT_SPEED: usize = 10;
/// Contains the position of the time.
pub(crate) const TIME_POSITION: (f32, f32) = (1205., 960.);

pub(crate) const SANDSTURM_CR: Resources<i16> = Resources {
oxygen: 0,
energy: 5,
life: 0,
};

#[allow(clippy::too_many_lines)]
/// Generates all machines with all their name, position, trades and resources.
/// # Returns
Expand All @@ -51,50 +46,9 @@ pub(crate) const SANDSTURM_CR: Resources<i16> = Resources {
/// `Vec<Resources>` - Returns the resources of the machine.
pub(crate) fn gen_all_machines() -> [(String, Rect, Vec<Trade>, Resources<i16>); 7] {
[
// Test machine, only for testing purpose -- should be deleted in final game
(
"test".to_string(),
Rect {
x: 700.0,
y: 500.0,
w: 100.0,
h: 100.0,
},
vec![
Trade::new(
"free_items".to_string(),
10,
State::Broken,
State::Idle,
true,
gen_inventory(-100, -100, -100),
),
Trade::new(
"reset_items".to_string(),
0,
State::Idle,
State::Running,
true,
gen_inventory(100, 97, 99),
),
Trade::new(
"free_items".to_string(),
0,
State::Running,
State::Idle,
true,
gen_inventory(-100, -100, -100),
),
],
Resources {
oxygen: -25,
energy: -25,
life: -4,
},
),
// Oxygen machine
(
"Sauerstoffgenerator".to_string(),
MACHINE_NAMES[1].to_string(),
Rect {
x: 280.0,
y: 230.0,
Expand Down Expand Up @@ -128,14 +82,14 @@ pub(crate) fn gen_all_machines() -> [(String, Rect, Vec<Trade>, Resources<i16>);
),
],
Resources {
oxygen: 20,
oxygen: 25,
energy: -30,
life: 0,
},
),
// Electricity machine
(
"Stromgenerator".to_string(),
MACHINE_NAMES[2].to_string(),
Rect {
x: 282.0,
y: 752.0,
Expand All @@ -145,7 +99,7 @@ pub(crate) fn gen_all_machines() -> [(String, Rect, Vec<Trade>, Resources<i16>);
vec![
Trade::new(
"fueling_Stromgenerator".to_string(),
1000,
700,
State::Broken,
State::Running,
true,
Expand All @@ -170,13 +124,13 @@ pub(crate) fn gen_all_machines() -> [(String, Rect, Vec<Trade>, Resources<i16>);
],
Resources {
oxygen: -5,
energy: 50,
energy: 200,
life: 0,
},
),
// worker machine
(
"Werkermaschine".to_string(),
MACHINE_NAMES[3].to_string(),
Rect {
x: 1000.0,
y: 780.0,
Expand Down Expand Up @@ -209,7 +163,7 @@ pub(crate) fn gen_all_machines() -> [(String, Rect, Vec<Trade>, Resources<i16>);
),
// 3d_printer machine
(
"3d_printer".to_string(),
MACHINE_NAMES[4].to_string(),
Rect {
x: 930.0,
y: 230.0,
Expand Down Expand Up @@ -242,7 +196,7 @@ pub(crate) fn gen_all_machines() -> [(String, Rect, Vec<Trade>, Resources<i16>);
),
// Communication module
(
"Kommunikationsmodul".to_string(),
MACHINE_NAMES[5].to_string(),
Rect {
x: 1640.0,
y: 320.0,
Expand Down Expand Up @@ -275,9 +229,9 @@ pub(crate) fn gen_all_machines() -> [(String, Rect, Vec<Trade>, Resources<i16>);
),
// first hole
(
"Loch".to_string(),
MACHINE_NAMES[6].to_string(),
Rect {
x: 680.0,
x: 780.0,
y: 230.0,
w: 32.0,
h: 18.0,
Expand All @@ -296,5 +250,28 @@ pub(crate) fn gen_all_machines() -> [(String, Rect, Vec<Trade>, Resources<i16>);
life: -2,
},
),
// second hole
(
MACHINE_NAMES[7].to_string(),
Rect {
x: 680.0,
y: 900.0,
w: 32.0,
h: 18.0,
},
vec![Trade::new(
"repair_Loch".to_string(),
100,
State::Running,
State::Idle,
false,
gen_inventory(2, 0, 0),
)],
Resources {
oxygen: -20,
energy: -5,
life: 0,
},
),
]
}
10 changes: 8 additions & 2 deletions game/src/backend/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ use std::io;
use std::sync::mpsc::SendError;
use tracing::error;

/// All Red Life errors
#[warn(clippy::enum_variant_names)]
#[derive(Debug)]
pub enum RLError {
/// All Errors caused by Drawing
Ui(GameError),
/// Errors caused by loading the assets
AssetError(String),
/// Errors caused by loading the Gamestate from a file
Deserialization(serde_yaml::Error),
/// FileSystem and other errors
IO(io::Error),
/// Errors where senders/receivers were not intialized properly
InitError(String),
}

Expand All @@ -35,12 +41,12 @@ impl From<io::Error> for RLError {
RLError::IO(e)
}
}

/// Creates an Io Error
fn create_io_error(message: &str, value: impl std::fmt::Display) -> RLError {
error!("{}: {}", message, value);
RLError::IO(io::Error::new(
io::ErrorKind::Other,
format!("{}: {}", message, value),
format!("{message}: {value}"),
))
}
/// Macro for converting a SendError to an RLError
Expand Down
Loading

0 comments on commit 01c9212

Please sign in to comment.