mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 10:35:08 +02:00
Prevent more glitch editions, enough should exist now
This commit is contained in:
parent
12e5b8200d
commit
cebf22f64f
@ -57,6 +57,9 @@ async function getExistingRocketeer( id, network='mainnet' ) {
|
|||||||
// ///////////////////////////////
|
// ///////////////////////////////
|
||||||
async function generateRocketeer( id, network='mainnet' ) {
|
async function generateRocketeer( id, network='mainnet' ) {
|
||||||
|
|
||||||
|
// Put dibs on the Rocketeer ID to make race conditions more unlikely
|
||||||
|
await db.collection( `${ network }Rocketeers` ).doc( id ).set( {}, { merge: true } )
|
||||||
|
|
||||||
// The base object of a new Rocketeer
|
// The base object of a new Rocketeer
|
||||||
const rocketeer = {
|
const rocketeer = {
|
||||||
name: `${ name.first() } ${ name.middle() } ${ name.last() } of ${ id % 42 == 0 ? 'the Towel' : pickRandomArrayEntry( heavenlyBodies ) }`,
|
name: `${ name.first() } ${ name.middle() } ${ name.last() } of ${ id % 42 == 0 ? 'the Towel' : pickRandomArrayEntry( heavenlyBodies ) }`,
|
||||||
@ -118,7 +121,7 @@ async function generateRocketeer( id, network='mainnet' ) {
|
|||||||
rocketeer.description = `${ rocketeer.name } is a proud member of the ${ rocketeer.attributes.find( ( { trait_type } ) => trait_type == 'patch' ).value } guild.`
|
rocketeer.description = `${ rocketeer.name } is a proud member of the ${ rocketeer.attributes.find( ( { trait_type } ) => trait_type == 'patch' ).value } guild.`
|
||||||
|
|
||||||
// Save new Rocketeer
|
// Save new Rocketeer
|
||||||
await db.collection( `${ network }Rocketeers` ).doc( id ).set( rocketeer )
|
await db.collection( `${ network }Rocketeers` ).doc( id ).set( rocketeer, { merge: true } )
|
||||||
|
|
||||||
return rocketeer
|
return rocketeer
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ function App() {
|
|||||||
<p>{ rocketeer.description || "This is a generic Rocketeer without a description. That should only happen during testing. Contact us on Discord if you see this." }</p>
|
<p>{ rocketeer.description || "This is a generic Rocketeer without a description. That should only happen during testing. Contact us on Discord if you see this." }</p>
|
||||||
|
|
||||||
<ul id="traits">
|
<ul id="traits">
|
||||||
{ rocketeer.attributes.map( ( { trait_type, value } ) => <li key={ trait_type }><span>{ trait_type }</span><span>{ value }</span></li> ) }
|
{ rocketeer.attributes?.map( ( { trait_type, value } ) => <li key={ trait_type }><span>{ trait_type }</span><span>{ value }</span></li> ) }
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user