diff --git a/DouShouQiIOS/DouShouQiIOS.xcodeproj/project.pbxproj b/DouShouQiIOS/DouShouQiIOS.xcodeproj/project.pbxproj index 8996acf..96dcbad 100644 --- a/DouShouQiIOS/DouShouQiIOS.xcodeproj/project.pbxproj +++ b/DouShouQiIOS/DouShouQiIOS.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 7B4508EA2BF206B10027E1EF /* DouShouQiIOSUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4508E92BF206B10027E1EF /* DouShouQiIOSUITestsLaunchTests.swift */; }; 7B4508F72BF2084B0027E1EF /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4508F62BF2084B0027E1EF /* PlayerView.swift */; }; 7B4508FA2BF214F50027E1EF /* PlayerListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4508F92BF214F50027E1EF /* PlayerListView.swift */; }; + 7BB279892BFDF79E00491801 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BB279882BFDF79E00491801 /* GameView.swift */; }; 7BDD43C72BFCC927003984FB /* MainMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDD43C62BFCC927003984FB /* MainMenuView.swift */; }; 7BDD43C92BFCD2C4003984FB /* HistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDD43C82BFCD2C4003984FB /* HistoryView.swift */; }; /* End PBXBuildFile section */ @@ -54,6 +55,7 @@ 7B4508E92BF206B10027E1EF /* DouShouQiIOSUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DouShouQiIOSUITestsLaunchTests.swift; sourceTree = ""; }; 7B4508F62BF2084B0027E1EF /* PlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = ""; }; 7B4508F92BF214F50027E1EF /* PlayerListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerListView.swift; sourceTree = ""; }; + 7BB279882BFDF79E00491801 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = ""; }; 7BDD43C62BFCC927003984FB /* MainMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuView.swift; sourceTree = ""; }; 7BDD43C82BFCD2C4003984FB /* HistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryView.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -166,6 +168,7 @@ 7B4508F92BF214F50027E1EF /* PlayerListView.swift */, 7BDD43C62BFCC927003984FB /* MainMenuView.swift */, 7BDD43C82BFCD2C4003984FB /* HistoryView.swift */, + 7BB279882BFDF79E00491801 /* GameView.swift */, ); path = View; sourceTree = ""; @@ -311,6 +314,7 @@ 7BDD43C72BFCC927003984FB /* MainMenuView.swift in Sources */, 7B4508CF2BF206AF0027E1EF /* ContentView.swift in Sources */, 7B4508CD2BF206AF0027E1EF /* DouShouQiIOSApp.swift in Sources */, + 7BB279892BFDF79E00491801 /* GameView.swift in Sources */, 7BDD43C92BFCD2C4003984FB /* HistoryView.swift in Sources */, 7B3B17642BF24B32002BC817 /* Player.swift in Sources */, 7B3B17672BF24ED6002BC817 /* FullButtonStyle.swift in Sources */, diff --git a/DouShouQiIOS/DouShouQiIOS/View/GameView.swift b/DouShouQiIOS/DouShouQiIOS/View/GameView.swift new file mode 100644 index 0000000..c520215 --- /dev/null +++ b/DouShouQiIOS/DouShouQiIOS/View/GameView.swift @@ -0,0 +1,105 @@ +// +// GameView.swift +// DouShouQiIOS +// +// Created by Pierre FERREIRA on 22/05/2024. +// + +import SwiftUI + +struct GameView: View { + @State private var turnNumber = 1 + @State private var gameTime = 0.0 // Temps en secondes + @State private var statusMessage = "C'est votre tour" + @State private var player1Pieces = 8 + @State private var player2Pieces = 8 + + var timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() + + let gridItems = Array(repeating: GridItem(.flexible()), count: 8) + + var body: some View { + VStack { + VStack { + Text(statusMessage) + .font(.title) + .padding(.top, 20) + + HStack { + Text("Tour: \(turnNumber)") + .font(.headline) + .frame(height: 50, alignment: .center) + .padding([.leading, .trailing], 20) + .background(Color.yellow) + .foregroundColor(Color.white) + .bold() + .cornerRadius(15) + + Spacer() + + Text("Temps: \(Int(gameTime))s") + .font(.headline) + .frame(height: 50, alignment: .center) + .padding([.leading, .trailing], 20) + .background(Color.yellow) + .foregroundColor(Color.white) + .bold() + .cornerRadius(15) .onReceive(timer) { _ in + gameTime += 1 + } + } + .padding([.leading, .trailing], 20) + } + + LazyVGrid(columns: gridItems, spacing: 5) { + ForEach(0..<64) { index in + Rectangle() + .foregroundColor((index / 8 + index % 8) % 2 == 0 ? .orange : .gray.opacity(0.2)) + .frame(height: 35) + .cornerRadius(10) + } + } + .padding(10) + .background(Color.yellow) + .cornerRadius(15) + .padding(20) + + HStack { + VStack { + Text("Pièces Joueur 1") + .font(.headline) + .padding(.bottom, 5) + + Text("\(player1Pieces)") + .font(.largeTitle) + .padding() + .background(Color.yellow.opacity(0.2)) + .cornerRadius(10) + } + .padding(20) + + Spacer() + + VStack { + Text("Pièces Joueur 2") + .font(.headline) + .padding(.bottom, 5) + + Text("\(player2Pieces)") + .font(.largeTitle) + .padding() + .background(Color.red.opacity(0.2)) + .cornerRadius(10) + } + .padding(20) + } + } + .navigationBarTitle("DouShouQi", displayMode: .inline) + } +} + +struct GameView_Previews: PreviewProvider { + static var previews: some View { + GameView() + } +} diff --git a/DouShouQiIOS/DouShouQiIOS/View/HistoryView.swift b/DouShouQiIOS/DouShouQiIOS/View/HistoryView.swift index 0b29f3a..908301a 100644 --- a/DouShouQiIOS/DouShouQiIOS/View/HistoryView.swift +++ b/DouShouQiIOS/DouShouQiIOS/View/HistoryView.swift @@ -79,13 +79,18 @@ struct HistoryView: View { Text(match.result) .foregroundColor(match.result == "Victoire" ? .green : .red) .padding(.trailing, 10) - } + }.listRowBackground(Color.yellow.opacity(0.1)) .padding() .background(match.result == "Victoire" ? Color.green.opacity(0.3) : Color.red.opacity(0.3)) .cornerRadius(10) + + + } - .navigationTitle("\(playerName)'s Historique") - } + .padding() + .navigationTitle("Historique de \(playerName)") + + }.background(Color.gray.opacity(0.1)) } } diff --git a/DouShouQiIOS/DouShouQiIOS/View/MainMenuView.swift b/DouShouQiIOS/DouShouQiIOS/View/MainMenuView.swift index 60656d0..1eea440 100644 --- a/DouShouQiIOS/DouShouQiIOS/View/MainMenuView.swift +++ b/DouShouQiIOS/DouShouQiIOS/View/MainMenuView.swift @@ -9,69 +9,67 @@ import SwiftUI struct MainMenuView: View { var body: some View { - VStack { - Image("DouShouQi") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 200, height: 200) - - - Text("DouShouQi") - .font(.largeTitle) - .bold() - .padding() + NavigationStack { - Button(action: { - // Action pour Jouer Seul - print("Jouer Seul tapped!") - }) { - Text("Jouer Seul") - .font(.title2) + VStack { + Image("DouShouQi") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 200, height: 200) + + + Text("DouShouQi") + .font(.largeTitle) + .bold() .padding() - .background(Color.yellow) - .foregroundColor(.white) - .cornerRadius(8) - } - .padding(.top, 10) - - Button(action: { - // Action pour Jouer en Multi - print("Jouer en Multi tapped!") - }) { - Text("Jouer en Multi") - .font(.title2) - .padding() - .background(Color.yellow) - .foregroundColor(.white) - .cornerRadius(8) - } - - NavigationLink(destination: PlayerListView()) { - Text("Leaderboard") - .font(.title2) - .padding() - .background(Color.yellow) - .foregroundColor(.white) - .cornerRadius(8) - } - .padding(.top, 20) - - Button(action: { - // Quitter - print("Quitter tapped!") - } - ) { - Text("Quitter") - .font(.title2) - .padding() - .foregroundColor(.yellow) - }.overlay( - RoundedRectangle(cornerRadius: 10) - .stroke(.yellow, lineWidth: 3) - ) - .padding(.top, 20) - - }.navigationBarBackButtonHidden(true) + + NavigationLink(destination: GameView()) { + Text("Jouer Seul") + .font(.title2) + .padding() + .background(Color.yellow) + .foregroundColor(.white) + .cornerRadius(8) + } + .padding(.top, 10) + + NavigationLink(destination: GameView()) { + Text("Jouer en Multi") + .font(.title2) + .padding() + .background(Color.yellow) + .foregroundColor(.white) + .cornerRadius(8) + } + + + NavigationLink(destination: PlayerListView()) { + Text("Leaderboard") + .font(.title2) + .padding() + .background(Color.yellow) + .foregroundColor(.white) + .cornerRadius(8) + } + .padding(.top, 20) + + Button(action: { + // Quitter + print("Quitter tapped!") + } + ) { + Text("Quitter") + .font(.title2) + .padding() + .foregroundColor(.yellow) + }.overlay( + RoundedRectangle(cornerRadius: 10) + .stroke(.yellow, lineWidth: 3) + ) + .padding(.top, 20) + + }.navigationBarBackButtonHidden(true) + } } }