Commit a958acc5 authored by nanahira's avatar nanahira

fix repo url and >>

parent 84a2927e
...@@ -43,8 +43,8 @@ export default class YGOProDeck { ...@@ -43,8 +43,8 @@ export default class YGOProDeck {
const value = const value =
buf[i] | (buf[i + 1] << 8) | (buf[i + 2] << 16) | (buf[i + 3] << 24); buf[i] | (buf[i + 1] << 8) | (buf[i + 2] << 16) | (buf[i + 3] << 24);
const id = value & 0xfffffff; const id = value & 0xfffffff;
const type = (value >> 28) & 0x3; const type = (value >>> 28) & 0x3;
const count = ((value >> 30) & 0x3) + 1; const count = ((value >>> 30) & 0x3) + 1;
const cards = [this.main, this.extra, this.side][type]; const cards = [this.main, this.extra, this.side][type];
for (let j = 0; j < count; j++) { for (let j = 0; j < count; j++) {
cards.push(id); cards.push(id);
......
...@@ -16,15 +16,15 @@ ...@@ -16,15 +16,15 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://code.mycard.moe/3rdeye/myproject.git" "url": "https://code.mycard.moe/mycard/ygopro-deck-encode.git"
}, },
"author": "Nanahira <nanahira@momobako.com>", "author": "Nanahira <nanahira@momobako.com>",
"license": "MIT", "license": "MIT",
"keywords": [], "keywords": [],
"bugs": { "bugs": {
"url": "https://code.mycard.moe/3rdeye/myproject/issues" "url": "https://code.mycard.moe/mycard/ygopro-deck-encode/issues"
}, },
"homepage": "https://code.mycard.moe/3rdeye/myproject", "homepage": "https://code.mycard.moe/mycard/ygopro-deck-encode",
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [
"js", "js",
......
...@@ -14,28 +14,28 @@ export class BufferWriter { ...@@ -14,28 +14,28 @@ export class BufferWriter {
} }
writeUint32LE(value: number) { writeUint32LE(value: number) {
this.buffer[this.pointer++] = value & 0xff; this.buffer[this.pointer++] = value & 0xff;
this.buffer[this.pointer++] = (value >> 8) & 0xff; this.buffer[this.pointer++] = (value >>> 8) & 0xff;
this.buffer[this.pointer++] = (value >> 16) & 0xff; this.buffer[this.pointer++] = (value >>> 16) & 0xff;
this.buffer[this.pointer++] = (value >> 24) & 0xff; this.buffer[this.pointer++] = (value >>> 24) & 0xff;
return this; return this;
} }
writeUint32BE(value: number) { writeUint32BE(value: number) {
this.buffer[this.pointer++] = (value >> 24) & 0xff; this.buffer[this.pointer++] = (value >>> 24) & 0xff;
this.buffer[this.pointer++] = (value >> 16) & 0xff; this.buffer[this.pointer++] = (value >>> 16) & 0xff;
this.buffer[this.pointer++] = (value >> 8) & 0xff; this.buffer[this.pointer++] = (value >>> 8) & 0xff;
this.buffer[this.pointer++] = value & 0xff; this.buffer[this.pointer++] = value & 0xff;
return this; return this;
} }
writeUint16LE(value: number) { writeUint16LE(value: number) {
this.buffer[this.pointer++] = value & 0xff; this.buffer[this.pointer++] = value & 0xff;
this.buffer[this.pointer++] = (value >> 8) & 0xff; this.buffer[this.pointer++] = (value >>> 8) & 0xff;
return this; return this;
} }
writeUint16BE(value: number) { writeUint16BE(value: number) {
this.buffer[this.pointer++] = (value >> 8) & 0xff; this.buffer[this.pointer++] = (value >>> 8) & 0xff;
this.buffer[this.pointer++] = value & 0xff; this.buffer[this.pointer++] = value & 0xff;
return this; return this;
} }
......
...@@ -19,23 +19,23 @@ describe('Sample test.', () => { ...@@ -19,23 +19,23 @@ describe('Sample test.', () => {
'base64', 'base64',
); );
expect(buf.readUInt32LE(0) & 0xfffffff).toBe(123); expect(buf.readUInt32LE(0) & 0xfffffff).toBe(123);
expect((buf.readUInt32LE(0) >> 28) & 0x3).toBe(0); expect((buf.readUInt32LE(0) >>> 28) & 0x3).toBe(0);
expect(((buf.readUInt32LE(0) >> 30) & 0x3) + 1).toBe(3); expect(((buf.readUInt32LE(0) >>> 30) & 0x3) + 1).toBe(3);
expect(buf.readUInt32LE(4) & 0xfffffff).toBe(456); expect(buf.readUInt32LE(4) & 0xfffffff).toBe(456);
expect((buf.readUInt32LE(4) >> 28) & 0x3).toBe(0); expect((buf.readUInt32LE(4) >>> 28) & 0x3).toBe(0);
expect(((buf.readUInt32LE(4) >> 30) & 0x3) + 1).toBe(2); expect(((buf.readUInt32LE(4) >>> 30) & 0x3) + 1).toBe(2);
expect(buf.readUInt32LE(8) & 0xfffffff).toBe(789); expect(buf.readUInt32LE(8) & 0xfffffff).toBe(789);
expect((buf.readUInt32LE(8) >> 28) & 0x3).toBe(0); expect((buf.readUInt32LE(8) >>> 28) & 0x3).toBe(0);
expect(((buf.readUInt32LE(8) >> 30) & 0x3) + 1).toBe(1); expect(((buf.readUInt32LE(8) >>> 30) & 0x3) + 1).toBe(1);
expect(buf.readUInt32LE(12) & 0xfffffff).toBe(1234); expect(buf.readUInt32LE(12) & 0xfffffff).toBe(1234);
expect((buf.readUInt32LE(12) >> 28) & 0x3).toBe(1); expect((buf.readUInt32LE(12) >>> 28) & 0x3).toBe(1);
expect(((buf.readUInt32LE(12) >> 30) & 0x3) + 1).toBe(1); expect(((buf.readUInt32LE(12) >>> 30) & 0x3) + 1).toBe(1);
expect(buf.readUInt32LE(16) & 0xfffffff).toBe(5678); expect(buf.readUInt32LE(16) & 0xfffffff).toBe(5678);
expect((buf.readUInt32LE(16) >> 28) & 0x3).toBe(1); expect((buf.readUInt32LE(16) >>> 28) & 0x3).toBe(1);
expect(((buf.readUInt32LE(16) >> 30) & 0x3) + 1).toBe(1); expect(((buf.readUInt32LE(16) >>> 30) & 0x3) + 1).toBe(1);
expect(buf.readUInt32LE(20) & 0xfffffff).toBe(12345); expect(buf.readUInt32LE(20) & 0xfffffff).toBe(12345);
expect((buf.readUInt32LE(20) >> 28) & 0x3).toBe(2); expect((buf.readUInt32LE(20) >>> 28) & 0x3).toBe(2);
expect(((buf.readUInt32LE(20) >> 30) & 0x3) + 1).toBe(1); expect(((buf.readUInt32LE(20) >>> 30) & 0x3) + 1).toBe(1);
expect(buf.length).toBe(24); expect(buf.length).toBe(24);
const decoded = new YGOProDeck().fromEncodedString(encoded); const decoded = new YGOProDeck().fromEncodedString(encoded);
expect(decoded.main).toStrictEqual(deck.main); expect(decoded.main).toStrictEqual(deck.main);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment