Properly render discounts

This commit is contained in:
tobspr 2022-06-23 14:59:09 +02:00
parent d976245cc1
commit 9f3cf49fad
10 changed files with 61 additions and 72 deletions

View File

@ -142,20 +142,15 @@
> .discount {
position: absolute;
@include S(top, -7px);
@include S(right, -5px);
@include S(top, -12px);
@include S(right, -15px);
background: #4c6b22;
color: #c5ea3f;
@include S(border-radius, $globalBorderRadius);
@include S(padding, 1px, 3px, 1px, 4px);
@include SuperSmallText;
@include PlainText;
text-transform: uppercase;
transform: rotate(1deg);
@include InlineAnimation(1.3s ease-in-out infinite) {
50% {
transform: rotate(4deg) scale(1.1);
}
}
transform: rotate(3deg);
}
}
}

View File

@ -327,14 +327,9 @@
color: #c5ea3f;
@include S(border-radius, $globalBorderRadius);
@include S(padding, 1px, 3px, 1px, 4px);
@include SuperSmallText;
@include PlainText;
text-transform: uppercase;
transform: rotate(1deg);
@include InlineAnimation(1.3s ease-in-out infinite) {
50% {
transform: rotate(4deg) scale(1.1);
}
}
transform: rotate(5deg);
}
}

View File

@ -22,9 +22,10 @@ export const THIRDPARTY_URLS = {
twitter: "https://twitter.com/tobspr",
privacyPolicy: "https://tobspr.io/privacy.html",
standaloneCampaignLink: G_IS_STANDALONE
? "https://get.shapez.io/bundle/$campaign"
: "https://get.shapez.io/$campaign",
standaloneCampaignLink:
G_IS_STANDALONE || true
? "https://get.shapez.io/bundle/$campaign"
: "https://get.shapez.io/$campaign",
puzzleDlcStorePage: "https://get.shapez.io/mm_puzzle_dlc?target=dlc",
levelTutorialVideos: {

View File

@ -42,7 +42,10 @@ export class HUDStandaloneAdvantages extends BaseHUDPart {
<button class="steamLinkButton steam_dlbtn_0">
${
globalConfig.currentDiscount > 0
? `<span class='discount'>-${globalConfig.currentDiscount}%!</span>`
? `<span class='discount'>${T.global.discount.replace(
"<percentage>",
String(globalConfig.currentDiscount)
)}</span>`
: ""
}
</button>

View File

@ -13,7 +13,10 @@ export class HUDWatermark extends BaseHUDPart {
globalConfig.currentDiscount > 0 ? ["withDiscount"] : [],
linkText +
(globalConfig.currentDiscount > 0
? `<span class='discount'>-${globalConfig.currentDiscount}%!</span>`
? `<span class='discount'>${T.global.discount.replace(
"<percentage>",
String(globalConfig.currentDiscount)
)}</span>`
: "")
);
this.trackClicks(this.linkElement, () => {

View File

@ -16,8 +16,6 @@ const chinaShapes = G_WEGAME_VERSION || G_CHINA_VERSION;
* @returns
*/
const WEB_DEMO_LEVELS = app => {
const variant = app.gameAnalytics.abtVariant;
const levels = [
// 1
// Circle
@ -39,7 +37,7 @@ const WEB_DEMO_LEVELS = app => {
// Rectangle
{
shape: "RuRuRuRu", // miners t1
required: variant === "0" ? 50 : 30,
required: 30,
reward: enumHubGoalRewards.reward_balancer,
},
@ -57,49 +55,35 @@ const WEB_DEMO_LEVELS = app => {
required: 75,
reward: enumHubGoalRewards.reward_tunnel,
},
// 6
// Painter
{
shape: "Cu------", // miners t2
required: 50,
reward: enumHubGoalRewards.reward_painter,
},
// 7
{
shape: "CrCrCrCr", // unused
required: 85,
reward: enumHubGoalRewards.reward_rotater_ccw,
},
// 8
{
shape: "RbRb----", // painter t2
required: 100,
reward: enumHubGoalRewards.reward_mixer,
},
{
shape: "RpRp----",
required: 0,
reward: enumHubGoalRewards.reward_demo_end,
},
];
if (["0", "1", "2", "3"].includes(variant)) {
levels.push(
// 6
// Painter
{
shape: "Cu------", // miners t2
required: variant === "0" ? 75 : 50,
reward: enumHubGoalRewards.reward_painter,
}
);
}
if (["0", "1", "2"].includes(variant)) {
levels.push(
// 7
{
shape: "CrCrCrCr", // unused
required: variant === "0" ? 120 : 85,
reward: enumHubGoalRewards.reward_rotater_ccw,
}
);
}
if (["0", "1"].includes(variant)) {
levels.push(
// 8
{
shape: "RbRb----", // painter t2
required: variant === "0" ? 170 : 100,
reward: enumHubGoalRewards.reward_mixer,
}
);
}
// End of demo
levels.push({
shape: levels[levels.length - 1].shape,
required: 0,
reward: enumHubGoalRewards.reward_demo_end,
});
return levels;
};
@ -168,7 +152,7 @@ const STEAM_DEMO_LEVELS = () => [
},
// End of demo
{
shape: "RbRb----",
shape: "CpCpCpCp",
required: 0,
reward: enumHubGoalRewards.reward_demo_end,
},

View File

@ -36,8 +36,8 @@ const analyticsUrl = G_IS_DEV ? "http://localhost:8001" : "https://analytics.sha
// Be sure to increment the ID whenever it changes
const analyticsLocalFile = G_IS_STEAM_DEMO ? "shapez_token_steamdemo.bin" : "shapez_token_123.bin";
const CURRENT_ABT = "abt_lvcp";
const CURRENT_ABT_COUNT = 4;
const CURRENT_ABT = "abt_dsct";
const CURRENT_ABT_COUNT = 2;
export class ShapezGameAnalytics extends GameAnalyticsInterface {
constructor(app) {

View File

@ -103,7 +103,10 @@ export class MainMenuState extends GameState {
<a href="#" class="steamLink steam_dlbtn_0" target="_blank">
${
globalConfig.currentDiscount > 0
? `<span class='discount'>-${globalConfig.currentDiscount}%!</span>`
? `<span class='discount'>${T.global.discount.replace(
"<percentage>",
String(globalConfig.currentDiscount)
)}</span>`
: ""
}
Play shapez on Steam

View File

@ -46,13 +46,16 @@ export class PreloadState extends GameState {
}
async fetchDiscounts() {
// Bundle is always -10% off
let baseDiscount = this.app.gameAnalytics.abtVariant === "0" ? 1 : 0.9;
await timeoutPromise(
fetch("https://analytics.shapez.io/v1/discounts")
.then(res => res.json())
.then(data => {
globalConfig.currentDiscount = Number(
data["1318690"].data.price_overview.discount_percent
);
globalConfig.currentDiscount =
100 -
baseDiscount * (100 - Number(data["1318690"].data.price_overview.discount_percent));
logger.log("Fetched current discount:", globalConfig.currentDiscount);
}),
2000

View File

@ -58,6 +58,8 @@ global:
# What symbol to use to separate the integer part from the fractional part of a number, e.g. "0.4"
decimalSeparator: "."
discount: -<percentage>% off!
# The suffix for large numbers, e.g. 1.3k, 400.2M, etc.
suffix:
thousands: k