Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie committed Mar 21, 2024
1 parent f12083d commit e9dd676
Show file tree
Hide file tree
Showing 17 changed files with 254 additions and 497 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100
"printWidth": 120
}
648 changes: 220 additions & 428 deletions puzzling-potions/package-lock.json

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions puzzling-potions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
"types": "tsc",
"prepreview": "run-s build",
"preview": "vite preview --open",
"clean": "rimraf public/assets/* dist/* .assetpack/*"
"clean": "rimraf public/assets/* dist/* .assetpack/*",
"lint:fix": "prettier --write src/**/*.ts"
},
"dependencies": {
"@pixi/sound": "^5.2.2",
"@pixi/spine-pixi": "^1.0.4",
"@pixi/ui": "^0.10.2",
"gsap": "^3.12.2",
"pixi.js": "^8.0.0-rc.2"
"@pixi/sound": "^6.0.0",
"@pixi/spine-pixi": "^1.0.6",
"@pixi/ui": "^2.0.0",
"gsap": "^3.12.5",
"pixi.js": "^8.0.3"
},
"devDependencies": {
"@assetpack/cli": "^0.8.0",
Expand All @@ -30,8 +31,9 @@
"@assetpack/plugin-texture-packer": "^0.8.0",
"@assetpack/plugin-webfont": "^0.8.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"typescript": "^5.2.2",
"vite": "^5.0.11"
"typescript": "^5.4.3",
"vite": "^5.2.2"
}
}
12 changes: 3 additions & 9 deletions puzzling-potions/src/match3/Match3Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ export class Match3Actions {

const type = match3GetPieceType(this.match3.board.grid, from);
const specialFrom = this.match3.special.isSpecial(type);
const specialTo = this.match3.special.isSpecial(
match3GetPieceType(this.match3.board.grid, to),
);
const specialTo = this.match3.special.isSpecial(match3GetPieceType(this.match3.board.grid, to));

// Always allow move that either or both are special pieces
if (specialFrom || specialTo) return true;
Expand Down Expand Up @@ -153,14 +151,10 @@ export class Match3Actions {
pieceA.animateSwap(viewPositionA.x, viewPositionA.y),
pieceB.animateSwap(viewPositionB.x, viewPositionB.y),
]);
} else if (
this.match3.special.isSpecial(match3GetPieceType(this.match3.board.grid, positionA))
) {
} else if (this.match3.special.isSpecial(match3GetPieceType(this.match3.board.grid, positionA))) {
// Pop piece A if is special
await this.match3.board.popPiece(positionA);
} else if (
this.match3.special.isSpecial(match3GetPieceType(this.match3.board.grid, positionB))
) {
} else if (this.match3.special.isSpecial(match3GetPieceType(this.match3.board.grid, positionB))) {
// Pop piece B if is special
await this.match3.board.popPiece(positionB);
}
Expand Down
4 changes: 1 addition & 3 deletions puzzling-potions/src/match3/Match3Board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export class Match3Board {
this.piecesContainer = new Container();
this.match3.addChild(this.piecesContainer);

this.piecesMask = new Graphics()
.rect(-2, -2, 4, 4)
.fill({ color: 0xff0000, alpha: 0.5});
this.piecesMask = new Graphics().rect(-2, -2, 4, 4).fill({ color: 0xff0000, alpha: 0.5 });
this.match3.addChild(this.piecesMask);
this.piecesContainer.mask = this.piecesMask;
}
Expand Down
2 changes: 1 addition & 1 deletion puzzling-potions/src/match3/Match3Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export const match3ValidModes = ['test', 'easy', 'normal', 'hard'] as const;

/** The game mode type */
export type Match3Mode = typeof match3ValidModes[number];
export type Match3Mode = (typeof match3ValidModes)[number];

/**
* Map of all available blocks for the game, ordered by game mode.
Expand Down
7 changes: 1 addition & 6 deletions puzzling-potions/src/match3/Match3Piece.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Container, FederatedPointerEvent, Sprite, Texture } from 'pixi.js';
import gsap from 'gsap';
import { Match3Position } from './Match3Utility';
import {
resolveAndKillTweens,
registerCustomEase,
pauseTweens,
resumeTweens,
} from '../utils/animation';
import { resolveAndKillTweens, registerCustomEase, pauseTweens, resumeTweens } from '../utils/animation';
import { app } from '../main';

/** Default piece options */
Expand Down
21 changes: 4 additions & 17 deletions puzzling-potions/src/match3/Match3Utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ export function match3GetRandomType(types: Match3Type[], exclude?: Match3Type[])
* @param positionA The first piece to swap
* @param positionB The second piece to swap
*/
export function match3SwapPieces(
grid: Match3Grid,
positionA: Match3Position,
positionB: Match3Position,
) {
export function match3SwapPieces(grid: Match3Grid, positionA: Match3Position, positionB: Match3Position) {
const typeA = match3GetPieceType(grid, positionA);
const typeB = match3GetPieceType(grid, positionB);

Expand Down Expand Up @@ -148,20 +144,15 @@ export function match3GetPieceType(grid: Match3Grid, position: Match3Position) {
export function match3IsValidPosition(grid: Match3Grid, position: Match3Position) {
const rows = grid.length;
const cols = grid[0].length;
return (
position.row >= 0 && position.row < rows && position.column >= 0 && position.column < cols
);
return position.row >= 0 && position.row < rows && position.column >= 0 && position.column < cols;
}

/**
* Loop through every position in the grid
* @param grid The grid in context
* @param fn Callback for each position in the grid
*/
export function match3ForEach(
grid: Match3Grid,
fn: (position: Match3Position, type: Match3Type) => void,
) {
export function match3ForEach(grid: Match3Grid, fn: (position: Match3Position, type: Match3Type) => void) {
for (let r = 0; r < grid.length; r++) {
for (let c = 0; c < grid[r].length; c++) {
fn({ row: r, column: c }, grid[r][c]);
Expand All @@ -176,11 +167,7 @@ export function match3ForEach(
* @param orientation If the search is horizontal or vertical
* @returns
*/
function match3GetMatchesByOrientation(
grid: Match3Grid,
matchSize: number,
orientation: Match3Orientation,
) {
function match3GetMatchesByOrientation(grid: Match3Grid, matchSize: number, orientation: Match3Orientation) {
const matches = [];
const rows = grid.length;
const columns = grid[0].length;
Expand Down
3 changes: 1 addition & 2 deletions puzzling-potions/src/popups/InfoPopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export class InfoPopup extends Container {
/** Dismiss the popup, animated */
public async hide() {
if (navigation.currentScreen) {
// TODO: Fix filters type issue
(navigation.currentScreen as any).filters = null;
navigation.currentScreen.filters = [];
}
gsap.killTweensOf(this.bg);
gsap.killTweensOf(this.panel.pivot);
Expand Down
3 changes: 1 addition & 2 deletions puzzling-potions/src/popups/PausePopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export class PausePopup extends Container {
/** Dismiss the popup, animated */
public async hide() {
if (navigation.currentScreen) {
// TODO: Fix filters type issue
(navigation.currentScreen as any).filters = null;
navigation.currentScreen.filters = [];
}
gsap.killTweensOf(this.bg);
gsap.killTweensOf(this.panel.pivot);
Expand Down
3 changes: 1 addition & 2 deletions puzzling-potions/src/popups/SettingsPopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ export class SettingsPopup extends Container {
/** Dismiss the popup, animated */
public async hide() {
if (navigation.currentScreen) {
// TODO: Fix filters type issue
(navigation.currentScreen as any).filters = null;
navigation.currentScreen.filters = [];
}
gsap.killTweensOf(this.bg);
gsap.killTweensOf(this.panel.pivot);
Expand Down
2 changes: 1 addition & 1 deletion puzzling-potions/src/screens/HomeScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class HomeScreen extends Container {
leftWidth: 32,
topHeight: 32,
rightWidth: 32,
bottomHeight: 32
bottomHeight: 32,
});
this.base.tint = 0x2c136c;
this.addChild(this.base);
Expand Down
2 changes: 1 addition & 1 deletion puzzling-potions/src/ui/Dragon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Dragon extends Container {

this.spine = Spine.from({
skeleton: 'common/dragon-skeleton.json',
atlas: 'common/dragon-skeleton.atlas'
atlas: 'common/dragon-skeleton.atlas',
});
// this.spine.autoUpdate = true;
this.spine.scale.set(0.3);
Expand Down
16 changes: 4 additions & 12 deletions puzzling-potions/src/ui/GameEffects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ import { waitFor } from '../utils/asyncUtils';
import { throttle } from '../utils/throttle';

/** Custom ease curve for x tweens of pieces flying to cauldron */
const easeJumpToCauldronX = registerCustomEase(
'M0,0,C0,0,0.063,-0.304,0.374,-0.27,0.748,-0.228,1,1,1,1',
);
const easeJumpToCauldronX = registerCustomEase('M0,0,C0,0,0.063,-0.304,0.374,-0.27,0.748,-0.228,1,1,1,1');

/** Custom ease curve for y tweens of pieces flying to cauldron */
const easeJumpToCauldronY = registerCustomEase(
'M0,0 C0,0 0.326,1.247 0.662,1.29 0.898,1.32 1,1 1,1 ',
);
const easeJumpToCauldronY = registerCustomEase('M0,0 C0,0 0.326,1.247 0.662,1.29 0.898,1.32 1,1 1,1 ');

/** Custom ease curve for scale tweens of pieces flying to cauldron */
const easeJumpToCauldronScale = registerCustomEase(
'M0,0,C0,0,0.043,-1.694,0.356,-1.694,1.026,-1.694,1,1,1,1',
);
const easeJumpToCauldronScale = registerCustomEase('M0,0,C0,0,0.043,-1.694,0.356,-1.694,1.026,-1.694,1,1,1,1');

/**
* All gameplay special effects, isolated on its own class in a way that can be changed freely, without affecting gameplay.
Expand Down Expand Up @@ -162,9 +156,7 @@ export class GameEffects extends Container {
animatedPiece.alpha = 1;
this.addChild(animatedPiece);
await waitFor(randomRange(0, 0.3));
throttle('pieceExplosion', 100, () =>
sfx.play('common/sfx-incorrect.wav', { volume: 0.5 }),
);
throttle('pieceExplosion', 100, () => sfx.play('common/sfx-incorrect.wav', { volume: 0.5 }));
this.playPopExplosion(position);
const upTime = duration * 0.4;
const downTime = duration * 0.6;
Expand Down
4 changes: 2 additions & 2 deletions puzzling-potions/src/ui/LargeButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class LargeButton extends FancyButton {
height: opts.height,
});

const hoverView = new NineSliceSprite({
const hoverView = new NineSliceSprite({
texture: Texture.from('button-large-hover'),
leftWidth: 36,
topHeight: 42,
Expand All @@ -42,7 +42,7 @@ export class LargeButton extends FancyButton {
height: opts.height,
});

const pressedView = new NineSliceSprite({
const pressedView = new NineSliceSprite({
texture: Texture.from('button-large-press'),
leftWidth: 36,
topHeight: 42,
Expand Down
2 changes: 1 addition & 1 deletion puzzling-potions/src/ui/ModeSwitcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ModeSwitcher extends RadioGroup {
height - padding * 2,
radius - padding,
)
.fill({ color: fillColor}),
.fill({ color: fillColor }),
unchecked: new Graphics()
.roundRect(0, 0, width, height, radius)
.fill({ color: bgColor })
Expand Down
2 changes: 1 addition & 1 deletion puzzling-potions/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"moduleResolution": "bundler",
"strict": true,
"resolveJsonModule": true,
"isolatedModules": true,
Expand Down

0 comments on commit e9dd676

Please sign in to comment.