BlueGit

blue-star tribegen

attempt at relationships tab

timfa Tim Falken · pushed by timfa

Authored 2026-02-03 · 9 months ago

Hash
960ca7e40b1c433868730d741b795c22770186ac
Parent
52fdcbf6
6 files changed +207 −7
web/css/style.css +43 −0
@@ -830,6 +830,49 @@ button {
830 830 gap: 8px;
831 831 }
832 832
833 .kobold-relationships-list {
834 display: flex;
835 flex-direction: column;
836 gap: 16px;
837 }
838
839 .relationships-section {
840 padding: 12px;
841 background: #f9f9f9;
842 border: 1px solid #e0e0e0;
843 border-radius: 5px;
844 }
845
846 .relationships-section h4 {
847 margin-bottom: 10px;
848 color: #667eea;
849 font-size: 1em;
850 }
851
852 .relationship-item {
853 display: flex;
854 justify-content: space-between;
855 align-items: center;
856 padding: 8px;
857 background: white;
858 border-radius: 4px;
859 margin-bottom: 6px;
860 }
861
862 .relationship-item:last-child {
863 margin-bottom: 0;
864 }
865
866 .relationship-name {
867 font-weight: 500;
868 color: #333;
869 }
870
871 .relationship-descriptor {
872 font-weight: bold;
873 font-size: 0.9em;
874 }
875
833 876 /* Config Screen */
834 877 .config-container {
835 878 background: white;
@@ -830,6 +830,49 @@ button {
830 gap: 8px;
830 gap: 8px;
831}
831}
832
832
833.kobold-relationships-list {
834 display: flex;
835 flex-direction: column;
836 gap: 16px;
837}
838
839.relationships-section {
840 padding: 12px;
841 background: #f9f9f9;
842 border: 1px solid #e0e0e0;
843 border-radius: 5px;
844}
845
846.relationships-section h4 {
847 margin-bottom: 10px;
848 color: #667eea;
849 font-size: 1em;
850}
851
852.relationship-item {
853 display: flex;
854 justify-content: space-between;
855 align-items: center;
856 padding: 8px;
857 background: white;
858 border-radius: 4px;
859 margin-bottom: 6px;
860}
861
862.relationship-item:last-child {
863 margin-bottom: 0;
864}
865
866.relationship-name {
867 font-weight: 500;
868 color: #333;
869}
870
871.relationship-descriptor {
872 font-weight: bold;
873 font-size: 0.9em;
874}
875
833/* Config Screen */
876/* Config Screen */
834.config-container {
877.config-container {
835 background: white;
878 background: white;
web/indexHtml.html +4 −0
@@ -180,6 +180,7 @@
180 180 <button class="kobold-tab-btn active" data-tab="stats">Stats</button>
181 181 <button class="kobold-tab-btn" data-tab="inventory">Inventory</button>
182 182 <button class="kobold-tab-btn" data-tab="injuries">Injuries</button>
183 <button class="kobold-tab-btn" data-tab="relationships">Relationships</button>
183 184 </div>
184 185 <div id="koboldStatsTab" class="kobold-tab-content active">
185 186 <div id="koboldStats" class="kobold-stats-grid"></div>
@@ -190,6 +191,9 @@
190 191 <div id="koboldInjuriesTab" class="kobold-tab-content">
191 192 <div id="koboldInjuries" class="kobold-injuries-list"></div>
192 193 </div>
194 <div id="koboldRelationshipsTab" class="kobold-tab-content">
195 <div id="koboldRelationships" class="kobold-relationships-list"></div>
196 </div>
193 197 </div>
194 198 </div>
195 199
@@ -180,6 +180,7 @@
180 <button class="kobold-tab-btn active" data-tab="stats">Stats</button>
180 <button class="kobold-tab-btn active" data-tab="stats">Stats</button>
181 <button class="kobold-tab-btn" data-tab="inventory">Inventory</button>
181 <button class="kobold-tab-btn" data-tab="inventory">Inventory</button>
182 <button class="kobold-tab-btn" data-tab="injuries">Injuries</button>
182 <button class="kobold-tab-btn" data-tab="injuries">Injuries</button>
183 <button class="kobold-tab-btn" data-tab="relationships">Relationships</button>
183 </div>
184 </div>
184 <div id="koboldStatsTab" class="kobold-tab-content active">
185 <div id="koboldStatsTab" class="kobold-tab-content active">
185 <div id="koboldStats" class="kobold-stats-grid"></div>
186 <div id="koboldStats" class="kobold-stats-grid"></div>
@@ -190,6 +191,9 @@
190 <div id="koboldInjuriesTab" class="kobold-tab-content">
191 <div id="koboldInjuriesTab" class="kobold-tab-content">
191 <div id="koboldInjuries" class="kobold-injuries-list"></div>
192 <div id="koboldInjuries" class="kobold-injuries-list"></div>
192 </div>
193 </div>
194 <div id="koboldRelationshipsTab" class="kobold-tab-content">
195 <div id="koboldRelationships" class="kobold-relationships-list"></div>
196 </div>
193 </div>
197 </div>
194 </div>
198 </div>
195
199
web/js/app.js +116 −1
@@ -2,7 +2,7 @@ var doneTyping = true;
2 2 // Main Game App
3 3 class TribeGenApp
4 4 {
5 constructor ()
5 constructor()
6 6 {
7 7 this.currentUser = null;
8 8 this.currentSave = null;
@@ -1324,6 +1324,7 @@ class TribeGenApp
1324 1324 this.renderKoboldStats(kobold);
1325 1325 this.renderKoboldInventory(kobold);
1326 1326 this.renderKoboldInjuries(kobold);
1327 this.renderKoboldRelationships(kobold);
1327 1328
1328 1329 // Setup tab buttons
1329 1330 document.querySelectorAll('.kobold-tab-btn').forEach(btn =>
@@ -1598,6 +1599,120 @@ class TribeGenApp
1598 1599 document.querySelector(`[data-tab="${tabName}"]`).classList.add('active');
1599 1600 }
1600 1601
1602 getLikeDescriptor (likeValue)
1603 {
1604 const val = Number(likeValue || 0);
1605
1606 if (val <= -40) return { text: 'terrible', color: '#d9534f' };
1607 if (val <= -30) return { text: 'awful', color: '#e74c3c' };
1608 if (val <= -20) return { text: 'poor', color: '#e8765d' };
1609 if (val <= -10) return { text: 'bad', color: '#ec8a6a' };
1610 if (val < 0) return { text: 'cold', color: '#f0a080' };
1611 if (val === 0) return { text: 'neutral', color: '#999' };
1612 if (val < 10) return { text: 'okay', color: '#95b9a5' };
1613 if (val < 20) return { text: 'good', color: '#7cb87b' };
1614 if (val < 30) return { text: 'nice', color: '#63b76f' };
1615 if (val < 40) return { text: 'great', color: '#51a859' };
1616 return { text: 'wonderful', color: '#27ae60' };
1617 }
1618
1619 renderKoboldRelationships (kobold)
1620 {
1621 const container = document.getElementById('koboldRelationships');
1622 container.innerHTML = '';
1623
1624 const likes = kobold.likes || {};
1625
1626 // Separate tribe members and rivals
1627 const tribeMembers = [];
1628 const rivals = [];
1629
1630 for (const [targetId, likeValue] of Object.entries(likes))
1631 {
1632 if (likeValue === 0) continue; // Skip neutral relationships
1633
1634 // Check if it's a tribe member
1635 const tribeMember = this.currentTribe.kobolds.find(k => k.id === targetId);
1636 if (tribeMember)
1637 {
1638 tribeMembers.push({ id: targetId, name: tribeMember.name, likeValue });
1639 } else
1640 {
1641 // Check if it's a rival
1642 const rivalData = this.currentSave?.rivals || [];
1643 const rival = rivalData.find(r => r.id === targetId);
1644 if (rival)
1645 {
1646 rivals.push({ id: targetId, name: rival.name, likeValue });
1647 }
1648 }
1649 }
1650
1651 // Sort by like value (descending)
1652 const sort = (a, b) => b.likeValue - a.likeValue;
1653 tribeMembers.sort(sort);
1654 rivals.sort(sort);
1655
1656 // Render tribe members
1657 if (tribeMembers.length > 0)
1658 {
1659 const tribeSection = document.createElement('div');
1660 tribeSection.className = 'relationships-section';
1661
1662 const tribeTitle = document.createElement('h4');
1663 tribeTitle.textContent = 'Tribe Members';
1664 tribeSection.appendChild(tribeTitle);
1665
1666 tribeMembers.forEach(member =>
1667 {
1668 const descriptor = this.getLikeDescriptor(member.likeValue);
1669 const item = document.createElement('div');
1670 item.className = 'relationship-item';
1671 item.innerHTML = `
1672 <span class="relationship-name">${member.name}</span>
1673 <span class="relationship-descriptor" style="color: ${descriptor.color}">${descriptor.text}</span>
1674 `;
1675 tribeSection.appendChild(item);
1676 });
1677
1678 container.appendChild(tribeSection);
1679 }
1680
1681 // Render rivals
1682 if (rivals.length > 0)
1683 {
1684 const rivalsSection = document.createElement('div');
1685 rivalsSection.className = 'relationships-section';
1686
1687 const rivalsTitle = document.createElement('h4');
1688 rivalsTitle.textContent = 'Rivals';
1689 rivalsSection.appendChild(rivalsTitle);
1690
1691 rivals.forEach(rival =>
1692 {
1693 const descriptor = this.getLikeDescriptor(rival.likeValue);
1694 const item = document.createElement('div');
1695 item.className = 'relationship-item';
1696 item.innerHTML = `
1697 <span class="relationship-name">${rival.name}</span>
1698 <span class="relationship-descriptor" style="color: ${descriptor.color}">${descriptor.text}</span>
1699 `;
1700 rivalsSection.appendChild(item);
1701 });
1702
1703 container.appendChild(rivalsSection);
1704 }
1705
1706 // Show message if no relationships
1707 if (tribeMembers.length === 0 && rivals.length === 0)
1708 {
1709 const noRels = document.createElement('p');
1710 noRels.style.color = '#999';
1711 noRels.textContent = 'No relationships to display.';
1712 container.appendChild(noRels);
1713 }
1714 }
1715
1601 1716 getStatLabel (statValue)
1602 1717 {
1603 1718 if (statValue >= 90) return 'godlike';
@@ -2,7 +2,7 @@ var doneTyping = true;
2// Main Game App
2// Main Game App
3class TribeGenApp
3class TribeGenApp
4{
4{
5 constructor ()
5 constructor()
6 {
6 {
7 this.currentUser = null;
7 this.currentUser = null;
8 this.currentSave = null;
8 this.currentSave = null;
@@ -1324,6 +1324,7 @@ class TribeGenApp
1324 this.renderKoboldStats(kobold);
1324 this.renderKoboldStats(kobold);
1325 this.renderKoboldInventory(kobold);
1325 this.renderKoboldInventory(kobold);
1326 this.renderKoboldInjuries(kobold);
1326 this.renderKoboldInjuries(kobold);
1327 this.renderKoboldRelationships(kobold);
1327
1328
1328 // Setup tab buttons
1329 // Setup tab buttons
1329 document.querySelectorAll('.kobold-tab-btn').forEach(btn =>
1330 document.querySelectorAll('.kobold-tab-btn').forEach(btn =>
@@ -1598,6 +1599,120 @@ class TribeGenApp
1598 document.querySelector(`[data-tab="${tabName}"]`).classList.add('active');
1599 document.querySelector(`[data-tab="${tabName}"]`).classList.add('active');
1599 }
1600 }
1600
1601
1602 getLikeDescriptor (likeValue)
1603 {
1604 const val = Number(likeValue || 0);
1605
1606 if (val <= -40) return { text: 'terrible', color: '#d9534f' };
1607 if (val <= -30) return { text: 'awful', color: '#e74c3c' };
1608 if (val <= -20) return { text: 'poor', color: '#e8765d' };
1609 if (val <= -10) return { text: 'bad', color: '#ec8a6a' };
1610 if (val < 0) return { text: 'cold', color: '#f0a080' };
1611 if (val === 0) return { text: 'neutral', color: '#999' };
1612 if (val < 10) return { text: 'okay', color: '#95b9a5' };
1613 if (val < 20) return { text: 'good', color: '#7cb87b' };
1614 if (val < 30) return { text: 'nice', color: '#63b76f' };
1615 if (val < 40) return { text: 'great', color: '#51a859' };
1616 return { text: 'wonderful', color: '#27ae60' };
1617 }
1618
1619 renderKoboldRelationships (kobold)
1620 {
1621 const container = document.getElementById('koboldRelationships');
1622 container.innerHTML = '';
1623
1624 const likes = kobold.likes || {};
1625
1626 // Separate tribe members and rivals
1627 const tribeMembers = [];
1628 const rivals = [];
1629
1630 for (const [targetId, likeValue] of Object.entries(likes))
1631 {
1632 if (likeValue === 0) continue; // Skip neutral relationships
1633
1634 // Check if it's a tribe member
1635 const tribeMember = this.currentTribe.kobolds.find(k => k.id === targetId);
1636 if (tribeMember)
1637 {
1638 tribeMembers.push({ id: targetId, name: tribeMember.name, likeValue });
1639 } else
1640 {
1641 // Check if it's a rival
1642 const rivalData = this.currentSave?.rivals || [];
1643 const rival = rivalData.find(r => r.id === targetId);
1644 if (rival)
1645 {
1646 rivals.push({ id: targetId, name: rival.name, likeValue });
1647 }
1648 }
1649 }
1650
1651 // Sort by like value (descending)
1652 const sort = (a, b) => b.likeValue - a.likeValue;
1653 tribeMembers.sort(sort);
1654 rivals.sort(sort);
1655
1656 // Render tribe members
1657 if (tribeMembers.length > 0)
1658 {
1659 const tribeSection = document.createElement('div');
1660 tribeSection.className = 'relationships-section';
1661
1662 const tribeTitle = document.createElement('h4');
1663 tribeTitle.textContent = 'Tribe Members';
1664 tribeSection.appendChild(tribeTitle);
1665
1666 tribeMembers.forEach(member =>
1667 {
1668 const descriptor = this.getLikeDescriptor(member.likeValue);
1669 const item = document.createElement('div');
1670 item.className = 'relationship-item';
1671 item.innerHTML = `
1672 <span class="relationship-name">${member.name}</span>
1673 <span class="relationship-descriptor" style="color: ${descriptor.color}">${descriptor.text}</span>
1674 `;
1675 tribeSection.appendChild(item);
1676 });
1677
1678 container.appendChild(tribeSection);
1679 }
1680
1681 // Render rivals
1682 if (rivals.length > 0)
1683 {
1684 const rivalsSection = document.createElement('div');
1685 rivalsSection.className = 'relationships-section';
1686
1687 const rivalsTitle = document.createElement('h4');
1688 rivalsTitle.textContent = 'Rivals';
1689 rivalsSection.appendChild(rivalsTitle);
1690
1691 rivals.forEach(rival =>
1692 {
1693 const descriptor = this.getLikeDescriptor(rival.likeValue);
1694 const item = document.createElement('div');
1695 item.className = 'relationship-item';
1696 item.innerHTML = `
1697 <span class="relationship-name">${rival.name}</span>
1698 <span class="relationship-descriptor" style="color: ${descriptor.color}">${descriptor.text}</span>
1699 `;
1700 rivalsSection.appendChild(item);
1701 });
1702
1703 container.appendChild(rivalsSection);
1704 }
1705
1706 // Show message if no relationships
1707 if (tribeMembers.length === 0 && rivals.length === 0)
1708 {
1709 const noRels = document.createElement('p');
1710 noRels.style.color = '#999';
1711 noRels.textContent = 'No relationships to display.';
1712 container.appendChild(noRels);
1713 }
1714 }
1715
1601 getStatLabel (statValue)
1716 getStatLabel (statValue)
1602 {
1717 {
1603 if (statValue >= 90) return 'godlike';
1718 if (statValue >= 90) return 'godlike';
web/src/Classes/Tribe.php +36 −0
@@ -434,6 +434,7 @@ class Tribe
434 434 $kobold->addInjury('malnourished-brink');
435 435 $story .= "{$kobold->getName()} is now on the brink of death from starvation.\n";
436 436 } elseif ($malnourishedId === 'malnourished-brink') {
437 $this->cleanupDeadKoboldLikes($kobold->getId());
437 438 $kobold->die();
438 439 $story .= "{$kobold->getName()} succumbed to starvation.\n";
439 440 }
@@ -903,6 +904,7 @@ class Tribe
903 904 $totalSeverity = $kobold->getTotalInjurySeverity();
904 905 if ($roll < ($kobold->getAge() + $totalSeverity)) {
905 906 $foodStory .= $kobold->getName() . " dies of old age.\n";
907 $this->cleanupDeadKoboldLikes($kobold->getId());
906 908 $kobold->die();
907 909 }
908 910 }
@@ -918,4 +920,38 @@ class Tribe
918 920 $roll = rand(1, 100);
919 921 return $roll <= $kobold->getAge();
920 922 }
923
924 /**
925 * Clean up all likes references to a kobold when they die
926 * Removes the kobold's ID from all other kobolds' likes arrays
927 * and from rival records
928 */
929 private function cleanupDeadKoboldLikes($koboldId)
930 {
931 // Remove from all other kobolds' likes
932 foreach ($this->kobolds as $other) {
933 if ($other->getId() !== $koboldId) {
934 if (!isset($other->dataStore)) {
935 $other->dataStore = new stdClass();
936 }
937 if (!isset($other->dataStore->likes)) {
938 $other->dataStore->likes = [];
939 }
940
941 // Remove the dead kobold from this kobold's likes
942 if (is_array($other->dataStore->likes)) {
943 unset($other->dataStore->likes[$koboldId]);
944 }
945 }
946 }
947
948 // Remove from rivals' likes if they exist
949 if (isset($this->dataStore->rivals) && is_array($this->dataStore->rivals)) {
950 foreach ($this->dataStore->rivals as &$rival) {
951 if (isset($rival['data']['likes']) && is_array($rival['data']['likes'])) {
952 unset($rival['data']['likes'][$koboldId]);
953 }
954 }
955 }
956 }
921 957 }
@@ -434,6 +434,7 @@ class Tribe
434 $kobold->addInjury('malnourished-brink');
434 $kobold->addInjury('malnourished-brink');
435 $story .= "{$kobold->getName()} is now on the brink of death from starvation.\n";
435 $story .= "{$kobold->getName()} is now on the brink of death from starvation.\n";
436 } elseif ($malnourishedId === 'malnourished-brink') {
436 } elseif ($malnourishedId === 'malnourished-brink') {
437 $this->cleanupDeadKoboldLikes($kobold->getId());
437 $kobold->die();
438 $kobold->die();
438 $story .= "{$kobold->getName()} succumbed to starvation.\n";
439 $story .= "{$kobold->getName()} succumbed to starvation.\n";
439 }
440 }
@@ -903,6 +904,7 @@ class Tribe
903 $totalSeverity = $kobold->getTotalInjurySeverity();
904 $totalSeverity = $kobold->getTotalInjurySeverity();
904 if ($roll < ($kobold->getAge() + $totalSeverity)) {
905 if ($roll < ($kobold->getAge() + $totalSeverity)) {
905 $foodStory .= $kobold->getName() . " dies of old age.\n";
906 $foodStory .= $kobold->getName() . " dies of old age.\n";
907 $this->cleanupDeadKoboldLikes($kobold->getId());
906 $kobold->die();
908 $kobold->die();
907 }
909 }
908 }
910 }
@@ -918,4 +920,38 @@ class Tribe
918 $roll = rand(1, 100);
920 $roll = rand(1, 100);
919 return $roll <= $kobold->getAge();
921 return $roll <= $kobold->getAge();
920 }
922 }
923
924 /**
925 * Clean up all likes references to a kobold when they die
926 * Removes the kobold's ID from all other kobolds' likes arrays
927 * and from rival records
928 */
929 private function cleanupDeadKoboldLikes($koboldId)
930 {
931 // Remove from all other kobolds' likes
932 foreach ($this->kobolds as $other) {
933 if ($other->getId() !== $koboldId) {
934 if (!isset($other->dataStore)) {
935 $other->dataStore = new stdClass();
936 }
937 if (!isset($other->dataStore->likes)) {
938 $other->dataStore->likes = [];
939 }
940
941 // Remove the dead kobold from this kobold's likes
942 if (is_array($other->dataStore->likes)) {
943 unset($other->dataStore->likes[$koboldId]);
944 }
945 }
946 }
947
948 // Remove from rivals' likes if they exist
949 if (isset($this->dataStore->rivals) && is_array($this->dataStore->rivals)) {
950 foreach ($this->dataStore->rivals as &$rival) {
951 if (isset($rival['data']['likes']) && is_array($rival['data']['likes'])) {
952 unset($rival['data']['likes'][$koboldId]);
953 }
954 }
955 }
956 }
921}
957}
web/src/Events/RivalEncounterEvent.php +4 −4
@@ -45,11 +45,11 @@ class RivalEncounterEvent extends MonthEndEvent
45 45 $kobold = $eligible[array_rand($eligible)];
46 46
47 47 // Initialize rivals if not present
48 if (!isset($this->tribe->dataStore->rivals)) {
49 $this->tribe->dataStore->rivals = [];
48 if (!isset($this->tribe->rivals)) {
49 $this->tribe->rivals = [];
50 50 }
51 51
52 $rivals = $this->tribe->dataStore->rivals;
52 $rivals = $this->tribe->rivals;
53 53
54 54 // Generate or pick a rival
55 55 $rival = null;
@@ -59,7 +59,7 @@ class RivalEncounterEvent extends MonthEndEvent
59 59 $rivalNames = ['Gruk', 'Zag', 'Mog', 'Drog', 'Bik', 'Kra', 'Nik', 'Tug', 'Vox', 'Warg'];
60 60 $rivalName = $rivalNames[array_rand($rivalNames)];
61 61 $rival = NPC::create($this->tribe->getSaveId(), $rivalName, 'individual', true);
62 $this->tribe->dataStore->rivals[] = $rival->toArray();
62 $this->tribe->rivals[] = $rival->toArray();
63 63 } elseif (!empty($rivals)) {
64 64 // Pick an existing rival
65 65 $rivalData = $rivals[array_rand($rivals)];
@@ -45,11 +45,11 @@ class RivalEncounterEvent extends MonthEndEvent
45 $kobold = $eligible[array_rand($eligible)];
45 $kobold = $eligible[array_rand($eligible)];
46
46
47 // Initialize rivals if not present
47 // Initialize rivals if not present
48 if (!isset($this->tribe->dataStore->rivals)) {
48 if (!isset($this->tribe->rivals)) {
49 $this->tribe->dataStore->rivals = [];
49 $this->tribe->rivals = [];
50 }
50 }
51
51
52 $rivals = $this->tribe->dataStore->rivals;
52 $rivals = $this->tribe->rivals;
53
53
54 // Generate or pick a rival
54 // Generate or pick a rival
55 $rival = null;
55 $rival = null;
@@ -59,7 +59,7 @@ class RivalEncounterEvent extends MonthEndEvent
59 $rivalNames = ['Gruk', 'Zag', 'Mog', 'Drog', 'Bik', 'Kra', 'Nik', 'Tug', 'Vox', 'Warg'];
59 $rivalNames = ['Gruk', 'Zag', 'Mog', 'Drog', 'Bik', 'Kra', 'Nik', 'Tug', 'Vox', 'Warg'];
60 $rivalName = $rivalNames[array_rand($rivalNames)];
60 $rivalName = $rivalNames[array_rand($rivalNames)];
61 $rival = NPC::create($this->tribe->getSaveId(), $rivalName, 'individual', true);
61 $rival = NPC::create($this->tribe->getSaveId(), $rivalName, 'individual', true);
62 $this->tribe->dataStore->rivals[] = $rival->toArray();
62 $this->tribe->rivals[] = $rival->toArray();
63 } elseif (!empty($rivals)) {
63 } elseif (!empty($rivals)) {
64 // Pick an existing rival
64 // Pick an existing rival
65 $rivalData = $rivals[array_rand($rivals)];
65 $rivalData = $rivals[array_rand($rivals)];
web/src/api/game.php +4 −2
@@ -628,7 +628,8 @@ if ($method === 'POST') {
628 628 'items' => $kobold->getItems() ?? [],
629 629 'injuries' => $kInjuries,
630 630 'is_leader' => $kobold->isLeader(),
631 'male' => $kobold->getMale()
631 'male' => $kobold->getMale(),
632 'likes' => isset($kobold->likes) && is_array($kobold->likes) ? $kobold->likes : []
632 633 ];
633 634 }
634 635
@@ -646,7 +647,8 @@ if ($method === 'POST') {
646 647 'food_count' => $tribe->getFoodCount(),
647 648 'food_time_remaining' => $tribe->foodTimeStr($tribe->getFoodCount()),
648 649 'created_at' => $tribe->getCreatedAt(),
649 'last_played' => $tribe->getLastPlayed()
650 'last_played' => $tribe->getLastPlayed(),
651 'rivals' => isset($tribe->rivals) ? $tribe->rivals : []
650 652 ],
651 653 'tribe' => [
652 654 'kobolds' => $kobolds,
@@ -628,7 +628,8 @@ if ($method === 'POST') {
628 'items' => $kobold->getItems() ?? [],
628 'items' => $kobold->getItems() ?? [],
629 'injuries' => $kInjuries,
629 'injuries' => $kInjuries,
630 'is_leader' => $kobold->isLeader(),
630 'is_leader' => $kobold->isLeader(),
631 'male' => $kobold->getMale()
631 'male' => $kobold->getMale(),
632 'likes' => isset($kobold->likes) && is_array($kobold->likes) ? $kobold->likes : []
632 ];
633 ];
633 }
634 }
634
635
@@ -646,7 +647,8 @@ if ($method === 'POST') {
646 'food_count' => $tribe->getFoodCount(),
647 'food_count' => $tribe->getFoodCount(),
647 'food_time_remaining' => $tribe->foodTimeStr($tribe->getFoodCount()),
648 'food_time_remaining' => $tribe->foodTimeStr($tribe->getFoodCount()),
648 'created_at' => $tribe->getCreatedAt(),
649 'created_at' => $tribe->getCreatedAt(),
649 'last_played' => $tribe->getLastPlayed()
650 'last_played' => $tribe->getLastPlayed(),
651 'rivals' => isset($tribe->rivals) ? $tribe->rivals : []
650 ],
652 ],
651 'tribe' => [
653 'tribe' => [
652 'kobolds' => $kobolds,
654 'kobolds' => $kobolds,