pub fn new(mut parties: Vec<Party<'a>>) -> Result<Self, io::Error>
	{
		let replay = BattleReplay::new()?;
		let rng = StdRng::from_seed(&[replay.seed()]);

		// Expose active parties for experience gaining.
		// Done after code that can return Result::Err so it's not done needlessly.
		let mut sides = HashMap::new();
		for party in &mut parties
		{
			party.expose_clear_all();
			let side_count = sides.entry(party.side()).or_insert(0);
			*side_count += 1;
		}
		for party_index in 0..parties.len()
		{
			BattleRunner::expose_party(&mut parties, party_index);
		}

		Ok(BattleRunner
		{
			state: BattleState::new(parties)?,
			effects: BattleEffects::new(),
			replay: replay,
			rng: rng,
			command: 0,
			sub_command: 0,
			turn: 0,
			sides_alive: sides,
			party_switch_waiting: 0,
			effect_current: Effect::None(NoneReason::None),
			retreat: false,
		})
	}
/// Generates a new battle object with a randomly generated RNG and empty command history.
Generates a new battle object with a randomly generated RNG and empty command history.
Generates a new battle object with a randomly generated RNG and empty command history .
pub fn new(mut parties: Vec<Party<'a>>) -> Result<Self, io::Error>
	{
		let replay = BattleReplay::new()?;
		let rng = StdRng::from_seed(&[replay.seed()]);
		// Expose active parties for experience gaining.
		// Done after code that can return Result::Err so it's not done needlessly.
		let mut sides = HashMap::new();
		for party in &mut parties
		{
			party.expose_clear_all();
			let side_count = sides.entry(party.side()).or_insert(0);
			*side_count += 1;
		}
		for party_index in 0..parties.len()
		{
			BattleRunner::expose_party(&mut parties, party_index);
		}
		Ok(BattleRunner
		{
			state: BattleState::new(parties)?,
			effects: BattleEffects::new(),
			replay: replay,
			rng: rng,
			command: 0,
			sub_command: 0,
			turn: 0,
			sides_alive: sides,
			party_switch_waiting: 0,
			effect_current: Effect::None(NoneReason::None),
			retreat: false,
		})
	}
pub fn new ( mut parties : Vec < Party < ' a > > ) -> Result < Self , io :: Error > { let replay = BattleReplay :: new ( ) ? ; let rng = StdRng :: from_seed ( & [ replay . seed ( ) ] ) ; // Expose active parties for experience gaining. // Done after code that can return Result::Err so it's not done needlessly. let mut sides = HashMap :: new ( ) ; for party in & mut parties { party . expose_clear_all ( ) ; let side_count = sides . entry ( party . side ( ) ) . or_insert ( 0 ) ; * side_count += 1 ; } for party_index in 0 .. parties . len ( ) { BattleRunner :: expose_party ( & mut parties , party_index ) ; } Ok ( BattleRunner { state : BattleState :: new ( parties ) ? , effects : BattleEffects :: new ( ) , replay : replay , rng : rng , command : 0 , sub_command : 0 , turn : 0 , sides_alive : sides , party_switch_waiting : 0 , effect_current : Effect :: None ( NoneReason :: None ) , retreat : false , } ) }
Generates a new battle object with a randomly generated RNG and empty command history.
Generates a new battle object with a randomly generated RNG and empty command history .
parties
Vec<Party<'a>>
parties
Vec<Party<'a>>