event logging/game over message
This commit is contained in:
parent
1c435f8d60
commit
f9057da71b
6 changed files with 79 additions and 17 deletions
BIN
image.png
BIN
image.png
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
|
|
@ -73,6 +73,7 @@ pub fn delete_the_dead(ecs: &mut World) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for victim in dead {
|
for victim in dead {
|
||||||
|
gamelog::record_event("death_count", 1);
|
||||||
ecs.delete_entity(victim).expect("Unable to delete.");
|
ecs.delete_entity(victim).expect("Unable to delete.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
75
src/gui.rs
75
src/gui.rs
|
|
@ -48,7 +48,7 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
||||||
50,
|
50,
|
||||||
RGB::named(rltk::YELLOW),
|
RGB::named(rltk::YELLOW),
|
||||||
RGB::named(rltk::BLACK),
|
RGB::named(rltk::BLACK),
|
||||||
&format!(" T{} ", crate::gamelog::get_event_count("Turn")),
|
&format!(" T{} ", crate::gamelog::get_event_count("turns")),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Render mouse cursor
|
// Render mouse cursor
|
||||||
|
|
@ -519,20 +519,69 @@ pub enum YesNoResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn game_over(ctx: &mut Rltk) -> YesNoResult {
|
pub fn game_over(ctx: &mut Rltk) -> YesNoResult {
|
||||||
ctx.print_color_centered(15, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "Your journey has ended!");
|
let mut x = 3;
|
||||||
ctx.print_color_centered(
|
let mut y = 3;
|
||||||
17,
|
let width = 45;
|
||||||
RGB::named(rltk::WHITE),
|
let height = 20;
|
||||||
|
ctx.draw_box(x, y, width, height, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
|
||||||
|
ctx.print_color(x + 3, y, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "You died!");
|
||||||
|
ctx.print_color(x + 3, y + height, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "ESC to close");
|
||||||
|
x += 2;
|
||||||
|
y += 2;
|
||||||
|
ctx.print_color(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
RGB::named(rltk::GREEN),
|
||||||
RGB::named(rltk::BLACK),
|
RGB::named(rltk::BLACK),
|
||||||
format!("You died after {} turns.", crate::gamelog::get_event_count("Turn")),
|
format!("You survived for {} turns.", crate::gamelog::get_event_count("turns")),
|
||||||
);
|
|
||||||
|
|
||||||
ctx.print_color_centered(
|
|
||||||
19,
|
|
||||||
RGB::named(rltk::MAGENTA),
|
|
||||||
RGB::named(rltk::BLACK),
|
|
||||||
"Press Escape to return to the menu.",
|
|
||||||
);
|
);
|
||||||
|
y += 2;
|
||||||
|
ctx.print_color(x, y, RGB::named(rltk::GREEN), RGB::named(rltk::BLACK), format!("And in the process, you"));
|
||||||
|
y += 1;
|
||||||
|
if crate::gamelog::get_event_count("descended") > 0 {
|
||||||
|
ctx.print_color(
|
||||||
|
x + 1,
|
||||||
|
y,
|
||||||
|
RGB::named(rltk::WHITE),
|
||||||
|
RGB::named(rltk::BLACK),
|
||||||
|
format!("- descended {} floor(s)", crate::gamelog::get_event_count("descended")),
|
||||||
|
);
|
||||||
|
y += 1;
|
||||||
|
}
|
||||||
|
if crate::gamelog::get_event_count("kick_count") > 0 {
|
||||||
|
ctx.print_color(
|
||||||
|
x + 1,
|
||||||
|
y,
|
||||||
|
RGB::named(rltk::WHITE),
|
||||||
|
RGB::named(rltk::BLACK),
|
||||||
|
format!(
|
||||||
|
"- kicked {} time(s), breaking {} object(s)",
|
||||||
|
crate::gamelog::get_event_count("kick_count"),
|
||||||
|
crate::gamelog::get_event_count("broken_doors")
|
||||||
|
),
|
||||||
|
);
|
||||||
|
y += 1;
|
||||||
|
}
|
||||||
|
if crate::gamelog::get_event_count("death_count") > 0 {
|
||||||
|
ctx.print_color(
|
||||||
|
x + 1,
|
||||||
|
y,
|
||||||
|
RGB::named(rltk::WHITE),
|
||||||
|
RGB::named(rltk::BLACK),
|
||||||
|
format!("- slew {} other creature(s)", crate::gamelog::get_event_count("death_count")),
|
||||||
|
);
|
||||||
|
y += 1;
|
||||||
|
}
|
||||||
|
if crate::gamelog::get_event_count("looked_for_help") > 0 {
|
||||||
|
ctx.print_color(
|
||||||
|
x + 1,
|
||||||
|
y,
|
||||||
|
RGB::named(rltk::WHITE),
|
||||||
|
RGB::named(rltk::BLACK),
|
||||||
|
format!("- forgot the controls {} time(s)", crate::gamelog::get_event_count("looked_for_help")),
|
||||||
|
);
|
||||||
|
y += 1;
|
||||||
|
}
|
||||||
|
|
||||||
match ctx.key {
|
match ctx.key {
|
||||||
None => YesNoResult::NoSelection,
|
None => YesNoResult::NoSelection,
|
||||||
|
|
|
||||||
|
|
@ -134,8 +134,8 @@ impl State {
|
||||||
let mut particle_system = particle_system::ParticleSpawnSystem {};
|
let mut particle_system = particle_system::ParticleSpawnSystem {};
|
||||||
|
|
||||||
vis.run_now(&self.ecs);
|
vis.run_now(&self.ecs);
|
||||||
mapindex.run_now(&self.ecs);
|
|
||||||
mob.run_now(&self.ecs);
|
mob.run_now(&self.ecs);
|
||||||
|
mapindex.run_now(&self.ecs);
|
||||||
trigger_system.run_now(&self.ecs);
|
trigger_system.run_now(&self.ecs);
|
||||||
inventory_system.run_now(&self.ecs);
|
inventory_system.run_now(&self.ecs);
|
||||||
item_use_system.run_now(&self.ecs);
|
item_use_system.run_now(&self.ecs);
|
||||||
|
|
@ -201,6 +201,7 @@ impl State {
|
||||||
let worldmap_resource = self.ecs.fetch::<Map>();
|
let worldmap_resource = self.ecs.fetch::<Map>();
|
||||||
current_depth = worldmap_resource.depth;
|
current_depth = worldmap_resource.depth;
|
||||||
}
|
}
|
||||||
|
gamelog::record_event("descended", 1);
|
||||||
self.generate_world_map(current_depth + 1);
|
self.generate_world_map(current_depth + 1);
|
||||||
|
|
||||||
// Notify player, restore health up to a point.
|
// Notify player, restore health up to a point.
|
||||||
|
|
@ -311,7 +312,7 @@ impl GameState for State {
|
||||||
RunState::PlayerTurn => {
|
RunState::PlayerTurn => {
|
||||||
self.run_systems();
|
self.run_systems();
|
||||||
self.ecs.maintain();
|
self.ecs.maintain();
|
||||||
gamelog::record_event("Turn", 1);
|
gamelog::record_event("turns", 1);
|
||||||
match *self.ecs.fetch::<RunState>() {
|
match *self.ecs.fetch::<RunState>() {
|
||||||
RunState::MagicMapReveal { row, cursed } => {
|
RunState::MagicMapReveal { row, cursed } => {
|
||||||
new_runstate = RunState::MagicMapReveal { row: row, cursed: cursed }
|
new_runstate = RunState::MagicMapReveal { row: row, cursed: cursed }
|
||||||
|
|
@ -448,6 +449,7 @@ impl GameState for State {
|
||||||
match result {
|
match result {
|
||||||
gui::YesNoResult::NoSelection => {}
|
gui::YesNoResult::NoSelection => {}
|
||||||
gui::YesNoResult::Yes => {
|
gui::YesNoResult::Yes => {
|
||||||
|
gamelog::record_event("looked_for_help", 1);
|
||||||
new_runstate = RunState::AwaitingInput;
|
new_runstate = RunState::AwaitingInput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -386,10 +386,18 @@ impl PrefabBuilder {
|
||||||
let mut y_: i32 = tile_y as i32;
|
let mut y_: i32 = tile_y as i32;
|
||||||
// Handle flipping
|
// Handle flipping
|
||||||
if flip_x {
|
if flip_x {
|
||||||
x_ = vault.height as i32 - 1 - x_;
|
x_ = vault.width as i32 - 1 - x_;
|
||||||
}
|
}
|
||||||
if flip_y {
|
if flip_y {
|
||||||
y_ = vault.width as i32 - 1 - y_;
|
y_ = vault.height as i32 - 1 - y_;
|
||||||
|
}
|
||||||
|
if x_ < 0 || y_ < 0 {
|
||||||
|
// If either of these go below 0, we run the risk of CTD, so just panic.
|
||||||
|
// Something went wrong with flipping/rotating/defining a vault.
|
||||||
|
panic!(
|
||||||
|
"X or Y went below 0 when trying to place a vault! DEBUGINFO == [H: {}, W: {}; FLIPPED X: {}, FLIPPED Y: {}; X_: {}, Y_: {}]",
|
||||||
|
vault.width, vault.height, flip_x, flip_y, x_, y_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let idx = build_data.map.xy_idx(x_ + chunk_x, y_ + chunk_y);
|
let idx = build_data.map.xy_idx(x_ + chunk_x, y_ + chunk_y);
|
||||||
if i < string_vec.len() {
|
if i < string_vec.len() {
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,7 @@ pub fn kick(i: i32, j: i32, ecs: &mut World) -> RunState {
|
||||||
.log();
|
.log();
|
||||||
something_was_destroyed = Some(*potential_target);
|
something_was_destroyed = Some(*potential_target);
|
||||||
viewshed.dirty = true;
|
viewshed.dirty = true;
|
||||||
|
gamelog::record_event("broken_doors", 1);
|
||||||
break;
|
break;
|
||||||
// 66% chance of just kicking it.
|
// 66% chance of just kicking it.
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -211,6 +212,7 @@ pub fn kick(i: i32, j: i32, ecs: &mut World) -> RunState {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
gamelog::record_event("kick_count", 1);
|
||||||
return RunState::PlayerTurn;
|
return RunState::PlayerTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue