Compare commits

..

No commits in common. "d6f4fdaa5b0b54b9e34268efa08f85071521893a" and "cefb0cc5f215c8fe0b9e03f8fd123a2fff2ff2b2" have entirely different histories.

8 changed files with 37 additions and 92 deletions

View File

@ -1,24 +0,0 @@
name: publish package
on:
push:
branches:
- main
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: run tests
run: |
cd ${{ gitea.workspace }}
cargo test --release
- name: build & release package
run: |
cd ${{ gitea.workspace }}
cargo build --release
cargo deb
ls -al target/debian
UPLOAD_FILE=$(ls target/debian/*.deb)
curl --user jlusiardi:${{ secrets.UPLOAD_TOKEN }} --upload-file ${UPLOAD_FILE} https://gitea.intern.haus-in-hirschaid.de/api/packages/jlusiardi/debian/pool/bionic/main/upload

View File

@ -11,14 +11,3 @@ crossterm = "0.28.1"
rand = "0.8.5" rand = "0.8.5"
petgraph = "0.6.5" petgraph = "0.6.5"
whoami = "1.5.2" whoami = "1.5.2"
[package.metadata.deb]
maintainer = "Joachim Lusiardi <joachim@lusiardi.de>"
copyright = "2024, Joachim Lusiardi <joachim@lusiardi.de>"
extended-description = """Little roguelike game"""
depends = "$auto"
section = "game"
priority = "optional"
assets = [
["target/release/el_diabolo", "/usr/bin/", "755"],
]

View File

@ -1,4 +1,3 @@
use rand::Rng;
use ratatui::style::Color; use ratatui::style::Color;
use crate::player::Player; use crate::player::Player;
@ -23,11 +22,11 @@ pub struct Chest {
impl Chest { impl Chest {
pub fn new(position: Position) -> Self { pub fn new(position: Position) -> Self {
let min_gold = 10 * (position.get_level()+1); let level = position.get_level();
let max_gold = min_gold + 10*position.get_level();
Self { Self {
position, position,
gold: rand::thread_rng().gen_range(min_gold..=max_gold), // TODO maybe randomize this?
gold: (level + 1) * 10,
} }
} }
} }
@ -62,11 +61,9 @@ pub struct Potion {
impl Potion { impl Potion {
pub fn new(position: Position) -> Self { pub fn new(position: Position) -> Self {
let min_health_gain = 5 + position.get_level();
let max_health_gain = min_health_gain + 3 * position.get_level();
Self { Self {
position, position,
health: rand::thread_rng().gen_range(min_health_gain..=max_health_gain), health: 5,
} }
} }
} }
@ -86,7 +83,7 @@ impl Artifact for Potion {
let new = player.get_life(); let new = player.get_life();
messages.insert( messages.insert(
0, 0,
format!("picked up potion and gained {} health.", new - old).to_string(), format!("picked up potion and gained {} hp.", new - old).to_string(),
); );
self.health = 0; self.health = 0;
} else { } else {

View File

@ -164,32 +164,25 @@ impl Game {
match m { match m {
None => {} None => {}
Some(m) => { Some(m) => {
// TODO fight the monster
let monster_dmg = m.damage() as i16;
let player_dmg = self.player.damage(); let player_dmg = self.player.damage();
self.player.change_life(-monster_dmg);
m.decrease_life(player_dmg); m.decrease_life(player_dmg);
if m.is_dead() {
self.player.gain_experience(m.get_experience_gain()); // inform player
self.messages.insert( self.messages.insert(
0, 0,
format!( format!("{} hits you for {} damage.", m.get_name(), monster_dmg).to_string(),
"you hit {} for {} damage and kill it.",
m.get_name(),
player_dmg
)
.to_string(),
); );
} else {
self.messages.insert( self.messages.insert(
0, 0,
format!("you hit {} for {} damage.", m.get_name(), player_dmg).to_string(), format!("you hit {} for {} damage.", m.get_name(), player_dmg).to_string(),
); );
let monster_dmg = m.damage() as i16; // monster died, player gains experience
self.player.change_life(-monster_dmg); if m.is_dead() {
self.player.gain_experience(m.get_experience_gain());
self.messages.insert(
0,
format!("{} hits you for {} damage.", m.get_name(), monster_dmg)
.to_string(),
);
} }
return m.is_dead(); return m.is_dead();
} }

View File

@ -147,8 +147,12 @@ impl Level {
if player.get_immutable_position().get_x() == new_x if player.get_immutable_position().get_x() == new_x
&& player.get_immutable_position().get_y() == new_y && player.get_immutable_position().get_y() == new_y
{ {
// TODO handle fight between monster and player
let monster_dmg = self.monsters[index].damage() as i16; let monster_dmg = self.monsters[index].damage() as i16;
let player_dmg = player.damage();
self.monsters[index].decrease_life(player_dmg);
player.change_life(-monster_dmg); player.change_life(-monster_dmg);
messages.insert( messages.insert(
0, 0,
format!( format!(
@ -158,23 +162,6 @@ impl Level {
) )
.to_string(), .to_string(),
); );
let player_dmg = player.damage();
self.monsters[index].decrease_life(player_dmg);
// if the attack did not kill the opponent, back down
if !player.is_dead() {
messages.insert(
0,
format!(
"you hit {} for {} damage and kill it.",
self.monsters[index].get_name(),
player_dmg
)
.to_string(),
);
self.monsters[index].get_position().change(-dx, -dy);
} else {
messages.insert( messages.insert(
0, 0,
format!( format!(
@ -184,6 +171,9 @@ impl Level {
) )
.to_string(), .to_string(),
); );
// if the attack did not kill the opponent, back down
if !player.is_dead() {
self.monsters[index].get_position().change(-dx, -dy);
} }
} }
break; break;

View File

@ -45,7 +45,7 @@ impl StatefulWidget for LevelWidget {
self.set_cell(buf, x, y, "Ω", Color::Black, Color::Gray); self.set_cell(buf, x, y, "Ω", Color::Black, Color::Gray);
} }
StructureElement::Wall => { StructureElement::Wall => {
// TODO add fancy walls with https://en.wikipedia.org/wiki/Box-drawing_characters // TODO add fancy walls
self.set_cell(buf, x, y, "#", FG_BROWN, Color::Gray); self.set_cell(buf, x, y, "#", FG_BROWN, Color::Gray);
} }
StructureElement::Floor => { StructureElement::Floor => {

View File

@ -8,7 +8,7 @@ pub trait HasPosition {
fn get_immutable_position(&self) -> &Position; fn get_immutable_position(&self) -> &Position;
} }
#[derive(PartialEq, Debug, Clone, Copy)] #[derive(PartialEq, Debug)]
pub struct Position { pub struct Position {
level: usize, level: usize,
x: usize, x: usize,