Exemplo n.º 1
0
//LoadMD gets MoveData from db
func (m *MojSQL) LoadMD(key int64, md *server.MoveData) (err error) {
	stmt, err := m.conn.Prepare("select fromto,beforegame,aftergame,promotion,who from 3manmv where id=?")
	defer stmt.Close()
	if err != nil {
		return
	}
	var ft []byte
	err = stmt.QueryRow(key).Scan(&ft, &md.BeforeGame, &md.AfterGame, &md.PawnPromotion, &md.Who)
	md.FromTo = fourint8(yas4(ft))
	return
}
Exemplo n.º 2
0
func (g *G) movechk() (oftp game.FromToProm, err error) {
	var i int64
	i, err = g.af(g)
	if err == nil {
		var md *server.MoveData
		md, _, err = g.c.Service.Move(i)
		if err != nil {
			return
		}
		if md.BeforeGame == g.gameid {
			g.gameid = md.AfterGame
			oftp = md.FromToProm()
			err = g.getstate()
		} else {
			e := ErrorNotAfter{*md, i, g.gameid}
			err = &e
		}
	}
	return
}