feat:提交
This commit is contained in:
176
tests/dev1/dataHandle/common/PlacePostionHelper.ts
Normal file
176
tests/dev1/dataHandle/common/PlacePostionHelper.ts
Normal file
@@ -0,0 +1,176 @@
|
||||
import { PlaceStyle, BoardPosition, PlaceBoard, PlaceBlock } from '../confClass'
|
||||
|
||||
|
||||
export class PlacePositionHelper // 靠板类
|
||||
{
|
||||
static turnPlacePosition(pb: PlaceBoard, newlocator: BoardPosition, config: any) {
|
||||
const { placeOriginByBoardLocation } = config
|
||||
|
||||
if (placeOriginByBoardLocation == false)
|
||||
return
|
||||
if (pb.isAdnormal())
|
||||
return // 余料板是余料板,不参与翻转
|
||||
let width = pb.width
|
||||
let length = pb.length
|
||||
// RIGHT_BOTTOM, 靠板
|
||||
if (newlocator == BoardPosition.RIGHT_BOTTOM) {
|
||||
for (let block of pb.blockList) {
|
||||
let x = width - block.placeX - block.placeWidth
|
||||
let y = block.placeY
|
||||
let placeStyle = this.getPlaceStyle_zy(block)
|
||||
block.placeX = x
|
||||
block.placeY = y
|
||||
block.placeStyle = placeStyle
|
||||
}
|
||||
}
|
||||
// RIGHT_TOP, 靠板
|
||||
if (newlocator == BoardPosition.RIGHT_TOP) {
|
||||
console.log('BoardPosition=BoardPosition.RIGHT_TOP')
|
||||
for (let block of pb.blockList) {
|
||||
let x = width - block.placeX - block.placeWidth
|
||||
let y = length - block.placeLength - block.placeY
|
||||
let placeStyle = this.getPlaceStyle_dj(block)
|
||||
block.placeX = x
|
||||
block.placeY = y
|
||||
block.placeStyle = placeStyle
|
||||
}
|
||||
}
|
||||
// 左上角, 靠板
|
||||
if (newlocator == BoardPosition.LEFT_TOP) {
|
||||
console.log('BoardPosition=BoardPosition.左上角')
|
||||
for (let block of pb.blockList) {
|
||||
let x = block.placeX
|
||||
let y = length - block.placeLength - block.placeY
|
||||
let placeStyle = this.getPlaceStyle_sx(block)
|
||||
block.placeX = x
|
||||
block.placeY = y
|
||||
block.placeStyle = placeStyle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static resetPlacePosition(pb: PlaceBoard, newlocator: BoardPosition, config: any) {
|
||||
|
||||
const { placeOriginByBoardLocation } = config
|
||||
if (placeOriginByBoardLocation == false)
|
||||
return
|
||||
|
||||
if (newlocator == BoardPosition.RIGHT_BOTTOM)
|
||||
return
|
||||
|
||||
let width = pb.width
|
||||
let length = pb.length
|
||||
// RIGHT_BOTTOM, 靠板
|
||||
if (newlocator == BoardPosition.RIGHT_TOP) {
|
||||
for (let block of pb.blockList) {
|
||||
let x = width - block.placeX - block.placeWidth
|
||||
let y = block.placeY
|
||||
let placeStyle = this.getPlaceStyle_zy(block)
|
||||
block.placeX = x
|
||||
block.placeY = y
|
||||
block.placeStyle = placeStyle
|
||||
}
|
||||
}
|
||||
// RIGHT_TOP, 靠板
|
||||
if (newlocator == BoardPosition.RIGHT_TOP) {
|
||||
for (let block of pb.blockList) {
|
||||
let x = width - block.placeX - block.placeWidth
|
||||
let y = length - block.placeLength - block.placeY
|
||||
let placeStyle = this.getPlaceStyle_dj(block)
|
||||
block.placeX = x
|
||||
block.placeY = y
|
||||
block.placeStyle = placeStyle
|
||||
}
|
||||
}
|
||||
// 左上角, 靠板
|
||||
if (newlocator == BoardPosition.LEFT_TOP) {
|
||||
for (let block of pb.blockList) {
|
||||
let x = block.placeX
|
||||
let y = length - block.placeLength - block.placeY
|
||||
let placeStyle = this.getPlaceStyle_sx(block)
|
||||
|
||||
block.placeX = x
|
||||
block.placeY = y
|
||||
block.placeStyle = placeStyle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获得新的放置方式
|
||||
static getPlaceStyle_zy(block: PlaceBlock): PlaceStyle // 左右翻,
|
||||
{
|
||||
// if (block.IsUnRegular == false && block.HasThroghModel == false) return block.placeStyle;
|
||||
|
||||
if (block.placeStyle == PlaceStyle.FRONT)
|
||||
return PlaceStyle.BACK
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_RIGHT)
|
||||
return PlaceStyle.BACK_TURN_LEFT
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_BACK)
|
||||
return PlaceStyle.BACK_TURN_BACK
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_LEFT)
|
||||
return PlaceStyle.BACK_TURN_RIGHT
|
||||
|
||||
if (block.placeStyle == PlaceStyle.BACK)
|
||||
return PlaceStyle.FRONT
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_LEFT)
|
||||
return PlaceStyle.FRONT_TURN_RIGHT
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_BACK)
|
||||
return PlaceStyle.FRONT_TURN_BACK
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_RIGHT)
|
||||
return PlaceStyle.FRONT_TURN_LEFT
|
||||
|
||||
|
||||
return PlaceStyle.FRONT
|
||||
}
|
||||
|
||||
static getPlaceStyle_sx(block: PlaceBlock): PlaceStyle // 上下翻,
|
||||
{
|
||||
// if (block.IsUnRegular == false && block.HasThroghModel == false) return block.placeStyle;
|
||||
|
||||
if (block.placeStyle == PlaceStyle.FRONT)
|
||||
return PlaceStyle.BACK_TURN_BACK
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_RIGHT)
|
||||
return PlaceStyle.BACK_TURN_RIGHT
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_BACK)
|
||||
return PlaceStyle.BACK
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_LEFT)
|
||||
return PlaceStyle.BACK_TURN_LEFT
|
||||
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_BACK)
|
||||
return PlaceStyle.FRONT
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_RIGHT)
|
||||
return PlaceStyle.FRONT_TURN_RIGHT
|
||||
if (block.placeStyle == PlaceStyle.BACK)
|
||||
return PlaceStyle.FRONT_TURN_BACK
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_LEFT)
|
||||
return PlaceStyle.FRONT_TURN_LEFT
|
||||
|
||||
|
||||
return PlaceStyle.FRONT
|
||||
}
|
||||
|
||||
static getPlaceStyle_dj(block: PlaceBlock): PlaceStyle // 对角翻
|
||||
{
|
||||
// if (block.IsUnRegular == false && block.HasThroghModel == false) return block.placeStyle;
|
||||
|
||||
if (block.placeStyle == PlaceStyle.FRONT)
|
||||
return PlaceStyle.FRONT_TURN_BACK
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_RIGHT)
|
||||
return PlaceStyle.FRONT_TURN_RIGHT
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_BACK)
|
||||
return PlaceStyle.FRONT
|
||||
if (block.placeStyle == PlaceStyle.FRONT_TURN_LEFT)
|
||||
return PlaceStyle.FRONT_TURN_RIGHT
|
||||
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_BACK)
|
||||
return PlaceStyle.BACK
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_RIGHT)
|
||||
return PlaceStyle.BACK_TURN_LEFT
|
||||
if (block.placeStyle == PlaceStyle.BACK)
|
||||
return PlaceStyle.BACK_TURN_BACK
|
||||
if (block.placeStyle == PlaceStyle.BACK_TURN_LEFT)
|
||||
return PlaceStyle.BACK_TURN_RIGHT
|
||||
|
||||
return PlaceStyle.FRONT
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user