增加房主修改功能

This commit is contained in:
kercylan98
2023-05-05 17:55:26 +08:00
parent 4f1ea8d667
commit 2038117c3b
2 changed files with 9 additions and 0 deletions
+7
View File
@@ -57,6 +57,13 @@ func (slf *Room[PlayerID, Player]) IsOwner(id PlayerID) bool {
return !slf.noMaster && slf.owner == id
}
func (slf *Room[PlayerID, Player]) ChangeOwner(id PlayerID) {
if slf.noMaster || slf.owner == id {
return
}
slf.owner = id
}
func (slf *Room[PlayerID, Player]) Join(player Player) error {
if slf.players.Size() >= slf.playerLimit && slf.playerLimit > 0 {
return ErrWorldPlayerLimit