Pokemon Id

<head>
<title>ポケモン: プレイヤーID関連情報鑑別</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0"/>
<style>
body {
    color: #333;
    font-family: sans-serif;
    font-size: .8em;
}
:root * {
    scrollbar-color: rgba(50, 50, 50, 0.3) rgba(0, 0, 0, 0);
    scrollbar-width: thin;
}
::-webkit-scrollbar {
    border: solid 1px rgba(0, 0, 0, 0);
    height: 9px;
    width: 9px;
}
::-webkit-scrollbar-thumb {
    background: rgba(50, 50, 50, 0.3);
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0);
}
 
.content {
    max-width: 35em;
}
.table {
    box-shadow: 1px 1px 3px #aaa;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    margin: .75em 0;
    padding: 1em;
}
button {
    appearance: none;
    background: #efefef;
    border-radius: 3px;
    cursor: pointer;
    margin: .75em 0;
}
textarea {
    border-radius: 3px;
    height: 15em;
    resize: vertical;
    width: 100%;
}
input,
textarea,
button {
    border: 1px solid #bbb;
    transition: all .25s, height 0s;
}
input:hover,
input:active,
input:focus,
textarea:hover,
textarea:active,
textarea:focus,
button:hover,
button:active,
button:focus {
    border: 1px solid #2196f3;
    outline: none;
}
</style>
<script type="module">
var [
  tid,
  sid
] = [...document.querySelectorAll('input')];
 
var [
  calc
] = [...document.querySelectorAll('button')];
 
var [
  result
] = [...document.querySelectorAll('textarea')];
 
/* ****** */
var _id = n => ('0'.repeat(15) + Number(n).toString(2)).slice(-16);
 
var _xor = (omote_id, ura_id) => parseInt(_id(omote_id), 2) ^ parseInt(_id(ura_id), 2);
 
var _encr = (a, b) => [...Array(b-a+1)].map((v,i)=>('0'.repeat(7)+(a+i).toString(16)).slice(-8).split(/([\da-f]{4})/i).filter(v=>v)).map(v=>[...v.map(w=>parseInt(w,16)), '0x'+v[0]+v[1]]);
 
var _melo = (omote_id, ura_id) => {
  var _a = {
    'メロメロボディ♂ (不問)': _encr(0x00000000, 0x00000018),
    'メロメロボディ♀ (♂7:♀1)': _encr(0x00000032, 0x0000004A),
    'メロメロボディ♀ (♂1:♀1)': _encr(0x00000096, 0x000000AE),
    'メロメロボディ♀ (♂1:♀3)': _encr(0x000000C8, 0x000000E0),
    'メロメロボディ♀ (♂3:♀1)': _encr(0x0000004B, 0x00000073)
  };
  var _b = [];
  Object.keys(_a).forEach(k=>{
    var _ = _a[k].filter(m=>(Number(omote_id)^Number(ura_id)^m[0]^m[1])<=7).map(v=>{
      var o = {
        abl: parseInt(v[2][9], 16) % 2 + 1,
        nat: ['がんばりや','さみしがり','ゆうかん ','いじっぱり','やんちゃ ','ずぶとい ','すなお  ','のんき  ','わんぱく ','のうてんき','おくびょう','せっかち ','まじめ  ','ようき  ','むじゃき ','ひかえめ ','おっとり ','れいせい ','てれや  ','うっかりや','おだやか ','おとなしい','なまいき ','しんちょう','きまぐれ '][parseInt(v[2], 16) % 25]
      };
      return `特性${o.abl} : ${o.nat} (${v[2]} : ${(Number(omote_id)^Number(ura_id)^v[0]^v[1])==0 ? '菱' : '星'}形 (Gen 8))`;
    });
 
    _.length && _b.push(` * ${k}:\n   * ${_.join('\n   * ')}`);
  });
  _b.length || _b.push('不可')
  return _b;
}
 
var _tree = (omote_id, ura_id) => {
  var _ = n => _id(n).split(/(\d{8})/).filter(v => v).map(v => parseInt(v, 2) % 21)
 
  var _x = [...(isNaN('' + ura_id) || ura_id=='') ? [] : _(ura_id), ..._(omote_id)];
 
  var _y = ['205ばんどうろ南','205ばんどうろ北','206ばんどうろ','207ばんどうろ','208ばんどうろ','209ばんどうろ','210ばんどうろ南','210ばんどうろ北','211ばんどうろ','212ばんどうろ北','212ばんどうろ南','213ばんどうろ','214ばんどうろ','215ばんどうろ','218ばんどうろ','221ばんどうろ','222ばんどうろ','たにまのはつでんしょ','ハクタイのもり (外側)','タタラせいてつじょ','ソノオのはなばたけ'];
 
  while(_x.length !== _x.filter((v, i, a) => !~v || a.indexOf(v) == i).length) {
    _x = _x.map((v, i, a) => (!~v || a.indexOf(v) == i) ? v : v + 1);
  }
 
  return _x.sort().map(v =>` * ${ _y[v]}`)
};
 
calc.onclick = e => {
  tid.value && (result.value = [
    `表ID (二進数):\n${_id(tid.value)}`,
    ...sid.value ? [
      `裏ID (二進数):\n${_id(sid.value)}`,
      `表ID XOR 裏ID:\n${tid.value ^ sid.value}\n(※"表ID XOR 裏ID XOR 性格値上位4桁 XOR 性格値上位4桁"が7 (Gen 3-5)あるいは15 (Gen 6)以下の時に色違い)`,
      `メロメロボディ乱数 (Gen 4):\n${_melo(tid.value,sid.value).join('\n')}`
    ] : [],
    `甘い香りのする木 (Gen 4: DPPt):\n${_tree(tid.value,sid.value).join('\n')}`
  ].join('\n\n'));
}
 
var def = (function(){
    var o = {};
    location.search.slice(1).split('&').filter(function(v) {return v}).forEach(function(v) {
        var _ = v.match(/(.+?)=(.*)/);
        o[_[1]] = _[2];
    });
    return o;
})();
 
def.tid && (tid.value = def.tid, def.sid && (sid.value = def.sid), calc.click());
</script>
</head>
<body>
<h1>ポケモン: プレイヤーID関連情報鑑別</h1>
<div class="content">
<div class="table">
<div class="item"><span>表ID:</span><input type="number"/></div>
<div class="item"><span>裏ID:</span><input type="number" placeholder="無記入でも可"/></div>
<button>計算</button>
<textarea></textarea>
</div>
</div>
</body>
特に明記しない限り、このページのコンテンツは次のライセンスの下にあります: Creative Commons Attribution-ShareAlike 3.0 License