examples/2048/2048/board.go
func (b *Board) Update(input *Input) error {
	for t := range b.tiles {
		if err := t.Update(); err != nil {
			return err
		}
	}
	if 0 < len(b.tasks) {
		t := b.tasks[0]
		if err := t(); err == taskTerminated {
			b.tasks = b.tasks[1:]
		} else if err != nil {
			return err
		}
		return nil
	}
	if dir, ok := input.Dir(); ok {
		if err := b.Move(dir); err != nil {
			return err
		}
	}
	return nil
}
func (b *Board) Update(input *Input) error {
	for t := range b.tiles {
		if err := t.Update(); err != nil {
			return err
		}
	}
	if 0 < len(b.tasks) {
		t := b.tasks[0]
		if err := t(); err == taskTerminated {
			b.tasks = b.tasks[1:]
		} else if err != nil {
			return err
		}
		return nil
	}
	if dir, ok := input.Dir(); ok {
		if err := b.Move(dir); err != nil {
			return err
		}
	}
	return nil
}
func ( b * Board ) Update ( input * Input ) error { for t := range b . tiles { if err := t . Update ( ) ; err != nil { return err } } if 0 < len ( b . tasks ) { t := b . tasks [ 0 ] if err := t ( ) ; err == taskTerminated { b . tasks = b . tasks [ 1 : ] } else if err != nil { return err } return nil } if dir , ok := input . Dir ( ) ; ok { if err := b . Move ( dir ) ; err != nil { return err } } return nil }
// Update updates the board state.
Update updates the board state .