diff --git a/app/src/main/java/com/wyattjmiller/tictactoeapp/Gameboard.kt b/app/src/main/java/com/wyattjmiller/tictactoeapp/Gameboard.kt index c66f58d..0e4e285 100644 --- a/app/src/main/java/com/wyattjmiller/tictactoeapp/Gameboard.kt +++ b/app/src/main/java/com/wyattjmiller/tictactoeapp/Gameboard.kt @@ -3,6 +3,7 @@ package com.wyattjmiller.tictactoeapp class Gameboard { private var mGameState: GameState private var mGamePiece: GamePiece + var stats: Stats = Stats() enum class GameState { None, @@ -37,20 +38,26 @@ class Gameboard { if (gameState == MainActivity.GameOption.Won) { when (mGameState) { GameState.GamePlayerTurnX -> { - Stats().updateGamesWon(mGameState) mGameState = GameState.GamePlayerWinX + stats.updateGamesWon(mGameState) + } + GameState.GamePlayerTurnO -> { + mGameState = GameState.GamePlayerWinO + stats.updateGamesWon(mGameState) } - GameState.GamePlayerTurnO -> mGameState = GameState.GamePlayerWinO } - Stats().updateGamesPlayed() + stats.updateGamesPlayed() } else { - if (gameState == MainActivity.GameOption.Cats) mGameState = GameState.GameCat else { + if (gameState == MainActivity.GameOption.Cats) { + mGameState = GameState.GameCat + stats.updateGamesWon(mGameState) + } else { when (mGameState) { GameState.GamePlayerTurnX -> mGameState = GameState.GamePlayerTurnO GameState.GamePlayerTurnO -> mGameState = GameState.GamePlayerTurnX } - Stats().updatePiecePlaced() + stats.updatePiecePlaced() } } } diff --git a/app/src/main/java/com/wyattjmiller/tictactoeapp/MainActivity.kt b/app/src/main/java/com/wyattjmiller/tictactoeapp/MainActivity.kt index d153740..cbc6423 100644 --- a/app/src/main/java/com/wyattjmiller/tictactoeapp/MainActivity.kt +++ b/app/src/main/java/com/wyattjmiller/tictactoeapp/MainActivity.kt @@ -30,8 +30,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { // Private variables - other variables private lateinit var mAllButtonList: List