/// <summary> /// /// </summary> /// <param player OR opponent table part="playerTablePart"></param> /// <param name="thisCardPosition"></param> /// <returns>returns an array of int - indexes of cards this ability applied to</returns> public int[] ApplyPassiveToAlly(CardTablePart playerTablePart, CardPosition thisCardPosition) { // Indexes of cards this ability applied to int[] result = new int[0]; for (int a = 0; a < cardAbilities.Length; a++) { CardAbility ability = cardAbilities[a]; // toAlly for (int i = 0; i < ability.toAlly.Length; i++) { switch (ability.toAlly[i]) { case ApplyToAlly.ALL: for (int row = 0; row < playerTablePart.cardArray.Length; row++) { for (int col = 0; col < playerTablePart.cardArray[row].Length; col++) { //Debug.Log("Passive ability applieed"); playerTablePart.cardArray[row][col].ApplyAbility(ability); result = HelperFunctions.Add(result, playerTablePart.cardArray[row][col].cardIndex); } } break; case ApplyToAlly.ITSELF: this.ApplyAbility(ability); result = HelperFunctions.Add <int>(result, this.cardIndex); break; case ApplyToAlly.LEFT: try { playerTablePart.cardArray[thisCardPosition.row][thisCardPosition.column - 1].ApplyAbility(ability); result = HelperFunctions.Add <int>(result, playerTablePart.cardArray[thisCardPosition.row][thisCardPosition.column - 1].cardIndex); } catch (IndexOutOfRangeException) { } break; case ApplyToAlly.RIGHT: try { playerTablePart.cardArray[thisCardPosition.row][thisCardPosition.column + 1].ApplyAbility(ability); result = HelperFunctions.Add <int>(result, playerTablePart.cardArray[thisCardPosition.row][thisCardPosition.column + 1].cardIndex); } catch (IndexOutOfRangeException) { } break; case ApplyToAlly.ROW: for (int col = 0; col < playerTablePart.cardArray[thisCardPosition.row].Length; col++) { playerTablePart.cardArray[thisCardPosition.row][col].ApplyAbility(ability); result = HelperFunctions.Add <int>(result, playerTablePart.cardArray[thisCardPosition.row][col].cardIndex); } break; case ApplyToAlly.RANDOM: { int row = playerTablePart.GetRandomRowWithCards(); if (row != -1) { int col = HelperFunctions.RandomExcept( 0, playerTablePart.cardArray[row].Length, thisCardPosition.column); if (col != 0) { playerTablePart.cardArray[row][col].ApplyAbility(ability); result = HelperFunctions.Add <int>(result, playerTablePart.cardArray[row][col].cardIndex); } } } break; case ApplyToAlly.NONE: break; default: break; } Debug.Log(" ApplyPassiveAbilityToAlly"); } } return(result); }
public int[] ApplyPassiveToOpponent(CardTablePart opponentTablePart, CardPosition thisCardPosition) { // Indexes of cards this ability applied to int[] result = new int[0]; for (int a = 0; a < cardAbilities.Length; a++) { CardAbility ability = cardAbilities[a]; // toOpponent for (int i = 0; i < ability.toOpponent.Length; i++) { switch (ability.toOpponent[i]) { case ApplyToOpponent.ALL: for (int row = 0; row < opponentTablePart.cardArray.Length; row++) { for (int col = 0; col < opponentTablePart.cardArray[row].Length; col++) { //Debug.Log("Passive ability applieed"); opponentTablePart.cardArray[row][col].ApplyAbility(ability); result = HelperFunctions.Add <int>(result, opponentTablePart.cardArray[row][col].cardIndex); } } break; case ApplyToOpponent.ROW: for (int col = 0; col < opponentTablePart.cardArray[thisCardPosition.row].Length; col++) { //TODO: !!!!!!!!!!!!!!!!!!!!!! //opponentTablePart.cardArray[thisCardPosition.row][col].ApplyAbility(ability); } break; case ApplyToOpponent.RANDOM: { //Debug.Log("Random applied"); int row = opponentTablePart.GetRandomRowWithCards(); if (row == -1) { break; } int col = UnityEngine.Random.Range( 0, opponentTablePart.cardArray[row].Length); opponentTablePart.cardArray[row][col].ApplyAbility(ability); result = HelperFunctions.Add <int>(result, opponentTablePart.cardArray[row][col].cardIndex); } break; case ApplyToOpponent.NONE: break; default: break; } Debug.Log(" ApplyPassiveAbilityToOpponent"); } } return(result); }