Titles
@@ -173,6 +173,7 @@
173
173
<button class="modal-close">×</button>
174
174
<div class="kobold-modal-header">
175
175
<h2 id="koboldModalName"></h2>
176
<p id="koboldModalTitle" class="kobold-title"></p>
176
177
<p id="koboldModalAge" class="kobold-age"></p>
177
178
</div>
178
179
<div id="koboldModalDescription" class="kobold-description"></div>
@@ -173,6 +173,7 @@173
<button class="modal-close">×</button>173
<button class="modal-close">×</button>174
<div class="kobold-modal-header">174
<div class="kobold-modal-header">175
<h2 id="koboldModalName"></h2>175
<h2 id="koboldModalName"></h2>176
<p id="koboldModalTitle" class="kobold-title"></p>176
<p id="koboldModalAge" class="kobold-age"></p>177
<p id="koboldModalAge" class="kobold-age"></p>177
</div>178
</div>178
<div id="koboldModalDescription" class="kobold-description"></div>179
<div id="koboldModalDescription" class="kobold-description"></div>@@ -855,13 +855,13 @@ class TribeGenApp
855
855
item.className = `tribe-item ${isInjured ? 'injured' : ''}`;
856
856
item.innerHTML = `
857
857
<table style="width:100%">
858
<td>
858
<td style="width:100px">
859
859
<img class="kobold-list-sprite" src="${spriteUrl}"/>
860
860
</td>
861
861
<td>
862
862
<div>
863
<div class="tribe-item-name">${kobold.name}</div>
864
<div class="tribe-item-age">${(kobold.age > 0 ? kobold.age : 0)} years</div>
863
<span class="tribe-item-name">${kobold.name}</span><span class="tribe-item-title">${kobold.title != '' ? (', ' + kobold.title) : ''}</span>
864
<div class="tribe-item-age">${(kobold.age > 0 ? kobold.age : 0)} years old</div>
865
865
</div>
866
866
</td>
867
867
</table>
@@ -1308,6 +1308,11 @@ class TribeGenApp
1308
1308
{
1309
1309
const modal = document.getElementById('koboldModal');
1310
1310
document.getElementById('koboldModalName').textContent = kobold.name;
1311
const titleEl = document.getElementById('koboldModalTitle');
1312
if (titleEl)
1313
{
1314
titleEl.textContent = kobold.title || '';
1315
}
1311
1316
1312
1317
const a = (kobold.ageCategory == "old" || kobold.ageCategory == "adult") ? "An" : "A";
1313
1318
@@ -855,13 +855,13 @@ class TribeGenApp855
item.className = `tribe-item ${isInjured ? 'injured' : ''}`;855
item.className = `tribe-item ${isInjured ? 'injured' : ''}`;856
item.innerHTML = `856
item.innerHTML = `857
<table style="width:100%">857
<table style="width:100%">858
<td>858
<td style="width:100px">859
<img class="kobold-list-sprite" src="${spriteUrl}"/>859
<img class="kobold-list-sprite" src="${spriteUrl}"/>860
</td>860
</td>861
<td>861
<td>862
<div>862
<div>863
<div class="tribe-item-name">${kobold.name}</div>863
<span class="tribe-item-name">${kobold.name}</span><span class="tribe-item-title">${kobold.title != '' ? (', ' + kobold.title) : ''}</span>864
<div class="tribe-item-age">${(kobold.age > 0 ? kobold.age : 0)} years</div>864
<div class="tribe-item-age">${(kobold.age > 0 ? kobold.age : 0)} years old</div>865
</div>865
</div>866
</td>866
</td>867
</table>867
</table>@@ -1308,6 +1308,11 @@ class TribeGenApp1308
{1308
{1309
const modal = document.getElementById('koboldModal');1309
const modal = document.getElementById('koboldModal');1310
document.getElementById('koboldModalName').textContent = kobold.name;1310
document.getElementById('koboldModalName').textContent = kobold.name;1311
const titleEl = document.getElementById('koboldModalTitle');1312
if (titleEl)1313
{1314
titleEl.textContent = kobold.title || '';1315
}1311
1316
1312
const a = (kobold.ageCategory == "old" || kobold.ageCategory == "adult") ? "An" : "A";1317
const a = (kobold.ageCategory == "old" || kobold.ageCategory == "adult") ? "An" : "A";1313
1318
@@ -61,6 +61,10 @@ class Kobold
61
61
62
62
arsort($rankedStats);
63
63
$statKeys = array_keys($rankedStats);
64
$statValues = array_values($rankedStats);
65
66
if ($statValues[0] < 50)
67
return $this->male ? "Tribesman" : "Tribeswoman";
64
68
65
69
$topStat = $statKeys[0] ?? null;
66
70
if ($topStat === null) {
@@ -61,6 +61,10 @@ class Kobold61
61
62
arsort($rankedStats);62
arsort($rankedStats);63
$statKeys = array_keys($rankedStats);63
$statKeys = array_keys($rankedStats);64
$statValues = array_values($rankedStats);65
66
if ($statValues[0] < 50)67
return $this->male ? "Tribesman" : "Tribeswoman";64
68
65
$topStat = $statKeys[0] ?? null;69
$topStat = $statKeys[0] ?? null;66
if ($topStat === null) {70
if ($topStat === null) {@@ -114,24 +114,51 @@ class Tribe
114
114
return false;
115
115
}
116
116
117
if ($kobold->getAgeCategory() == "egg")
118
return false;
119
if ($kobold->getAgeCategory() == "baby")
120
return false;
121
if ($kobold->getAgeCategory() == "young")
122
return false;
123
124
if ($kobold->getHighestStatName() !== $statName) {
125
return false;
126
}
127
117
128
$targetStat = $kobold->getStat($statName);
118
if ($targetStat === null) {
129
if ($targetStat === null || $targetStat < 50) {
119
130
return false;
120
131
}
121
132
122
$bestStat = $targetStat;
133
$hasPeer = false;
123
134
foreach ($this->getKobolds() as $otherKobold) {
124
135
if ($otherKobold->getId() === $kobold->getId()) {
125
136
continue;
126
137
}
127
138
139
if ($otherKobold->getHighestStatName() !== $statName) {
140
continue;
141
}
142
143
if ($otherKobold->getAgeCategory() == "egg")
144
continue;
145
if ($otherKobold->getAgeCategory() == "baby")
146
continue;
147
if ($otherKobold->getAgeCategory() == "young")
148
continue;
149
150
if ($otherKobold->isLeader())
151
continue;
152
153
$hasPeer = true;
154
128
155
$otherStat = $otherKobold->getStat($statName);
129
if ($otherStat !== null && $otherStat > $bestStat) {
156
if ($otherStat !== null && $otherStat > $targetStat) {
130
157
return false;
131
158
}
132
159
}
133
160
134
return true;
161
return $hasPeer;
135
162
}
136
163
137
164
public function getKoboldTitle($kobold)
@@ -140,11 +167,28 @@ class Tribe
140
167
return false;
141
168
}
142
169
170
$elder = $kobold->getAgeCategory() == "old" ? "Elder " : "";
171
172
if ($kobold->isLeader())
173
return $elder . "Chieftain";
174
175
if ($kobold->getAgeCategory() == "egg")
176
return "Egg";
177
if ($kobold->getAgeCategory() == "baby")
178
return "Baby";
179
if ($kobold->getAgeCategory() == "young")
180
return "Youngling";
181
143
182
if ($this->isBestInTribeForStat($kobold, $kobold->getHighestStatName())) {
144
return "Chief " . $kobold->getTitle(false);
183
return $elder . "Chief " . $kobold->getTitle(false);
145
184
}
146
185
147
return $kobold->getTitle();
186
return $elder . $kobold->getTitle();
187
}
188
189
public function getTitleForKobold($kobold)
190
{
191
return $this->getKoboldTitle($kobold);
148
192
}
149
193
150
194
private function loadStorage()
@@ -114,24 +114,51 @@ class Tribe114
return false;114
return false;115
}115
}116
116
117
if ($kobold->getAgeCategory() == "egg")118
return false;119
if ($kobold->getAgeCategory() == "baby")120
return false;121
if ($kobold->getAgeCategory() == "young")122
return false;123
124
if ($kobold->getHighestStatName() !== $statName) {125
return false;126
}127
117
$targetStat = $kobold->getStat($statName);128
$targetStat = $kobold->getStat($statName);118
if ($targetStat === null) {129
if ($targetStat === null || $targetStat < 50) {119
return false;130
return false;120
}131
}121
132
122
$bestStat = $targetStat;133
$hasPeer = false;123
foreach ($this->getKobolds() as $otherKobold) {134
foreach ($this->getKobolds() as $otherKobold) {124
if ($otherKobold->getId() === $kobold->getId()) {135
if ($otherKobold->getId() === $kobold->getId()) {125
continue;136
continue;126
}137
}127
138
139
if ($otherKobold->getHighestStatName() !== $statName) {140
continue;141
}142
143
if ($otherKobold->getAgeCategory() == "egg")144
continue;145
if ($otherKobold->getAgeCategory() == "baby")146
continue;147
if ($otherKobold->getAgeCategory() == "young")148
continue;149
150
if ($otherKobold->isLeader())151
continue;152
153
$hasPeer = true;154
128
$otherStat = $otherKobold->getStat($statName);155
$otherStat = $otherKobold->getStat($statName);129
if ($otherStat !== null && $otherStat > $bestStat) {156
if ($otherStat !== null && $otherStat > $targetStat) {130
return false;157
return false;131
}158
}132
}159
}133
160
134
return true;161
return $hasPeer;135
}162
}136
163
137
public function getKoboldTitle($kobold)164
public function getKoboldTitle($kobold)@@ -140,11 +167,28 @@ class Tribe140
return false;167
return false;141
}168
}142
169
170
$elder = $kobold->getAgeCategory() == "old" ? "Elder " : "";171
172
if ($kobold->isLeader())173
return $elder . "Chieftain";174
175
if ($kobold->getAgeCategory() == "egg")176
return "Egg";177
if ($kobold->getAgeCategory() == "baby")178
return "Baby";179
if ($kobold->getAgeCategory() == "young")180
return "Youngling";181
143
if ($this->isBestInTribeForStat($kobold, $kobold->getHighestStatName())) {182
if ($this->isBestInTribeForStat($kobold, $kobold->getHighestStatName())) {144
return "Chief " . $kobold->getTitle(false);183
return $elder . "Chief " . $kobold->getTitle(false);145
}184
}146
185
147
return $kobold->getTitle();186
return $elder . $kobold->getTitle();187
}188
189
public function getTitleForKobold($kobold)190
{191
return $this->getKoboldTitle($kobold);148
}192
}149
193
150
private function loadStorage()194
private function loadStorage()@@ -37,6 +37,7 @@ if ($method === 'POST') {
37
37
$kobolds[] = [
38
38
'id' => $kobold->getId(),
39
39
'name' => $kobold->getAgeCategory() !== "egg" ? $kobold->getName() : "Egg",
40
'title' => $tribe->getTitleForKobold($kobold),
40
41
'ageCategory' => $kobold->getAgeCategory(),
41
42
'age' => $kobold->getAge(),
42
43
'stats' => [
@@ -785,6 +786,7 @@ function getKobolds($tribe, $getRivals): array
785
786
$kobolds[] = [
786
787
'id' => $kobold->getId(),
787
788
'name' => $kobold->getAgeCategory() !== "egg" ? $kobold->getName() : "Egg",
789
'title' => $tribe->getTitleForKobold($kobold),
788
790
'age' => $kobold->getAge(),
789
791
'ageCategory' => $kobold->getAgeCategory(),
790
792
'stats' => [
@@ -37,6 +37,7 @@ if ($method === 'POST') {37
$kobolds[] = [37
$kobolds[] = [38
'id' => $kobold->getId(),38
'id' => $kobold->getId(),39
'name' => $kobold->getAgeCategory() !== "egg" ? $kobold->getName() : "Egg",39
'name' => $kobold->getAgeCategory() !== "egg" ? $kobold->getName() : "Egg",40
'title' => $tribe->getTitleForKobold($kobold),40
'ageCategory' => $kobold->getAgeCategory(),41
'ageCategory' => $kobold->getAgeCategory(),41
'age' => $kobold->getAge(),42
'age' => $kobold->getAge(),42
'stats' => [43
'stats' => [@@ -785,6 +786,7 @@ function getKobolds($tribe, $getRivals): array785
$kobolds[] = [786
$kobolds[] = [786
'id' => $kobold->getId(),787
'id' => $kobold->getId(),787
'name' => $kobold->getAgeCategory() !== "egg" ? $kobold->getName() : "Egg",788
'name' => $kobold->getAgeCategory() !== "egg" ? $kobold->getName() : "Egg",789
'title' => $tribe->getTitleForKobold($kobold),788
'age' => $kobold->getAge(),790
'age' => $kobold->getAge(),789
'ageCategory' => $kobold->getAgeCategory(),791
'ageCategory' => $kobold->getAgeCategory(),790
'stats' => [792
'stats' => [