TikTok-mGBA-Emulator/node/source/classes/modules/tiktok/Gift.ts

57 lines
No EOL
1.6 KiB
TypeScript

export class Gift {
private giftId: number;
private costDiamonds: number;
private name: string;
/**
* Create a new Gift object
* @param data { giftId: number, costDiamonds: number, name: string}
*/
constructor(data: { giftId: number, costDiamonds: number, name: string }) {
this.giftId = data.giftId;
this.costDiamonds = data.costDiamonds;
this.name = data.name;
}
/**
* Get the unique identifier for the gift
* @returns {number} The unique identifier for the gift
*/
public getGiftId(): number {
return this.giftId;
}
/**
* Get the cost of the gift in diamonds
* @returns {number} The cost of the gift in diamonds
*/
public getCostDiamonds(): number {
return this.costDiamonds;
}
/**
* Get the name of the gift
* @returns {string} The name of the gift
*/
public getName(): string {
return this.name;
}
/**
* Get the estimated value of the diamonds in euros
* @param {boolean} withdrawableValue The withdrawable value of the gift for creators, otherwise the original value
* @returns {number} The value of the gift in euros
*/
public getEstimatedValueInEuro(withdrawableValue: boolean = true): number {
let leftValue;
if(withdrawableValue) {
leftValue = this.getCostDiamonds() / 2;
} else {
leftValue = this.getCostDiamonds();
}
let valueInDollars = leftValue;
let valueInEuroCent = valueInDollars * 0.95;
let valueInEuro = valueInEuroCent / 100;
return Math.ceil(valueInEuro * 100) / 100;
}
}