Last active
February 3, 2021 12:34
-
-
Save humanfactors/b04d427890d72a56457997b243d71fd0 to your computer and use it in GitHub Desktop.
Kards Resource Converter ready for Feb 10th! Check what wildcards you'll get!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
convert_table = data.frame( | |
stringsAsFactors = FALSE, | |
type = c("Standard", "Limited", "Special", "Elite"), | |
Resources = c(4L, 10L, 40L, 160L), | |
Amount = c(3, 3, 3, 1) | |
) | |
# 3 x Standard -> 3 x Limited -> 3 x Standard -> 3 x Limited -> 3 x Special -> 1 x Elite | |
order = unlist(list(rep("Standard",3),rep("Limited",3),rep("Standard",3),rep("Limited",3),rep("Special",3),"Elite")) | |
# Utility function | |
get_cost <- function(type_arg) { | |
x = with(convert_table, Resources[type == type_arg]) | |
return(x[[1]]) | |
} | |
# Setup | |
total_cost = 0 | |
cum_cost = rep(0,length(order)) | |
for (i in 1:length(order)) { | |
i_cost = get_cost(order[[i]]) | |
total_cost = total_cost + i_cost | |
cum_cost[i] = total_cost | |
} | |
# Check how many cards you'll get | |
convert_check = function(res) { | |
cycles = res %/% 364 | |
leftover = res %% 364 | |
cards = rep(order,cycles) | |
leftovers = order[which(cum_cost<=leftover)] | |
next_buyup = order[which(cum_cost>=leftover)][1] | |
next_price = cum_cost[which(cum_cost>=leftover)][1] - leftover + 1 | |
next2_buyup = order[which(cum_cost>=leftover)][2] | |
cat("Up next will be a ", next2_buyup, "and you'll need an additional", next_price, "resources") | |
return(table(c(cards, leftovers, next_buyup))) | |
} | |
# Remember to multiply your resource amount by 2!!!! | |
convert_check(100) | |
convert_check(224*2) | |
convert_check(1000) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment