コード例 #1
0
		private Boolean MayTakeAction(TurnStepAction action, AvatarTurnState turnState)
		{
			if (action.RequiresAction && turnState.HasTakenAction)
			{ return false; } // Cannot use this action if the player has already taken his action this turn.
			else if (action.RequiresMovement && turnState.MovementPointsLeft <= 0)
			{ return false; } // Cannot use this action if the player has no movement points left this turn.
			return true;
		}
コード例 #2
0
		public void BreakFocus()
		{ _focusAction = null; }
コード例 #3
0
		virtual public TurnStepAction DoTakeTurnStep(QuestAnalyzer mapAnalyzer, ChanceProvider chanceProvider)
		{
			if (!IsHeroAlive) // Can't play if dead.
			{
				if (_sentDeathMessage)
				{ return null; }
				else
				{
					_sentDeathMessage = true;
					return new DeadTurnStepAction(this);
				}
			}
			if (TurnState.MovementPointsLeft <= 0 && TurnState.HasTakenAction) // We can continue our turn as long as we have movement points left, and have not taken our action
			{ return null; }

			// Determine the action to perform
			TurnStepAction action = null;
			for (int i = 0; i < _avatarClass.ActionStrategies.Count && action == null; i++)
			{
				AbstractActionStrategy strategy = _avatarClass.ActionStrategies[i];
				if (_focusAction == null || strategy.CanBreakFocus)
				{
					action = strategy.FindAction(this, TurnState, mapAnalyzer, chanceProvider);
					
					if (action != null && !MayTakeAction(action, TurnState))
					{ action = null; }

					if (action != null)
					{ _focusAction = null; }
				}
			}

			if (_focusAction != null && _focusAction.AcceptsAvatarFocus && _focusAction.HasMoreTurns) // If our focus action still has stuff to do, let it keep focus
			{
				if (MayTakeAction(_focusAction, TurnState))
				{ action = _focusAction; }
			}

			if (action == null) // If we can't figure anything else out, then end the turn.
			{
				action = new ConfusedTurnStepAction(this); // In the real game, this should never happen.  Avatars should always find *something* to do.
				TurnState.HasTakenAction = true;
				TurnState.MovementPointsLeft = 0;
			}

			if (action.AcceptsAvatarFocus && action.HasMoreTurns) // If the action is multi-step, focus on it until something interrupts us
			{ _focusAction = action; }

			return action;
		}