object detonated

This commit is contained in:
Robin Appelman 2021-12-21 23:20:40 +01:00
commit fdd6fe498e
2 changed files with 16 additions and 0 deletions

View file

@ -96,6 +96,7 @@ pub enum GameEvent<'a> {
Extinguished(ExtinguishedEvent<'a>),
GameOver(GameOverEvent<'a>),
FinalScore(FinalScoreEvent),
ObjectDetonated(ObjectDetonatedEvent<'a>),
LogFileClosed,
}
@ -210,6 +211,9 @@ impl<'a> GameEvent<'a> {
GameEvent::FinalScore(final_score_event_parser(raw.params).with_type(raw.ty)?)
}
RawEventType::LogFileClosed => GameEvent::LogFileClosed,
RawEventType::ObjectDetonated => GameEvent::ObjectDetonated(
object_detonated_event_parser(raw.params).with_type(raw.ty)?,
),
_ => {
todo!("{:?} not parsed yet", raw.ty);
}

View file

@ -249,6 +249,18 @@ pub fn killed_object_event_parser(input: &str) -> IResult<&str, KilledObjectEven
))
}
#[derive(Debug)]
pub struct ObjectDetonatedEvent<'a> {
pub object: Option<&'a str>,
pub position: Option<(i32, i32, i32)>,
}
pub fn object_detonated_event_parser(input: &str) -> IResult<&str, ObjectDetonatedEvent> {
let (input, object) = opt(param_parse("object"))(input)?;
let (input, position) = opt(param_parse_with("attacker_position", position))(input)?;
Ok((input, ObjectDetonatedEvent { object, position }))
}
#[derive(Debug)]
pub struct ExtinguishedEvent<'a> {
pub against: RawSubject<'a>,