Skip to content

Commit edf3218

Browse files
author
web3blind
committed
Publish temple prayers to Chronicle
1 parent 2ff807c commit edf3218

7 files changed

Lines changed: 78 additions & 13 deletions

File tree

app/css/main.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,3 +1796,24 @@ body,
17961796
background: var(--color-surface-2);
17971797
color: var(--color-text);
17981798
}
1799+
1800+
1801+
.temple-social-toggle {
1802+
display: flex;
1803+
align-items: flex-start;
1804+
gap: 8px;
1805+
margin: var(--space-xs) 0;
1806+
color: var(--color-text);
1807+
}
1808+
1809+
.temple-social-toggle input {
1810+
min-width: 20px;
1811+
min-height: 20px;
1812+
margin-top: 2px;
1813+
}
1814+
1815+
.temple-social-note {
1816+
margin-top: 0;
1817+
color: var(--color-text-muted);
1818+
font-size: 0.85rem;
1819+
}

app/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<link rel="icon" type="image/png" sizes="192x192" href="assets/icons/viz-magic-192.png?v=20260712c">
1414
<link rel="icon" type="image/png" sizes="512x512" href="assets/icons/viz-magic-512.png?v=20260712c">
1515
<link rel="apple-touch-icon" href="assets/icons/viz-magic-192.png?v=20260712c">
16-
<link rel="stylesheet" href="css/main.css?v=20260712h">
16+
<link rel="stylesheet" href="css/main.css?v=20260712i">
1717
<link rel="stylesheet" href="css/themes.css">
1818
<link rel="stylesheet" href="css/accessibility.css">
1919
</head>
@@ -120,8 +120,8 @@
120120
<script src="js/config.js?v=20260712a"></script>
121121

122122
<!-- I18n -->
123-
<script src="js/i18n/ru.js?v=20260712i"></script>
124-
<script src="js/i18n/en.js?v=20260712i"></script>
123+
<script src="js/i18n/ru.js?v=20260712j"></script>
124+
<script src="js/i18n/en.js?v=20260712j"></script>
125125

126126
<!-- Utilities -->
127127
<script src="js/utils/helpers.js?v=20260621l"></script>
@@ -202,7 +202,7 @@
202202
<script src="js/ui/screens/settings.js?v=20260712b"></script>
203203
<script src="js/ui/screens/help.js?v=20260712a"></script>
204204
<script src="js/ui/screens/leaderboard.js"></script>
205-
<script src="js/ui/screens/temple.js?v=20260712b"></script>
205+
<script src="js/ui/screens/temple.js?v=20260712c"></script>
206206

207207
<!-- Main App Controller (must be last) -->
208208
<script src="js/ui/app.js?v=20260712a"></script>

app/js/i18n/en.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,11 @@ var LangEN = {
10441044
temple_prayer_labor_hands: 'God of Labor, strengthen my hands so the hammer does not argue with my fingers and work goes well.',
10451045
temple_prayer_labor_craft: 'Lord of craft, may iron be reasonable today, wood patient, and I not too confident.',
10461046
temple_prayer_labor_patience: 'God of Labor, give me patience for one good step more than laziness has.',
1047+
temple_social_publish: 'Publish the prayer to the Chronicle',
1048+
temple_social_note: 'This creates a separate #viz_magic #temple post so the prayer is visible in the social feed.',
1049+
temple_social_post: '{name} prays at the Temple. {deity}, hear this: “{prayer}” #viz_magic #temple {tag}',
1050+
temple_social_success: 'Prayer published to the Chronicle.',
1051+
temple_social_failed: 'The offering was accepted, but the prayer post was not sent. The reward is saved.',
10471052
temple_energy_check_failed: 'Could not check mana before the offering.',
10481053
temple_not_enough_mana: 'Not enough mana for the offering.',
10491054
temple_rule_blessing: 'After an offering, a small temporary blessing applies: Fire slightly boosts fire spells, Labor slightly helps loot fortune.',

app/js/i18n/ru.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,11 @@ var LangRU = {
10441044
temple_prayer_labor_hands: 'Бог Труда, укрепи руки мои, чтобы молот не спорил с пальцами, а дело спорилось.',
10451045
temple_prayer_labor_craft: 'Владыка ремесла, пусть железо сегодня будет понятливым, дерево — терпеливым, а я — не слишком самоуверенным.',
10461046
temple_prayer_labor_patience: 'Бог Труда, дай терпения на один хороший шаг больше, чем у лени.',
1047+
temple_social_publish: 'Опубликовать молитву в Хронику',
1048+
temple_social_note: 'Это создаст отдельный пост с #viz_magic #temple, чтобы молитву увидели в социальной ленте.',
1049+
temple_social_post: '{name} молится в Храме. {deity}, услышь: «{prayer}» #viz_magic #temple {tag}',
1050+
temple_social_success: 'Молитва опубликована в Хронику.',
1051+
temple_social_failed: 'Подношение принято, но пост молитвы не отправился. Награда сохранена.',
10471052
temple_energy_check_failed: 'Не удалось проверить ману перед подношением.',
10481053
temple_not_enough_mana: 'Недостаточно маны для подношения.',
10491054
temple_rule_blessing: 'После подношения действует малое временное благословение: Огонь чуть усиливает огненные заклинания, Труд — удачу в добыче.',

app/js/ui/screens/temple.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ var TempleScreen = (function() {
1818
id: 'fire_goddess',
1919
target: 'null',
2020
image: 'assets/deities/goddess-fire.svg',
21-
item: 'flame_votive_mark'
21+
item: 'flame_votive_mark',
22+
socialTag: '#fire'
2223
},
2324
{
2425
id: 'labor_god',
2526
target: 'committee',
2627
image: 'assets/deities/god-labor.svg',
27-
item: 'labor_votive_mark'
28+
item: 'labor_votive_mark',
29+
socialTag: '#labor'
2830
}
2931
];
3032

@@ -82,6 +84,11 @@ var TempleScreen = (function() {
8284
'<p class="temple-reward">' + t('temple_reward') + ': ' + t('item_' + deity.item) + '</p>' +
8385
'<label class="temple-prayer-label" for="temple-prayer-' + deity.id + '">' + t('temple_prayer_label') + '</label>' +
8486
_renderPrayerSelect(deity, t) +
87+
'<label class="temple-social-toggle">' +
88+
'<input type="checkbox" id="temple-social-' + deity.id + '" checked> ' +
89+
'<span>' + t('temple_social_publish') + '</span>' +
90+
'</label>' +
91+
'<p class="temple-social-note">' + t('temple_social_note') + '</p>' +
8592
'<p class="temple-cooldown">' + cooldownText + '</p>' +
8693
'<button type="button" class="btn btn-primary temple-offer-btn" data-deity="' + deity.id + '">' +
8794
t('temple_offer_button').replace('{cost}', Helpers.bpToPercent(OFFERING_ENERGY)) +
@@ -124,6 +131,8 @@ var TempleScreen = (function() {
124131
}
125132
var select = Helpers.$('temple-prayer-' + deity.id);
126133
var prayerText = select ? Helpers.t(select.value) : '';
134+
var socialToggle = Helpers.$('temple-social-' + deity.id);
135+
var shouldPublish = !socialToggle || socialToggle.checked;
127136

128137
busy = true;
129138
Toast.info(Helpers.t('temple_offering_started'));
@@ -157,11 +166,33 @@ var TempleScreen = (function() {
157166
} else {
158167
StateEngine.saveCheckpoint(function() {});
159168
Toast.success(Helpers.t('temple_offering_success'));
169+
if (shouldPublish) {
170+
_publishPrayerPost(deity, prayerText, user);
171+
}
160172
}
161173
render();
162174
});
163175
});
164176
}
165177

178+
179+
function _publishPrayerPost(deity, prayerText, user) {
180+
var character = StateEngine.getCharacter(user);
181+
var name = character && character.name ? character.name : user;
182+
var deityName = Helpers.t('temple_' + deity.id + '_name');
183+
var text = Helpers.t('temple_social_post')
184+
.replace('{name}', name)
185+
.replace('{deity}', deityName)
186+
.replace('{prayer}', prayerText)
187+
.replace('{tag}', deity.socialTag || '#temple');
188+
VizBroadcast.chroniclePost(text, function(err) {
189+
if (err) {
190+
Toast.info(Helpers.t('temple_social_failed'));
191+
} else {
192+
Toast.success(Helpers.t('temple_social_success'));
193+
}
194+
});
195+
}
196+
166197
return { render: render };
167198
})();

app/sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Viz Magic — Service Worker
2-
var CACHE_NAME = 'viz-magic-v42';
2+
var CACHE_NAME = 'viz-magic-v43';
33
var ASSETS = [
44
'/',
55
'/index.html',

tests/player-bug-regressions.test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ test('high-traffic UI narration, screen announcements, and inventory stat labels
342342

343343
test('service worker updates quickly and keeps navigations network-first', function () {
344344
const swJs = read('app/sw.js');
345-
assert.ok(/viz-magic-v42/.test(swJs), 'service worker cache version should be bumped');
345+
assert.ok(/viz-magic-v43/.test(swJs), 'service worker cache version should be bumped');
346346
assert.ok(/self\.skipWaiting\(\)/.test(swJs), 'service worker should activate new cache without waiting for all tabs to close');
347347
assert.ok(/self\.clients\.claim\(\)/.test(swJs), 'service worker should claim clients after activation');
348348
assert.ok(/event\.request\.mode === 'navigate'[\s\S]*fetch\(event\.request\)/.test(swJs), 'navigation requests should prefer network to avoid stale cached index');
@@ -391,7 +391,7 @@ test('mobile entry helpers cover keyboard paste, home-screen shortcut, nav parit
391391
assert.ok(/SoundManager\.setVolume\(sfxVolume \/ 100\)/.test(read('app/js/ui/screens/settings.js')), 'settings should apply stored SFX volume on render');
392392
assert.ok(/localStorage\.setItem\(STORAGE_PREFIX \+ 'sfx_volume'/.test(read('app/js/ui/sound.js')), 'sound manager should persist SFX volume');
393393
assert.ok(/var volume = _getStoredNumber\('sfx_volume', 0\.5\)/.test(read('app/js/ui/sound.js')), 'sound manager should restore persisted SFX volume');
394-
assert.ok(/viz-magic-v42/.test(read('app/sw.js')), 'service worker cache should be bumped for UI changes');
394+
assert.ok(/viz-magic-v43/.test(read('app/sw.js')), 'service worker cache should be bumped for UI changes');
395395
});
396396

397397

@@ -449,11 +449,11 @@ test('magical weather is labelled and affects hunts', function () {
449449
assert.ok(/forecast-card-effect/.test(homeJs + mainCss), 'forecast effect column needs its own thematic icon/card');
450450
assert.ok(/function getCurrentFestival/.test(worldEventsJs), 'magical holidays should sometimes appear in the forecast');
451451
assert.ok(/festival_today_prefix/.test(homeJs + ruJs + enJs), 'forecast holidays should have localized copy');
452-
assert.ok(/i18n\/ru.js\?v=20260712i/.test(indexHtml), 'Russian weather copy must be cache-busted');
453-
assert.ok(/i18n\/en.js\?v=20260712i/.test(indexHtml), 'English weather copy must be cache-busted');
452+
assert.ok(/i18n\/ru.js\?v=20260712j/.test(indexHtml), 'Russian weather copy must be cache-busted');
453+
assert.ok(/i18n\/en.js\?v=20260712j/.test(indexHtml), 'English weather copy must be cache-busted');
454454
assert.ok(/home.js\?v=20260712g/.test(indexHtml), 'home forecast layout must be cache-busted');
455455
assert.ok(/world-events.js\?v=20260712g/.test(indexHtml), 'world events forecast pool must be cache-busted');
456-
assert.ok(/main.css\?v=20260712h/.test(indexHtml), 'forecast grid CSS must be cache-busted');
456+
assert.ok(/main.css\?v=20260712i/.test(indexHtml), 'forecast grid CSS must be cache-busted');
457457
assert.ok(/season_effect_prefix/.test(homeJs + ruJs + enJs), 'home forecast should explain gameplay effect');
458458
assert.ok(/seasonBonuses\[spell\.school\]/.test(combatJs), 'season school bonus should affect spell attack');
459459
assert.ok(/creatureAttackMod/.test(combatJs), 'weather should affect creature danger in hunt combat');
@@ -481,6 +481,9 @@ test('temple tab uses balanced on-chain offerings without direct pay-to-win stat
481481
assert.ok(/function templeOffering/.test(broadcastJs), 'temple offering should have a broadcast wrapper');
482482
assert.ok(/award\(targetAccount, energy/.test(broadcastJs), 'temple offering should send a VIZ award to the deity account');
483483
assert.ok(/prayerText/.test(broadcastJs + templeJs), 'temple offerings should include selected prayer text in the public memo/action');
484+
assert.ok(/temple_social_publish/.test(templeJs + ruJs + enJs), 'temple should offer an optional Chronicle prayer post for native promotion');
485+
assert.ok(/VizBroadcast\.chroniclePost/.test(templeJs), 'temple social prayer should use Chronicle posts');
486+
assert.ok(/#viz_magic #temple/.test(ruJs + enJs), 'temple social posts should include discoverable tags');
484487
assert.ok(/VizAccount\.calculateCurrentEnergy/.test(templeJs), 'temple should check current mana before broadcasting an award');
485488
assert.ok(/case AT\.TEMPLE_OFFERING/.test(stateEngineJs), 'state engine should replay temple offerings');
486489
assert.ok(/function _handleTempleOffering/.test(stateEngineJs), 'temple offering handler should exist');
@@ -494,7 +497,7 @@ test('temple tab uses balanced on-chain offerings without direct pay-to-win stat
494497
assert.ok(/OFFERING_ENERGY = 50/.test(templeJs), 'offering cost should be small and explicit');
495498
assert.ok(/fire_goddess[\s\S]*target:\s*'null'/.test(templeJs), 'fire goddess should burn through null');
496499
assert.ok(/labor_god[\s\S]*target:\s*'committee'/.test(templeJs), 'labor god should support committee');
497-
assert.ok(/screen-temple/.test(indexHtml) && /temple\.js\?v=20260712b/.test(indexHtml), 'temple screen should be loaded and cache-busted');
500+
assert.ok(/screen-temple/.test(indexHtml) && /temple\.js\?v=20260712c/.test(indexHtml), 'temple screen should be loaded and cache-busted');
498501
assert.ok(/id: 'temple'/.test(navJs + homeJs) && /nav_temple/.test(ruJs + enJs), 'temple should be reachable from navigation/home');
499502
});
500503

0 commit comments

Comments
 (0)