Esempio n. 1
0
// NewPlayer returns an initialized Player.
func NewPlayer(id ID, name string, conn ssh.Channel) *Player {

	colouredName := fmt.Sprintf("%s%s%s", colours[id], name, ansi.Set(ansi.Reset))

	p := &Player{
		id:      id,
		name:    name,
		cname:   colouredName,
		dead:    true,
		ready:   false,
		playing: make(chan bool, 1),
		d:       dup,
		resizes: make(chan resize),
		conn:    ansi.Wrap(conn),
		logf:    log.New(os.Stdout, colouredName+" ", 0).Printf,
		once:    &sync.Once{},
	}
	return p
}
Esempio n. 2
0
	top    = '⠛'
	bottom = '⣤'
	empty  = ' '
)

type Direction byte

const (
	dup Direction = iota + 65
	ddown
	dright
	dleft
)

var colours = map[ID][]byte{
	blank: ansi.Set(ansi.White),
	wall:  ansi.Set(ansi.White),
	ID(1): ansi.Set(ansi.Blue),
	ID(2): ansi.Set(ansi.Green),
	ID(3): ansi.Set(ansi.Magenta),
	ID(4): ansi.Set(ansi.Cyan),
	ID(5): ansi.Set(ansi.Yellow),
	ID(6): ansi.Set(ansi.Red),
}

type resize struct {
	width, height uint32
}

// A Player represents a live TCP connection from a client
type Player struct {