Skip to content

Commit

Permalink
Fix third party sonhos transaction taxes and improve wording in some …
Browse files Browse the repository at this point in the history
…of the messages
  • Loading branch information
MrPowerGamerBR committed Jan 29, 2025
1 parent 7762e25 commit 7941bdc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ object ThirdPartyPaymentSonhosTransactionTransformer : SonhosTransactionTransfor
append(
i18nContext.get(
SonhosCommand.TRANSACTIONS_I18N_PREFIX.Types.Payment.ThirdPartyReceived(
transaction.sonhos + transaction.tax,
transaction.sonhos,
transaction.sonhos - transaction.tax,
convertToUserNameCodeBlockPreviewTag(
transaction.givenBy.value.toLong(),
giverUserInfo?.name,
Expand Down Expand Up @@ -76,8 +76,8 @@ object ThirdPartyPaymentSonhosTransactionTransformer : SonhosTransactionTransfor
append(
i18nContext.get(
SonhosCommand.TRANSACTIONS_I18N_PREFIX.Types.Payment.ThirdPartySent(
transaction.sonhos + transaction.tax,
transaction.sonhos,
transaction.sonhos - transaction.tax,
convertToUserNameCodeBlockPreviewTag(
transaction.receivedBy.value.toLong(),
receiverUserInfo?.name,
Expand All @@ -92,7 +92,7 @@ object ThirdPartyPaymentSonhosTransactionTransformer : SonhosTransactionTransfor
append(
i18nContext.get(
SonhosCommand.TRANSACTIONS_I18N_PREFIX.Types.Payment.ThirdPartySentNoTax(
transaction.sonhos + transaction.tax,
transaction.sonhos,
convertToUserNameCodeBlockPreviewTag(
transaction.receivedBy.value.toLong(),
receiverUserInfo?.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
it[PaymentSonhosTransactionResults.timestamp] = now
}

val serializedMetadata = sonhosTransferRequestData[SonhosTransferRequests.metadata]

val storedTransaction = StoredPaymentSonhosTransaction(
giverProfile.id.value.toLong(),
receiverProfile.id.value.toLong(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class ThirdPartySonhosTransferInteractionsListener(val loritta: LorittaBot) : Li

if (giverHasAccepted && receiverHasAccepted) {
val howMuch = sonhosTransferRequestData[ThirdPartySonhosTransferRequests.quantity]
val howMuchShouldBeRemoved = howMuch + sonhosTransferRequestData[ThirdPartySonhosTransferRequests.tax]
val howMuchShouldBeAdded = sonhosTransferRequestData[ThirdPartySonhosTransferRequests.quantity]
val howMuchShouldBeRemoved = howMuch
val howMuchShouldBeAdded = sonhosTransferRequestData[ThirdPartySonhosTransferRequests.quantity] - sonhosTransferRequestData[ThirdPartySonhosTransferRequests.tax]

val receiverProfile = loritta.pudding.users.getOrCreateUserProfile(
net.perfectdreams.loritta.serializable.UserId(sonhosTransferRequestData[ThirdPartySonhosTransferRequests.receiver])
Expand Down Expand Up @@ -182,6 +182,7 @@ class ThirdPartySonhosTransferInteractionsListener(val loritta: LorittaBot) : Li
sonhosTransferRequestData[ThirdPartySonhosTransferRequests.receiver],
sonhosTransferRequestData[ThirdPartySonhosTransferRequests.giver],
howMuch,
sonhosTransferRequestData[ThirdPartySonhosTransferRequests.tax],
updatedReceiverProfile.money,
receiverRanking,
updatedGiverProfile.money,
Expand Down Expand Up @@ -221,10 +222,28 @@ class ThirdPartySonhosTransferInteractionsListener(val loritta: LorittaBot) : Li
user(result.receiverId)
}

styled(
i18nContext.get(SonhosCommand.PAY_I18N_PREFIX.SuccessfullyTransferred("<@${result.receiverId}>", result.howMuch)),
Emotes.Handshake
)
if (result.tax != 0L) {
styled(
i18nContext.get(
SonhosCommand.PAY_I18N_PREFIX.ThirdPartySuccessfullyTransferred(
"<@${result.receiverId}>",
result.howMuch - result.tax,
result.tax
)
),
Emotes.Handshake
)
} else {
styled(
i18nContext.get(
SonhosCommand.PAY_I18N_PREFIX.ThirdPartySuccessfullyTransferredNoTax(
"<@${result.receiverId}>",
result.howMuch
)
),
Emotes.Handshake
)
}

// Let's add a random emoji just to look cute
val user1Emote = SonhosUtils.HANGLOOSE_EMOTES.random()
Expand Down Expand Up @@ -341,6 +360,7 @@ class ThirdPartySonhosTransferInteractionsListener(val loritta: LorittaBot) : Li
val receiverId: Long,
val giverId: Long,
val howMuch: Long,
val tax: Long,
val receiverQuantity: Long,
val receiverRanking: Long?,
val giverQuantity: Long,
Expand Down
4 changes: 3 additions & 1 deletion resources/languages/pt/commands/pay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ acceptTransfer: "Aceitar Transferência ({acceptedQuantity,number}/2)"
cancel: "Cancelar"
youAreGoingToTransfer: "Você está prestes a transferir **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}** para {receiver}!"

thirdPartyIsGoingToTransfer: "{sender} está prestes a transferir **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} ({sonhosTaxQuantity,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} de taxa)** para {receiver}!"
thirdPartyIsGoingToTransfer: "{sender} está prestes a transferir **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} (dos {sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}, {sonhosTaxQuantity,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} são de taxa)** para {receiver}!"
thirdPartyIsGoingToTransferNoTax: "{sender} está prestes a transferir **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} (sem precisar pagar taxa!)** para {receiver}!"

confirmTheTransaction: "Para confirmar a transação, você e {receiver} devem aceitar a transação até {time} ({timeRelative})!"
Expand All @@ -13,6 +13,8 @@ transferAccepted: "Transferência Aceita"
transferFailed: "Transferência Falhou - {failReason}"
transferCancelled: "Transferência Cancelada"
successfullyTransferred: "Transferência realizada com sucesso! {receiver} recebeu **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}**!"
thirdPartySuccessfullyTransferred: "Transferência realizada com sucesso! {receiver} recebeu **{sonhosAfterTax,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} (e {tax,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} foram para o governo)**!"
thirdPartySuccessfullyTransferredNoTax: "Transferência realizada com sucesso! {receiver} recebeu **{sonhosAfterTax,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} (e o governo recebeu nadinha de taxa)**!"
transferredSonhos: "{user} agora possui {sonhosEmoji} **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}**!"
transferredSonhosWithRanking: "{user} agora possui {sonhosEmoji} **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}** e está em **#{rankingPosition,number} lugar** no ranking!"
selfAccountIsTooNew: "Espere aí, a sua conta é muito nova! Antes de poder transferir sonhos, você precisa aguardar até {time} ({timeRelative}) antes de começar a transferir sonhos."
Expand Down

0 comments on commit 7941bdc

Please sign in to comment.