Not found in scope

So I am working on the war card app and am running into a weird thing the var playerCard or cpuCardin the func deal() is saying it cannot be found in the scope. Every other location where the they are named it works not sure what I am missing.

Using Xcode ver 15.4 thanks for the help.
Here is the code
import SwiftUI

struct ContentView: View {

@State var playerCard = "card3"
@State var cpuCard = "card4"

var playerScore = 0
var cpuScore = 0

var body: some View {
    
    ZStack{
        Image("background-plain")
            .resizable()
            .ignoresSafeArea()
        VStack{
            Spacer()
            Image("logo")
            Spacer()
            HStack{
                Spacer()
                Image(playerCard)
                Spacer()
                Image(cpuCard)
                Spacer()
            }
            Spacer()
            Button(action: {
                     deal()
                 }, label: {
                    Image("button")
                 })
                            
        Spacer()
        HStack{
            Spacer()
            VStack{
                Text("Player")
                    .font(.headline)
                    .padding(.bottom, 10.0)
                Text(String(playerScore))
                    .font(.largeTitle)
            }
            Spacer()
            VStack{
                
                Text("CPU")
                    .font(.headline)
                    .padding(.bottom, 10.0)
                Text(String(cpuScore))
                    .font(.largeTitle)
               
            }
            Spacer()
        }

            Spacer()
        } .foregroundColor(.white)
            Spacer()
            
        }
    }
}

func deal(){
    playerCard = "card" + String(Int.random(in: 2...14))
    cpuCard = "card" + String(Int.random(in: 2...14))
  
}

#Preview {
    ContentView()
}

Your function needs to be inside the struct, currently it’s outside

(Just move it one curly bracket intent upwards)

@equalloch

You will also need to declare playerScore and cpuScore as @State var

@State var playerScore = 0
@State var cpuScore = 0

@State is a special property wrapper that enables a var to be changed inside a SwiftUI struct.

I made that correction after I posted. I noticed it was missing. Curly brackets are a pain to try and follow sometimes.