|
|
@ -1,7 +1,9 @@ |
|
|
|
|
|
|
|
use crate::lib::ai::AI; |
|
|
|
use crate::Point; |
|
|
|
use crate::Point; |
|
|
|
|
|
|
|
use crate::Screen; |
|
|
|
use std::collections::HashMap; |
|
|
|
use std::collections::HashMap; |
|
|
|
use crate::lib::ai::AI; |
|
|
|
|
|
|
|
|
|
|
|
use ncurses::*; |
|
|
|
|
|
|
|
|
|
|
|
use downcast_rs::{impl_downcast, Downcast}; |
|
|
|
use downcast_rs::{impl_downcast, Downcast}; |
|
|
|
|
|
|
|
|
|
|
@ -25,9 +27,16 @@ impl Ant { |
|
|
|
impl Entity for Ant {} |
|
|
|
impl Entity for Ant {} |
|
|
|
|
|
|
|
|
|
|
|
impl Renderable for Ant { |
|
|
|
impl Renderable for Ant { |
|
|
|
fn render(&self) -> &str { |
|
|
|
fn representation(&self) -> &str { |
|
|
|
"o" |
|
|
|
"o" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fn before_render(&self) { |
|
|
|
|
|
|
|
attron(A_BOLD()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn after_render(&self) { |
|
|
|
|
|
|
|
attroff(A_BOLD()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub struct Queen { |
|
|
|
pub struct Queen { |
|
|
@ -37,14 +46,27 @@ pub struct Queen { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Renderable for Queen { |
|
|
|
impl Renderable for Queen { |
|
|
|
fn render(&self) -> &str { |
|
|
|
fn representation(&self) -> &str { |
|
|
|
"q" |
|
|
|
"q" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn before_render(&self) { |
|
|
|
|
|
|
|
attron(A_BOLD()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn after_render(&self) { |
|
|
|
|
|
|
|
attroff(A_BOLD()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub trait Renderable { |
|
|
|
pub trait Renderable: AI { |
|
|
|
fn render(&self) -> &str { |
|
|
|
fn representation(&self) -> &str; |
|
|
|
"z" |
|
|
|
fn before_render(&self) {} |
|
|
|
|
|
|
|
fn after_render(&self) {} |
|
|
|
|
|
|
|
fn render(&self, b: &Screen) { |
|
|
|
|
|
|
|
self.before_render(); |
|
|
|
|
|
|
|
b.render(&self.get_position(), self.representation()); |
|
|
|
|
|
|
|
self.after_render(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -67,9 +89,17 @@ pub struct Egg { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Renderable for Egg { |
|
|
|
impl Renderable for Egg { |
|
|
|
fn render(&self) -> &str { |
|
|
|
fn representation(&self) -> &str { |
|
|
|
"e" |
|
|
|
"e" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn before_render(&self) { |
|
|
|
|
|
|
|
attron(A_BOLD()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn after_render(&self) { |
|
|
|
|
|
|
|
attroff(A_BOLD()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Egg { |
|
|
|
impl Egg { |
|
|
@ -123,4 +153,3 @@ impl Entities { |
|
|
|
id |
|
|
|
id |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|