1
This commit is contained in:
parent
2fec28e2cb
commit
c5086a2e20
@ -1,10 +1,20 @@
|
||||
const utils = require('j7/utils');
|
||||
const bcutils = require('j7/bcutils');
|
||||
const basewrap = require('./basewrap');
|
||||
|
||||
class Present extends basewrap.BaseWrap {
|
||||
|
||||
randItem() {
|
||||
let item = null;
|
||||
item = {
|
||||
itemId: 3100,
|
||||
tokenType: bcutils.HERO_TYPE
|
||||
};
|
||||
return item;
|
||||
}
|
||||
|
||||
getCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
4
server/web3helper/package-lock.json
generated
4
server/web3helper/package-lock.json
generated
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "web3server",
|
||||
"name": "web3helper",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "web3server",
|
||||
"name": "web3helper",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@metamask/eth-sig-util": "^4.0.0",
|
||||
|
@ -9,9 +9,10 @@ class Present extends BaseService {
|
||||
async init() {
|
||||
this.gameId = 2006;
|
||||
this.nowTime = utils.getUtcTime();
|
||||
this.tokenTime = nowTime;
|
||||
this.idx = 1;
|
||||
this.tokenTime = this.nowTime;
|
||||
this.idx = 0;
|
||||
|
||||
//console.log(utils.pad(undefined, 2));
|
||||
const {err, conn} = await app.getDbConn('MarketDb0');
|
||||
if (err) {
|
||||
throw 'db error:' + err;
|
||||
@ -31,22 +32,24 @@ class Present extends BaseService {
|
||||
async processList(name, list) {
|
||||
for (let i in list){
|
||||
const presentMeta = list[i];
|
||||
const randItem = item.randItem();
|
||||
const randItem = presentMeta.randItem();
|
||||
if (randItem) {
|
||||
const itemId = randItem['itemId'];
|
||||
const tokenType = randItem['tokenType'];
|
||||
await this.processOne(bcutils.BC_FUNC_GUILD,
|
||||
name,
|
||||
presentMeta,
|
||||
itemId,
|
||||
tokenType,
|
||||
seqId,
|
||||
this.genIdx());
|
||||
for (let ii = 0; ii < presentMeta.getCount(); ++ii) {
|
||||
await this.processOne(bcutils.BC_FUNC_GUILD,
|
||||
name,
|
||||
presentMeta,
|
||||
itemId,
|
||||
tokenType,
|
||||
ii + 1,
|
||||
this.genIdx());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async processOne(funcId, name, presentMeta, itemId, tokenType, seqId) {
|
||||
async processOne(funcId, name, presentMeta, itemId, tokenType, seqId, idx) {
|
||||
const tokenId = bcutils.genTokenId(
|
||||
this.gameId,
|
||||
funcId,
|
||||
@ -54,6 +57,7 @@ class Present extends BaseService {
|
||||
1,
|
||||
idx
|
||||
);
|
||||
console.log(tokenId);
|
||||
const sented = await this.isSented(name, presentMeta, seqId);
|
||||
if (!sented) {
|
||||
const {err} = await this.conn.insert(
|
||||
@ -63,8 +67,8 @@ class Present extends BaseService {
|
||||
['batch_id', name],
|
||||
['row_id', presentMeta['id']],
|
||||
['seq_id', seqId],
|
||||
['account', presentMeta['account']],
|
||||
['game_id', gameId],
|
||||
['account', bcutils.toNormalAddress(presentMeta['account'])],
|
||||
['game_id', this.gameId],
|
||||
|
||||
['bc_mint_itemid', itemId],
|
||||
['bc_mint_token_type', tokenType],
|
||||
@ -92,12 +96,16 @@ class Present extends BaseService {
|
||||
}
|
||||
|
||||
genIdx() {
|
||||
if (idx < bcutils.BC_MAX_TOKEN_IDX) {
|
||||
++idx;
|
||||
let newIdx = this.idx;
|
||||
if (this.idx < bcutils.BC_MAX_TOKEN_IDX) {
|
||||
newIdx = this.idx;
|
||||
++this.idx;
|
||||
} else {
|
||||
idx = 1;
|
||||
this.idx = 0;
|
||||
newIdx = this.idx;
|
||||
++this.tokenTime;
|
||||
}
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
}
|
||||
|
2
third_party/j7
vendored
2
third_party/j7
vendored
@ -1 +1 @@
|
||||
Subproject commit 5eb3c611daf61cdbbacb4e81c73e73ce2d919c06
|
||||
Subproject commit 29150ac5c02664638c888598f658bf9349918926
|
Loading…
x
Reference in New Issue
Block a user