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

		if self.processing != BattleInputState::Ready
		{
			return BattleError::Rejected;
		}

		let active_attack = &self.runner.state().parties()[party].active_member(active).member.attacks()[attack];
		if active_attack.limit_left() == 0
		{
			return BattleError::AttackLimit;
		}

		// TODO: This should be side check, not party check.
		let same_party = party == target_party;
		if (active_attack.attack().target & Target::SIDE_ENEMY) == 0 && !same_party
		{
			return BattleError::AttackTarget;
		}
		if (active_attack.attack().target & Target::SIDE_ALLY) == 0 && same_party
		{
			return BattleError::AttackTarget;
		}

		let is_adjacent = Target::is_adjacent_with(active, target_active);
		if (active_attack.attack().target & Target::RANGE_ADJACENT) == 0 && is_adjacent
		{
			return BattleError::AttackTarget;
		}
		if (active_attack.attack().target & Target::RANGE_OPPOSITE) == 0 && !is_adjacent
		{
			return BattleError::AttackTarget;
		}

		let same_member = active == target_active;
		if (active_attack.attack().target & Target::TARGET_SELF) == 0 && same_party && same_member
		{
			return BattleError::AttackTarget;
		}

		let command_attack = CommandAttack
		{
			party: party,
			member: active,
			target_party: target_party,
			target_member: target_active,
			attack_index: attack,
		};

		self.queue.command_add(CommandType::Attack(command_attack), party, active);

		BattleError::None
	}
/// Adds a command for attacking another party's member.
Adds a command for attacking another party's member.
Adds a command for attacking another party ' s member .
pub fn command_add_attack(&mut self, party: usize, active: usize, attack: usize,
		target_party: usize, target_active: usize) -> BattleError
	{
		debug_assert!(party <= self.state().parties().len());
		debug_assert!(active <= self.state().parties()[party].active_count());
		debug_assert!(target_party <= self.state().parties().len());
		debug_assert!(target_active <= self.state().parties()[target_party].active_count());
		if self.processing != BattleInputState::Ready
		{
			return BattleError::Rejected;
		}
		let active_attack = &self.runner.state().parties()[party].active_member(active).member.attacks()[attack];
		if active_attack.limit_left() == 0
		{
			return BattleError::AttackLimit;
		}
		// TODO: This should be side check, not party check.
		let same_party = party == target_party;
		if (active_attack.attack().target & Target::SIDE_ENEMY) == 0 && !same_party
		{
			return BattleError::AttackTarget;
		}
		if (active_attack.attack().target & Target::SIDE_ALLY) == 0 && same_party
		{
			return BattleError::AttackTarget;
		}
		let is_adjacent = Target::is_adjacent_with(active, target_active);
		if (active_attack.attack().target & Target::RANGE_ADJACENT) == 0 && is_adjacent
		{
			return BattleError::AttackTarget;
		}
		if (active_attack.attack().target & Target::RANGE_OPPOSITE) == 0 && !is_adjacent
		{
			return BattleError::AttackTarget;
		}
		let same_member = active == target_active;
		if (active_attack.attack().target & Target::TARGET_SELF) == 0 && same_party && same_member
		{
			return BattleError::AttackTarget;
		}
		let command_attack = CommandAttack
		{
			party: party,
			member: active,
			target_party: target_party,
			target_member: target_active,
			attack_index: attack,
		};
		self.queue.command_add(CommandType::Attack(command_attack), party, active);
		BattleError::None
	}
pub fn command_add_attack ( & mut self , party : usize , active : usize , attack : usize , target_party : usize , target_active : usize ) -> BattleError { debug_assert ! ( party self state ( ) parties ( ) len ( ) ) ; debug_assert ! ( active self state ( ) parties ( ) [ party ] active_count ( ) ) ; debug_assert ! ( target_party self state ( ) parties ( ) len ( ) ) ; debug_assert ! ( target_active self state ( ) parties ( ) [ target_party ] active_count ( ) ) ; if self . processing != BattleInputState :: Ready { return BattleError :: Rejected ; } let active_attack = & self . runner . state ( ) . parties ( ) [ party ] . active_member ( active ) . member . attacks ( ) [ attack ] ; if active_attack . limit_left ( ) == 0 { return BattleError :: AttackLimit ; } // TODO: This should be side check, not party check. let same_party = party == target_party ; if ( active_attack . attack ( ) . target & Target :: SIDE_ENEMY ) == 0 && ! same_party { return BattleError :: AttackTarget ; } if ( active_attack . attack ( ) . target & Target :: SIDE_ALLY ) == 0 && same_party { return BattleError :: AttackTarget ; } let is_adjacent = Target :: is_adjacent_with ( active , target_active ) ; if ( active_attack . attack ( ) . target & Target :: RANGE_ADJACENT ) == 0 && is_adjacent { return BattleError :: AttackTarget ; } if ( active_attack . attack ( ) . target & Target :: RANGE_OPPOSITE ) == 0 && ! is_adjacent { return BattleError :: AttackTarget ; } let same_member = active == target_active ; if ( active_attack . attack ( ) . target & Target :: TARGET_SELF ) == 0 && same_party && same_member { return BattleError :: AttackTarget ; } let command_attack = CommandAttack { party : party , member : active , target_party : target_party , target_member : target_active , attack_index : attack , } ; self . queue . command_add ( CommandType :: Attack ( command_attack ) , party , active ) ; BattleError :: None }
Adds a command for attacking another party's member.
Adds a command for attacking another party ' s member .
&mut self
party
usize
active
usize
attack
usize
target_party
usize
target_active
usize
&mut self
party
usize
active
usize
attack
usize
target_party
usize
target_active
usize