ArcherArcher
首页
快速开始
项目介绍
  • 简体中文
  • English
首页
快速开始
项目介绍
  • 简体中文
  • English
  • 首页
  • 基础配置

    • 项目介绍
    • 快速开始
    • 常见问题
    • 联系我们
  • 二次开发

    • 基础知识
    • 基础框架
    • 雀魂开发

      • 牌名

        • 基本
      • 管理器

        • 大厅管理器
      • 游戏接口

        • 基本
      • lq

        • 基本
      • 动作类型

        • 基本
      • 游戏状态

        • 基本
      • 登录事件

        • 登录事件
        • 进阶:麻将事件登录
      • 弃牌

        • 基础
        • 进阶
      • 吃
      • 碰
      • 杠
      • 取消、跳过
  • 插件系统

    • 基础使用
    • 资源类插件开发
  • 自动Review

    • 自动Review
  • 天凤个室对战

    • 在天凤个室与Mortal对局

回顾

在上一节中, 我们只是简单的调用 actions 接口来进行出牌操作。但是我们知道在 雀魂 游戏中在立直(Riichi)后全程由服务端自动丢弃最后一张牌, 所以我们在上一章节的代码就要改一改, 在自己已经立直的情况下, 取消该动作。

如何判断

  • 在 gamestate 这个库中提供了一些游戏状态可以辅助你进行判断游戏当前的状态

示例代码

package main

import (
  "github.com/moxcomic/Archer/actions"
  "github.com/moxcomic/lq"
)

const (
  E_PlayOperation_None           = iota
  E_PlayOperation_Discard
  E_PlayOperation_Chi
  E_PlayOperation_Pon
  E_PlayOperation_Ankan
  E_PlayOperation_Minkan
  E_PlayOperation_Kakan
  E_PlayOperation_RiiChi
  E_PlayOperation_Tsumo
  E_PlayOperation_Ron
  E_PlayOperation_JiuZhongJiuPai
  E_PlayOperation_Babei
  E_PlayOperation_HuanSanZhang
  E_PlayOperation_DingQue
  E_PlayOperation_Reveal
  E_PlayOperation_Unveil
  E_PlayOperation_LockTile
  E_PlayOperation_Revealliqi
)

func onExecute(result *lq.NotifyAIResult, risk []float64, r, m, f, t float64) {
  if result.GetResult()[0].GetType() == E_PlayOperation_Discard {
    if gamestate.Inst().Riichi()[0] {
      if gamestate.Inst().IsOperation(E_PlayOperation_Ankan) {
        actions.NewMajsoulActions().Cancel()
      }
      
      return
    }
    
    actions.NewMajsoulActions().Discard(result.GetResult()[0].GetTile(), result.GetResult()[0].GetMoqie())
  }
}
  • 我们在 onExecute 函数中判断游戏当前是否处于立直状态, 如果是立直状态, 并且当前动作是 E_PlayOperation_Ankan, 则取消该动作。
  • 否则, 我们调用 Discard 动作接口来进行出牌操作。
  • 注意: 由于 Discard 动作接口的调用需要传入牌和摸牌信息, 所以我们需要从 result.GetResult()[0].GetTile() 和 result.GetResult()[0].GetMoqie() 中获取牌和摸切信息。
  • gamestate 参考 gamestate
Prev
基础