Skip to content

Commit 6904f1e

Browse files
committed
Merge branch 'upmain' into vice-week
2 parents fee5b7e + a5c6063 commit 6904f1e

16 files changed

Lines changed: 857 additions & 100 deletions

File tree

‎README.md‎

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

‎e63334287a3deaa3/boostball/carbon-star.js‎

Lines changed: 448 additions & 0 deletions
Large diffs are not rendered by default.

‎e63334287a3deaa3/boostball/es.js‎

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎e63334287a3deaa3/boostball/index.html‎

Lines changed: 130 additions & 7 deletions
Large diffs are not rendered by default.

‎e63334287a3deaa3/boostball/kit.js‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ function Stage(parent,spr,R,main,camera){
825825
flash(a){if(main){const d=G.camera.position.distanceTo(S.world(S.x0,3,3));G.flash(a*clamp(1.2-d/150,.25,1))}},
826826
snd(fn){const A=G.audio();if(A)try{fn(A,A.actx.currentTime,main?1:.6)}catch(e){}},
827827
play(no,p,team){
828-
const def=GOALS[no];if(!def)return false;
828+
const def=GOALS[no];if(!def||def.gift)return false;
829829
S.stop();
830830
S.no=no;S.def=def;S.t=0;S.prev=-1;S.team=team;S.T=G.TEAM[team];S.col=S.T.col;S.q=G.low()?.5:1;S.d={};
831831
if(main){S.sg=p.z>0?-1:1;S.ox=0;S.oz=p.z>0?G.AL:-G.AL;root.position.set(0,0,S.oz);root.rotation.y=S.sg>0?0:Math.PI;S.B.set(clamp(S.sg*p.x,-GW+3,GW-3),clamp(p.y,BR,GH-3),clamp(S.sg*(p.z-S.oz),-5,1.5))}
@@ -1263,11 +1263,15 @@ const GOALS=[null,
12631263
S.snd((A,tt,v)=>{popSnd(A,tt,v,900);for(let i=0;i<9;i++){const f=2200+Math.random()*1500;A.tone(tt+.1+i*.11,.07,'sine',f,f*1.25,.05*v)}})}
12641264
if(S.at(1.5))S.em(c.x+rand(-1,1),c.y+3,c.z,0,-.4,0,1.9,1.3,CELL.feather,0xffffff,O({grav:.8,wob:5,spin:1.5,drag:1}));
12651265
}
1266-
}
1266+
},
1267+
// 22 Carbon Star: an exclusive gift (../captains.js GIFTS). It is drawn by carbon-star.js, never by a Stage here, and
1268+
// only for a goal by a player who has it (index.html checks the scorer's account); this entry only lets the Kit list
1269+
// it for those players. An older page has no 22 here and plays the fireball.
1270+
{gift:'bb-goal-carbon-star',dur:0}
12671271
];
12681272
let mainStage=null;
12691273
function goal(no,p,team){
1270-
if(!GOALS[no])return false;
1274+
if(!GOALS[no]||GOALS[no].gift)return false;
12711275
const spr=sprites();
12721276
if(!mainStage)mainStage=Stage(G.scene,spr,{lo:TRAIL_SLOTS*TRAIL_MAX,hi:spr.n,i:TRAIL_SLOTS*TRAIL_MAX},true,G.camera);
12731277
return mainStage.play(no,p,team);
@@ -1283,17 +1287,20 @@ function clearGoal(){if(mainStage)mainStage.stop()}
12831287
// boostball-kit ({slot: item id}).
12841288
const CAT=()=>window.BackRoomCosmetics&&window.BackRoomCosmetics.gameItems?window.BackRoomCosmetics:null;
12851289
const LISTS=[DECALS,TRAILS,GOALS,TOPPERS,HATS,WHEELS,ENGINES],TABS=['Decal','Boost trail','Goal explosion','Topper','Hat','Wheels','Engine'];
1290+
// an exclusive gift (GOALS[22]) is listed only for a player who has it (G.giftOk: its owner, a captain, or the test switch)
1291+
const giftOf=(slot,no)=>{const d=LISTS[slot]&&LISTS[slot][no];return d&&d.gift||''};
1292+
const shown=(slot,no)=>{const g=giftOf(slot,no);return !g||!!(G.giftOk&&G.giftOk(g))};
12861293
function items(slot){
1287-
const C=CAT(),L=C?C.gameItems('boostball',SLOTS[slot]).filter(it=>has(slot,it.no)):[];
1294+
const C=CAT(),L=C?C.gameItems('boostball',SLOTS[slot]).filter(it=>has(slot,it.no)&&shown(slot,it.no)):[];
12881295
if(L.length||!LISTS[slot])return L;
1289-
return LISTS[slot].map((d,i)=>i?{no:i,id:'bb-'+SLOTS[slot]+'-'+i,name:TABS[slot]+' '+i,desc:'',rarity:'common'}:null).filter(Boolean); // no catalogue: numbers only
1296+
return LISTS[slot].map((d,i)=>i&&shown(slot,i)?{no:i,id:'bb-'+SLOTS[slot]+'-'+i,name:TABS[slot]+' '+i,desc:'',rarity:'common'}:null).filter(Boolean); // no catalogue: numbers only
12901297
}
1291-
const owns=it=>!G.cosOn()||CAT().owned().items.indexOf(it.id)>=0;
1298+
const owns=it=>!G.cosOn()||!!giftOf(SLOTS.indexOf(it.slot),it.no)||CAT().owned().items.indexOf(it.id)>=0;
12921299
let cur=[0,0,0,0,0,0,0];
12931300
function saved(){let o=null;try{o=JSON.parse(G.store.get('kit','')||'null')}catch(e){}return o&&typeof o==='object'?o:{}}
12941301
function mine(){
12951302
const k=[0,0,0,0,0,0,0];
1296-
if(G.cosOn()){const e=CAT().gameEquipped('boostball');SLOTS.forEach((s,i)=>{if(e[s]&&has(i,e[s].no))k[i]=e[s].no})}
1303+
if(G.cosOn()){const e=CAT().gameEquipped('boostball');SLOTS.forEach((s,i)=>{if(e[s]&&has(i,e[s].no)&&shown(i,e[s].no))k[i]=e[s].no})}
12971304
else if(G.garageOn){const o=saved();SLOTS.forEach((s,i)=>{const it=items(i).find(x=>x.id===o[s]);if(it)k[i]=it.no})}
12981305
cur=k;return G.kitOf(k);
12991306
}
@@ -1302,7 +1309,7 @@ function wear(slot,it){
13021309
else{const o=saved();if(it)o[SLOTS[slot]]=it.id;else delete o[SLOTS[slot]];G.store.set('kit',JSON.stringify(o))}
13031310
G.setKit(mine());paintMenu();
13041311
}
1305-
function botKit(){const r=(L,p)=>Math.random()<p?1+Math.floor(Math.random()*(L.length-1)):0;return G.kitOf([r(DECALS,.7),r(TRAILS,.7),r(GOALS,.8),r(TOPPERS,.3),r(HATS,.3),r(WHEELS,.4)])}
1312+
function botKit(){const r=(L,p)=>{if(Math.random()>=p)return 0;let i;do{i=1+Math.floor(Math.random()*(L.length-1))}while(L[i]&&L[i].gift);return i}; /* never a gift */return G.kitOf([r(DECALS,.7),r(TRAILS,.7),r(GOALS,.8),r(TOPPERS,.3),r(HATS,.3),r(WHEELS,.4)])}
13061313
let tab=0,note='',swKey='';
13071314
const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
13081315
function menu(){
@@ -1343,7 +1350,7 @@ function paintMenu(){
13431350
grid.innerHTML='<button type="button" data-no="0" aria-pressed="'+(!cur[tab])+'">None</button>'+L.map(it=>{
13441351
const lock=!owns(it),r=RC[it.rarity];
13451352
return '<button type="button" data-no="'+it.no+'" aria-pressed="'+(cur[tab]===it.no)+'"'+(lock?' class="locked" aria-disabled="true"':'')+' title="'+esc(it.desc||it.name)+(r?' ('+r.name+')':'')+'">'+
1346-
(tab===0?'<canvas width="96" height="32" aria-hidden="true"></canvas>':C&&C.itemSvg?C.itemSvg(it.id,26):'')+esc(it.name)+(r?'<i style="background:'+r.color+'" aria-hidden="true"></i>':'')+'</button>'}).join('');
1353+
(tab===0?'<canvas width="96" height="32" aria-hidden="true"></canvas>':C&&C.itemSvg?C.itemSvg(it.id,26):'')+esc(it.name)+(giftOf(tab,it.no)?'<small style="font-weight:600;opacity:.8">made for Carbon</small>':'')+(r?'<i style="background:'+r.color+'" aria-hidden="true"></i>':'')+'</button>'}).join('');
13471354
swKey='';
13481355
const it=L.find(x=>x.no===cur[tab]);
13491356
document.getElementById('kitNote').innerHTML=note||(it?'<b>'+esc(it.name)+'.</b> '+esc(it.desc||''):['No decal: plain team paint.','No trail: the usual boost flame.','No goal explosion: the usual fireball.','No topper.','No hat.','The usual wheels.','The usual engine sound.'][tab]);
@@ -1367,11 +1374,12 @@ function pvInit(Gr){
13671374
const b=Build();for(const s of[-1,1])b.cyl(.35,.35,GH,0xf4f6ff,s*GW,GH/2,0);b.cyl(.35,.35,GW*2,0xf4f6ff,0,GH,0,0,0,Math.PI/2);b.box(GW*2,GH,.2,0x16202c,0,GH/2,-9);set.add(b.mesh());
13681375
pv={spr,cam,stage,set,R:{lo:0,hi:TRAIL_MAX,i:0},st:{acc:0}};
13691376
}
1370-
function preview(no){const Gr=G.garage;if(!Gr||!GOALS[no])return;if(!pv)pvInit(Gr);pv.stage.play(no,new V3(2.5,3,-1.5),0)}
1377+
function preview(no){const Gr=G.garage;if(!Gr||!GOALS[no])return;if(GOALS[no].gift){if(pv)pv.stage.stop();if(G.giftPreview)G.giftPreview();return}if(!pv)pvInit(Gr);pv.stage.play(no,new V3(2.5,3,-1.5),0)}
13711378
const _z=new V3();
13721379
function garageFrame(Gr,dt){
13731380
paintSwatches();
13741381
if(!Gr.model)return false;
1382+
if(G.giftFrame&&G.giftFrame(Gr,dt))return true; // Carbon Star's preview (carbon-star.js) is playing in the garage picture
13751383
if(!pv){if(!(tab===1&&cur[1]))return false;pvInit(Gr)}
13761384
const car=Gr.model.g;
13771385
if(pv.stage.live){

‎e63334287a3deaa3/captains.js‎

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
* comes back into view, when account.js says the account changed (on this page or the page around this frame) and
3939
* when another tab signs in or out (account.js's 'acct' entry in localStorage changes).
4040
*
41+
* EXCLUSIVE GIFTS: a few items are made for one player (GIFTS below: account id -> item ids). They are not for sale,
42+
* not in any chest or pack and cannot be gifted on; the captains get the ones in CAPTAIN_GIFTS too. A game asks:
43+
* gift(item) does the account signed in here have this gift? (false while the first check runs)
44+
* gift(item, uid) does another player's account have it? Used to check who scored before drawing a
45+
* gift for them: a page draws it only for a goal by a player whose id is in the table
46+
* (or a captain, for CAPTAIN_GIFTS), whatever that player's data claims. A captain is
47+
* known only once miles.js is here: call giftsReady() first (it fetches miles.js once).
48+
* account() the id of the Google account signed in here ('' for a guest or signed out)
49+
* onAccount(fn) fn(uid) whenever the signed-in account changes (captain or not)
50+
* To add another gift: put '<account id>': ['<item id>'] in GIFTS (the account id is the player's Google account uid on this
51+
* site's Firebase project), add the item to cosmetics.js with give: 'exclusive', and make its game draw it only when
52+
* gift(item, scorer) is true. See README, captains.js.
53+
*
4154
* THIS IS NOT A LOCK. The check runs in the visitor's own browser and the account ids are public, so someone who
4255
* edits the page in their browser can still open these screens. It keeps the options out of sight; nothing on the
4356
* server enforces it. What a player wears is looks only in every game.
@@ -50,6 +63,14 @@
5063
// false: Captains only (miles.js's OWNERS).
5164
var VICE_CAPTAINS_TOO = false; // Captains only: Vice Captains see nothing, like everyone else
5265

66+
// EXCLUSIVE GIFTS (see the top): account id -> the item ids made for that player alone. Nobody else is offered them,
67+
// and pages draw them only for these accounts. Ids are the cosmetics.js item ids.
68+
var GIFTS = {
69+
'BExn2DzDMQYrXn4AVp7BjzQT5dP2': ['bb-goal-carbon-star'] // Carbon: Boostball's Carbon Star goal explosion
70+
};
71+
// Gifts the captains (the same captains as above) may wear too, in their own Kit, labelled as made for their owner.
72+
var CAPTAIN_GIFTS = ['bb-goal-carbon-star'];
73+
5374
var API_KEY = 'AIzaSyDZD_Ku8cixteXfwkDYzGv3GKiZFF8sRSM'; // the site's Firebase project (public; the same one as in stats.js)
5475
var AUTH_KEY = 'firebase:authUser:' + API_KEY + ':[DEFAULT]';
5576
var me0 = document.currentScript;
@@ -126,23 +147,36 @@
126147
}
127148

128149
// ---------------- The answer ----------------
129-
var cap = false, known = false, uid = '', seq = 0, listeners = [], readyDone, ready = new Promise(function (r) { readyDone = r; });
150+
var cap = false, known = false, uid = '', seq = 0, listeners = [], accountListeners = [], readyDone, ready = new Promise(function (r) { readyDone = r; });
130151
function settle(n, c, u) {
131152
if (n !== seq) return; // a newer check is running: its answer is the one that counts
132-
var changed = c !== cap;
153+
var changed = c !== cap, moved = u !== uid;
133154
cap = c; uid = u;
134155
if (!known) { known = true; readyDone(cap); }
156+
if (moved) accountListeners.forEach(function (f) { try { f(uid); } catch (e) { try { console.error(e); } catch (_) {} } });
135157
if (!changed) return;
136158
listeners.forEach(function (f) { try { f(cap); } catch (e) { try { console.error(e); } catch (_) {} } });
137159
try { document.dispatchEvent(new CustomEvent('backroom:captain', { detail: { captain: cap } })); } catch (e) {}
138160
}
161+
function isCaptain(M, id) { return !!M && !!id && (M.isOwner(id) || (VICE_CAPTAINS_TOO && M.isVice(id))); }
162+
// Has account `id` the gift `item`? Its own entry in GIFTS, or a captain for CAPTAIN_GIFTS. `id` omitted: the account
163+
// signed in here (a captain as answered by the check above).
164+
function gift(item, id) {
165+
var mine = id === undefined;
166+
id = mine ? uid : String(id || '');
167+
if (!id || !/^[A-Za-z0-9]{1,128}$/.test(id)) return false;
168+
var own = Object.prototype.hasOwnProperty.call(GIFTS, id) ? GIFTS[id] : null;
169+
if (own && own.indexOf(item) >= 0) return true;
170+
if (CAPTAIN_GIFTS.indexOf(item) < 0) return false;
171+
return mine ? cap : isCaptain(miles(), id);
172+
}
139173
function check() {
140174
var n = ++seq;
141175
return (standIn !== undefined ? Promise.resolve(standIn) : peek()).then(function (u) {
142176
var id = u && u.isAnonymous === false && typeof u.uid === 'string' && /^[A-Za-z0-9]{1,128}$/.test(u.uid) ? u.uid : '';
143177
if (!id) return settle(n, false, ''); // signed out, or one of the games' guest accounts
144178
if (known && id === uid) return settle(n, cap, uid);
145-
return lists().then(function (M) { settle(n, !!M && (M.isOwner(id) || (VICE_CAPTAINS_TOO && M.isVice(id))), id); });
179+
return lists().then(function (M) { settle(n, isCaptain(M, id), id); });
146180
}).catch(function () { settle(n, false, ''); });
147181
}
148182
var again = 0;
@@ -169,13 +203,18 @@
169203
known: function () { return known; },
170204
ready: ready,
171205
onChange: function (f) { if (typeof f === 'function') listeners.push(f); },
172-
check: check
206+
check: check,
207+
gift: gift,
208+
giftsReady: function () { return lists().then(function () {}, function () {}); },
209+
account: function () { return uid; },
210+
onAccount: function (f) { if (typeof f === 'function') accountListeners.push(f); }
173211
};
174212
// Test hook (automated browsers only): stand in for the signed-in account. as(uid) a Google account, as(uid, false)
175213
// a guest (anonymous) account, as(null) signed out, real() the browser's own again. Each returns a promise for the check.
176214
if (navigator.webdriver) window.__captains = {
177215
as: function (id, google) { standIn = id ? { uid: String(id), isAnonymous: google === false } : null; return check().then(function () { return cap; }); },
178216
real: function () { standIn = undefined; return check().then(function () { return cap; }); },
217+
gift: function (id, items) { GIFTS[String(id)] = items ? [].concat(items) : []; }, // add or empty a GIFTS entry, for tests
179218
peek: peek, AUTH_KEY: AUTH_KEY, get uid() { return uid; }, get viceToo() { return VICE_CAPTAINS_TOO; }
180219
};
181220
if (SWITCHES_ONLY) { known = true; readyDone(false); } else check();

‎e63334287a3deaa3/cosmetics.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
I('boostball', 'engine', 2, 'Buzz', 'uncommon', '#FFD23F', '#FF8A1F', 'High and angry, like a go-kart.');
364364
I('boostball', 'engine', 3, 'Rumble', 'rare', '#7A5230', '#FF4D6D', 'A big lazy burble.');
365365
I('boostball', 'engine', 4, 'Whirr', 'epic', '#3EE6FF', '#FFFFFF', 'Electric: it sings as it speeds up.');
366+
I('boostball', 'goal', 22, 'Carbon Star', 'legendary', '#2A1048', '#FF6A2E', 'Made for Carbon: a red giant flares in the goal and the whole arena drifts into deep space.'); ITEM_BY_ID['bb-goal-carbon-star'].give = 'exclusive'; // an exclusive gift (../captains.js GIFTS): in no pack or chest, never sold or gifted on
366367
// Slipstream sponsors (all made up): signing with one is free, and its sticker goes on the car. c1 and c2 are its colours.
367368
I('slipstream', 'sponsor', 1, 'Zoomi Cola', 'common', '#12B5A6', '#FFF3D6', 'Fizzy, fast and slightly too sweet.');
368369
I('slipstream', 'sponsor', 2, 'Burnout Coffee', 'common', '#3B2416', '#FFB347', 'Roasted until the tyres smoke.');

‎e63334287a3deaa3/index.html‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ <h3>Blockstorm</h3>
320320
<div class="body">
321321
<h3>Sky Duel</h3>
322322
<p class="gc-blurb">Dogfights in little planes over peaks and canyons, with guns, homing missiles and flares.</p>
323-
<ul class="gc-chips" aria-label="At a glance"><li class="on">Online · up to 8</li><li>Bots</li><li>1v1 · FFA · 2v2</li></ul>
323+
<ul class="gc-chips" aria-label="At a glance"><li class="on">Online · up to 8</li><li>Ranked</li><li>Bots</li><li>1v1 · FFA · 2v2</li></ul>
324324
<details class="gc-more">
325325
<summary aria-label="More about Sky Duel"><span aria-hidden="true"></span></summary>
326326
<div class="gc-info">
@@ -329,6 +329,7 @@ <h3>Sky Duel</h3>
329329
<li>Online rooms for up to 8 pilots: Quick match drops you into a public free-for-all, or pick a room code and send friends the invite link</li>
330330
<li>Duel (1v1), free-for-all or 2v2; the room's host picks the mode, the kill target, the time and the bots</li>
331331
<li>Bots at three levels (Rookie, Veteran, Ace) fill the empty seats, or fly solo against them</li>
332+
<li>A ranked rating (Elo) for online matches against other people, with a leaderboard</li>
332333
<li>A lead marker for the guns, lock-on missiles, flares, boost, a barrel-roll dodge, and repair, missile and flare rings to fly through</li>
333334
<li>Radar, target boxes, a kill feed, contrails and four planes to pick from</li>
334335
</ul>

0 commit comments

Comments
 (0)