Merge pull request 'Transparent gold ingot on Discovery Rewards —367' (#19) from dev/MC:dev/ticket-367-transparent-ingot into checkpoint/alpha-1.0.0.3

Reviewed-on: unimatrix/MC#19
This commit is contained in:
Unimatrix 2026-11-04 22:42:20 +01:00
commit 27ab62fdae
5 changed files with 15 additions and 2 deletions

View file

@ -56,7 +56,7 @@ export function mountQuestRewardForm(document,window,fetcher=fetch){
const host=document.getElementById('shop-quest-dock')||document.getElementById('game');if(!host)return null;
const el=(tag,text)=>{const node=document.createElement(tag);if(text!==undefined)node.textContent=text;return node;};
const card=el('article');card.className='quest-reward-card';card.hidden=true;card.setAttribute('aria-labelledby','quest-reward-title');
const header=el('div');header.className='quest-reward-heading';const art=el('img');art.src='/assets/menu-0.webp';art.alt='';art.width=64;art.height=64;art.loading='lazy';
const header=el('div');header.className='quest-reward-heading';const art=el('img');art.src='/assets/reward-gold-ingot-transparent-v1.png';art.alt='';art.width=64;art.height=64;art.loading='lazy';
const heading=el('div');heading.append(el('p','YOUR EARNED DISCOVERIES'));heading.firstElementChild.className='quest-reward-eyebrow';const title=el('h3','Redeem a discovery code');title.id='quest-reward-title';heading.append(title);header.append(art,heading);
const intro=el('p','Keep your in-game discovery code private. Rewards belong to your verified Minecraft identity and can be redeemed once.');intro.className='quest-reward-intro';
const status=el('p');status.className='quest-reward-status';status.setAttribute('role','status');status.setAttribute('aria-live','polite');status.setAttribute('aria-atomic','true');

View file

@ -48,7 +48,7 @@ import {createCommunityRewards} from '../node/community-rewards.mjs';
import {createAccountAdmin} from '../node/account-admin.mjs';
import {createServerControl} from './server-control.mjs';
const types={'.html':'text/html; charset=utf-8','.js':'text/javascript; charset=utf-8','.mjs':'text/javascript; charset=utf-8','.css':'text/css; charset=utf-8'};
const sharedAssets=new Set(['ornament.webp','guild.webp','minecraft-hero.webp','menu-0.webp','menu-5.webp','menu-6.webp','menu-9.webp','menu-12.webp','item-23.webp','dunemark-icon-64.png','arrakis-lore-frieze.svg']);
const sharedAssets=new Set(['ornament.webp','guild.webp','minecraft-hero.webp','menu-0.webp','reward-gold-ingot-transparent-v1.png','menu-5.webp','menu-6.webp','menu-9.webp','menu-12.webp','item-23.webp','dunemark-icon-64.png','arrakis-lore-frieze.svg']);
export function createPanel(db,settings={},dependencies={}){
const origin=new URL(settings.CP_ORIGIN||'https://cp.dunerealms.com').origin;
const auth=createAuth(db,origin,settings),links=createGameLink(db,settings,origin),rewards=createCommunityRewards(db,settings,origin);

View file

@ -0,0 +1,7 @@
# Ticket367 — transparent reward ingot
Replaced only the Discovery Rewards heading image with a sibling transparent PNG derived from the existing pixel-art ingot. Original `menu-0.webp` retained. CP explicitly serves the new PNG with its existing PNG content type; no reward or redemption logic changed.
14 tests pass:12 existing discovery/redemption behaviour checks and2 artwork/asset checks. PNG alpha is decoded in the asset test: all four corners fully transparent, substantial empty background and visible nearly opaque ingot pixels. Live CP image loaded successfully and inspected against the green card background, including mobile view.
Backup: /root/ticket367-before-20261104. Scoped rollout: new asset, one heading URL and CP static asset allowlist; CP restart only. No database writes or actual redemption. Evidence output/ticket367-20261104/live-transparent.png.

View file

@ -0,0 +1,6 @@
import test from 'node:test';import assert from 'node:assert/strict';import{readFileSync}from'node:fs';import{inflateSync}from'node:zlib';
test('reward ingot has real transparent alpha, not a painted background',()=>{
const p=readFileSync(new URL('../web/assets/reward-gold-ingot-transparent-v1.png',import.meta.url));assert.equal(p.subarray(1,4).toString(),'PNG');const w=p.readUInt32BE(16),h=p.readUInt32BE(20);assert.equal(p[24],8);assert.equal(p[25],6);let parts=[];for(let i=8;i<p.length;){let n=p.readUInt32BE(i);if(p.toString('ascii',i+4,i+8)==='IDAT')parts.push(p.subarray(i+8,i+8+n));i+=n+12;}const raw=inflateSync(Buffer.concat(parts)),stride=w*4;let prior=Buffer.alloc(stride),pos=0,transparent=0,solid=0;const corners=[];for(let y=0;y<h;y++){let f=raw[pos++],row=Buffer.alloc(stride);for(let x=0;x<stride;x++){let a=x>=4?row[x-4]:0,b=prior[x],c=x>=4?prior[x-4]:0,v=0;if(f===1)v=a;else if(f===2)v=b;else if(f===3)v=Math.floor((a+b)/2);else if(f===4){let q=a+b-c,pa=Math.abs(q-a),pb=Math.abs(q-b),pc=Math.abs(q-c);v=pa<=pb&&pa<=pc?a:pb<=pc?b:c;}else assert.equal(f,0);row[x]=(raw[pos++]+v)&255;}for(let x=3;x<stride;x+=4){if(row[x]===0)transparent++;if(row[x]>=240)solid++;}if(y===0||y===h-1)corners.push(row[3],row[stride-1]);prior=row;}assert(corners.every(a=>a===0));assert(transparent>w*h*.3);assert(solid>w*h*.1);
});
test('reward heading uses transparent sibling asset served by CP',()=>{const ui=readFileSync(new URL('../control-panel/public/quest-rewards.mjs',import.meta.url),'utf8'),server=readFileSync(new URL('../control-panel/server.mjs',import.meta.url),'utf8');assert(ui.includes("art.src='/assets/reward-gold-ingot-transparent-v1.png'"));assert(server.includes("'reward-gold-ingot-transparent-v1.png'"));});

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB