4.6.0 • Published 2 years ago

wqisland-island v4.6.0

Weekly downloads
12
License
MIT
Repository
github
Last release
2 years ago

围棋岛

研究模式

this.resourceObj &&  this.resourceObj.off()
this.resourceObj = new Resource({
  $el: this.$refs.resource, // 必填,canvas对象
  sz: 13, // 必填,棋盘大小
  width: 500, // 必填,棋盘宽和高度,建议style写的多大就是多大
  content: sgf, // 必填, sgf 文件
  enableMouseOver: true, //  可填,是否开启鼠标移动效果,针对于pc端
  enableTouch: false, // 可填,是否开启移动端点击事件
  onError (e) {   // 必填,这道题做错事件
    console.log(e)
  },
  onDeadStones (stones, type) { // 选填,当前提子,提子类型  1 黑子 -1 白子
    console.log(stones, type)
  }
})
this.resourceObj.goFirstStep()  第一步
this.resourceObj.goStep(-1) 上一步
this.resourceObj.goStep(1) 下一步
this.resourceObj.goLastStep() 最后一步

打谱模式

this.score && this.score.off()
this.score = new Score({
  $el: [this.$refs.score1, this.$refs.score2], //必填,2个canvas对象
  sz: 13, // 必填,棋盘大小
  width: 500,  // 必填,棋盘宽和高度,建议style写的多大就是多大
  content: sgf, // 必填, sgf 文件
  enableMouseOver: true, //  可填,是否开启鼠标移动效果,针对于pc端
  enableTouch: false, // 可填,是否开启移动端点击事件
  onError (e) {  // 必填,这道题做错事件
    console.log(e)
  },
  onSuccess ({code, message}) { // 必填,做成功事件
    console.log(code, message)
  },
  onDeadStones (stones, type) { // 选填,当前提子,提子类型  1 黑子 -1 白子
    console.log(stones, type)
  },
  complete: () => {  // 必填,题目准备完成事件,需要主动调用start开始这道题
    console.log('准备完成')
    // 准备完成之后,主动触发游戏
    this.score.start()
  },
  ETLaZi: () => { // 机器落子事件
    console.log('机器落子')
  }
})

练习模式

this.practice && this.practice.off()
this.practice = new Practice({
  $el: this.$refs.practice, // 必填,canvas对象
  sz: 13, // 必填,棋盘大小
  width: 500, // 必填,棋盘宽和高度,建议style写的多大就是多大
  type: type, // 必填,题目类型 0 执行题 1 单选题 2 判断题 3 棋子笑脸题 4 棋子外点击三角符号题
  content: sgf, // 必填, sgf 文件
  enableTouch: false, // 可填,是否开启移动端点击事件
  onError (e) {  // 必填,这道题做错事件
    console.log(e)
  },
  onSuccess ({code, message}) { // 必填,做成功事件,有些题目需要自己去拿this.practice里面内容去判断是否正常,比如单选题
    this.practice.getSelected() // 获取选中棋子
    console.log(code, message)
  },
})

吃子 本地逻辑 (只有普通吃子)

this.manMachine && this.manMachine.off()
this.manMachine = new ManMachine({
  $el: this.$refs.manMachine, // 必填,canvas对象
  sz: 9,  // 必填,棋盘大小
  width: 500, // 必填,棋盘宽和高度,建议style写的多大就是多大
  whoBefore: 'et', // 必填,谁先下棋,用户先 传user,机器先传et
  level: 4, // 必填,1-5, 数字越大,机器越强
  stones: 5, // 必填,吃多少子算赢
  enableMouseOver: true, //  可填,是否开启鼠标移动效果,针对于pc端
  enableTouch: false, // 可填,是否开启移动端点击事件
  userChess: (point) => {   // 可填,用户是否需要确认落子,需要确认的话,开启此方法
    console.log(point)
    setTimeout(() => {
      this.manMachine.submit()  // 用户确认落子事件,交给用户自由发挥
    }, 3000)
  },
  etWant (type) {     // 可填,机器正在下子事件
    // type wanting 正在思考  wanted 思考完成,已下
    console.log(type)
  },
  onError (e) {  // 必填,暴露一些错误或者提示,比如不允许下子或者其他一些业务逻辑不允许情况
    console.log(e)
  },
  onSuccess (isWin, stones, level, sgf) {   // 必填,true代表人赢,false代表机器赢, 'flat'代表平局(现在逻辑是大于60手就平局)
    console.log(isWin, stones, level, sgf)
  },
  onKillStone (user_num, bt_num) {    // 必填,吃子数量回调(用户被吃子,人机被吃子)
    console.log(user_num, bt_num)
  },
})

吃子 外部接口 (包含花式吃子和普通吃子,只有9路和13路才有花式吃子,其他路没有数据)

this.manMachineHs &&  this.manMachineHs.off()
this.manMachineHs = new ManMachineHs({
  $el: this.$refs.manMachineHs, // 必填,canvas对象
  sz: 13,  // 必填,棋盘大小
  width: 500, // 必填,棋盘宽和高度,建议style写的多大就是多大
  whoBefore: 'et',  // 必填,谁先下棋,用户先 传user,机器先传et
  hs: true,  // 可填,是否花式围地,可以手动控制是否需要花式处理
  level: 25, // 必填,可传 5,7,8,9,10,15,20,25 数字越小,难度越大
  stones: 9, // 必填,吃多少子算赢(一般根据棋盘大小来,9路盘吃9子,13路盘吃9子)
  enableMouseOver: true,  //可填, 是否开启鼠标移动效果,针对于pc端
  enableTouch: false,    // 可填,是否开启移动端点击事件
  userChess: (point) => {   // 可填,用户是否需要确认落子,需要确认的话,开启此方法
    console.log(point)
    setTimeout(() => {
      this.manMachine.submit()  // 用户确认落子事件,交给用户自由发挥
    }, 3000)
  },
  etWant (type) {     // 可填,机器正在下子事件
    // type wanting 正在思考  wanted 思考完成,已下
    console.log(type)
  },
  onError (e) {  // 必填,暴露一些错误或者提示,比如不允许下子或者其他一些业务逻辑不允许情况
    console.log(e)
  },
  onSuccess (isWin, stones, level, sgf) {   // 必填,true代表人赢,false代表机器赢, 'flat'代表平局(现在逻辑是大于60手就平局)
    console.log(isWin, stones, level, sgf)
  },
  onKillStone (user_num, bt_num) {    // 必填,吃子数量回调(用户被吃子,人机被吃子)
    console.log(user_num, bt_num)
  },
})

围地 外部接口(包含花式围地和普通围地,只有13路才有花式围地,其他路没有数据)

this.manMachineWd &&  this.manMachineWd.off() // 建议每次off一下,释放内存
this.manMachineWd = new ManMachineWd({
  $el: this.$refs.manMachineWd,  // 必填,canvas对象
  sz: 13, // 必填,棋盘大小
  width: 500,  // 必填,棋盘宽和高度,建议style写的多大就是多大
  whoBefore: 'user',  // 必填,谁先下棋,用户先 传user,机器先传et
  hs: true, // 可填,是否花式围地,可以手动控制是否需要花式处理
  level: 25, // 必填,可传 5,7,8,9,10,15,20,25 数字越小,难度越大
  enableMouseOver: true,  //可填, 是否开启鼠标移动效果,针对于pc端
  enableTouch: false,    // 可填,是否开启移动端点击事件
  userChess: (point) => {   // 可填,用户是否需要确认落子,需要确认的话,开启此方法
    console.log(point)
    setTimeout(() => {
      this.manMachine.submit()  // 用户确认落子事件,交给用户自由发挥
    }, 3000)
  },
  etWant (type) {     // 可填,机器正在下子事件
    // type wanting 正在思考  wanted 思考完成,已下
    console.log(type)
  },
  onError (e) {  // 必填,暴露一些错误或者提示,比如不允许下子或者其他一些业务逻辑不允许情况
    console.log(e)
  },
  onSuccess (isWin, stones, level, sgf) {   // 必填,true代表人赢,false代表机器赢, 'flat'代表平局, 'shuzi'代表进入数子阶段,业务主动调用suzi的方法,得到返回结果显示到页面上
    console.log(isWin, stones, level, sgf)
  },
  onKillStone (user_num, bt_num) {    // 必填,吃子数量回调(用户被吃子,人机被吃子)
    console.log(user_num, bt_num)
  },
})
4.5.0

2 years ago

4.4.0

2 years ago

4.6.0

2 years ago

4.3.0

2 years ago

4.2.5

3 years ago

4.2.3

3 years ago

4.2.4

3 years ago

4.2.2

3 years ago

4.2.1

3 years ago

4.2.0

3 years ago

4.1.0

3 years ago

4.0.0

3 years ago

3.9.0

3 years ago

3.8.0

3 years ago

3.7.0

3 years ago

3.6.0

3 years ago

3.5.0

3 years ago

3.3.0

3 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.5.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.9.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago