0.1.4
This commit is contained in:
		@@ -2,11 +2,11 @@ import { Application, Container, EventEmitter, Text, Ticker } from 'pixi.js'
 | 
			
		||||
import { Scale, type ScaleFunction } from '@/game/utilities/scale'
 | 
			
		||||
import type { AnimationOptions, Movement, PlayerDto, TileDto } from '@/common/interfaces'
 | 
			
		||||
import { Tile } from '@/game/Tile'
 | 
			
		||||
import { DIRECTIONS, createContainer, isTilePair } from '@/common/helpers'
 | 
			
		||||
import { createContainer, isTilePair } from '@/common/helpers'
 | 
			
		||||
import { createText } from '@/game/utilities/fonts'
 | 
			
		||||
import { LoggingService } from '@/services/LoggingService'
 | 
			
		||||
import { GlowFilter } from 'pixi-filters'
 | 
			
		||||
import { ORIENTATION_ANGLES } from '@/common/constants'
 | 
			
		||||
import { DIRECTION_INDEXES, DIRECTIONS, ORIENTATION_ANGLES } from '@/common/constants'
 | 
			
		||||
import type { OtherHand } from './OtherHand'
 | 
			
		||||
import { sound } from '@pixi/sound'
 | 
			
		||||
import { t } from '@/i18n'
 | 
			
		||||
@@ -181,6 +181,8 @@ export class Board extends EventEmitter {
 | 
			
		||||
    const tileDto = tile.toPlain()
 | 
			
		||||
    let direction = move.type === 'left' ? this.leftDirection : this.rightDirection
 | 
			
		||||
 | 
			
		||||
    move.direction = this.hasSpaceToMove(move)
 | 
			
		||||
 | 
			
		||||
    if (this.tiles.length === 0) {
 | 
			
		||||
      x = 0
 | 
			
		||||
      y = 0
 | 
			
		||||
@@ -592,6 +594,22 @@ export class Board extends EventEmitter {
 | 
			
		||||
    return [canPlayNorth, canPlayEast, canPlaySouth, canPlayWest]
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  hasSpaceToMove(move: Movement): string | undefined {
 | 
			
		||||
    if (move.tile === undefined || move.direction === undefined) {
 | 
			
		||||
      return undefined
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const nextValidMoves = this.nextTileValidMoves(move.tile, move.type)
 | 
			
		||||
    let index = DIRECTION_INDEXES[move.direction]
 | 
			
		||||
    let valid = nextValidMoves[index]
 | 
			
		||||
    while (!valid && index < nextValidMoves.length) {
 | 
			
		||||
      index++
 | 
			
		||||
      valid = nextValidMoves[index % nextValidMoves.length]
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return DIRECTIONS[index]
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  clean() {
 | 
			
		||||
    this.tiles = []
 | 
			
		||||
    this.boneyard = []
 | 
			
		||||
 
 | 
			
		||||
@@ -81,8 +81,7 @@ export class Game extends EventEmitter {
 | 
			
		||||
  iniialStuff(app: Application) {
 | 
			
		||||
    app.stage.addChild(this.backgroundLayer)
 | 
			
		||||
    const background = new Sprite(Assets.get(`bg-${this.options.background}`))
 | 
			
		||||
    background.width = this.app.canvas.width
 | 
			
		||||
    background.height = this.app.canvas.height
 | 
			
		||||
 | 
			
		||||
    this.backgroundLayer.addChild(background)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user