glue code
This commit is contained in:
parent
ddffc25db6
commit
05fdb77c98
@ -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
|
||||
stats.updateGamesWon(mGameState)
|
||||
} else {
|
||||
if (gameState == MainActivity.GameOption.Cats) mGameState = GameState.GameCat else {
|
||||
when (mGameState) {
|
||||
GameState.GamePlayerTurnX -> mGameState = GameState.GamePlayerTurnO
|
||||
GameState.GamePlayerTurnO -> mGameState = GameState.GamePlayerTurnX
|
||||
}
|
||||
Stats().updatePiecePlaced()
|
||||
stats.updatePiecePlaced()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
|
||||
// Private variables - other variables
|
||||
private lateinit var mAllButtonList: List<Button>
|
||||
private var mGameWon: GameOption = GameOption.No
|
||||
private var mGameboard = Gameboard()
|
||||
private var mStats = Stats()
|
||||
var mGameboard = Gameboard()
|
||||
|
||||
enum class GameOption {
|
||||
Won,
|
||||
@ -151,6 +150,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
|
||||
|
||||
fun clickGameStats(view: View?) {
|
||||
// dialog appears for game stats
|
||||
val dialog = StatsDialogFragment()
|
||||
dialog.sendStats(mGameboard.stats)
|
||||
dialog.show(supportFragmentManager, "")
|
||||
}
|
||||
|
||||
private fun checkGameState(button: Button) {
|
||||
|
Loading…
Reference in New Issue
Block a user