1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Adjust for the summer sale

This commit is contained in:
tobspr
2022-06-23 19:48:53 +02:00
parent 1e6199b213
commit e2907a1ab8
39 changed files with 332 additions and 137 deletions

View File

@@ -153,6 +153,14 @@
transform: rotate(3deg);
}
}
.specialOffer {
color: #000000;
@include PlainText;
align-self: center;
text-align: center;
@include S(margin-top, 5px);
}
}
.point {

View File

@@ -332,6 +332,18 @@
transform: rotate(5deg);
}
}
.specialOffer {
color: #000000;
@include PlainText;
align-self: center;
text-align: center;
@include S(margin-top, 5px);
@include InlineAnimation(1s ease-in-out infinite) {
50% {
transform: scale(1.02, 1.03) translateY(2%);
}
}
}
.points {
display: grid;

View File

@@ -49,6 +49,11 @@ export class HUDStandaloneAdvantages extends BaseHUDPart {
: ""
}
</button>
${
["1", "3"].includes(this.root.app.gameAnalytics.abtVariant)
? `<span class="specialOffer">${T.global.discountSummerSale}</span>`
: ""
}
<button class="otherCloseButton" data-btn-variant="${G_IS_STEAM_DEMO ? "steam-demo" : "prod"}">${
T.ingame.standaloneAdvantages.no_thanks
}</button>

View File

@@ -1,4 +1,4 @@
import { globalConfig, THIRDPARTY_URLS } from "../../core/config";
import { globalConfig } from "../../core/config";
import { createLogger } from "../../core/logging";
import { queryParamOptions } from "../../core/query_parameters";
import { randomInt } from "../../core/utils";
@@ -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_dsct";
const CURRENT_ABT_COUNT = 2;
const CURRENT_ABT = "abt_ssst";
const CURRENT_ABT_COUNT = 4;
export class ShapezGameAnalytics extends GameAnalyticsInterface {
constructor(app) {

View File

@@ -42,8 +42,7 @@ export class MainMenuState extends GameState {
const showLanguageIcon = !G_CHINA_VERSION && !G_WEGAME_VERSION;
const showExitAppButton = G_IS_STANDALONE;
const showPuzzleDLC =
G_IS_DEV ||
(!G_WEGAME_VERSION && (G_IS_STANDALONE || WEB_STEAM_SSO_AUTHENTICATED) && !G_IS_STEAM_DEMO);
!G_WEGAME_VERSION && (G_IS_STANDALONE || WEB_STEAM_SSO_AUTHENTICATED) && !G_IS_STEAM_DEMO;
const showWegameFooter = G_WEGAME_VERSION;
const hasMods = MODS.anyModsActive();
@@ -111,6 +110,11 @@ export class MainMenuState extends GameState {
}
Play shapez on Steam
</a>
${
["1", "3"].includes(this.app.gameAnalytics.abtVariant)
? `<span class="specialOffer">${T.global.discountSummerSale}</span>`
: ""
}
${!G_IS_STEAM_DEMO ? `<div class="onlinePlayerCount"></div>` : ""}
`;

View File

@@ -47,22 +47,25 @@ export class PreloadState extends GameState {
}
async fetchDiscounts() {
// Bundle is always -10% off
let baseDiscount = this.app.gameAnalytics.abtVariant === "0" ? 1 : 0.9;
// Summer sale specific
const bundle = ["0", "1"].includes(this.app.gameAnalytics.abtVariant);
globalConfig.currentDiscount = 60;
globalConfig.standaloneCampaignLink = bundle
? "https://get.shapez.io/bundle/$campaign"
: "https://get.shapez.io/$campaign";
await timeoutPromise(
fetch("https://analytics.shapez.io/v1/discounts")
.then(res => res.json())
.then(data => {
globalConfig.currentDiscount =
100 -
baseDiscount * (100 - Number(data["1318690"].data.price_overview.discount_percent));
logger.log("Fetched current discount:", globalConfig.currentDiscount);
}),
2000
).catch(err => {
logger.warn("Failed to fetch current discount:", err);
});
// Regular
// 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);
// logger.log("Fetched current discount:", globalConfig.currentDiscount);
// }),
// 2000
// ).catch(err => {
// logger.warn("Failed to fetch current discount:", err);
// });
}
async sendBeacon() {