adjustments

This commit is contained in:
milo
2025-09-13 13:52:44 +02:00
parent 2503730a39
commit 02d4580552
9 changed files with 98 additions and 16 deletions

View File

@@ -101,7 +101,7 @@ export async function handleInventoryCommand(req, res, client, interactionId) {
components.push({
type: MessageComponentTypes.BUTTON,
custom_id: `upgrade_${interactionId}`,
label: `Upgrade ⏫ (${process.env.VALO_UPGRADE_PRICE || (currentSkin.maxPrice/10).toFixed(0)})`,
label: `Upgrade ⏫ (${process.env.VALO_UPGRADE_PRICE || (currentSkin.maxPrice/10).toFixed(0)} Flopos)`,
style: ButtonStyleTypes.PRIMARY,
});
}
@@ -113,14 +113,19 @@ export async function handleInventoryCommand(req, res, client, interactionId) {
embeds: [{
title: `Inventaire de ${targetMember.user.globalName || targetMember.user.username}`,
color: parseInt(currentSkin.tierColor, 16) || 0xF2F3F3,
footer: { text: `Page 1/${inventorySkins.length} | Valeur Totale : ${totalPrice.toFixed(0)}` },
footer: { text: `Page 1/${inventorySkins.length} | Valeur Totale : ${totalPrice.toFixed(0)} Flopos` },
fields: [{
name: `${currentSkin.displayName} | ${currentSkin.currentPrice.toFixed(0)}`,
name: `${currentSkin.displayName} | ${currentSkin.currentPrice.toFixed(0)} Flopos`,
value: `${currentSkin.tierText}\nChroma : ${getChromaText(currentSkin, skinData)} | ${getChromaName(currentSkin, skinData)}\nLvl : **${currentSkin.currentLvl}**/${skinData.levels.length}`,
}],
image: { url: getImageUrl(currentSkin, skinData) },
}],
components: [{ type: MessageComponentTypes.ACTION_ROW, components: components }],
components: [{ type: MessageComponentTypes.ACTION_ROW, components: components },
{ type: MessageComponentTypes.ACTION_ROW, components: {
type: MessageComponentTypes.BUTTON,
url: `${process.env.FLAPI_URL}/akhy/${targetMember.id}`,
label: 'Voir sur FlopoSite',
style: ButtonStyleTypes.LINK,}}],
},
});

View File

@@ -100,7 +100,7 @@ export async function handleSearchCommand(req, res, client, interactionId) {
color: parseInt(currentSkin.tierColor, 16) || 0xF2F3F3,
fields: [{
name: `**${currentSkin.displayName}**`,
value: `${currentSkin.tierText}\nValeur Max: **${currentSkin.maxPrice}** ${ownerText}`,
value: `${currentSkin.tierText}\nValeur Max: **${currentSkin.maxPrice} Flopos** ${ownerText}`,
}],
image: { url: getImageUrl(skinData) },
footer: { text: `Résultat 1/${resultSkins.length}` },

View File

@@ -38,7 +38,7 @@ export async function handleSkinsCommand(req, res, client) {
// Add the formatted skin info to our fields array
fields.push({
name: `#${index + 1} - **${skin.displayName}**`,
value: `Valeur Max: **${skin.maxPrice}** | ${ownerText}`,
value: `Valeur Max: **${skin.maxPrice} Flopos** | ${ownerText}`,
inline: false,
});
}

View File

@@ -108,7 +108,7 @@ export async function handleInventoryNav(req, res, client) {
components.push({
type: MessageComponentTypes.BUTTON,
custom_id: `upgrade_${interactionId}`,
label: `Upgrade ⏫ (${process.env.VALO_UPGRADE_PRICE || (currentSkin.maxPrice/10).toFixed(0)})`,
label: `Upgrade ⏫ (${process.env.VALO_UPGRADE_PRICE || (currentSkin.maxPrice/10).toFixed(0)} Flopos)`,
style: ButtonStyleTypes.PRIMARY,
});
}
@@ -120,14 +120,19 @@ export async function handleInventoryNav(req, res, client) {
embeds: [{
title: `Inventaire de ${targetMember.user.globalName || targetMember.user.username}`,
color: parseInt(currentSkin.tierColor, 16) || 0xF2F3F3,
footer: { text: `Page ${page + 1}/${amount} | Valeur Totale : ${totalPrice.toFixed(0)}` },
footer: { text: `Page ${page + 1}/${amount} | Valeur Totale : ${totalPrice.toFixed(0)} Flopos` },
fields: [{
name: `${currentSkin.displayName} | ${currentSkin.currentPrice.toFixed(0)}`,
name: `${currentSkin.displayName} | ${currentSkin.currentPrice.toFixed(0)} Flopos`,
value: `${currentSkin.tierText}\nChroma : ${getChromaText(currentSkin, skinData)} | ${getChromaName(currentSkin, skinData)}\nLvl : **${currentSkin.currentLvl}**/${skinData.levels.length}`,
}],
image: { url: getImageUrl(currentSkin, skinData) },
}],
components: [{ type: MessageComponentTypes.ACTION_ROW, components: components }],
components: [{ type: MessageComponentTypes.ACTION_ROW, components: components },
{ type: MessageComponentTypes.ACTION_ROW, components: {
type: MessageComponentTypes.BUTTON,
url: `${process.env.FLAPI_URL}/akhy/${targetMember.id}`,
label: 'Voir sur FlopoSite',
style: ButtonStyleTypes.LINK,}}],
},
});

View File

@@ -96,7 +96,7 @@ export async function handleSearchNav(req, res, client) {
color: parseInt(currentSkin.tierColor, 16) || 0xF2F3F3,
fields: [{
name: `**${currentSkin.displayName}**`,
value: `${currentSkin.tierText}\nValeur Max: **${currentSkin.maxPrice}** ${ownerText}`,
value: `${currentSkin.tierText}\nValeur Max: **${currentSkin.maxPrice} Flopos** ${ownerText}`,
}],
image: { url: getImageUrl(skinData) },
footer: { text: `Résultat ${page + 1}/${amount}` },

View File

@@ -179,7 +179,7 @@ function buildFinalEmbed(succeeded, skin, skinData) {
embed.addFields(
{ name: 'Nouveau Niveau', value: `${skin.currentLvl}/${skinData.levels.length}`, inline: true },
{ name: 'Nouveau Chroma', value: `${skin.currentChroma}/${skinData.chromas.length}`, inline: true },
{ name: 'Nouvelle Valeur', value: `**${skin.currentPrice}**`, inline: true }
{ name: 'Nouvelle Valeur', value: `**${skin.currentPrice} Flopos**`, inline: true }
);
} else {
embed.addFields({ name: 'Statut', value: 'Aucun changement.' });

View File

@@ -185,7 +185,7 @@ async function handleAdminCommands(message) {
for (let i = 0; i < amount; i++) {
sum += parseFloat(randomSkinPrice());
}
console.log(`Result for ${amount} skins: Avg: ~${(sum / amount).toFixed(0)} | Total: ${sum.toFixed(0)} | Elapsed: ${Date.now() - start_at}ms`);
console.log(`Result for ${amount} skins: Avg: ~${(sum / amount).toFixed(0)} Flopos | Total: ${sum.toFixed(0)} Flopos | Elapsed: ${Date.now() - start_at}ms`);
break;
case `${prefix}:sotd`:
initTodaysSOTD();

View File

@@ -4,6 +4,8 @@
import {emitToast} from "../server/socket.js";
import {getUser, insertLog, updateUserCoins} from "../database/index.js";
import {client} from "../bot/client.js";
import {EmbedBuilder} from "discord.js";
export const RANKS = ["A","2","3","4","5","6","7","8","9","T","J","Q","K"];
export const SUITS = ["d","s","c","h"];
@@ -236,7 +238,7 @@ export function dealerPlay(room) {
}
}
export function settleAll(room) {
export async function settleAll(room) {
room.status = "payout";
const allRes = {}
for (const p of Object.values(room.players)) {
@@ -251,6 +253,7 @@ export function settleAll(room) {
blackjackPayout: room.settings.blackjackPayout,
});
allRes[p.id] = res;
p.totalDelta += res.delta
if (res.result === 'win' || res.result === 'push') {
const userDB = getUser.get(p.id);
if (userDB) {
@@ -272,6 +275,27 @@ export function settleAll(room) {
emitToast({ type: `payout-res`, allRes });
hand.result = res.result;
hand.delta = res.delta;
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find(
ch => ch.name === 'général' || ch.name === 'general'
);
const msg = await generalChannel.messages.fetch(p.msgId);
const updatedEmbed = new EmbedBuilder()
.setDescription(`<@${p.id}> joue au Blackjack.`)
.addFields(
{
name: `Gains`,
value: `**${p.totalDelta >= 0 ? '+' + p.totalDelta : p.totalDelta}** Flopos`,
inline: true
},
)
.setColor(p.totalDelta >= 0 ? 0x22A55B : 0xED4245)
.setTimestamp(new Date());
await msg.edit({ embeds: [updatedEmbed], components: [] });
} catch (e) {
console.log(e);
}
}
}

View File

@@ -18,6 +18,7 @@ import {
import { getUser, updateUserCoins, insertLog } from "../../database/index.js";
import { client } from "../../bot/client.js";
import {emitToast, emitUpdate} from "../socket.js";
import {EmbedBuilder} from "discord.js";
export function blackjackRoutes(io) {
const router = express.Router();
@@ -56,7 +57,7 @@ export function blackjackRoutes(io) {
await sleep(room.settings.animation?.dealerDrawMs ?? 500);
}
settleAll(room);
await settleAll(room);
room.status = "payout";
room.phase_ends_at = Date.now() + (room.settings.phaseDurations.payoutMs ?? 10000);
emitUpdate("payout", snapshot(room))
@@ -126,16 +127,63 @@ export function blackjackRoutes(io) {
hands: [{ cards: [], stood: false, busted: false, doubled: false, surrendered: false, hasActed: false }],
activeHand: 0,
joined_at: Date.now(),
msgId: null,
totalDelta: 0,
};
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find(
ch => ch.name === 'général' || ch.name === 'general'
);
const embed = new EmbedBuilder()
.setDescription(`<@${userId}> joue au Blackjack`)
.addFields(
{
name: `Gains`,
value: `**${room.players[userId].totalDelta >= 0 ? '+' + room.players[userId].totalDelta : room.players[userId].totalDelta}** Flopos`,
inline: true
},
)
.setColor('#5865f2')
.setTimestamp(new Date());
const msg = await generalChannel.send({ embeds: [embed] });
room.players[userId].msgId = msg.id;
} catch (e) {
console.log(e);
}
emitUpdate("player-joined", snapshot(room));
return res.status(200).json({ message: "joined" });
});
router.post("/leave", (req, res) => {
router.post("/leave", async (req, res) => {
const { userId } = req.body;
if (!userId || !room.players[userId]) return res.status(404).json({ message: "not in room" });
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find(
ch => ch.name === 'général' || ch.name === 'general'
);
const msg = await generalChannel.messages.fetch(room.players[userId].msgId);
const updatedEmbed = new EmbedBuilder()
.setDescription(`<@${userId}> a quitté la table de Blackjack.`)
.addFields(
{
name: `Gains`,
value: `**${room.players[userId].totalDelta >= 0 ? '+' + room.players[userId].totalDelta : room.players[userId].totalDelta}** Flopos`,
inline: true
},
)
.setColor(room.players[userId].totalDelta >= 0 ? 0x22A55B : 0xED4245)
.setTimestamp(new Date());
await msg.edit({ embeds: [updatedEmbed], components: [] });
} catch (e) {
console.log(e);
}
const p = room.players[userId];
if (p.inRound) {
// leave after round to avoid abandoning an active bet