Skip to content

Commit

Permalink
v1.0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
ricott1 committed Nov 14, 2024
1 parent bf16076 commit 320fa4b
Show file tree
Hide file tree
Showing 115 changed files with 4,994 additions and 3,661 deletions.
140 changes: 74 additions & 66 deletions Cargo.lock

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[package]
name = "rebels"
version = "1.0.19"
version = "1.0.20"
edition = "2021"
authors = ["Alessandro Ricottone <[email protected]>"]
license = "GPL-3.0-or-later"
description = "Anarchic spacepirates playing basketball in your terminal"
readme = "README.md"
homepage = "https://github.com/ricott1/rebels-in-the-sky"
repository = "https://github.com/ricott1/rebels-in-the-sky"
keywords = ["cli", "pirates", "rebels", "game"]
categories = ["games"]

[profile.release]
strip = true
Expand All @@ -16,17 +24,18 @@ opt-level = 1
opt-level = 3

[dependencies]
anyhow = "1.0.91"
anyhow = "1.0.93"
async-trait = "0.1.83"
chrono = "0.4.38"
clap = { version = "4.5.20", features = ["derive"] }
crossterm = "0.28.1"
directories = "5.0.1"
ed25519-dalek = "2.1.1"
flate2 = { version = "1.0.17", features = ["zlib-ng"], default-features = false }
futures = "0.3.30"
gif = "0.13.1"
glam = "0.29.0"
image = "0.25.4"
glam = "0.29.2"
image = "0.25.5"
imageproc = "0.25.0"
include_dir = "0.7.4"
itertools = "0.13.0"
Expand All @@ -48,20 +57,20 @@ rand = "0.8.5"
rand_chacha = "0.3.1"
rand_distr = "0.4.3"
ratatui = { version = "0.29.0", features = ["unstable-backend-writer"] }
rodio = "0.19.0"
russh = "0.45.0"
russh-keys = "0.45.0"
serde = { version = "1.0.212", features = ["derive", "default"] }
rodio = "0.20.1"
russh = "0.46.0"
russh-keys = "0.46.0"
serde = { version = "1.0.214", features = ["derive", "default"] }
serde_json = "1.0.132"
serde_repr = "0.1.19"
sha2 = "0.10.8"
stream-download = { version = "0.9.0", features = ["reqwest-rustls"] }
stream-download = { version = "0.11.2", features = ["reqwest-rustls"] }
strum = { version = "0.26.3", features = ["derive"] }
strum_macros = "0.26.4"
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.1", features = ["full"] }
tokio-util = "0.7.12"
tui-textarea = "0.7.0"
unicode-width = "0.2.0"
url = "2.5.2"
url = "2.5.3"
uuid = { version = "1.11.0", features = ["v4", "serde"] }
void = "1.0.2"
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ https://github.com/user-attachments/assets/aaa02f04-06db-4da5-8fa4-732b60083e66


It's the year 2101. Corporations have taken over the world.
The only way to be free is to join a pirate crew and start plundering the galaxy. The only means of survival is to play basketball.
The only way to be free is to join a pirate crew and start plundering the galaxy. The only mean of survival is to play basketball.

Now it's your turn to go out there and make a name for yourself. Create your crew and start wandering the galaxy in search of worthy basketball opponents.

Expand All @@ -19,15 +19,22 @@ Connect via SSH to try the game.

Save files are deleted after 2 days of inactivity.

## Download
## Installation

Compiled binaries of the last release can be also downloaded at https://rebels.frittura.org.
### Build

## Music
You need to have the rust toolchain installed --> https://www.rust-lang.org/tools/install. Then you can clone the repo and build the game with

Previous versions had the option to play music directly in the game, but this was removed to reduce the binary size and now music is streamed from internet radios. Nevertheless, you can still listen to the game soundtrack directly by connecting to `https://radio.frittura.org/rebels.ogg`!
`cargo build --release`

You can add more radio stations by including them in `assets/data/stream_data.json`.
### With cargo

`cargo install rebels`

### From the latest release page

- Download the latest release asset for your platform from https://rebels.frittura.org;
- Give execution permissions to the executable with `chmod +x rebels`

### Distro Packages

Expand All @@ -46,22 +53,12 @@ You can add more radio stations by including them in `assets/data/stream_data.js
pacman -S rebels-in-the-sky
```

## Build

You need to have the rust toolchain installed --> https://www.rust-lang.org/tools/install. Then you can build the game with

`cargo build --release`

## Run

This game runs as a terminal application, meaning that you just need to run the executable from your terminal with

`./rebels`

If you downloaded the binaries, you will first need to give execution permissions to the executable with

`chmod +x rebels`

Suggested minimal terminal size: 160x48. Not all terminals support the game colors nicely, so you might need to try different ones. Here is a list of tested terminals:

- Linux: whatever the default terminal is, it should work
Expand All @@ -70,10 +67,17 @@ Suggested minimal terminal size: 160x48. Not all terminals support the game colo

**Important**: currently local bot teams are generated by default to make the game more enjoyable. This behaviour can be disabled by passing the `-f` flag to the executable. In the future, when more players will be available, the game will default to online teams only.

## Music

Previous versions had the option to play music directly in the game, but this was removed to reduce the binary size and now music is streamed from internet radios. Nevertheless, you can still listen to the game soundtrack directly by connecting to `https://radio.frittura.org/rebels.ogg`!

You can add more radio stations by including them in `assets/data/stream_data.json`.


## Credits

- Planet gifs were generated using the [pixel planet generator](https://deep-fold.itch.io/pixel-planet-generator) by [Deep Fold](https://deep-fold.itch.io/).
- Special thanks to [Il Deposito](https://www.ildeposito.org) for inspiration and the great musical archive.
- Planet gifs were generated using the [pixel planet generator](https://deep-fold.itch.io/pixel-planet-generator) by [Deep Fold](https://deep-fold.itch.io/).
- Special thanks to [Il Deposito](https://www.ildeposito.org) for inspiration and the great musical archive.

## Contribution

Expand Down
Binary file added assets/accessories/eye_patch_octopulp_central.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions assets/data/planets_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"resources": {},
"filename": "sol",
"rotation_period": 6,
"revolution_period": 180,
"revolution_period": 360,
"gravity": 100,
"asteroid_probability": 0.0,
"planet_type": 1,
Expand All @@ -48,7 +48,7 @@
"resources": {},
"filename": "proxima",
"rotation_period": 3,
"revolution_period": 120,
"revolution_period": 360,
"gravity": 80,
"asteroid_probability": 0.0,
"planet_type": 1,
Expand Down Expand Up @@ -173,7 +173,7 @@
},
"filename": "earth",
"rotation_period": 9,
"revolution_period": 120,
"revolution_period": 180,
"gravity": 10,
"asteroid_probability": 0.5,
"planet_type": 2,
Expand Down Expand Up @@ -296,7 +296,7 @@
},
"filename": "rocky",
"rotation_period": 9,
"revolution_period": 120,
"revolution_period": 360,
"gravity": 2,
"asteroid_probability": 0.0,
"planet_type": 8,
Expand All @@ -323,7 +323,7 @@
},
"filename": "phobos",
"rotation_period": 6,
"revolution_period": 120,
"revolution_period": 180,
"gravity": 2,
"asteroid_probability": 0.0,
"planet_type": 8,
Expand Down
Binary file modified assets/head/octopulp1.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/hull/mask_jester_standard.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/hull/mask_pincher_large.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/hull/mask_pincher_standard.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/hull/mask_shuttle_large.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/hull/mask_shuttle_small.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/hull/mask_shuttle_standard.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/hull/pincher_large.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 added assets/shooter/jester_double.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 added assets/shooter/jester_quadruple.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 added assets/shooter/pincher_double1.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 added assets/shooter/pincher_double2.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 added assets/shooter/pincher_quadruple1.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 added assets/shooter/pincher_quadruple2.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 added assets/shooter/shuttle_single0.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 added assets/shooter/shuttle_single1.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 added assets/shooter/shuttle_single2.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 added assets/shooter/shuttle_triple0.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 added assets/shooter/shuttle_triple1.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 added assets/shooter/shuttle_triple2.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 added assets/space_adventure/asteroid_big0.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/space_adventure/asteroid_big1.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/space_adventure/asteroid_big2.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 removed assets/space_adventure/asteroid_big3.png
Binary file not shown.
Binary file added assets/space_adventure/asteroid_huge0.png
Binary file modified assets/space_adventure/asteroid_huge1.png
Binary file modified assets/space_adventure/asteroid_huge2.png
Binary file removed assets/space_adventure/asteroid_huge3.png
Diff not rendered.
Binary file added assets/space_adventure/asteroid_small0.png
Binary file modified assets/space_adventure/asteroid_small1.png
Binary file modified assets/space_adventure/asteroid_small2.png
Binary file removed assets/space_adventure/asteroid_small3.png
Diff not rendered.
Binary file removed assets/storage/mask_pincher_single.png
Diff not rendered.
Binary file added assets/storage/mask_pincher_single1.png
Binary file added assets/storage/mask_pincher_single2.png
Binary file removed assets/storage/pincher_single.png
Diff not rendered.
Binary file added assets/storage/pincher_single1.png
Binary file added assets/storage/pincher_single2.png
12 changes: 7 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use stream_download::StreamDownload;
use tokio::select;
use void::Void;

const NETWORK_HANDLER_INIT_INTERVAL: u128 = 10 * SECONDS;
const NETWORK_HANDLER_INIT_INTERVAL: Tick = 10 * SECONDS;

#[derive(Debug, PartialEq)]
pub enum AppState {
Expand All @@ -40,6 +40,7 @@ pub struct App {
seed_ip: Option<String>,
network_port: Option<u16>,
store_prefix: String,
pub new_version_notified: bool,
}

impl App {
Expand Down Expand Up @@ -194,6 +195,7 @@ impl App {
seed_ip,
network_port,
store_prefix: store_prefix.to_string(),
new_version_notified: false,
}
}

Expand Down Expand Up @@ -227,7 +229,6 @@ impl App {
Some(streaming_data) = Self::conditional_audio_event(& self.audio_player) => self.handle_streaming_data(streaming_data)?,
Some(swarm_event) = Self::conditional_network_event(&mut self.network_handler) => self.handle_network_events(swarm_event)?,
app_event = tui.events.next() => {

match app_event{
TerminalEvent::Tick {tick} => {
self.handle_tick_events(tick)?;
Expand All @@ -240,12 +241,13 @@ impl App {
if let Err(e) = tui.draw(&mut self.ui, &self.world, self.audio_player.as_ref()).await {
error!("Drawing error: {e}");
}
},
TerminalEvent::Mouse(mouse_event) => {self.handle_mouse_events(mouse_event)?;
},
TerminalEvent::Mouse(mouse_event) => {
self.handle_mouse_events(mouse_event)?;
if let Err(e) = tui.draw(&mut self.ui, &self.world, self.audio_player.as_ref()).await {
error!("Drawing error: {e}");
}
},
},
TerminalEvent::Resize(w, h) => tui.resize((w, h))?,
TerminalEvent::Quit => self.quit()?,
}
Expand Down
1 change: 1 addition & 0 deletions src/game_engine/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub enum ActionSituation {
AfterOffensiveRebound,
AfterLongOffensiveRebound,
AfterDefensiveRebound,
AfterSubstitution,
MissedShot,
Turnover,
CloseShot,
Expand Down
66 changes: 31 additions & 35 deletions src/game_engine/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,12 @@ impl<'game> Game {
game.attendance = attendance as u32;
let mut default_output = ActionOutput::default();
default_output.description = format!(
"{} vs {}. Game is about to start here on {}! There are {} people in the stadium.",
home_name, away_name, planet.name, game.attendance
"{} vs {}. Game is about to start here on {}! There are {} {}people in the stadium.",
home_name,
away_name,
planet.name,
game.attendance,
if game.attendance == 69 { "(nice) " } else { "" }
);
default_output.random_seed = seed;
game.action_results.push(default_output);
Expand Down Expand Up @@ -280,7 +284,7 @@ impl<'game> Game {
ActionSituation::LongShot => Action::LongShot,
ActionSituation::MissedShot => Action::Rebound,
ActionSituation::EndOfQuarter => Action::StartOfQuarter,
ActionSituation::BallInBackcourt => {
ActionSituation::AfterSubstitution | ActionSituation::BallInBackcourt => {
let brawl_probability = BRAWL_ACTION_PROBABILITY
* (self.home_team_in_game.tactic.brawl_probability_modifier()
+ self.away_team_in_game.tactic.brawl_probability_modifier());
Expand Down Expand Up @@ -474,9 +478,8 @@ impl<'game> Game {
fn get_rng_seed(&self) -> [u8; 32] {
let mut seed = [0; 32];
seed[0..16].copy_from_slice(self.id.as_bytes());
seed[16..32].copy_from_slice(self.starting_at.to_be_bytes().as_ref());
// Overwrite first two bytes with timer value
seed[0..2].copy_from_slice(self.timer.value.to_be_bytes().as_ref());
seed[16..24].copy_from_slice(self.starting_at.to_be_bytes().as_ref());
seed[24..26].copy_from_slice(self.timer.value.to_be_bytes().as_ref());

seed
}
Expand Down Expand Up @@ -719,7 +722,7 @@ impl<'game> Game {
..Default::default()
});
}
_ =>
(false, false) =>
// Check if teams make substitutions. Only if ball is out
{
if let Some(sub) = Substitution::execute(action_input, self, rng) {
Expand All @@ -740,7 +743,7 @@ impl<'game> Game {
mod tests {
use super::Game;
use crate::game_engine::types::TeamInGame;
use crate::types::GameId;
use crate::types::{AppResult, GameId};
use crate::types::{SystemTimeTick, Tick};
use crate::world::constants::DEFAULT_PLANET_ID;
use crate::world::world::World;
Expand All @@ -749,36 +752,28 @@ mod tests {

#[ignore]
#[test]
fn test_game() {
fn test_game() -> AppResult<()> {
let mut world = World::new(None);
let rng = &mut ChaCha8Rng::seed_from_u64(world.seed);

// world.initialize(true);

// let home_planet = world.planets.get(&DEFAULT_PLANET_ID).unwrap();
let id0 = world
.generate_random_team(
rng,
DEFAULT_PLANET_ID.clone(),
"Testen".to_string(),
"Tosten".to_string(),
)
.unwrap();
let id1 = world
.generate_random_team(
rng,
DEFAULT_PLANET_ID.clone(),
"Holalo".to_string(),
"Halley".to_string(),
)
.unwrap();

let home_team = world.get_team(id0).unwrap().clone();
let id0 = world.generate_random_team(
rng,
DEFAULT_PLANET_ID.clone(),
"Testen".to_string(),
"Tosten".to_string(),
)?;
let id1 = world.generate_random_team(
rng,
DEFAULT_PLANET_ID.clone(),
"Holalo".to_string(),
"Halley".to_string(),
)?;

let home_team = world.get_team(&id0).unwrap().clone();

let checked_player_id = home_team.player_ids[0];
let quickness_before = world
.get_player(checked_player_id)
.unwrap()
.get_player_or_err(&checked_player_id)?
.athletics
.quickness
.clone();
Expand All @@ -791,7 +786,7 @@ mod tests {
home_team_in_game.unwrap(),
away_team_in_game.unwrap(),
Tick::now(),
&world.get_planet(DEFAULT_PLANET_ID.clone()).unwrap(),
&world.get_planet(&DEFAULT_PLANET_ID).unwrap(),
);

game.home_team_in_game
Expand Down Expand Up @@ -821,11 +816,12 @@ mod tests {
let _ = world.handle_tick_events(Tick::now());
}
let quickness_after = world
.get_player(checked_player_id)
.unwrap()
.get_player_or_err(&checked_player_id)?
.athletics
.quickness
.clone();
println!("{} {}", quickness_before, quickness_after);

Ok(())
}
}
2 changes: 1 addition & 1 deletion src/game_engine/rebound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{
collections::HashMap,
};

const MIN_REBOUND_VALUE: u16 = 42;
const MIN_REBOUND_VALUE: u16 = 40;
const REBOUND_POSITION_SCALING: f32 = 12.0;

fn position_rebound_bonus(idx: usize) -> f32 {
Expand Down
Loading

0 comments on commit 320fa4b

Please sign in to comment.