-
Notifications
You must be signed in to change notification settings - Fork 0
/
downButton.js
185 lines (164 loc) · 5.17 KB
/
downButton.js
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
class CharacterSheet {
constructor(
totalLevel,
displayedClass,
class1,
class2,
class3,
classLevel1,
classLevel2,
classLevel3,
attributePoints,
bonusPoints,
skillPoints,
alignment,
race,
attributeArray,
skillValuesArray,
printout
)
{
this.totalLevel = totalLevel
this.displayedClass = displayedClass
this.class1 = class1
this.class2 = class2
this.class3 = class3
this.classLevel1 = classLevel1
this.classLevel2 = classLevel2
this.classLevel3 = classLevel3
this.attributePoints = attributePoints
this.bonusPoints = bonusPoints
this.skillPoints = skillPoints
this.alignment = alignment
this.race = race
this.attributeArray = attributeArray
this.skillValuesArray = skillValuesArray
this.printout = printout
}
}
function onLevelUpdate() {
liveAttrValues = document.getElementsByClassName('attrValues')
SkillValues = document.getElementsByClassName('SkillValues')
currentAttrValues = []
AV = Array.from(liveAttrValues)
AV.forEach((boop)=>{currentAttrValues.push(boop.textContent)})
currentSkillValues = []
SV = Array.from(SkillValues)
SV.forEach((boop)=>{currentSkillValues.push(boop.textContent)})
bonusPoints = document.getElementById('BonusAttributePoints')
attributePoints = document.getElementById('InitialAttributePoints')
currentAttributePoints = []
AP = Array.from(attributePoints)
AP.forEach((boop)=>{currentAttributePoints.push(boop.textContent)})
currentBonusPoints = []
BP = Array.from(bonusPoints)
BP.forEach((boop)=>{currentBonusPoints.push(boop.textContent)})
switch (displayedClass) {
case selectedClassOne.NAME:
currentClass = selectedClassOne
break;
case selectedClassTwo.NAME:
currentClass = selectedClassTwo
break;
case selectedClassThree.NAME:
currentClass = selectedClassThree
break;
default:
break;
}
classOneIndex = DropDownMenus.classONE.selectedIndex
classTwoIndex = DropDownMenus.classTWO.selectedIndex
classThreeIndex = DropDownMenus.classTHREE.selectedIndex
currentLevel = TotalLevel.textContent
totalAttrPts = attributePoints.textContent
totalBonusPts = bonusPoints.textContent
totalSkillPts = SkillPointDisplay.textContent
thisAlignment = characterAlignment.selectedIndex
thisRace = Race.selectedIndex
thisPage = Printout.innerHTML
boop = new CharacterSheet(
currentLevel,
displayedClass,
classOneIndex,
classTwoIndex,
classThreeIndex,
ClassLevel1,
ClassLevel2,
ClassLevel3,
totalAttrPts,
totalBonusPts,
totalSkillPts,
thisAlignment,
thisRace,
currentAttrValues,
currentSkillValues,
thisPage
)
CharacterBook.push(boop)
lastLevel=currentLevel-1
}
function delevel() {
if (lastLevel>=0) {
CharacterBook.pop()
console.log(lastLevel)
console
//lastLevel = length(CharacterBook)
TotalLevel.innerText = CharacterBook[lastLevel].totalLevel
displayedClass = CharacterBook[lastLevel].displayedClass
DropDownMenus.classONE.selectedIndex = CharacterBook[lastLevel].class1
DropDownMenus.classTWO.selectedIndex = CharacterBook[lastLevel].class2
DropDownMenus.classTHREE.selectedIndex = CharacterBook[lastLevel].class3
CL1.innerText = +CharacterBook[lastLevel].classLevel1
ClassLevel1 = CL1.innerText
CL2.innerText = CharacterBook[lastLevel].classLevel2
ClassLevel2 = CL2.innerText
CL3.innerText = CharacterBook[lastLevel].classLevel3
ClassLevel3 = CL3.innerText
attributePoints.innerText = CharacterBook[lastLevel].attributePoints
bonusPoints.innerText = CharacterBook[lastLevel].bonusPoints
SkillPointDisplay.innerText = CharacterBook[lastLevel].skillPoints
characterAlignment.selectedIndex = CharacterBook[lastLevel].alignment
Race.selectedIndex = CharacterBook[lastLevel].race
Printout.innerHTML = CharacterBook[lastLevel].printout
paintTheThing(CharacterBook[lastLevel].attributeArray, liveAttrValues)
paintTheThing(CharacterBook[lastLevel].skillValuesArray, SkillValues)
lastLevel-=1
attributeMods()
}
}
function paintTheThing(thisIsAnArray, thisIsANodeList) {
for (let index = 0; index < thisIsAnArray.length; index++) {
thisIsANodeList[index].innerText = +thisIsAnArray[index];
}
}
//let page1 = new CharacterSheet( 0,
// 'null',
// 'null',
// 'null',
// 'null',
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
// 'null',
// 'null',
// 'null',
// 'null',
// 'null')
//let CharacterBook = [page1];
let CharacterBook = [];
let lastLevel
let currentAttributePoints = []
let AP = Array.from(attributePoints)
AP.forEach((boop)=>{currentAttributePoints.push(boop.textContent)})
currentBonusPoints = []
let BP = Array.from(bonusPoints)
BP.forEach((boop)=>{currentBonusPoints.push(boop.textContent)})
currentAttrValues = []
let AV = Array.from(liveAttrValues)
AV.forEach((boop)=>{currentAttrValues.push(boop.textContent)})
currentSkillValues = []
let SV = Array.from(SkillValues)
SV.forEach((boop)=>{currentSkillValues.push(boop.textContent)})