pub fn command_add_switch(&mut self, party: usize, active: usize, target: usize) -> BattleError
	{
		debug_assert!(party <= self.state().parties().len());
		debug_assert!(active <= self.state().parties()[party].active_count());
		debug_assert!(target <= self.state().parties()[party].member_count());

		if self.processing != BattleInputState::Ready
		{
			BattleError::Rejected
		}
		else if self.state().parties()[party].member(target).health() == 0
		{
			BattleError::SwitchHealth
		}
		else if self.state().parties()[party].active_member_index(active) == target
		{
			BattleError::SwitchActive
		}
		else
		{
			for active_index in 0..self.state().parties()[party].active_count()
			{
				if let Some(command) = self.queue.command_get(party, active_index)
				{
					if let CommandType::Switch(ref switch) = *command
					{
						if switch.target == target && switch.member != active
						{
							return BattleError::SwitchQueued;
						}
					}
				}
			}

			let command_switch = CommandSwitch
			{
				party: party,
				member: active,
				target: target,
			};
			self.queue.command_add(CommandType::Switch(command_switch), party, active);
			BattleError::None
		}
	}
/// Adds a command for switching an active party member with another party member.
///
/// The requested `target` party member must be referenced by member index, even if it is an
/// active member.
///
Adds a command for switching an active party member with another party member.
The requested `target` party member must be referenced by member index, even if it is an
active member.
Adds a command for switching an active party member with another party member . The requested ` target ` party member must be referenced by member index even if it is an active member .
pub fn command_add_switch(&mut self, party: usize, active: usize, target: usize) -> BattleError
	{
		debug_assert!(party <= self.state().parties().len());
		debug_assert!(active <= self.state().parties()[party].active_count());
		debug_assert!(target <= self.state().parties()[party].member_count());
		if self.processing != BattleInputState::Ready
		{
			BattleError::Rejected
		}
		else if self.state().parties()[party].member(target).health() == 0
		{
			BattleError::SwitchHealth
		}
		else if self.state().parties()[party].active_member_index(active) == target
		{
			BattleError::SwitchActive
		}
		else
		{
			for active_index in 0..self.state().parties()[party].active_count()
			{
				if let Some(command) = self.queue.command_get(party, active_index)
				{
					if let CommandType::Switch(ref switch) = *command
					{
						if switch.target == target && switch.member != active
						{
							return BattleError::SwitchQueued;
						}
					}
				}
			}
			let command_switch = CommandSwitch
			{
				party: party,
				member: active,
				target: target,
			};
			self.queue.command_add(CommandType::Switch(command_switch), party, active);
			BattleError::None
		}
	}
pub fn command_add_switch ( & mut self , party : usize , active : usize , target : usize ) -> BattleError { debug_assert ! ( party self state ( ) parties ( ) len ( ) ) ; debug_assert ! ( active self state ( ) parties ( ) [ party ] active_count ( ) ) ; debug_assert ! ( target self state ( ) parties ( ) [ party ] member_count ( ) ) ; if self . processing != BattleInputState :: Ready { BattleError :: Rejected } else if self . state ( ) . parties ( ) [ party ] . member ( target ) . health ( ) == 0 { BattleError :: SwitchHealth } else if self . state ( ) . parties ( ) [ party ] . active_member_index ( active ) == target { BattleError :: SwitchActive } else { for active_index in 0 .. self . state ( ) . parties ( ) [ party ] . active_count ( ) { if let Some ( command ) = self . queue . command_get ( party , active_index ) { if let CommandType :: Switch ( ref switch ) = * command { if switch . target == target && switch . member != active { return BattleError :: SwitchQueued ; } } } } let command_switch = CommandSwitch { party : party , member : active , target : target , } ; self . queue . command_add ( CommandType :: Switch ( command_switch ) , party , active ) ; BattleError :: None } }
Adds a command for switching an active party member with another party member.
Adds a command for switching an active party member with another party member .
&mut self
party
usize
active
usize
target
usize
&mut self
party
usize
active
usize
target
usize