Refactor task handling to use VecDeque references

- Change `get_tasks` to return `&VecDeque<Tasks>` instead of a formatted
  `String`.
- Introduce `get_tasks_formatted` for display purposes.
- Update `MinerUnit`, `Unit` trait, `Units` enum, and its `Option`
  implementation accordingly.
- Add `EMPTY_TASKS` lazy static for handling empty task lists.
- Adjust `BoardState` to use the new task API (commented out
  conditional).
This commit is contained in:
GarandPLG committed 2026-05-18 14:48:07 +02:00
1 parent e4728aab5d
commit 7c9e3d28f0
4 files changed
+30 -6

No files matched your search

@@ -3,6 +3,7 @@ use ratatui::{
style::Stylize,
text::{Line, Span},
};
use std::collections::VecDeque;
pub trait Unit {
fn is_unit(&self) -> bool {
@@ -25,10 +26,12 @@ pub trait Unit {
fn get_coords(&self) -> (usize, usize);
fn get_tasks(&self) -> String;
fn get_tasks(&self) -> &VecDeque<Tasks>;
fn set_task(&mut self, task: Tasks);
fn get_tasks_formatted(&self) -> String;
fn base_text(&self) -> Vec<Line<'_>> {
let owner: Span<'_> = self.get_owner().get_span();
let hp: u16 = self.get_hp();
@@ -36,7 +39,7 @@ pub trait Unit {
let hp_percent: u16 = hp * 100 / max_hp;
let can_dig: bool = self.get_can_dig();
let digging_power: f32 = self.get_digging_power();
let tasks: String = self.get_tasks();
let tasks: String = self.get_tasks_formatted();
let mut lines: Vec<Line<'_>> = Vec::from([
Line::from_iter(["Owner: ".gray(), owner]),