class SimpleTicTacToeCell : ItemFragment() { private val associatedPlayerProperty = SimpleIntegerProperty(CellValue.no_player.ordinal) var associatedPlayer by associatedPlayerProperty override val root = button { prefWidth = 60.0 prefHeight = 60.0 graphic = group { rectangle { width = 60.0 height = 60.0 arcWidth = 15.0 arcHeight = 15.0 stroke = Color.BLACK fill = Color.WHITE strokeWidth = 5.0 } group { line { startX = 10.0 startY = 10.0 endX = 50.0 endY = 50.0 stroke = Color.BLUE strokeWidth = 3.0 } line { startX = 10.0 startY = 50.0 endX = 50.0 endY = 10.0 stroke = Color.BLUE strokeWidth = 3.0 } isVisible = associatedPlayer == CellValue.cross.ordinal } circle { centerX = 30.0 centerY = 30.0 radius = 20.0 stroke = Color.RED fill = Color.WHITE strokeWidth = 3.0 isVisible = associatedPlayer == CellValue.circle.ordinal } } setOnMouseClicked { if (associatedPlayer == CellValue.no_player.ordinal){ associatedPlayerProperty.set(GridLogic.currentPlayer.ordinal) GridLogic.togglePlayer() } } } }