Darts Game Tracker

# UI setup for taking user inputs
library(shiny)
Warning: package 'shiny' was built under R version 4.3.2
textInput("player1", "Player 1 Name")
textInput("player2", "Player 2 Name")
numericInput("score1", "Player 1 Score", value = 0, min = 0)
numericInput("score2", "Player 2 Score", value = 0, min = 0)
actionButton("calculate", "Calculate")
textOutput("result")

shinyServer(function(input, output) { output\(result <- renderText({ # Ensure input scores are treated as numeric score1 <- as.numeric(input\)score1) score2 <- as.numeric(input$score2)

# Assuming the game starts at 501 points
startPoints <- 501
remaining1 <- startPoints - score1
remaining2 <- startPoints - score2

# Basic comparison for demonstration
if (remaining1 < 0 || remaining2 < 0) {
  "One of the players has finished. Check the scores!"
} else if (remaining1 < remaining2) {
  paste(input$player1, "is closer to winning with", remaining1, "points remaining.")
} else if (remaining2 < remaining1) {
  paste(input$player2, "is closer to winning with", remaining2, "points remaining.")
} else {
  "It's a tie! Both players have the same points remaining."
}

}) })