Commit 2255fe81 authored by nanahira's avatar nanahira

js

parent 6b0fc57c
Pipeline #6514 failed with stages
in 5 minutes and 10 seconds
......@@ -71,7 +71,7 @@ class YGOProMessagesHelper {
this.structs = new Map();
for (let name in this.structs_declaration) {
const declaration = this.structs_declaration[name];
let result = struct_1.Struct();
let result = (0, struct_1.Struct)();
for (let field of declaration) {
if (field.encoding) {
switch (field.encoding) {
......@@ -180,7 +180,7 @@ class YGOProMessagesHelper {
}
handlerCollection.get(translatedProto).push(handlerObj);
}
async handleBuffer(messageBuffer, direction, protoFilter, params) {
async handleBuffer(messageBuffer, direction, protoFilter, params, disconnectIfInvalid = false) {
let feedback = null;
let messageLength = 0;
let bufferProto = 0;
......@@ -215,7 +215,14 @@ class YGOProMessagesHelper {
else {
if (messageBuffer.length >= 2 + messageLength) {
const proto = this.constants[direction][bufferProto];
let cancel = proto && protoFilter && underscore_1.default.indexOf(protoFilter, proto) === -1;
let cancel = proto && protoFilter && !protoFilter.includes(proto);
if (cancel && disconnectIfInvalid) {
feedback = {
type: "INVALID_PACKET",
message: `${direction} proto not allowed`
};
break;
}
let buffer = messageBuffer.slice(3, 2 + messageLength);
//console.log(l, direction, proto, cancel);
for (let priority = 0; priority < 4; ++priority) {
......
......@@ -19,7 +19,7 @@ class AthleticChecker {
return deckText;
}
async getAthleticDecks() {
if (this.athleticDeckCache && moment_1.default().diff(this.lastAthleticDeckFetchTime, "seconds") < this.config.ttl) {
if (this.athleticDeckCache && (0, moment_1.default)().diff(this.lastAthleticDeckFetchTime, "seconds") < this.config.ttl) {
return this.athleticDeckCache;
}
const { data } = await axios_1.default.get(this.config.rankURL, {
......@@ -30,7 +30,7 @@ class AthleticChecker {
});
const athleticDecks = data.slice(0, this.config.rankCount).map(m => m.name);
this.athleticDeckCache = athleticDecks;
this.lastAthleticDeckFetchTime = moment_1.default();
this.lastAthleticDeckFetchTime = (0, moment_1.default)();
return athleticDecks;
}
async getDeckType(deck) {
......
......@@ -67,7 +67,7 @@ class DataManager {
}
}
async init() {
this.db = await typeorm_1.createConnection({
this.db = await (0, typeorm_1.createConnection)({
type: "mysql",
synchronize: true,
supportBigNumbers: true,
......@@ -133,7 +133,7 @@ class DataManager {
const replay = new CloudReplay_1.CloudReplay();
replay.id = id;
replay.fromBuffer(buffer);
replay.date = moment_1.default().toDate();
replay.date = (0, moment_1.default)().toDate();
const players = playerInfos.map(p => {
const player = CloudReplayPlayer_1.CloudReplayPlayer.fromPlayerInfo(p);
return player;
......@@ -224,12 +224,12 @@ class DataManager {
if (ban) {
ban.count += count;
const banTime = ban.count > 3 ? Math.pow(2, ban.count - 3) * 2 : 0;
const banDate = moment_1.default(ban.time);
if (moment_1.default().isAfter(banDate)) {
ban.time = moment_1.default().add(banTime, 'm').toDate();
const banDate = (0, moment_1.default)(ban.time);
if ((0, moment_1.default)().isAfter(banDate)) {
ban.time = (0, moment_1.default)().add(banTime, 'm').toDate();
}
else {
ban.time = moment_1.default(banDate).add(banTime, 'm').toDate();
ban.time = (0, moment_1.default)(banDate).add(banTime, 'm').toDate();
}
if (!underscore_1.default.contains(ban.reasons, reason)) {
ban.reasons.push(reason);
......@@ -239,7 +239,7 @@ class DataManager {
else {
ban = new RandomDuelBan_1.RandomDuelBan();
ban.ip = ip;
ban.time = moment_1.default().toDate();
ban.time = (0, moment_1.default)().toDate();
ban.count = count;
ban.reasons = [reason];
ban.needTip = 1;
......@@ -414,7 +414,7 @@ class DataManager {
async saveDuelLog(name, roomId, cloudReplayId, replayFilename, roomMode, duelCount, playerInfos) {
const duelLog = new DuelLog_1.DuelLog();
duelLog.name = name;
duelLog.time = moment_1.default().toDate();
duelLog.time = (0, moment_1.default)().toDate();
duelLog.roomId = roomId;
duelLog.cloudReplayId = cloudReplayId;
duelLog.replayFileName = replayFilename;
......
......@@ -17,7 +17,7 @@ function encodeDeck(deck) {
buffer.writeInt32LE(cardCode, pointer);
pointer += 4;
}
assert_1.default(pointer === bufferSize, `Invalid buffer size. Expected: ${bufferSize}. Got: ${pointer}`);
(0, assert_1.default)(pointer === bufferSize, `Invalid buffer size. Expected: ${bufferSize}. Got: ${pointer}`);
return buffer;
}
exports.encodeDeck = encodeDeck;
......@@ -28,7 +28,7 @@ function decodeDeck(buffer) {
const sideLength = buffer.readInt32LE(pointer);
pointer += 4;
const correctBufferLength = (2 + mainLength + sideLength) * 4;
assert_1.default(buffer.length >= (2 + mainLength + sideLength) * 4, `Invalid buffer size. Expected: ${correctBufferLength}. Got: ${buffer.length}`);
(0, assert_1.default)(buffer.length >= (2 + mainLength + sideLength) * 4, `Invalid buffer size. Expected: ${correctBufferLength}. Got: ${buffer.length}`);
const main = [];
const side = [];
for (let i = 0; i < mainLength; ++i) {
......
......@@ -18,22 +18,22 @@ let Ban = class Ban extends CreateAndUpdateTimeBase_1.CreateAndUpdateTimeBase {
name;
};
__decorate([
typeorm_1.PrimaryGeneratedColumn({ unsigned: true, type: global.PrimaryKeyType || 'bigint' }),
(0, typeorm_1.PrimaryGeneratedColumn)({ unsigned: true, type: global.PrimaryKeyType || 'bigint' }),
__metadata("design:type", Number)
], Ban.prototype, "id", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column({ type: "varchar", length: 64, nullable: true }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)({ type: "varchar", length: 64, nullable: true }),
__metadata("design:type", String)
], Ban.prototype, "ip", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column({ type: "varchar", length: 20, nullable: true }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)({ type: "varchar", length: 20, nullable: true }),
__metadata("design:type", String)
], Ban.prototype, "name", void 0);
Ban = __decorate([
typeorm_1.Entity(),
typeorm_1.Unique(["ip", "name"])
(0, typeorm_1.Entity)(),
(0, typeorm_1.Unique)(["ip", "name"])
], Ban);
exports.Ban = Ban;
//# sourceMappingURL=Ban.js.map
\ No newline at end of file
......@@ -18,15 +18,15 @@ class BasePlayer extends CreateAndUpdateTimeBase_1.CreateAndUpdateTimeBase {
pos;
}
__decorate([
typeorm_1.PrimaryGeneratedColumn({ unsigned: true, type: global.PrimaryKeyType || 'bigint' }),
(0, typeorm_1.PrimaryGeneratedColumn)({ unsigned: true, type: global.PrimaryKeyType || 'bigint' }),
__metadata("design:type", Number)
], BasePlayer.prototype, "id", void 0);
__decorate([
typeorm_1.Column({ type: "varchar", length: 20 }),
(0, typeorm_1.Column)({ type: "varchar", length: 20 }),
__metadata("design:type", String)
], BasePlayer.prototype, "name", void 0);
__decorate([
typeorm_1.Column({ type: "tinyint" }),
(0, typeorm_1.Column)({ type: "tinyint" }),
__metadata("design:type", Number)
], BasePlayer.prototype, "pos", void 0);
exports.BasePlayer = BasePlayer;
......
......@@ -29,7 +29,7 @@ let CloudReplay = class CloudReplay extends CreateAndUpdateTimeBase_1.CreateAndU
}
date;
getDateString() {
return moment_1.default(this.date).format('YYYY-MM-DD HH:mm:ss');
return (0, moment_1.default)(this.date).format('YYYY-MM-DD HH:mm:ss');
}
players;
getPlayerNamesString() {
......@@ -42,24 +42,24 @@ let CloudReplay = class CloudReplay extends CreateAndUpdateTimeBase_1.CreateAndU
}
};
__decorate([
typeorm_1.PrimaryColumn({ unsigned: true, type: global.PrimaryKeyType || 'bigint' }),
(0, typeorm_1.PrimaryColumn)({ unsigned: true, type: global.PrimaryKeyType || 'bigint' }),
__metadata("design:type", Number)
], CloudReplay.prototype, "id", void 0);
__decorate([
typeorm_1.Column({ type: "text" }),
(0, typeorm_1.Column)({ type: "text" }),
__metadata("design:type", String)
], CloudReplay.prototype, "data", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column({ type: "datetime" }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)({ type: "datetime" }),
__metadata("design:type", Date)
], CloudReplay.prototype, "date", void 0);
__decorate([
typeorm_1.OneToMany(() => CloudReplayPlayer_1.CloudReplayPlayer, player => player.cloudReplay),
(0, typeorm_1.OneToMany)(() => CloudReplayPlayer_1.CloudReplayPlayer, player => player.cloudReplay),
__metadata("design:type", Array)
], CloudReplay.prototype, "players", void 0);
CloudReplay = __decorate([
typeorm_1.Entity({
(0, typeorm_1.Entity)({
orderBy: {
date: "DESC"
}
......
......@@ -26,16 +26,16 @@ let CloudReplayPlayer = CloudReplayPlayer_1 = class CloudReplayPlayer extends Ba
}
};
__decorate([
typeorm_1.Index(),
typeorm_1.Column({ type: "varchar", length: 128 }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)({ type: "varchar", length: 128 }),
__metadata("design:type", String)
], CloudReplayPlayer.prototype, "key", void 0);
__decorate([
typeorm_1.ManyToOne(() => CloudReplay_1.CloudReplay, replay => replay.players),
(0, typeorm_1.ManyToOne)(() => CloudReplay_1.CloudReplay, replay => replay.players),
__metadata("design:type", CloudReplay_1.CloudReplay)
], CloudReplayPlayer.prototype, "cloudReplay", void 0);
CloudReplayPlayer = CloudReplayPlayer_1 = __decorate([
typeorm_1.Entity()
(0, typeorm_1.Entity)()
], CloudReplayPlayer);
exports.CloudReplayPlayer = CloudReplayPlayer;
//# sourceMappingURL=CloudReplayPlayer.js.map
\ No newline at end of file
......@@ -16,11 +16,11 @@ class CreateAndUpdateTimeBase {
updateTime;
}
__decorate([
typeorm_1.CreateDateColumn(),
(0, typeorm_1.CreateDateColumn)(),
__metadata("design:type", Date)
], CreateAndUpdateTimeBase.prototype, "createTime", void 0);
__decorate([
typeorm_1.UpdateDateColumn(),
(0, typeorm_1.UpdateDateColumn)(),
__metadata("design:type", Date)
], CreateAndUpdateTimeBase.prototype, "updateTime", void 0);
exports.CreateAndUpdateTimeBase = CreateAndUpdateTimeBase;
......
......@@ -32,12 +32,12 @@ let DuelLog = class DuelLog extends CreateAndUpdateTimeBase_1.CreateAndUpdateTim
const viewPlayers = underscore_1.default.clone(this.players);
viewPlayers.sort((p1, p2) => p1.pos - p2.pos);
const playerString = viewPlayers[0].realName.split("$")[0] + (viewPlayers[2] ? "+" + viewPlayers[2].realName.split("$")[0] : "") + " VS " + (viewPlayers[1] ? viewPlayers[1].realName.split("$")[0] : "AI") + (viewPlayers[3] ? "+" + viewPlayers[3].realName.split("$")[0] : "");
return `<${this.id}> ${playerString} ${moment_1.default(this.time).format("YYYY-MM-DD HH-mm-ss")}`;
return `<${this.id}> ${playerString} ${(0, moment_1.default)(this.time).format("YYYY-MM-DD HH-mm-ss")}`;
}
getViewJSON(tournamentModeSettings) {
const data = {
id: this.id,
time: moment_1.default(this.time).format("YYYY-MM-DD HH:mm:ss"),
time: (0, moment_1.default)(this.time).format("YYYY-MM-DD HH:mm:ss"),
name: this.name + (tournamentModeSettings.show_info ? " (Duel:" + this.duelCount + ")" : ""),
roomid: this.roomId,
cloud_replay_id: "R#" + this.cloudReplayId,
......@@ -56,46 +56,46 @@ let DuelLog = class DuelLog extends CreateAndUpdateTimeBase_1.CreateAndUpdateTim
}
};
__decorate([
typeorm_1.PrimaryGeneratedColumn({ unsigned: true, type: global.PrimaryKeyType || 'bigint' }),
(0, typeorm_1.PrimaryGeneratedColumn)({ unsigned: true, type: global.PrimaryKeyType || 'bigint' }),
__metadata("design:type", Number)
], DuelLog.prototype, "id", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column("datetime"),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)("datetime"),
__metadata("design:type", Date)
], DuelLog.prototype, "time", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column({ type: "varchar", length: 20 }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)({ type: "varchar", length: 20 }),
__metadata("design:type", String)
], DuelLog.prototype, "name", void 0);
__decorate([
typeorm_1.Column("int"),
(0, typeorm_1.Column)("int"),
__metadata("design:type", Number)
], DuelLog.prototype, "roomId", void 0);
__decorate([
typeorm_1.Column(global.PrimaryKeyType || 'bigint'),
(0, typeorm_1.Column)(global.PrimaryKeyType || 'bigint'),
__metadata("design:type", Number)
], DuelLog.prototype, "cloudReplayId", void 0);
__decorate([
typeorm_1.Column({ type: "varchar", length: 256 }),
(0, typeorm_1.Column)({ type: "varchar", length: 256 }),
__metadata("design:type", String)
], DuelLog.prototype, "replayFileName", void 0);
__decorate([
typeorm_1.Column("tinyint", { unsigned: true }),
(0, typeorm_1.Column)("tinyint", { unsigned: true }),
__metadata("design:type", Number)
], DuelLog.prototype, "roomMode", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column("tinyint", { unsigned: true }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)("tinyint", { unsigned: true }),
__metadata("design:type", Number)
], DuelLog.prototype, "duelCount", void 0);
__decorate([
typeorm_1.OneToMany(() => DuelLogPlayer_1.DuelLogPlayer, player => player.duelLog),
(0, typeorm_1.OneToMany)(() => DuelLogPlayer_1.DuelLogPlayer, player => player.duelLog),
__metadata("design:type", Array)
], DuelLog.prototype, "players", void 0);
DuelLog = __decorate([
typeorm_1.Entity({
(0, typeorm_1.Entity)({
orderBy: {
id: "DESC"
}
......
......@@ -30,20 +30,20 @@ let DuelLogPlayer = DuelLogPlayer_1 = class DuelLogPlayer extends BasePlayer_1.B
this.startDeckBuffer = null;
return;
}
this.startDeckBuffer = DeckEncoder_1.encodeDeck(deck).toString("base64");
this.startDeckBuffer = (0, DeckEncoder_1.encodeDeck)(deck).toString("base64");
}
getStartDeck() {
return DeckEncoder_1.decodeDeck(Buffer.from(this.startDeckBuffer, "base64"));
return (0, DeckEncoder_1.decodeDeck)(Buffer.from(this.startDeckBuffer, "base64"));
}
setCurrentDeck(deck) {
if (deck === null) {
this.currentDeckBuffer = null;
return;
}
this.currentDeckBuffer = DeckEncoder_1.encodeDeck(deck).toString("base64");
this.currentDeckBuffer = (0, DeckEncoder_1.encodeDeck)(deck).toString("base64");
}
getCurrentDeck() {
return DeckEncoder_1.decodeDeck(Buffer.from(this.currentDeckBuffer, "base64"));
return (0, DeckEncoder_1.decodeDeck)(Buffer.from(this.currentDeckBuffer, "base64"));
}
duelLog;
static fromDuelLogPlayerInfo(info) {
......@@ -63,49 +63,49 @@ let DuelLogPlayer = DuelLogPlayer_1 = class DuelLogPlayer extends BasePlayer_1.B
}
};
__decorate([
typeorm_1.Index(),
typeorm_1.Column({ type: "varchar", length: 20 }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)({ type: "varchar", length: 20 }),
__metadata("design:type", String)
], DuelLogPlayer.prototype, "realName", void 0);
__decorate([
typeorm_1.Column({ type: "varchar", length: 64, nullable: true }),
(0, typeorm_1.Column)({ type: "varchar", length: 64, nullable: true }),
__metadata("design:type", String)
], DuelLogPlayer.prototype, "ip", void 0);
__decorate([
typeorm_1.Column("tinyint", { unsigned: true }),
(0, typeorm_1.Column)("tinyint", { unsigned: true }),
__metadata("design:type", Number)
], DuelLogPlayer.prototype, "isFirst", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column("tinyint"),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)("tinyint"),
__metadata("design:type", Number)
], DuelLogPlayer.prototype, "score", void 0);
__decorate([
typeorm_1.Column("int", { nullable: true }),
(0, typeorm_1.Column)("int", { nullable: true }),
__metadata("design:type", Number)
], DuelLogPlayer.prototype, "lp", void 0);
__decorate([
typeorm_1.Column("smallint", { nullable: true }),
(0, typeorm_1.Column)("smallint", { nullable: true }),
__metadata("design:type", Number)
], DuelLogPlayer.prototype, "cardCount", void 0);
__decorate([
typeorm_1.Column("text", { nullable: true }),
(0, typeorm_1.Column)("text", { nullable: true }),
__metadata("design:type", String)
], DuelLogPlayer.prototype, "startDeckBuffer", void 0);
__decorate([
typeorm_1.Column("text", { nullable: true }),
(0, typeorm_1.Column)("text", { nullable: true }),
__metadata("design:type", String)
], DuelLogPlayer.prototype, "currentDeckBuffer", void 0);
__decorate([
typeorm_1.Column("tinyint"),
(0, typeorm_1.Column)("tinyint"),
__metadata("design:type", Number)
], DuelLogPlayer.prototype, "winner", void 0);
__decorate([
typeorm_1.ManyToOne(() => DuelLog_1.DuelLog, duelLog => duelLog.players),
(0, typeorm_1.ManyToOne)(() => DuelLog_1.DuelLog, duelLog => duelLog.players),
__metadata("design:type", DuelLog_1.DuelLog)
], DuelLogPlayer.prototype, "duelLog", void 0);
DuelLogPlayer = DuelLogPlayer_1 = __decorate([
typeorm_1.Entity()
(0, typeorm_1.Entity)()
], DuelLogPlayer);
exports.DuelLogPlayer = DuelLogPlayer;
//# sourceMappingURL=DuelLogPlayer.js.map
\ No newline at end of file
......@@ -26,27 +26,27 @@ let RandomDuelBan = class RandomDuelBan extends CreateAndUpdateTimeBase_1.Create
}
};
__decorate([
typeorm_1.PrimaryColumn({ type: "varchar", length: 64 }),
(0, typeorm_1.PrimaryColumn)({ type: "varchar", length: 64 }),
__metadata("design:type", String)
], RandomDuelBan.prototype, "ip", void 0);
__decorate([
typeorm_1.Column("datetime"),
(0, typeorm_1.Column)("datetime"),
__metadata("design:type", Date)
], RandomDuelBan.prototype, "time", void 0);
__decorate([
typeorm_1.Column("smallint"),
(0, typeorm_1.Column)("smallint"),
__metadata("design:type", Number)
], RandomDuelBan.prototype, "count", void 0);
__decorate([
typeorm_1.Column({ type: "simple-array" }),
(0, typeorm_1.Column)({ type: "simple-array" }),
__metadata("design:type", Array)
], RandomDuelBan.prototype, "reasons", void 0);
__decorate([
typeorm_1.Column({ type: "tinyint", unsigned: true }),
(0, typeorm_1.Column)({ type: "tinyint", unsigned: true }),
__metadata("design:type", Number)
], RandomDuelBan.prototype, "needTip", void 0);
RandomDuelBan = __decorate([
typeorm_1.Entity()
(0, typeorm_1.Entity)()
], RandomDuelBan);
exports.RandomDuelBan = RandomDuelBan;
//# sourceMappingURL=RandomDuelBan.js.map
\ No newline at end of file
......@@ -49,30 +49,30 @@ let RandomDuelScore = class RandomDuelScore extends CreateAndUpdateTimeBase_1.Cr
}
};
__decorate([
typeorm_1.PrimaryColumn({ type: "varchar", length: 20 }),
(0, typeorm_1.PrimaryColumn)({ type: "varchar", length: 20 }),
__metadata("design:type", String)
], RandomDuelScore.prototype, "name", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column("int", { unsigned: true, default: 0 }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)("int", { unsigned: true, default: 0 }),
__metadata("design:type", Number)
], RandomDuelScore.prototype, "winCount", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column("int", { unsigned: true, default: 0 }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)("int", { unsigned: true, default: 0 }),
__metadata("design:type", Number)
], RandomDuelScore.prototype, "loseCount", void 0);
__decorate([
typeorm_1.Index(),
typeorm_1.Column("int", { unsigned: true, default: 0 }),
(0, typeorm_1.Index)(),
(0, typeorm_1.Column)("int", { unsigned: true, default: 0 }),
__metadata("design:type", Number)
], RandomDuelScore.prototype, "fleeCount", void 0);
__decorate([
typeorm_1.Column("int", { unsigned: true, default: 0 }),
(0, typeorm_1.Column)("int", { unsigned: true, default: 0 }),
__metadata("design:type", Number)
], RandomDuelScore.prototype, "winCombo", void 0);
RandomDuelScore = __decorate([
typeorm_1.Entity()
(0, typeorm_1.Entity)()
], RandomDuelScore);
exports.RandomDuelScore = RandomDuelScore;
//# sourceMappingURL=RandomDuelScore.js.map
\ No newline at end of file
......@@ -17,15 +17,15 @@ let User = class User extends CreateAndUpdateTimeBase_1.CreateAndUpdateTimeBase
chatColor;
};
__decorate([
typeorm_1.PrimaryColumn({ type: "varchar", length: 128 }),
(0, typeorm_1.PrimaryColumn)({ type: "varchar", length: 128 }),
__metadata("design:type", String)
], User.prototype, "key", void 0);
__decorate([
typeorm_1.Column("varchar", { length: 16, nullable: true }),
(0, typeorm_1.Column)("varchar", { length: 16, nullable: true }),
__metadata("design:type", String)
], User.prototype, "chatColor", void 0);
User = __decorate([
typeorm_1.Entity()
(0, typeorm_1.Entity)()
], User);
exports.User = User;
//# sourceMappingURL=User.js.map
\ No newline at end of file
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