CardSimEngine/cardsim/messages.go
Kistaro Windrider 45bbfe4e8f
Initial commit.
No tests. Not complete.
2023-03-26 23:40:44 -07:00

28 lines
687 B
Go

package cardsim
import "fmt"
// Message is an opaque interface representing a displayable message.
// Using an interface here allows for implementation of new message display
// and formatting features without rewriting all existing callers.
type Message interface {
fmt.Stringer
}
type stringMessage string
func (s stringMessage) String() string {
return string(s)
}
// MsgStr returns a Message representing a fixed string.
func MsgStr(s string) Message {
return stringMessage(s)
}
// Msgf is a Sprintf-like function that produces a Message equivalent to the
// one created by MsgStr.
func Msgf(f string, args ...any) Message {
return stringMessage(fmt.Sprintf(f, args...))
}