library(xlsx)
nPacks <- 16
fileName <- list.files(".", pattern = ".xlsx")
cubeDf <- read.xlsx(fileName, sheetIndex = 1)
colorIds <- as.vector(cubeDf[, 2])
cube <- as.vector(cubeDf[, 1])
# select colors
colorToOmit <- "R" # sample(c("W", "U", "R", "B", "G"), 1)
colorList <- strsplit(colorIds, split = NULL)
rowsToKeep <- rep(1, length(cube))
for(i in 1:length(cube))
if(colorToOmit %in% colorList[[i]])
rowsToKeep[i] <- 0
cube <- cube[which(rowsToKeep == 1)]
# seed in shocklands
shocklands <- c("Blood Crypt", "Godless Shrine", "Overgrown Tomb",
"Sacred Foundry", "Stomping Ground", "Temple Garden", "Breeding Pool",
"Hallowed Fountain", "Watery Grave", "Steam Vents")
shockIds <- which(cube %in% shocklands)
gridPile <- cube[shockIds]
cube <- cube[-shockIds]
gridPile <- c(gridPile, sample(cube, size=9*nPacks - length(shockIds)))
gridPile <- sample(gridPile)
pack <- gridPile[1:9]
printPack <- function(pack, i) {
cat("Pack", i, "\n", file="gridDraft.txt", append=TRUE)
cat("[spoiler][ci=small]", pack[1], "\n", pack[2], "\n", pack[3],
"[/ci]", "\n", sep="", file="gridDraft.txt", append=TRUE)
cat("[ci=small]", pack[4], "\n", pack[5], "\n", pack[6],
"[/ci]", "\n", sep="", file="gridDraft.txt", append=TRUE)
cat("[ci=small]", pack[7], "\n", pack[8], "\n", pack[9], "[/ci]", "\n",
"\n", sep="", file="gridDraft.txt", append=TRUE)
cat("Row 1:\n1 ", pack[1], "\n1 ", pack[2], "\n1 ", pack[3], "\n \n",
sep="", file="gridDraft.txt", append=TRUE)
cat("Row 2:\n1 ", pack[4], "\n1 ", pack[5], "\n1 ", pack[6], "\n \n",
sep="", file="gridDraft.txt", append=TRUE)
cat("Row 3:\n1 ", pack[7], "\n1 ", pack[8], "\n1 ", pack[9], "\n \n",
sep="", file="gridDraft.txt", append=TRUE)
cat("Column 1:\n1 ", pack[1], "\n1 ", pack[4], "\n1 ", pack[7], "\n \n",
sep="", file="gridDraft.txt", append=TRUE)
cat("Column 2:\n1 ", pack[2], "\n1 ", pack[5], "\n1 ", pack[8], "\n \n",
sep="", file="gridDraft.txt", append=TRUE)
cat("Column 3:\n1 ", pack[3], "\n1 ", pack[6], "\n1 ", pack[9],
"\n[/spoiler]\n \n",
sep="", file="gridDraft.txt", append=TRUE)
}
cat("Grid Drafting!", "\n", "\n", file="gridDraft.txt")
for(i in 1:nPacks) {
pack <- gridPile[1:9 + (i-1)*9]
printPack(pack, i)
}