6 fs, |
6 fs, |
7 io::{self, BufReader, Read, Write}, |
7 io::{self, BufReader, Read, Write}, |
8 str::FromStr, |
8 str::FromStr, |
9 }; |
9 }; |
10 |
10 |
|
11 #[derive(PartialEq, Debug)] |
11 struct Demo { |
12 struct Demo { |
12 teams: Vec<TeamInfo>, |
13 teams: Vec<TeamInfo>, |
13 config: Vec<GameCfg>, |
14 config: Vec<GameCfg>, |
14 messages: Vec<String>, |
15 messages: Vec<String>, |
15 } |
16 } |
339 |
340 |
340 for item in game_config { |
341 for item in game_config { |
341 let mut tuple = item.into_tuple()?; |
342 let mut tuple = item.into_tuple()?; |
342 let mut tuple_iter = tuple.drain(..); |
343 let mut tuple_iter = tuple.drain(..); |
343 let name = tuple_iter.next()?.into_string()?; |
344 let name = tuple_iter.next()?.into_string()?; |
344 let value = tuple_iter.next()?; |
345 let mut value = tuple_iter.next()?.into_list()?; |
|
346 let mut value_iter = value.drain(..); |
345 |
347 |
346 let config_item = match &name[..] { |
348 let config_item = match &name[..] { |
347 "AMMO" => { |
349 "AMMO" => GameCfg::Ammo( |
348 let mut ammo = value.into_list()?; |
350 value_iter.next()?.into_string()?, |
349 let mut ammo_iter = ammo.drain(..); |
351 value_iter.next().and_then(|v| v.into_string()), |
350 GameCfg::Ammo( |
352 ), |
351 ammo_iter.next()?.into_string()?, |
353 "SCHEME" => GameCfg::Scheme( |
352 ammo_iter.next().and_then(|v| v.into_string()), |
354 value_iter.next()?.into_string()?, |
353 ) |
355 value_iter.filter_map(|v| v.into_string()).collect(), |
354 } |
356 ), |
355 "SCHEME" => { |
357 "SCRIPT" => GameCfg::Script(value_iter.next()?.into_string()?), |
356 let mut scheme = value.into_list()?; |
358 "THEME" => GameCfg::Theme(value_iter.next()?.into_string()?), |
357 let mut scheme_iter = scheme.drain(..); |
|
358 GameCfg::Scheme( |
|
359 scheme_iter.next()?.into_string()?, |
|
360 scheme_iter |
|
361 .next()? |
|
362 .into_list()? |
|
363 .drain(..) |
|
364 .filter_map(|v| v.into_string()) |
|
365 .collect(), |
|
366 ) |
|
367 } |
|
368 "SCRIPT" => GameCfg::Script(value.into_string()?), |
|
369 "THEME" => GameCfg::Theme(value.into_string()?), |
|
370 _ => None?, |
359 _ => None?, |
371 }; |
360 }; |
372 config.push(config_item); |
361 config.push(config_item); |
373 } |
362 } |
374 |
363 |