Commit a0c59744 authored by nanahira's avatar nanahira

Merge branch 'master' into ai-play

parents 067acae9 155224ee
Pipeline #10038 failed with stages
in 84 minutes and 47 seconds
......@@ -45,7 +45,7 @@ class AthleticChecker {
try {
const athleticDecks = await this.getAthleticDecks();
const deckType = await this.getDeckType(deck);
const athletic = athleticDecks.includes(deckType);
const athletic = athleticDecks.findIndex(d => d === deckType) + 1;
return { success: true, athletic, message: null };
}
catch (e) {
......
......@@ -21,7 +21,7 @@ interface AthleticDecksReturnData {
interface ReturnMessage {
success: boolean;
athletic?: boolean;
athletic?: number;
message: string;
}
......@@ -63,8 +63,8 @@ export class AthleticChecker {
try {
const athleticDecks = await this.getAthleticDecks();
const deckType = await this.getDeckType(deck);
const athletic = athleticDecks.includes(deckType);
return { success: true, athletic, message: null }
const athletic = athleticDecks.findIndex(d => d === deckType) + 1;
return { success: true, athletic, message: null };
} catch (e) {
return { success: false, message: e.toString() };
}
......
......@@ -220,6 +220,7 @@
"source": "mycard-athletic"
},
"rankCount": 10,
"banCount": 0,
"ttl": 600
},
"test_mode": {
......
......@@ -208,6 +208,8 @@
"stand_bot_removed": "Deck resetted.",
"refresh_success": "Refresh field succeeded.",
"refresh_failed": "Refresh field failed.",
"banned_athletic_deck_part1": "Entertainment Mode does not allow top ",
"banned_athletic_deck_part2": " popular meta decks. Please change your deck.",
"using_athletic_deck": " is using a competitive deck."
},
"es-es": {
......@@ -565,6 +567,8 @@
"stand_bot_removed": "已重置卡组。",
"refresh_success": "刷新场面成功。",
"refresh_fail": "刷新场面失败。",
"banned_athletic_deck_part1": "娱乐匹配中禁止使用使用数前",
"banned_athletic_deck_part2": "的竞技卡组。请更换卡组。",
"using_athletic_deck": " 正在使用竞技卡组。"
},
"ko-kr": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,19 +11,16 @@
],
"author": "zh99998 <zh99998@gmail.com>, mercury233 <me@mercury233.me>, Nanahira <78877@qq.com>",
"dependencies": {
"@types/bunyan": "^1.8.6",
"@types/node": "^14.0.13",
"@types/underscore": "^1.10.24",
"async": "^3.2.0",
"axios": "^0.19.2",
"bunyan": "^1.8.14",
"challonge": "latest",
"challonge": "^2.2.0",
"coffeescript": "^2.5.1",
"deepmerge": "latest",
"formidable": "latest",
"geoip-country-lite": "latest",
"deepmerge": "^4.2.2",
"formidable": "^2.0.1",
"geoip-country-lite": "^1.0.0",
"jszip": "^3.5.0",
"load-json-file": "latest",
"load-json-file": "^6.2.0",
"lzma": "^2.3.2",
"moment": "^2.29.1",
"mysql": "^2.18.1",
......@@ -32,12 +29,11 @@
"q": "^1.5.1",
"querystring": "^0.2.0",
"reflect-metadata": "^0.1.13",
"request": "latest",
"sqlite3": "latest",
"request": "^2.88.2",
"sqlite3": "^5.0.2",
"typeorm": "^0.2.29",
"typescript": "^4.0.5",
"underscore": "^1.11.0",
"underscore.string": "latest",
"underscore.string": "^3.3.6",
"ws": "^1.1.1"
},
"license": "AGPL-3.0",
......@@ -48,5 +44,11 @@
"pre": "node ygopro-pre.js",
"updated": "node ygopro-update.js",
"webhook": "node ygopro-webhook.js"
},
"devDependencies": {
"@types/bunyan": "^1.8.8",
"@types/node": "^17.0.19",
"@types/underscore": "^1.11.4",
"typescript": "^4.5.5"
}
}
......@@ -1114,7 +1114,7 @@ CLIENT_is_able_to_reconnect = global.CLIENT_is_able_to_reconnect = (client, deck
if client.system_kicked
return false
disconnect_info = disconnect_list[CLIENT_get_authorize_key(client)]
unless disconnect_info
unless disconnect_info and disconnect_info.deckbuf
return false
room = ROOM_all[disconnect_info.room_id]
if !room
......@@ -2881,34 +2881,38 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2)
room.dueling_players[pos].lp -= val
room.dueling_players[pos].lp = 0 if room.dueling_players[pos].lp < 0
if 0 < room.dueling_players[pos].lp <= 100
ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK)
if room.dueling_players[pos]
room.dueling_players[pos].lp -= val
room.dueling_players[pos].lp = 0 if room.dueling_players[pos].lp < 0
if 0 < room.dueling_players[pos].lp <= 100
ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK)
if msg_name == 'RECOVER' and client.pos == 0
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2)
room.dueling_players[pos].lp += val
if room.dueling_players[pos]
room.dueling_players[pos].lp += val
if msg_name == 'LPUPDATE' and client.pos == 0
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2)
room.dueling_players[pos].lp = val
if room.dueling_players[pos]
room.dueling_players[pos].lp = val
if msg_name == 'PAY_LPCOST' and client.pos == 0
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2)
room.dueling_players[pos].lp -= val
room.dueling_players[pos].lp = 0 if room.dueling_players[pos].lp < 0
if 0 < room.dueling_players[pos].lp <= 100
ygopro.stoc_send_chat_to_room(room, "${lp_low_self}", ygopro.constants.COLORS.PINK)
if room.dueling_players[pos]
room.dueling_players[pos].lp -= val
room.dueling_players[pos].lp = 0 if room.dueling_players[pos].lp < 0
if 0 < room.dueling_players[pos].lp <= 100
ygopro.stoc_send_chat_to_room(room, "${lp_low_self}", ygopro.constants.COLORS.PINK)
#track card count
#todo: track card count in tag mode
......@@ -3668,44 +3672,60 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)->
struct.set("deckbuf", [4392470, 4392470])
ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED)
client.deck_good = false
else if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.deck_check and !client.is_local
decks = await fs.promises.readdir(settings.modules.tournament_mode.deck_path)
if decks.length
struct.set("mainc", 1)
struct.set("sidec", 1)
struct.set("deckbuf", [4392470, 4392470])
buffer = struct.buffer
found_deck=false
for deck in decks
if deck_name_match(deck, client.name)
found_deck=deck
if found_deck
deck_text = await fs.promises.readFile(settings.modules.tournament_mode.deck_path+found_deck,{encoding:"ASCII"})
deck_array=deck_text.split("\n")
deck_main=[]
deck_side=[]
current_deck=deck_main
for line in deck_array
if line.indexOf("!side")>=0
current_deck=deck_side
card=parseInt(line)
current_deck.push(card) unless isNaN(card)
if _.isEqual(buff_main, deck_main) and _.isEqual(buff_side, deck_side)
deckbuf=deck_main.concat(deck_side)
struct.set("mainc", deck_main.length)
struct.set("sidec", deck_side.length)
struct.set("deckbuf", deckbuf)
buffer = struct.buffer
#log.info("deck ok: " + client.name)
ygopro.stoc_send_chat(client, "${deck_correct_part1} #{found_deck} ${deck_correct_part2}", ygopro.constants.COLORS.BABYBLUE)
else
#log.info("bad deck: " + client.name + " / " + buff_main + " / " + buff_side)
ygopro.stoc_send_chat(client, "${deck_incorrect_part1} #{found_deck} ${deck_incorrect_part2}", ygopro.constants.COLORS.RED)
return false
else
if room.arena and settings.modules.athletic_check.enabled and settings.modules.athletic_check.banCount
athleticCheckResult = await athleticChecker.checkAthletic({main: buff_main, side: buff_side})
if athleticCheckResult.success
if athleticCheckResult.athletic and athleticCheckResult.athletic <= settings.modules.athletic_check.banCount
struct.set("mainc", 1)
struct.set("sidec", 1)
struct.set("deckbuf", [4392470, 4392470])
ygopro.stoc_send_chat(client, "${banned_athletic_deck_part1}#{settings.modules.athletic_check.banCount}${banned_athletic_deck_part2}", ygopro.constants.COLORS.RED)
client.deck_good = false
return false
else
#log.info("player deck not found: " + client.name)
ygopro.stoc_send_chat(client, "#{client.name}${deck_not_found}", ygopro.constants.COLORS.RED)
client.deck_good = false
log.warn("GET ATHLETIC FAIL", client.name, athleticCheckResult.message)
if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.deck_check and !client.is_local
decks = await fs.promises.readdir(settings.modules.tournament_mode.deck_path)
if decks.length
struct.set("mainc", 1)
struct.set("sidec", 1)
struct.set("deckbuf", [4392470, 4392470])
buffer = struct.buffer
found_deck=false
for deck in decks
if deck_name_match(deck, client.name)
found_deck=deck
if found_deck
deck_text = await fs.promises.readFile(settings.modules.tournament_mode.deck_path+found_deck,{encoding:"ASCII"})
deck_array=deck_text.split("\n")
deck_main=[]
deck_side=[]
current_deck=deck_main
for line in deck_array
if line.indexOf("!side")>=0
current_deck=deck_side
card=parseInt(line)
current_deck.push(card) unless isNaN(card)
if _.isEqual(buff_main, deck_main) and _.isEqual(buff_side, deck_side)
deckbuf=deck_main.concat(deck_side)
struct.set("mainc", deck_main.length)
struct.set("sidec", deck_side.length)
struct.set("deckbuf", deckbuf)
buffer = struct.buffer
#log.info("deck ok: " + client.name)
ygopro.stoc_send_chat(client, "${deck_correct_part1} #{found_deck} ${deck_correct_part2}", ygopro.constants.COLORS.BABYBLUE)
else
#log.info("bad deck: " + client.name + " / " + buff_main + " / " + buff_side)
ygopro.stoc_send_chat(client, "${deck_incorrect_part1} #{found_deck} ${deck_incorrect_part2}", ygopro.constants.COLORS.RED)
client.deck_good = false
return false
else
#log.info("player deck not found: " + client.name)
ygopro.stoc_send_chat(client, "#{client.name}${deck_not_found}", ygopro.constants.COLORS.RED)
client.deck_good = false
return false
if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and client.deck_good and !client.is_local and !client.bot_bound
client.bot_bound = true
ygopro.stoc_send_chat(client, "${stand_bot_added}", ygopro.constants.COLORS.BABYBLUE)
......
......@@ -1463,7 +1463,7 @@
return false;
}
disconnect_info = disconnect_list[CLIENT_get_authorize_key(client)];
if (!disconnect_info) {
if (!(disconnect_info && disconnect_info.deckbuf)) {
return false;
}
room = ROOM_all[disconnect_info.room_id];
......@@ -3774,12 +3774,14 @@
pos = pos * 2;
}
val = buffer.readInt32LE(2);
room.dueling_players[pos].lp -= val;
if (room.dueling_players[pos].lp < 0) {
room.dueling_players[pos].lp = 0;
}
if ((0 < (ref1 = room.dueling_players[pos].lp) && ref1 <= 100)) {
ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK);
if (room.dueling_players[pos]) {
room.dueling_players[pos].lp -= val;
if (room.dueling_players[pos].lp < 0) {
room.dueling_players[pos].lp = 0;
}
if ((0 < (ref1 = room.dueling_players[pos].lp) && ref1 <= 100)) {
ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK);
}
}
}
if (msg_name === 'RECOVER' && client.pos === 0) {
......@@ -3791,7 +3793,9 @@
pos = pos * 2;
}
val = buffer.readInt32LE(2);
room.dueling_players[pos].lp += val;
if (room.dueling_players[pos]) {
room.dueling_players[pos].lp += val;
}
}
if (msg_name === 'LPUPDATE' && client.pos === 0) {
pos = buffer.readUInt8(1);
......@@ -3802,7 +3806,9 @@
pos = pos * 2;
}
val = buffer.readInt32LE(2);
room.dueling_players[pos].lp = val;
if (room.dueling_players[pos]) {
room.dueling_players[pos].lp = val;
}
}
if (msg_name === 'PAY_LPCOST' && client.pos === 0) {
pos = buffer.readUInt8(1);
......@@ -3813,12 +3819,14 @@
pos = pos * 2;
}
val = buffer.readInt32LE(2);
room.dueling_players[pos].lp -= val;
if (room.dueling_players[pos].lp < 0) {
room.dueling_players[pos].lp = 0;
}
if ((0 < (ref2 = room.dueling_players[pos].lp) && ref2 <= 100)) {
ygopro.stoc_send_chat_to_room(room, "${lp_low_self}", ygopro.constants.COLORS.PINK);
if (room.dueling_players[pos]) {
room.dueling_players[pos].lp -= val;
if (room.dueling_players[pos].lp < 0) {
room.dueling_players[pos].lp = 0;
}
if ((0 < (ref2 = room.dueling_players[pos].lp) && ref2 <= 100)) {
ygopro.stoc_send_chat_to_room(room, "${lp_low_self}", ygopro.constants.COLORS.PINK);
}
}
}
//track card count
......@@ -4801,7 +4809,7 @@
});
ygopro.ctos_follow('UPDATE_DECK', true, async function(buffer, info, client, server, datas) {
var buff_main, buff_side, card, current_deck, deck, deck_array, deck_main, deck_side, deck_text, deckbuf, decks, found_deck, i, j, l, len, len1, line, oppo_pos, recover_player_data, recoveredDeck, room, struct, win_pos;
var athleticCheckResult, buff_main, buff_side, card, current_deck, deck, deck_array, deck_main, deck_side, deck_text, deckbuf, decks, found_deck, i, j, l, len, len1, line, oppo_pos, recover_player_data, recoveredDeck, room, struct, win_pos;
if (settings.modules.reconnect.enabled && client.pre_reconnecting) {
if (!CLIENT_is_able_to_reconnect(client) && !CLIENT_is_able_to_kick_reconnect(client)) {
ygopro.stoc_send_chat(client, "${reconnect_failed}", ygopro.constants.COLORS.RED);
......@@ -4898,56 +4906,79 @@
struct.set("deckbuf", [4392470, 4392470]);
ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED);
client.deck_good = false;
return false;
}
} else if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.deck_check && !client.is_local) {
decks = (await fs.promises.readdir(settings.modules.tournament_mode.deck_path));
if (decks.length) {
struct.set("mainc", 1);
struct.set("sidec", 1);
struct.set("deckbuf", [4392470, 4392470]);
buffer = struct.buffer;
found_deck = false;
for (j = 0, len = decks.length; j < len; j++) {
deck = decks[j];
if (deck_name_match(deck, client.name)) {
found_deck = deck;
} else {
if (room.arena && settings.modules.athletic_check.enabled && settings.modules.athletic_check.banCount) {
athleticCheckResult = (await athleticChecker.checkAthletic({
main: buff_main,
side: buff_side
}));
if (athleticCheckResult.success) {
if (athleticCheckResult.athletic && athleticCheckResult.athletic <= settings.modules.athletic_check.banCount) {
struct.set("mainc", 1);
struct.set("sidec", 1);
struct.set("deckbuf", [4392470, 4392470]);
ygopro.stoc_send_chat(client, `\${banned_athletic_deck_part1}${settings.modules.athletic_check.banCount}\${banned_athletic_deck_part2}`, ygopro.constants.COLORS.RED);
client.deck_good = false;
return false;
}
}
if (found_deck) {
deck_text = (await fs.promises.readFile(settings.modules.tournament_mode.deck_path + found_deck, {
encoding: "ASCII"
}));
deck_array = deck_text.split("\n");
deck_main = [];
deck_side = [];
current_deck = deck_main;
for (l = 0, len1 = deck_array.length; l < len1; l++) {
line = deck_array[l];
if (line.indexOf("!side") >= 0) {
current_deck = deck_side;
}
card = parseInt(line);
if (!isNaN(card)) {
current_deck.push(card);
} else {
log.warn("GET ATHLETIC FAIL", client.name, athleticCheckResult.message);
}
}
if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.deck_check && !client.is_local) {
decks = (await fs.promises.readdir(settings.modules.tournament_mode.deck_path));
if (decks.length) {
struct.set("mainc", 1);
struct.set("sidec", 1);
struct.set("deckbuf", [4392470, 4392470]);
buffer = struct.buffer;
found_deck = false;
for (j = 0, len = decks.length; j < len; j++) {
deck = decks[j];
if (deck_name_match(deck, client.name)) {
found_deck = deck;
}
}
if (_.isEqual(buff_main, deck_main) && _.isEqual(buff_side, deck_side)) {
deckbuf = deck_main.concat(deck_side);
struct.set("mainc", deck_main.length);
struct.set("sidec", deck_side.length);
struct.set("deckbuf", deckbuf);
buffer = struct.buffer;
//log.info("deck ok: " + client.name)
ygopro.stoc_send_chat(client, `\${deck_correct_part1} ${found_deck} \${deck_correct_part2}`, ygopro.constants.COLORS.BABYBLUE);
if (found_deck) {
deck_text = (await fs.promises.readFile(settings.modules.tournament_mode.deck_path + found_deck, {
encoding: "ASCII"
}));
deck_array = deck_text.split("\n");
deck_main = [];
deck_side = [];
current_deck = deck_main;
for (l = 0, len1 = deck_array.length; l < len1; l++) {
line = deck_array[l];
if (line.indexOf("!side") >= 0) {
current_deck = deck_side;
}
card = parseInt(line);
if (!isNaN(card)) {
current_deck.push(card);
}
}
if (_.isEqual(buff_main, deck_main) && _.isEqual(buff_side, deck_side)) {
deckbuf = deck_main.concat(deck_side);
struct.set("mainc", deck_main.length);
struct.set("sidec", deck_side.length);
struct.set("deckbuf", deckbuf);
buffer = struct.buffer;
//log.info("deck ok: " + client.name)
ygopro.stoc_send_chat(client, `\${deck_correct_part1} ${found_deck} \${deck_correct_part2}`, ygopro.constants.COLORS.BABYBLUE);
} else {
//log.info("bad deck: " + client.name + " / " + buff_main + " / " + buff_side)
ygopro.stoc_send_chat(client, `\${deck_incorrect_part1} ${found_deck} \${deck_incorrect_part2}`, ygopro.constants.COLORS.RED);
client.deck_good = false;
return false;
}
} else {
//log.info("bad deck: " + client.name + " / " + buff_main + " / " + buff_side)
ygopro.stoc_send_chat(client, `\${deck_incorrect_part1} ${found_deck} \${deck_incorrect_part2}`, ygopro.constants.COLORS.RED);
//log.info("player deck not found: " + client.name)
ygopro.stoc_send_chat(client, `${client.name}\${deck_not_found}`, ygopro.constants.COLORS.RED);
client.deck_good = false;
return false;
}
} else {
//log.info("player deck not found: " + client.name)
ygopro.stoc_send_chat(client, `${client.name}\${deck_not_found}`, ygopro.constants.COLORS.RED);
client.deck_good = false;
}
}
}
......
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