Commit bdea6e15 authored by nanahira's avatar nanahira

athletic deck ban

parent 808073d5
...@@ -45,7 +45,7 @@ class AthleticChecker { ...@@ -45,7 +45,7 @@ class AthleticChecker {
try { try {
const athleticDecks = await this.getAthleticDecks(); const athleticDecks = await this.getAthleticDecks();
const deckType = await this.getDeckType(deck); 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 }; return { success: true, athletic, message: null };
} }
catch (e) { catch (e) {
......
...@@ -21,7 +21,7 @@ interface AthleticDecksReturnData { ...@@ -21,7 +21,7 @@ interface AthleticDecksReturnData {
interface ReturnMessage { interface ReturnMessage {
success: boolean; success: boolean;
athletic?: boolean; athletic?: number;
message: string; message: string;
} }
...@@ -63,8 +63,8 @@ export class AthleticChecker { ...@@ -63,8 +63,8 @@ export class AthleticChecker {
try { try {
const athleticDecks = await this.getAthleticDecks(); const athleticDecks = await this.getAthleticDecks();
const deckType = await this.getDeckType(deck); 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 } return { success: true, athletic, message: null };
} catch (e) { } catch (e) {
return { success: false, message: e.toString() }; return { success: false, message: e.toString() };
} }
......
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
"source": "mycard-athletic" "source": "mycard-athletic"
}, },
"rankCount": 10, "rankCount": 10,
"banCount": 0,
"ttl": 600 "ttl": 600
}, },
"test_mode": { "test_mode": {
......
...@@ -173,6 +173,8 @@ ...@@ -173,6 +173,8 @@
"windbot_disable_random_room": "By adding the AI, this random game won't get any new player unless they enter the room name:", "windbot_disable_random_room": "By adding the AI, this random game won't get any new player unless they enter the room name:",
"refresh_success": "Refresh field succeeded.", "refresh_success": "Refresh field succeeded.",
"refresh_failed": "Refresh field failed.", "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." "using_athletic_deck": " is using a competitive deck."
}, },
"es-es": { "es-es": {
...@@ -495,6 +497,8 @@ ...@@ -495,6 +497,8 @@
"windbot_disable_random_room": "因为添加了AI,本随机对战房间将只能通过房间名加入:", "windbot_disable_random_room": "因为添加了AI,本随机对战房间将只能通过房间名加入:",
"refresh_success": "刷新场面成功。", "refresh_success": "刷新场面成功。",
"refresh_fail": "刷新场面失败。", "refresh_fail": "刷新场面失败。",
"banned_athletic_deck_part1": "娱乐匹配中禁止使用使用数前",
"banned_athletic_deck_part2": "的竞技卡组。请更换卡组。",
"using_athletic_deck": " 正在使用竞技卡组。" "using_athletic_deck": " 正在使用竞技卡组。"
}, },
"ko-kr": { "ko-kr": {
......
...@@ -3321,42 +3321,55 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)-> ...@@ -3321,42 +3321,55 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)->
struct.set("sidec", 1) struct.set("sidec", 1)
struct.set("deckbuf", [4392470, 4392470]) struct.set("deckbuf", [4392470, 4392470])
ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED)
else if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.deck_check and fs.readdirSync(settings.modules.tournament_mode.deck_path).length return false
decks = await fs.promises.readdir(settings.modules.tournament_mode.deck_path) else
if decks.length if settings.modules.athletic_check.enabled and settings.modules.athletic_check.banCount
struct.set("mainc", 1) athleticCheckResult = await athleticChecker.checkAthletic({main: buff_main, side: buff_side})
struct.set("sidec", 1) if athleticCheckResult.success
struct.set("deckbuf", [4392470, 4392470]) if athleticCheckResult.athletic and athleticCheckResult.athletic <= settings.modules.athletic_check.banCount
buffer = struct.buffer struct.set("mainc", 1)
found_deck=false struct.set("sidec", 1)
for deck in decks struct.set("deckbuf", [4392470, 4392470])
if deck_name_match(deck, client.name) ygopro.stoc_send_chat(client, "${banned_athletic_deck_part1}#{settings.modules.athletic_check.banCount}${banned_athletic_deck_part2}", ygopro.constants.COLORS.RED)
found_deck=deck 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 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)
else else
#log.info("player deck not found: " + client.name) log.warn("GET ATHLETIC FAIL", client.name, athleticCheckResult.message)
ygopro.stoc_send_chat(client, "#{client.name}${deck_not_found}", ygopro.constants.COLORS.RED) if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.deck_check
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)
else
#log.info("player deck not found: " + client.name)
ygopro.stoc_send_chat(client, "#{client.name}${deck_not_found}", ygopro.constants.COLORS.RED)
await return false await return false
ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server, datas)-> ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server, datas)->
......
...@@ -4338,7 +4338,7 @@ ...@@ -4338,7 +4338,7 @@
}); });
ygopro.ctos_follow('UPDATE_DECK', true, async function(buffer, info, client, server, datas) { 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 (settings.modules.reconnect.enabled && client.pre_reconnecting) {
if (!CLIENT_is_able_to_reconnect(client) && !CLIENT_is_able_to_kick_reconnect(client)) { 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); ygopro.stoc_send_chat(client, "${reconnect_failed}", ygopro.constants.COLORS.RED);
...@@ -4433,54 +4433,74 @@ ...@@ -4433,54 +4433,74 @@
struct.set("sidec", 1); struct.set("sidec", 1);
struct.set("deckbuf", [4392470, 4392470]); struct.set("deckbuf", [4392470, 4392470]);
ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED);
return false;
} }
} else if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.deck_check && fs.readdirSync(settings.modules.tournament_mode.deck_path).length) { } else {
decks = (await fs.promises.readdir(settings.modules.tournament_mode.deck_path)); if (settings.modules.athletic_check.enabled && settings.modules.athletic_check.banCount) {
if (decks.length) { athleticCheckResult = (await athleticChecker.checkAthletic({
struct.set("mainc", 1); main: buff_main,
struct.set("sidec", 1); side: buff_side
struct.set("deckbuf", [4392470, 4392470]); }));
buffer = struct.buffer; if (athleticCheckResult.success) {
found_deck = false; if (athleticCheckResult.athletic && athleticCheckResult.athletic <= settings.modules.athletic_check.banCount) {
for (j = 0, len = decks.length; j < len; j++) { struct.set("mainc", 1);
deck = decks[j]; struct.set("sidec", 1);
if (deck_name_match(deck, client.name)) { struct.set("deckbuf", [4392470, 4392470]);
found_deck = deck; ygopro.stoc_send_chat(client, `\${banned_athletic_deck_part1}${settings.modules.athletic_check.banCount}\${banned_athletic_deck_part2}`, ygopro.constants.COLORS.RED);
return false;
} }
} } else {
if (found_deck) { log.warn("GET ATHLETIC FAIL", client.name, athleticCheckResult.message);
deck_text = (await fs.promises.readFile(settings.modules.tournament_mode.deck_path + found_deck, { }
encoding: "ASCII" }
})); if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.deck_check) {
deck_array = deck_text.split("\n"); decks = (await fs.promises.readdir(settings.modules.tournament_mode.deck_path));
deck_main = []; if (decks.length) {
deck_side = []; struct.set("mainc", 1);
current_deck = deck_main; struct.set("sidec", 1);
for (l = 0, len1 = deck_array.length; l < len1; l++) { struct.set("deckbuf", [4392470, 4392470]);
line = deck_array[l]; buffer = struct.buffer;
if (line.indexOf("!side") >= 0) { found_deck = false;
current_deck = deck_side; for (j = 0, len = decks.length; j < len; j++) {
} deck = decks[j];
card = parseInt(line); if (deck_name_match(deck, client.name)) {
if (!isNaN(card)) { found_deck = deck;
current_deck.push(card);
} }
} }
if (_.isEqual(buff_main, deck_main) && _.isEqual(buff_side, deck_side)) { if (found_deck) {
deckbuf = deck_main.concat(deck_side); deck_text = (await fs.promises.readFile(settings.modules.tournament_mode.deck_path + found_deck, {
struct.set("mainc", deck_main.length); encoding: "ASCII"
struct.set("sidec", deck_side.length); }));
struct.set("deckbuf", deckbuf); deck_array = deck_text.split("\n");
buffer = struct.buffer; deck_main = [];
//log.info("deck ok: " + client.name) deck_side = [];
ygopro.stoc_send_chat(client, `\${deck_correct_part1} ${found_deck} \${deck_correct_part2}`, ygopro.constants.COLORS.BABYBLUE); 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);
}
} else { } else {
//log.info("bad deck: " + client.name + " / " + buff_main + " / " + buff_side) //log.info("player deck not found: " + client.name)
ygopro.stoc_send_chat(client, `\${deck_incorrect_part1} ${found_deck} \${deck_incorrect_part2}`, ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, `${client.name}\${deck_not_found}`, ygopro.constants.COLORS.RED);
} }
} else {
//log.info("player deck not found: " + client.name)
ygopro.stoc_send_chat(client, `${client.name}\${deck_not_found}`, ygopro.constants.COLORS.RED);
} }
} }
} }
......
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