-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollCourse.js
More file actions
111 lines (100 loc) · 2.45 KB
/
rollCourse.js
File metadata and controls
111 lines (100 loc) · 2.45 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const courseTable = {
"General Studies": {
"Arcana":"arc",
"Investigation":"inv",
"Medicine":"med",
"Perception":"prc"
},
"Witherbloom": {
"Animal Handling":"ani",
"Nature":"nat",
"Medicine":"med",
"Survival":"sur"
},
"Silverquill": {
"Deception":"dec",
"Insight":"ins",
"Intimidation":"itm",
"Perception":"prc",
"Persuasion":"prs"
},
"Quandrix": {
"Arcana":"arc",
"History":"his",
"Insight":"ins",
"Investigation":"inv",
"Nature":"nat"
},
"Lorehold": {
"Arcana":"arc",
"History":"his",
"Insight":"ins",
"Investigation":"inv",
"Religion":"rel"
},
"Prismari": {
"Athletics":"ath",
"Acrobatics":"acr",
"Performance":"prf",
"Persuasion":"prc",
"Sleight of Hand":"slt"
},
};
function getCourseFlag(){
let ret = game.user.getFlag("world", "courseLoad");
if (ret == null){
ret = ["General Studies", "General Studies", "General Studies", "General Studies"];
}
return ret;
}
function generateCourseOption(currentCourse, defaultCourse){
let courseOption = `
<option
value=${currentCourse}
${(defaultCourse == currentCourse) ?"selected":""}
>
${currentCourse}
</option>`;
return courseOption;
}
function generateAllCourseOptions(defaultCourse){
let courseOptions = "";
for (const courseName in courseTable){
courseOptions += generateCourseOption(courseName, defaultCourse);
}
return courseOptions;
}
function modifyArray(array, index, value){
array[index] = value;
return array;
}
function generateCourseDropDown(nb, courseLoad){
let courseDropDown = `
<label for="course${nb}"> Course ${nb}</label>
<select name="course${nb}" id="course${nb}" >
${generateAllCourseOptions(courseLoad[nb-1])} "
</select>
<br>
`;
return courseDropDown;
}
function generateAllDropDown(courseLoad){
let ret = "";
for (let i = 1; i < 5; i++){
ret += generateCourseDropDown(i, courseLoad);
}
return ret;
}
let content = `
<form>
${generateAllDropDown(getCourseFlag())}
<button value="Set courses" onclick="game.user.setFlag('world','courseLoad', [document.getElementById('course1').value,document.getElementById('course2').value,document.getElementById('course3').value,document.getElementById('course4').value])">Set courses</button>
</form>
`;
new Dialog({
title: "This",
content: content,
buttons: { close: { label: "Close" }}
},{
resizable: true,
}).render(true);