Commit 1d28038f authored by nanahira's avatar nanahira

hide score name

parent 17b16309
Pipeline #29623 passed with stages
in 9 minutes and 50 seconds
......@@ -528,12 +528,12 @@ class DataManager {
newScore.name = name;
return await this.saveRandomDuelScore(newScore);
}
async getRandomDuelScoreDisplay(name) {
async getRandomDuelScoreDisplay(name, displayName = name.split("$")[0]) {
const score = await this.getRandomDuelScore(name);
if (!score) {
return `${name.split("$")[0]} \${random_score_blank}`;
return `${displayName} \${random_score_blank}`;
}
return score.getScoreText();
return score.getScoreText(displayName);
}
async randomDuelPlayerWin(name) {
const score = await this.getOrCreateRandomDuelScore(name);
......
......@@ -528,12 +528,12 @@ export class DataManager {
newScore.name = name;
return await this.saveRandomDuelScore(newScore);
}
async getRandomDuelScoreDisplay(name: string) {
async getRandomDuelScoreDisplay(name: string, displayName = name.split("$")[0]) {
const score = await this.getRandomDuelScore(name);
if(!score) {
return `${name.split("$")[0]} \${random_score_blank}`;
return `${displayName} \${random_score_blank}`;
}
return score.getScoreText();
return score.getScoreText(displayName);
}
async randomDuelPlayerWin(name: string) {
const score = await this.getOrCreateRandomDuelScore(name);
......
......@@ -33,8 +33,7 @@ let RandomDuelScore = class RandomDuelScore extends CreateAndUpdateTimeBase_1.Cr
++this.fleeCount;
this.lose();
}
getScoreText() {
const displayName = this.getDisplayName();
getScoreText(displayName = this.getDisplayName()) {
const total = this.winCount + this.loseCount;
if (this.winCount < 2 && total < 3) {
return `${displayName} \${random_score_not_enough}`;
......
......@@ -40,8 +40,7 @@ export class RandomDuelScore extends CreateAndUpdateTimeBase {
this.lose();
}
getScoreText() {
const displayName = this.getDisplayName();
getScoreText(displayName = this.getDisplayName()) {
const total = this.winCount + this.loseCount;
if (this.winCount < 2 && total < 3) {
return `${displayName} \${random_score_not_enough}`;
......@@ -53,4 +52,4 @@ export class RandomDuelScore extends CreateAndUpdateTimeBase {
return `\${random_score_part1}${displayName} \${random_score_part2} ${Math.ceil(this.winCount / total * 100)}\${random_score_part3} ${Math.ceil(this.fleeCount / total * 100)}\${random_score_part4}`;
}
}
}
\ No newline at end of file
}
......@@ -709,10 +709,10 @@ ROOM_player_flee = global.ROOM_player_flee = (name)->
await dataManager.randomDuelPlayerFlee(name)
return
ROOM_player_get_score = global.ROOM_player_get_score = (player)->
ROOM_player_get_score = global.ROOM_player_get_score = (player, display_name)->
if !settings.modules.mysql.enabled
return ""
return await dataManager.getRandomDuelScoreDisplay(player.name_vpass)
return await dataManager.getRandomDuelScoreDisplay(player.name_vpass, display_name)
ROOM_find_or_create_by_name = global.ROOM_find_or_create_by_name = (name, player_ip)->
uname=name.toUpperCase()
......@@ -2446,9 +2446,10 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
#client.score_shown = true
return
if settings.modules.random_duel.record_match_scores and room.random_type == 'M'
ygopro.stoc_send_chat_to_room(room, await ROOM_player_get_score(client), ygopro.constants.COLORS.GREEN)
for player in room.players when player.pos != 7 and player != client
ygopro.stoc_send_chat(client, await ROOM_player_get_score(player), ygopro.constants.COLORS.GREEN)
ygopro.stoc_send_chat_to_room(room, await ROOM_player_get_score(client, client.name), ygopro.constants.COLORS.GREEN)
if not settings.modules.hide_name
for player in room.players when player.pos != 7 and player != client
ygopro.stoc_send_chat(client, await ROOM_player_get_score(player, room.getMaskedPlayerName(player, client)), ygopro.constants.COLORS.GREEN)
if !room.recorder
room.recorder = recorder = net.connect room.port, ->
ygopro.ctos_send recorder, 'PLAYER_INFO', {
......
......@@ -916,11 +916,11 @@
await dataManager.randomDuelPlayerFlee(name);
};
ROOM_player_get_score = global.ROOM_player_get_score = async function(player) {
ROOM_player_get_score = global.ROOM_player_get_score = async function(player, display_name) {
if (!settings.modules.mysql.enabled) {
return "";
}
return (await dataManager.getRandomDuelScoreDisplay(player.name_vpass));
return (await dataManager.getRandomDuelScoreDisplay(player.name_vpass, display_name));
};
ROOM_find_or_create_by_name = global.ROOM_find_or_create_by_name = async function(name, player_ip) {
......@@ -3215,12 +3215,14 @@
}
//client.score_shown = true
if (settings.modules.random_duel.record_match_scores && room.random_type === 'M') {
ygopro.stoc_send_chat_to_room(room, (await ROOM_player_get_score(client)), ygopro.constants.COLORS.GREEN);
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
if (player.pos !== 7 && player !== client) {
ygopro.stoc_send_chat(client, (await ROOM_player_get_score(player)), ygopro.constants.COLORS.GREEN);
ygopro.stoc_send_chat_to_room(room, (await ROOM_player_get_score(client, client.name)), ygopro.constants.COLORS.GREEN);
if (!settings.modules.hide_name) {
ref = room.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
if (player.pos !== 7 && player !== client) {
ygopro.stoc_send_chat(client, (await ROOM_player_get_score(player, room.getMaskedPlayerName(player, client))), ygopro.constants.COLORS.GREEN);
}
}
}
}
......
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