FIBS (online backgammon) client library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
760 B

package fibs
import (
"fmt"
"io"
"strings"
"time"
"unicode"
)
var (
StatusWriter io.Writer
GameWriter io.Writer
)
func l(s string) {
s = strings.TrimRightFunc(s, unicode.IsSpace)
s = strings.ReplaceAll(s, "\a", "")
s = strings.ReplaceAll(s, "\r", "")
m := time.Now().Format("15:04") + " " + s
if StatusWriter != nil {
StatusWriter.Write([]byte(m + "\n"))
return
}
fmt.Println(m)
}
func lf(format string, a ...interface{}) {
l(fmt.Sprintf(format, a...))
}
func lg(s string) {
s = strings.TrimRightFunc(s, unicode.IsSpace)
s = strings.ReplaceAll(s, "\a", "")
s = strings.ReplaceAll(s, "\r", "")
m := time.Now().Format("15:04") + " " + s
if GameWriter != nil {
GameWriter.Write([]byte(m + "\n"))
return
}
fmt.Println(m)
}