Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

有一个问题 #1

Open
cssbee opened this issue Apr 24, 2019 · 1 comment
Open

有一个问题 #1

cssbee opened this issue Apr 24, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@cssbee
Copy link

cssbee commented Apr 24, 2019

首先,很完美,很棒!
请问,如何能知道一个棋子正在"将军"状态<意思:对方必须做应对,否则就可以杀死对面的首领>
我找到了game.moves{},这里面只包含一方的moves,不包含另一方,如果能包含另一方,就可以从moves里找到是否包含"将 or 帅"来判断,这个棋子处于 “将军” 状态。
再次感谢伟大的工作!!

@lengyanyu258
Copy link
Owner

lengyanyu258 commented Apr 25, 2019

才发现 xiangqi.js 这个 repo 没有开 Issues 🤦‍♂️


现在,你可以用.moves({ verbose: true, opponent: true })去找到对手的照着:

var Xiangqi = require('./xiangqi').Xiangqi;
var xiangqi = new Xiangqi();

xiangqi.load('rnbakab1r/9/1c5c1/p1p1p3p/6p2/6P2/P1P1P1n1P/1C5C1/5K3/RNBA1ABNR r - - 0 1');
xiangqi.in_check();
// true
xiangqi.moves({ verbose: true, opponent: true });
//[ ...
//  { color: 'b',
//    from: 'g3',
//    to: 'f1',
//    flags: 'c',
//    piece: 'n',
//    captured: 'k',
//    iccs: 'g3f1' },
//  ... ]

@lengyanyu258 lengyanyu258 added the enhancement New feature or request label Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants