diff --git a/Battle Cards/Battle Cards/Array+Identifiable.swift b/Battle Cards/Battle Cards/Array+Identifiable.swift index 38ed77f..764ee00 100644 --- a/Battle Cards/Battle Cards/Array+Identifiable.swift +++ b/Battle Cards/Battle Cards/Array+Identifiable.swift @@ -8,27 +8,7 @@ import Foundation -// Extends the capabilities of Array if the element inside is identifiable -extension Array where Element: Identifiable { - - // Find the index of the first element using the id - func firstIndexOf(element: Element) -> Int? { - - // Basic loop through the array - for index in 0.. { self.indices.filter{ $0 < self.count / 2 }.map{ self[$0] } diff --git a/Battle Cards/Battle Cards/BattleSystem.swift b/Battle Cards/Battle Cards/BattleSystem.swift index 2d8264d..12ae0b0 100644 --- a/Battle Cards/Battle Cards/BattleSystem.swift +++ b/Battle Cards/Battle Cards/BattleSystem.swift @@ -57,7 +57,7 @@ struct BattleSystem where Color: Equatable, Element: Equatable { } mutating func choose(card: Card, makeColor: (Int) -> Color, makeElement: (Int) -> Element) { - if let cardIndex: Int = playerHand.firstIndexOf(element: card) { + if let cardIndex: Int = playerHand.firstIndex(of: card) { // Retrieve card from hand let chosen = playerHand.remove(at: cardIndex) diff --git a/Battle Cards/Battle Cards/ContentView.swift b/Battle Cards/Battle Cards/ContentView.swift index 927b2a5..e39b3bd 100644 --- a/Battle Cards/Battle Cards/ContentView.swift +++ b/Battle Cards/Battle Cards/ContentView.swift @@ -187,7 +187,7 @@ struct ContentView: View { private func chooseCard(card: BattleSystem.Card) { // Check if selected card is real - guard emojiCardGame.playerHand.firstIndexOf(element: card) != nil else { + guard emojiCardGame.playerHand.firstIndex(of: card) != nil else { return } audio.playSound(.flip)