eq2go/internal/chat/types.go

133 lines
3.8 KiB
Go

package chat
import (
"context"
"time"
)
// ChannelMessage represents a message sent to a channel
type ChannelMessage struct {
SenderID int32
SenderName string
Message string
LanguageID int32
ChannelName string
Timestamp time.Time
IsEmote bool
IsOOC bool
}
// ChannelMember represents a member in a channel
type ChannelMember struct {
CharacterID int32
CharacterName string
Level int32
Race int32
Class int32
JoinedAt time.Time
}
// ChannelInfo provides basic channel information for client lists
type ChannelInfo struct {
Name string
HasPassword bool
MemberCount int
LevelRestriction int32
RaceRestriction int32
ClassRestriction int32
ChannelType int
}
// ChatChannelData represents persistent channel data from database
type ChatChannelData struct {
Name string
Password string
LevelRestriction int32
ClassRestriction int32
RaceRestriction int32
}
// ChannelDatabase defines database operations for chat channels
type ChannelDatabase interface {
// LoadWorldChannels retrieves all persistent world channels from database
LoadWorldChannels(ctx context.Context) ([]ChatChannelData, error)
// SaveChannel persists a channel to database (world channels only)
SaveChannel(ctx context.Context, channel ChatChannelData) error
// DeleteChannel removes a channel from database
DeleteChannel(ctx context.Context, channelName string) error
}
// ClientManager handles client communication for chat system
type ClientManager interface {
// SendChannelList sends available channels to a client
SendChannelList(characterID int32, channels []ChannelInfo) error
// SendChannelMessage delivers a message to a client
SendChannelMessage(characterID int32, message ChannelMessage) error
// SendChannelUpdate notifies client of channel membership changes
SendChannelUpdate(characterID int32, channelName string, action int, characterName string) error
// SendChannelUserList sends who list to client
SendChannelUserList(characterID int32, channelName string, members []ChannelMember) error
// IsClientConnected checks if a character is currently online
IsClientConnected(characterID int32) bool
}
// PlayerManager provides player information for chat system
type PlayerManager interface {
// GetPlayerInfo retrieves basic player information
GetPlayerInfo(characterID int32) (PlayerInfo, error)
// ValidatePlayer checks if player meets channel requirements
ValidatePlayer(characterID int32, levelReq, raceReq, classReq int32) bool
// GetPlayerLanguages returns languages known by player
GetPlayerLanguages(characterID int32) ([]int32, error)
}
// LanguageProcessor handles multilingual chat processing
type LanguageProcessor interface {
// ProcessMessage processes a message for language comprehension
ProcessMessage(senderID, receiverID int32, message string, languageID int32) (string, error)
// CanUnderstand checks if receiver can understand sender's language
CanUnderstand(senderID, receiverID int32, languageID int32) bool
// GetDefaultLanguage returns the default language for a character
GetDefaultLanguage(characterID int32) int32
}
// PlayerInfo contains basic player information needed for chat
type PlayerInfo struct {
CharacterID int32
CharacterName string
Level int32
Race int32
Class int32
IsOnline bool
}
// ChatStatistics provides statistics about chat system usage
type ChatStatistics struct {
TotalChannels int
WorldChannels int
CustomChannels int
TotalMembers int
MessagesPerHour int
ActiveChannels int
}
// ChannelFilter provides filtering options for channel lists
type ChannelFilter struct {
MinLevel int32
MaxLevel int32
Race int32
Class int32
IncludeCustom bool
IncludeWorld bool
}