mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-01 01:13:25 +00:00
97d0a05d58
## Description: Added rewarded video ads for skin trials via Playwire's manuallyCreateRewardUi API. Users can now click "Try me" to watch a video ad and receive a temporary skin trial. Upon completion a temporary flare is granted to the player so they have ~5 minutes to use the skin. added getPlayerCosmeticsRefs and getPlayerCosmetics to Cosmetics.ts to centralize cosmetic retrieval & validation. <img width="801" height="534" alt="Screenshot 2026-02-10 at 7 58 14 PM" src="https://github.com/user-attachments/assets/51cc378c-2feb-4692-8cf2-20ee54cea3b8" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { LitElement, html } from "lit";
|
|
import { customElement, state } from "lit/decorators.js";
|
|
import { crazyGamesSDK } from "src/client/CrazyGamesSDK";
|
|
import { getGamesPlayed } from "src/client/Utils";
|
|
import { GameType } from "src/core/game/Game";
|
|
import { GameView } from "../../../core/game/GameView";
|
|
import "../../components/VideoPromo";
|
|
import { Layer } from "./Layer";
|
|
|
|
@customElement("spawn-video-ad")
|
|
export class SpawnVideoAd extends LitElement implements Layer {
|
|
public game: GameView;
|
|
|
|
@state() private shouldShow = false;
|
|
@state() private adComplete = false;
|
|
|
|
createRenderRoot() {
|
|
return this;
|
|
}
|
|
|
|
init() {
|
|
if (
|
|
!window.adsEnabled ||
|
|
window.innerWidth < 768 ||
|
|
crazyGamesSDK.isOnCrazyGames() ||
|
|
this.game.config().gameConfig().gameType === GameType.Singleplayer ||
|
|
getGamesPlayed() < 3 // Don't show to new players
|
|
) {
|
|
return;
|
|
}
|
|
this.shouldShow = true;
|
|
}
|
|
|
|
tick() {
|
|
if (this.adComplete) return;
|
|
// Hide when spawn phase ends
|
|
if (this.shouldShow && !this.game.inSpawnPhase()) {
|
|
this.shouldShow = false;
|
|
this.requestUpdate();
|
|
}
|
|
}
|
|
|
|
private handleComplete = () => {
|
|
this.adComplete = true;
|
|
this.shouldShow = false;
|
|
};
|
|
|
|
shouldTransform(): boolean {
|
|
return false;
|
|
}
|
|
|
|
render() {
|
|
if (!this.shouldShow || this.adComplete) {
|
|
return html``;
|
|
}
|
|
|
|
return html`
|
|
<div class="fixed bottom-0 left-0 z-[9999] pointer-events-auto">
|
|
<video-ad
|
|
style="width: 400px; max-width: 400px; height: 225px; aspect-ratio: auto;"
|
|
.onComplete="${this.handleComplete}"
|
|
></video-ad>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|