mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-22 22:28:22 +03:00
fix card gen issues
This commit is contained in:
@@ -4,13 +4,23 @@ export const CARD_ID_REGEX = /^(?:[0-9]{4} ?){5}$/i;
|
||||
* Generates a random Aime card id.
|
||||
*/
|
||||
export function generateAimeCardId(): string {
|
||||
let id: string;
|
||||
let cardId = '';
|
||||
|
||||
do {
|
||||
id = Math.floor(Math.random() * 1e20).toString().padStart(20, '0');
|
||||
} while (id[0] === '3'); // https://gitea.tendokyu.moe/Dniel97/segatools/src/commit/37c26ecadb2ce4d2cb3a61ce96c2c931ba2fc346/aimeio/aimeio.c#L191
|
||||
|
||||
return id;
|
||||
while (true) {
|
||||
// don't start with a 3
|
||||
const firstDigit = Math.floor(Math.random() * 10);
|
||||
|
||||
if (firstDigit !== 3) {
|
||||
cardId = firstDigit.toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < 19; i++) {
|
||||
cardId += Math.floor(Math.random() * 10).toString();
|
||||
}
|
||||
|
||||
return cardId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user