mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-10-05 21:28:08 +03:00
add amusement ic access code encode/decode
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,23 +1,12 @@
|
||||
import {encodeAccessCode} from "./card-encoding";
|
||||
|
||||
export const CARD_ID_REGEX = /^(?:[0-9]{4} ?){5}$/i;
|
||||
export const AMNET_COMPANY_ID = 597;
|
||||
|
||||
export function generateCardNumber(): string {
|
||||
let cardId = '';
|
||||
|
||||
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;
|
||||
// serial between 5000 and 99999999999
|
||||
const serial = Math.floor(Math.random() * 99999994999) + 5000;
|
||||
return encodeAccessCode(AMNET_COMPANY_ID, serial, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export * from './api';
|
||||
export * from './card';
|
||||
export * from './gameIds';
|
||||
export * from './gameIds';
|
||||
|
||||
export {decodeAccessCode as DecodeAMAccessCode, encodeAccessCode as EncodeAMAccessCode} from './card-encoding';
|
||||
Reference in New Issue
Block a user