Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cds-10 create rules for 2 player 3 player 4 player and 6 player games #19

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "bfc0b6f81adc06ce5121eb23f628473638d67c5c",
"version" : "1.2022062300.0"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "837d4af6ead57cec1fc38007892500d3139c7556",
"version" : "10.16.0"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "56f681586ff006a7982b53dc94082eea31971acf",
"version" : "10.16.0"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "aae45a320fd0d11811820335b1eabc8753902a40",
"version" : "9.2.5"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "c38ce365d77b04a9a300c31061c5227589e5597b",
"version" : "7.11.5"
}
},
{
"identity" : "grpc-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "a673bc2937fbe886dd1f99c401b01b6d977a9c98",
"version" : "1.49.1"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "d415594121c9e8a4f9d79cecee0965cf35e74dbd",
"version" : "3.1.1"
}
},
{
"identity" : "interop-ios-for-google-sdks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
"state" : {
"revision" : "2d12673670417654f08f5f90fdd62926dc3a2648",
"version" : "100.0.0"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b",
"version" : "1.22.2"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
"version" : "2.30909.0"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e",
"version" : "2.3.1"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "3c54ab05249f59f2c6641dd2920b8358ea9ed127",
"version" : "1.24.0"
}
},
{
"identity" : "swiftuisnackbar",
"kind" : "remoteSourceControl",
"location" : "https://github.com/zaniluca/SwiftUISnackbar",
"state" : {
"branch" : "main",
"revision" : "ff5132c91e3a3855af679e648b95c8ab60c5eeb1"
}
}
],
"version" : 2
}
2 changes: 1 addition & 1 deletion Cards.xcodeproj/xcshareddata/xcschemes/Cards.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
skipped = "YES"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,4 @@
uuid = "52D84923-A4D3-49DB-B62A-CB6DDE57D9AC"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6F341A58-BBFC-4853-BC7A-23992093E7F4"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Cards/views/LoadingScreen.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "70"
endingLineNumber = "70"
landmarkName = "equalNumOfPlayersOnTeam(players:)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
12 changes: 6 additions & 6 deletions Cards/ui/NamesAroundTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ struct NamesAroundTable: View {
}
.offset(y: -120)
.rotationEffect(.degrees(Double(startingRotation + (multiplier * index))))
// .onChange(of: firebaseHelper.players, initial: false, {
// sortedPlayerList = firebaseHelper.players
// .lazy
// .filter { $0.player_num != firebaseHelper.playerInfo!.player_num}
// .sorted(by: { $0.player_num! < $1.player_num!})
// })
.onChange(of: firebaseHelper.players, initial: false, {
sortedPlayerList = firebaseHelper.players
.lazy
.filter { $0.player_num != firebaseHelper.playerInfo!.player_num}
.sorted(by: { $0.player_num! < $1.player_num!})
})
}
.onAppear(perform: {
switch(firebaseHelper.gameInfo?.num_teams ?? 3) {
Expand Down
7 changes: 7 additions & 0 deletions Cards/views/GameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ struct GameView: View {
DeckOfCardsView()
.scaleEffect(x: 0.65, y: 0.65)
.position(x: geo.frame(in: .global).midX, y: geo.frame(in: .global).midY / 1.2)
.onChange(of: firebaseHelper.gameInfo?.turn, initial: true, {
if firebaseHelper.gameInfo?.turn == 1 {
Task {
await firebaseHelper.shuffleAndDealCards(cardsInHand_binding: $cardsInHand)
}
}
})

// game that is being played
VStack {
Expand Down
2 changes: 1 addition & 1 deletion Cards/views/games/cribbage/CribbageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct Cribbage: View {
.offset(y: 50)
.scaleEffect(x: 2, y: 2)
.onAppear(perform: {
cardsInHand = [CardItem(id: 39, value: "A", suit: "club"), CardItem(id: 40, value: "2", suit: "club"), CardItem(id: 26, value: "A", suit: "diamond"), CardItem(id: 27, value: "2", suit: "diamond"), CardItem(id: 39, value: "A", suit: "club"), CardItem(id: 40, value: "2", suit: "club"), CardItem(id: 26, value: "A", suit: "diamond"), CardItem(id: 27, value: "2", suit: "diamond")]
cardsInHand = [CardItem(id: 39, value: "A", suit: "club"), CardItem(id: 40, value: "2", suit: "club"), CardItem(id: 26, value: "6", suit: "diamond"), CardItem(id: 27, value: "2", suit: "diamond"), CardItem(id: 39, value: "7", suit: "club"), CardItem(id: 40, value: "2", suit: "heart")]
})
}
}
Expand Down
103 changes: 77 additions & 26 deletions Cards/views/games/cribbage/TurnOneView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,105 @@ struct TurnOneView: View {

var body: some View {
VStack {
HStack(spacing: 10) {
if cardsDragged.count > 0 {
CardView(cardItem: cardsDragged[0], cardIsDisabled: $cardIsDisabled)
} else {
CardPlaceHolder()
.border(firstDropAreaBorderColor, width: firstDropAreaBorderWidth)
.dropDestination(for: CardItem.self) { items, location in
if !cardsDragged.contains(items.first!) {
switch (firebaseHelper.gameInfo?.num_players ?? 6) {
case 2:
HStack {
if cardsDragged.count == 0 {
CardPlaceHolder()
.border(firstDropAreaBorderColor, width: firstDropAreaBorderWidth)
.dropDestination(for: CardItem.self) { items, location in
cardsDragged.append(items.first!)
cardsInHand.removeAll(where: { card in
card == items.first!
})
return true
} isTargeted: { inDropArea in
firstDropAreaBorderColor = inDropArea ? .green : .clear
firstDropAreaBorderWidth = inDropArea ? 7.0 : 1.0
}
CardPlaceHolder()
.border(secondDropAreaBorderColor, width: secondDropAreaBorderWidth)
.dropDestination(for: CardItem.self) { items, location in
cardsDragged.append(items.first!)
cardsInHand.removeAll(where: { card in
card == items.first!
})
return true
} isTargeted: { inDropArea in
secondDropAreaBorderColor = inDropArea ? .green : .clear
secondDropAreaBorderWidth = inDropArea ? 7.0 : 1.0
}
} else {
if cardsDragged.count == 1 {
CardView(cardItem: cardsDragged[0], cardIsDisabled: .constant(true))
CardPlaceHolder()
.border(secondDropAreaBorderColor, width: secondDropAreaBorderWidth)
.dropDestination(for: CardItem.self) { items, location in
cardsDragged.append(items.first!)
cardsInHand.removeAll(where: { card in
card == items.first!
})
return true
} isTargeted: { inDropArea in
secondDropAreaBorderColor = inDropArea ? .green : .clear
secondDropAreaBorderWidth = inDropArea ? 7.0 : 1.0
}

} else {
CardView(cardItem: cardsDragged[0], cardIsDisabled: .constant(true))
CardView(cardItem: cardsDragged[1], cardIsDisabled: .constant(true))
}
}
}
case 3,4:
if cardsDragged.count == 0 {
CardPlaceHolder()
.border(firstDropAreaBorderColor, width: firstDropAreaBorderWidth)
.dropDestination(for: CardItem.self) { items, location in
cardsDragged.append(items.first!)
cardsInHand.removeAll(where: { card in
card == items.first!
})
return true
} isTargeted: { inDropArea in
firstDropAreaBorderColor = inDropArea ? .green : .clear
firstDropAreaBorderWidth = inDropArea ? 7.0 : 1.0
}
} else {
CardView(cardItem: cardsDragged[0], cardIsDisabled: .constant(true))
}
case 6:
let dealer = firebaseHelper.players.first(where: { player in
player.is_dealer!
})

if firebaseHelper.gameInfo?.num_teams ?? 2 == 2 {
if cardsDragged.count > 1 {
CardView(cardItem: cardsDragged[1], cardIsDisabled: $cardIsDisabled)
} else {
if (firebaseHelper.playerInfo?.is_dealer! ?? true)
/* or if player is "to the left" of the dealer */
|| ((firebaseHelper.playerInfo?.player_num! ?? 1 + 1) % (firebaseHelper.gameInfo?.num_players ?? 2)) != (dealer?.player_num! ?? 1) {
Text("Waiting for players to discard...")
} else {
if cardsDragged.count == 0 {
CardPlaceHolder()
.border(secondDropAreaBorderColor, width: secondDropAreaBorderWidth)
.border(firstDropAreaBorderColor, width: firstDropAreaBorderWidth)
.dropDestination(for: CardItem.self) { items, location in
if !cardsDragged.contains(items.first!) {
cardsDragged.append(items.first!)
cardsInHand.removeAll(where: { card in
card == items.first!
})
}
cardsDragged.append(items.first!)
cardsInHand.removeAll(where: { card in
card == items.first!
})
return true
} isTargeted: { inDropArea in
secondDropAreaBorderColor = inDropArea ? .green : .clear
secondDropAreaBorderWidth = inDropArea ? 7.0 : 1.0
firstDropAreaBorderColor = inDropArea ? .green : .clear
firstDropAreaBorderWidth = inDropArea ? 7.0 : 1.0
}
} else {
CardView(cardItem: cardsDragged[0], cardIsDisabled: .constant(true))
}
}
default:
Text("don't get here")
}
}
.frame(height: 100)
.onAppear(perform: {
Task {
await firebaseHelper.shuffleAndDealCards(cardsInHand_binding: $cardsInHand)
}
})
.onChange(of: cardsDragged) {
if playerReady() {
cardIsDisabled = true
Expand Down
Loading