/// <summary> /// Adds the move in list of available moves for the specific match /// </summary> /// <returns><c>true</c>, if move was added, <c>false</c> otherwise.</returns> /// <param name="move">Move.</param> public bool AddMove(Move move) { if (AvailableMoves.FindIndex(a => a.Label.ToLower() == move.Label.ToLower()) == -1) { AvailableMoves.Add(move); return(true); } else { WriteLine("Move with label {0} exists!", move.Label); } return(false); }
public Warrior(int level, IChanceService chanceService, string name = null) : base(name ?? "Warrior" , level , LevelUpManager.GetHealthByLevel <Warrior>(level) , LevelUpManager.GetManaByLevel <Warrior>(level) , LevelUpManager.GetStrengthByLevel <Warrior>(level) , LevelUpManager.GetDefenseByLevel <Warrior>(level) , LevelUpManager.GetSpeedByLevel <Warrior>(level) , LevelUpManager.GetEvadeByLevel <Warrior>(level) , LevelUpManager.GetLuckByLevel <Warrior>(level) , chanceService , SpellFactory.GetSpellsByLevel <Warrior>(level) , MoveFactory.GetMovesByLevel <Warrior>(level)) { _attackIndex = AvailableMoves.FindIndex(bm => bm.MoveType == BattleMoveType.Attack); _evadeIndex = AvailableMoves.FindIndex(bm => bm.MoveType == BattleMoveType.Status && (bm as StatusMove)?.Status is AutoEvadeStatus && !((AutoEvadeStatus)((StatusMove)bm).Status).ShouldCounterAttack); _evadeAndCounterIndex = AvailableMoves.FindIndex(bm => bm.MoveType == BattleMoveType.Status && (bm as StatusMove)?.Status is AutoEvadeStatus && ((AutoEvadeStatus)((StatusMove)bm).Status).ShouldCounterAttack); _attackBoostIndex = AvailableMoves.FindIndex(bm => bm.MoveType == BattleMoveType.Status && (bm as StatusMove)?.Status is StatMultiplierStatus); _attackBoostMove = AvailableMoves[_attackBoostIndex] as StatusMove; }
/// <summary> /// Gets a tactical move based on previous Player 1 move. If we are currently in Game 1 (no previous move), then a random move is returned /// </summary> /// <returns>The tactical move.</returns> /// <param name="maxRange">Max range to choose a move from the list of available moves.</param> public int GetTacticalMove(int maxRange) { // if this is game 1 (not previous move from Player 1) return random if (this.MovesHistory.Count == 0) { return(new Random().Next(1, maxRange)); } else { // Previous move of Player 1 int item = this.MovesHistory[this.MovesHistory.Count - 1].Item1; Move previousMove = AvailableMoves[item]; foreach (var moveItem in AvailableMoves) { if (moveItem.FindIfBeats(previousMove)) { // this move beats previous Player 1 move return(AvailableMoves.FindIndex(a => a.Label == moveItem.Label)); } } //end foreach return(new Random().Next(1, maxRange)); // Added because of a warning in editor and just in case I missed something } //end else }