MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / HasQuest

Method HasQuest

internal/scripting/room_func.go:361–400  ·  view source on GitHub ↗

Returns a list of userIds found to have the questId if userIdParty is specified, will only check users in the party of the user.

(questId string, partyUserId ...int)

Source from the content-addressed store, hash-verified

359// Returns a list of userIds found to have the questId
360// if userIdParty is specified, will only check users in the party of the user.
361func (r ScriptRoom) HasQuest(questId string, partyUserId ...int) []int {
362
363 hasQuestUsers := []int{}
364
365 // Only check the user and their party?
366 if len(partyUserId) > 0 && partyUserId[0] > 0 {
367
368 if party := parties.Get(partyUserId[0]); party != nil {
369 for _, userId := range party.GetMembers() {
370 if user := users.GetByUserId(userId); user != nil {
371 if user.Character.HasQuest(questId) {
372 hasQuestUsers = append(hasQuestUsers, userId)
373 }
374 }
375 }
376
377 return hasQuestUsers
378 }
379
380 // No party, so just check the user
381 if user := users.GetByUserId(partyUserId[0]); user != nil {
382 if user.Character.HasQuest(questId) {
383 hasQuestUsers = append(hasQuestUsers, user.UserId)
384 }
385 }
386
387 return hasQuestUsers
388 }
389
390 // Just check all players
391 for _, userId := range r.roomRecord.GetPlayers() {
392 if user := users.GetByUserId(userId); user != nil {
393 if user.Character.HasQuest(questId) {
394 hasQuestUsers = append(hasQuestUsers, userId)
395 }
396 }
397 }
398
399 return hasQuestUsers
400}
401
402// Returns a list of userIds found to NOT have the questId
403// if userIdParty is specified, will only check users in the party of the user.

Callers 1

MissingQuestMethod · 0.45

Calls 4

GetFunction · 0.92
GetByUserIdFunction · 0.92
GetMembersMethod · 0.45
GetPlayersMethod · 0.45

Tested by

no test coverage detected