-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmModify.r
75 lines (73 loc) · 2.7 KB
/
cmModify.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Script to modify Claim matrix for Conan Map claiming system.
# Might fail if you give it incorrect commands. I need to take the time to put in better error handling
# Nathan Pratt
# 8/23/18
library(stringr)
source("conanFx.r")
ar = readRDS(claimMatrixFile)
tmpList = readRDS("MetaData/cmMapCoordsFinal.rds")
claimableCoords = tmpList$Claimable
OutOfPlayCoords = tmpList$OutofPlay
poiCoords = tmpList$POI
options(warn = 1)
mkChanges = function(ar, claimableCoords){
cont = T
while(cont){
input = readline("What would you like to do?\na = Add claim\nr = Remove claim\nra = Remove all claims for a clan\nf = Finished\n")
if (tolower(input) == "a"){
input = readline("Enter the Clan receiving this claim: ")
clan = input
cancel = F
if (!(clan %in% dimnames(ar)[[3]])){
loop = T
while(loop){
currClans = dimnames(ar)[[3]][-1]
print(paste(0:length(currClans), c(clan, currClans), collapse = ", ", sep = ": "))
input = readline(paste0(clan, " not found in current clans.\nWould you prefer to select a clan that already exists?\nEnter index or '0' to use ", clan, ".\n"))
numInput = as.numeric(input)
if (input == "0"){
loop = F
ar = AddClanToMapArray(ar, clan)
} else if (numInput %in% 1:length(currClans)){
loop = F
clan = currClans[numInput]
} else if (input == "c"){
cancel = T
} else {
warning("Input not recognized as valid index.")
}
}
}
input = readline("Enter coordinates (separate with space or ','): ")
coords = str_match_all(input, "\\w+")[[1]][,1]
ar = ConvertArrayValuesToT(ar, coords, clan, claimableCoords)
} else if (tolower(input) == "r"){
input = readline("Enter the coords to neutralize (Separate with space or ','): ")
coords = str_match_all(input, "\\w+")[[1]][,1]
ar = ConvertArrayValuesToT(ar, coords, "None", claimableCoords, overwrite = T)
} else if (tolower(input) == "ra"){
input = readline(paste0(paste0(dimnames(ar)[[3]][-1], collapse = "\n"), "\n", "Enter clan name to remove: "))
if (!(input %in% dimnames(ar)[[3]])){
warning(paste0(input, " not found in array."))
} else {
ar = ar[,,dimnames(ar)[[3]] != input]
}
} else if (tolower(input == "f")){
cont = F
}
print("Success")
}
return(ar)
}
promptSave = function(ar){
input = readline("Would you like to save your changes? (y/Y): ")
if (tolower(input) == "y"){
saveRDS(ar, claimMatrixFile)
print("Save complete.")
} else {
print("Discarding changes...")
}
}
ar = mkChanges(ar, claimableCoords)
#promptSave(ar)
options(warn = 0)