Skip to content

Commit

Permalink
nba(jump ball): cadence
Browse files Browse the repository at this point in the history
* Fix pre{}.
  • Loading branch information
chumeston committed Dec 12, 2024
1 parent 8af70fc commit 44b09b5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contracts/JumpBall.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ access(all) contract JumpBall {

// Add an opponent to a game
access(all) fun addOpponent(gameID: UInt64, player: &Player) {
let game = JumpBall.games[gameID] ?? panic("Game does not exist.")

pre {
game.opponent == nil: "Opponent has already been added."
player.canCreateGame(): "Player does not have a valid collection capability to be added as an opponent."
}

let game = JumpBall.games[gameID] ?? panic("Game does not exist.")

game.opponent = player.address
game.opponentCap = player.collectionCap
JumpBall.addGameForUser(player.address, gameID)
Expand Down Expand Up @@ -297,13 +297,13 @@ access(all) contract JumpBall {

// Destroy a game and clean up resources
access(all) fun destroyGame(gameID: UInt64) {
let game <- JumpBall.games.remove(key: gameID) ?? panic("Game does not exist.")

// Ensure all NFTs have been withdrawn
pre {
game.nfts.isEmpty: "All NFTs must be withdrawn before destroying the game."
}

let game <- JumpBall.games.remove(key: gameID) ?? panic("Game does not exist.")

// Remove game from userGames mapping
JumpBall.removeGameForUser(game.creator, gameID)
if let opponent = game.opponent {
Expand Down

0 comments on commit 44b09b5

Please sign in to comment.