Skip to content

Commit

Permalink
Removed SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
neki-dev committed Nov 22, 2023
1 parent b40ed02 commit a18ee0c
Show file tree
Hide file tree
Showing 43 changed files with 67 additions and 864 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
"scripts": {
"start": "vite --host",
"build": "vite build --mode vanilla",
"build:crazy_games": "vite build --mode crazy_games",
"build:poki": "vite build --mode poki",
"test": "jest",
"lint": "eslint \"./**/*.{js,ts,tsx}\" --ignore-path .gitignore --fix"
},
Expand Down
Binary file removed src/assets/sprites/hud/ads.png
Binary file not shown.
9 changes: 0 additions & 9 deletions src/const/ads.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/const/game.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { GameEnvironment, GameFlag, GamePlatform } from '~type/game';

export const CONTAINER_ID = 'game-container';

export const AUDIO_VOLUME = 0.1;
Expand All @@ -11,31 +9,3 @@ export const DEBUG_MODS = {
position: false,
path: false,
};

export const ENVIRONMENTS: Record<GamePlatform, GameEnvironment> = {
[GamePlatform.POKI]: {
sdk: 'https://game-cdn.poki.com/scripts/v2/poki-sdk.js',
flags: {
[GameFlag.ADS]: true,
[GameFlag.AUTO_ORIENTATION]: true,
},
},
[GamePlatform.CRAZY_GAMES]: {
sdk: 'https://sdk.crazygames.com/crazygames-sdk-v2.js',
flags: {
[GameFlag.ADS]: true,
[GameFlag.COPYRIGHT]: true,
},
},
[GamePlatform.VANILLA]: {
flags: {
[GameFlag.BLOOD]: true,
[GameFlag.COPYRIGHT]: true,
},
},
[GamePlatform.DEVELOPMENT]: {
flags: {
[GameFlag.BLOOD]: true,
},
},
};
54 changes: 10 additions & 44 deletions src/game/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import Phaser from 'phaser';
import {
AUDIO_VOLUME, CONTAINER_ID, DEBUG_MODS,
} from '~const/game';
import { Analytics } from '~lib/analytics';
import { Environment } from '~lib/environment';
import { SDK } from '~lib/sdk';
import { registerShaders } from '~lib/shader';
import { Storage } from '~lib/storage';
import { Tutorial } from '~lib/tutorial';
Expand All @@ -27,7 +24,6 @@ import {
} from '~type/game';
import { MenuPage } from '~type/menu';
import { IScreen } from '~type/screen';
import { SDKAdsType } from '~type/sdk';
import { StorageSave } from '~type/storage';
import { IWorld } from '~type/world';

Expand Down Expand Up @@ -89,10 +85,6 @@ export class Game extends Phaser.Game implements IGame {
},
});

Analytics.Register();

SDK.ToggleLoadState(true);

this.readSettings();

if (!this.isSettingEnabled(GameSettings.TUTORIAL)) {
Expand Down Expand Up @@ -127,7 +119,7 @@ export class Game extends Phaser.Game implements IGame {
|| (this.state === GameState.PAUSED && !this.isSaved)
);

if (needConfirm && Environment.Platform !== 'development') {
if (needConfirm && ENV_MODE !== 'development') {
event.preventDefault();
// @ts-ignore
// eslint-disable-next-line no-param-reassign
Expand All @@ -138,12 +130,6 @@ export class Game extends Phaser.Game implements IGame {
window.addEventListener('contextmenu', (event: Event) => {
event.preventDefault();
});

window.addEventListener('error', (event: ErrorEvent) => {
Analytics.TrackError(
event.error ?? new Error(event.message ?? 'Undefined error'),
);
});
}

public pauseGame() {
Expand All @@ -168,16 +154,14 @@ export class Game extends Phaser.Game implements IGame {
return;
}

SDK.ShowAds(SDKAdsType.MIDGAME).then(() => {
this.setState(GameState.STARTED);
this.setState(GameState.STARTED);

this.scene.systemScene.scene.stop(GameScene.MENU);
this.scene.systemScene.scene.stop(GameScene.MENU);

this.world.scene.resume();
this.screen.scene.resume();
this.world.scene.resume();
this.screen.scene.resume();

this.isSaved = false;
});
this.isSaved = false;
}

public continueGame(save: StorageSave) {
Expand All @@ -187,9 +171,7 @@ export class Game extends Phaser.Game implements IGame {

this.usedSave = save;

SDK.ShowAds(SDKAdsType.MIDGAME).then(() => {
this.startGame();
});
this.startGame();
}

public startNewGame() {
Expand All @@ -199,13 +181,7 @@ export class Game extends Phaser.Game implements IGame {

this.usedSave = null;

if (this.sessionsCount === 0) {
this.startGame();
} else {
SDK.ShowAds(SDKAdsType.MIDGAME).then(() => {
this.startGame();
});
}
this.startGame();
}

private startGame() {
Expand Down Expand Up @@ -262,10 +238,7 @@ export class Game extends Phaser.Game implements IGame {
}

this.stopGame(false);

SDK.ShowAds(SDKAdsType.MIDGAME).then(() => {
this.startGame();
});
this.startGame();
}

public finishGame() {
Expand All @@ -284,15 +257,9 @@ export class Game extends Phaser.Game implements IGame {

this.scene.systemScene.scene.stop(GameScene.SCREEN);
this.scene.systemScene.scene.launch(GameScene.GAMEOVER, { stat, record });

Analytics.TrackEvent({
world: this.world,
success: false,
});
}

public toggleSystemPause(state: boolean) {
SDK.TogglePlayState(!state);
this.events.emit(GameEvents.TOGGLE_PAUSE, state);

if (state) {
Expand All @@ -313,7 +280,6 @@ export class Game extends Phaser.Game implements IGame {
this.state = state;

if (prevPauseState !== nextPauseState) {
SDK.TogglePlayState(!nextPauseState);
this.events.emit(GameEvents.TOGGLE_PAUSE, nextPauseState);
}
}
Expand Down Expand Up @@ -359,7 +325,7 @@ export class Game extends Phaser.Game implements IGame {
if (
this.scale.isFullscreen
|| this.isDesktop()
|| Environment.Platform === 'development'
|| ENV_MODE === 'development'
) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions src/game/scenes/menu/interface/content/save-game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React, {
} from 'react';

import { MAX_GAME_SAVES } from '~const/game';
import { Environment } from '~lib/environment';
import { phrase } from '~lib/lang';
import { Storage } from '~lib/storage';
import { Button } from '~scene/system/interface/button';
Expand All @@ -30,7 +29,7 @@ export const SaveGame: React.FC = () => {

const reachedLimit = (
saves.length >= MAX_GAME_SAVES
&& Environment.Platform !== 'development'
&& ENV_MODE !== 'development'
);

const onSelectSave = (save: StorageSave) => {
Expand Down
10 changes: 3 additions & 7 deletions src/game/scenes/menu/interface/copyright/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';

import pkg from '../../../../../../package.json';
import { Environment } from '~lib/environment';
import { GameFlag } from '~type/game';

import {
Wrapper, Icon, About, Discord, Author, Link,
Expand All @@ -13,11 +11,9 @@ export const Copyright: React.FC = () => (
<About>
<Author>
Created by{' '}
{Environment.GetFlag(GameFlag.COPYRIGHT) ? (
<Link href={pkg.author.url} target="_blank">
{pkg.author.name}
</Link>
) : pkg.author.name}
<Link href={pkg.author.url} target="_blank">
{pkg.author.name}
</Link>
</Author>
Version {pkg.version}
</About>
Expand Down
50 changes: 0 additions & 50 deletions src/game/scenes/screen/interface/ads-reward/index.tsx

This file was deleted.

61 changes: 0 additions & 61 deletions src/game/scenes/screen/interface/ads-reward/modal/index.tsx

This file was deleted.

Loading

0 comments on commit a18ee0c

Please sign in to comment.