• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16export class DistributedDataModel {
17  public isOver: boolean = false
18  public step: number = 0
19  public chessMapArr: Array<Array<string>> = []
20  public chessX: number = -1
21  public chessY: number = -1
22  public fallGather: Array<Array<number>> = []
23  public clickCount: number = 0
24  public fallLocation: Array<number> = []
25
26  constructor(isOver: boolean) {
27    this.isOver = isOver
28  }
29
30  init() {
31    this.isOver = false
32    for (let i = 0; i < 15; i++) {
33      this.chessMapArr[i] = []
34      for (let j = 0; j < 15; j++) {
35        this.chessMapArr[i][j] = ''
36      }
37    }
38    this.chessX = -1
39    this.chessY = -1
40  }
41
42  fallChess(x: number, y: number, color: string) {
43    this.fallGather.unshift([x, y])
44    this.chessMapArr[x][y] = color
45    this.chessX = x
46    this.chessY = y
47  }
48}
49