[steemmonsters] 내가 없는 카드 목록 정보 확인하기
서두
- 개인적으로 기록 보관 목적으로 글을 남겨 봅니다.
- 소스는 필요한 부분이 있다면 마음것 사용하셔도 됩니다.
개요
내가 없는 카드 목록 정보를 손쉽게 확인하기 위해 만들어 봤습니다. 추후 카드 구매 시 우선순위를 두기 위함 입니다. 또한 자동 대전을 구성할 때 존재하지 않는 카드 정보는 제외한 상태에서 댁을 구성하는 등 다양한 곳에서 사용될 수 잇습니다.
처리 로직
- 전체 카드 목록 정보 조회
- 내 카드 목록 정보 조회
- 내 카드 목록을 id 기준으로 distinct 후, 전체 카드 id 목록에서 없는 정보만 도출
- 없는 카드 목록 정보를 출력
소스코드
소스코드는 nodejs 로 작성 되었으며, 전체를 기록하면 분량이 많아져 일부만 표현될 수 있습니다.
async function init(){
const RARITY = ['COMMON','RARE', 'EPIC', 'LEGENDARY'];
let author = process.argv[2];
author = author!=undefined ? author : 'wonsama';
let details = await sm_cards.details();
let cards = (await sm_cards.collection(author)).cards;
cards = cards
.map(x=>x.card_detail_id)
.filter((value, index, self)=>self.indexOf(value)===index);
cards.sort((a,b)=>parseInt(a)-parseInt(b));
let excepts = [];
for(let i=1;i<=details.length;i++){
if(!cards.includes(i)){
excepts.push(i);
}
}
console.log();
for(let idx of excepts){
// DETAILS
let c = details[idx-1];
console.log(`${c.id.toString().padEnd(3,' ')} / ${c.name.padEnd(20,' ')} / ${c.color.padEnd(5,' ')} / ${RARITY[c.rarity-1].padEnd(10,' ')}`);
}
console.log(excepts.join(', '));
console.log();
}
init();
0
0
0.000
Thank you for your continued support towards JJM. For each 1000 JJM you are holding, you can get an additional 1% of upvote. 10,000JJM would give you a 11% daily voting from the 700K SP virus707 account.
#wdice
Posted using Partiko Android
#wdice
#wdice
#wdice