# Tsumego extension
This extension allows you to insert a tsumego block into the website. However for now it is just a draft, so it could be buggy.
![Tsumego block screenshot](/extensions/tsumego/screenshot.png?raw=true)
## Installation
You need import all WGo javascript files (or minified versions) and files `tsumego.js` and `tsumego.css`.
```html
<script type="text/javascript" src="wgo/wgo.min.js"></script>
<script type="text/javascript" src="wgo/wgo.player.min.js"></script>
<script type="text/javascript" src="tsumego.js"></script>
<link rel="stylesheet" type="text/css" href="tsumego.css">
```
## Usage
Tsumego block can be created with the following code:
```javascript
new WGo.Tsumego(targetElement, options);
```
The first argument `targetElement` is a DOM element, where the tsumego block will be inserted. Don't forget, that this element must exist in the time of calling the constructor. Second argument is a configuration object.
### Options
Class `WGo.Tsumego` is a descendant of class `Wgo.Player` so configurable options are the same. However there are some new options, related to tsumegos.
* `movePlayed` - callback, which is called after every user's move
* `endOfVariation` - callback, which is called at the end of a variation (it can be either solution or incorrect variation)
* `answerDelay` - delay in milliseconds before computer plays its move (default `500`)
* `displayHintButton` - if true, a hint button will be displayed in the user interface (default `true`)
* `debug` - if true, variations will be highlighted on the board (default `false`)
### Tsumego
Tsumego can be any SGF or `WGo.Kifu` object and can be provided with one of these parameters: `sgf`, `sgfFile`, `json` of the configuration object. It also has to meet some conditions.
In the first node of the SGF you need to setup a position of the tsumego. This can be done with any SGF editor. Then you can define unlimited number of variations - good or bad. However the last node (move) of correct variations has to contain `TE` property. This will indicate, the variation is a solution.
Moreover you can set a viewport of the tsumego with `VW` property. See [SGF specification](http://www.red-bean.com/sgf/properties.html#VW) for more info about this property.
### Example
```javascript
var tsumego = new WGo.Tsumego(document.getElementById("tsumego_wrapper"), {
sgf: "(;FF[4]GM[1]VW[aa:jg]SZ[19]ST[2]EV[N° 1 .|. Level #2]AB[bb][cb][db][fb]AW[ea][eb][bc][cc][dc]C[Black to play]FG[1](;B[ec];W[fc];B[ed];W[gb](;B[fd];W[gc](;B[ab];W[ba](;B[bd];W[cd];B[ce];W[be](;B[dd];W[ad];B[ac]C[Correct!]TE[1])(;B[ac];W[ad];B[dd]C[Correct!]TE[1]))(;B[ce];W[ac]C[Fail!]))(;B[da];W[fa];B[ab];W[ba]C[Fail!]))(;B[ab];W[ba];B[fd];W[gc](;B[bd];W[cd];B[ce];W[be](;B[dd];W[ad];B[ac]C[Correct!]TE[1])(;B[ac];W[ad];B[dd]C[Correct!]TE[1]))(;B[ce];W[ac]C[Fail!]))(;B[da];W[fa];B[ab];W[ba]C[Fail!]))(;B[da];W[fc];B[ab];W[ba]C[Fail!]))",
debug: true,
});
tsumego.setCoordinates(true);
```
File test.html also contains a working example.
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
gomaster.zip (91个子文件)
wgo.js-master
docs
tutorial-board.html 7KB
tutorials
tutorial-player-1.html 1KB
tutorial-board-3.html 1KB
tutorial-player-6.html 1KB
tutorial-board-5.html 3KB
tutorial-player-2.html 1KB
tutorial-board-4.html 2KB
tutorial-player-5.html 1KB
tutorial-player-7.html 2KB
tutorial-board-2.html 853B
tutorial-player-3.html 1KB
tutorial-player-4.html 1KB
tutorial-board-1.html 682B
docs.html 34KB
player.html 24KB
extensions
tsumego
readme.md 3KB
test.html 2KB
screenshot.png 152KB
tsumego.js 12KB
tsumego.css 13KB
changelog.txt 471B
readme.md 1KB
demo2.html 28KB
test
test03.html 5KB
test05.html 2KB
test04.html 2KB
test02.html 2KB
test01.html 4KB
test06.html 3KB
demo1.html 1KB
demo5.html 2KB
demo4.html 2KB
themes
wgo.player.dark.css 2KB
textures
wood2.jpg 52KB
wood6.jpg 51KB
wood5.jpg 2KB
wood4.jpg 42KB
wood3.jpg 36KB
i18n
i18n.es.js 2KB
i18n.cs.js 1KB
i18n.ro.js 2KB
i18n.ja.js 2KB
i18n.vi.js 2KB
i18n.fr.js 2KB
i18n.en.js 2KB
i18n.zh.js 2KB
i18n.de.js 2KB
i18n.ca.js 2KB
i18n.it.js 2KB
.gitignore 3KB
demo3.html 3KB
wgo
basicplayer.commentbox.js 6KB
basicplayer.js 15KB
stones
white09_128.png 22KB
white06_128.png 24KB
white00_128.png 22KB
white05_128.png 21KB
black01_128.png 20KB
white10_128.png 21KB
black00_128.png 21KB
black02_128.png 20KB
white01_128.png 23KB
white04_128.png 22KB
black03_128.png 19KB
white02_128.png 23KB
white03_128.png 22KB
white07_128.png 23KB
white08_128.png 23KB
sgfparser.js 4KB
black_64.png 7KB
basicplayer.infobox.js 5KB
player.fullscreen.js 3KB
basicplayer.component.js 1004B
wgo.player.min.js 49KB
wgo.player.css 26KB
wood_1024.jpg 187KB
player.editable.js 4KB
wgo.min.js 25KB
white_128.png 26KB
black_128.png 24KB
player.js 16KB
wgo.js 58KB
scoremode.js 7KB
wood1.jpg 36KB
white_64.png 8KB
wood_512.jpg 54KB
kifu.js 18KB
player.permalink.js 2KB
basicplayer.control.js 13KB
build.sh 1KB
.gitattributes 483B
共 91 条
- 1
资源评论
urhero
- 粉丝: 28
- 资源: 94
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功