Skip to content

Commit

Permalink
Add new Group methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Foereaper committed Oct 14, 2023
1 parent 1e94624 commit 8720eef
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMangos/GroupMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ namespace LuaGroup
// Not implemented methods
{ "IsBFGroup", nullptr }, // not implemented
{ "ConvertToLFG", nullptr }, // not implemented
{ "GetMemberFlags", nullptr }, // not implemented
{ "SetMemberFlag", nullptr }, // not implemented

{ NULL, NULL }
};
Expand Down
2 changes: 2 additions & 0 deletions Mangos/GroupMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ namespace LuaGroup
// Not implemented methods
{ "IsBFGroup", nullptr }, // not implemented
{ "ConvertToLFG", nullptr }, // not implemented
{ "GetMemberFlags", nullptr }, // not implemented
{ "SetMemberFlag", nullptr }, // not implemented

{ NULL, NULL }
};
Expand Down
52 changes: 51 additions & 1 deletion TrinityCore/GroupMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,28 @@ namespace LuaGroup
return 1;
}

/**
* Returns the [Group] members' flags
*
* <pre>
* enum GroupMemberFlags
* {
* MEMBER_FLAG_ASSISTANT = 1,
* MEMBER_FLAG_MAINTANK = 2,
* MEMBER_FLAG_MAINASSIST = 4
* };
* </pre>
*
* @param ObjectGuid guid : guid of the player
* @return uint8 flags
*/
int GetMemberFlags(lua_State* L, Group* group)
{
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
Eluna::Push(L, group->GetMemberFlags(guid));
return 1;
}

/**
* Sets the leader of this [Group]
*
Expand Down Expand Up @@ -372,7 +394,33 @@ namespace LuaGroup
group->ConvertToLFG();
return 0;
}


/**
* Sets or removes a flag for a [Group] member
*
* <pre>
* enum GroupMemberFlags
* {
* MEMBER_FLAG_ASSISTANT = 1,
* MEMBER_FLAG_MAINTANK = 2,
* MEMBER_FLAG_MAINASSIST = 4
* };
* </pre>
*
* @param ObjectGuid target : GUID of the target
* @param bool apply : add the `flag` if `true`, remove the `flag` otherwise
* @param [GroupMemberFlags] flag : the flag to set or unset
*/
int SetMemberFlag(lua_State* L, Group* group)
{
ObjectGuid target = Eluna::CHECKVAL<ObjectGuid>(L, 2);
bool apply = Eluna::CHECKVAL<bool>(L, 3);
GroupMemberFlags flag = static_cast<GroupMemberFlags>(Eluna::CHECKVAL<uint32>(L, 4));

group->SetGroupMemberFlag(target, apply, flag);
return 0;
}

ElunaRegister<Group> GroupMethods[] =
{
// Getters
Expand All @@ -382,11 +430,13 @@ namespace LuaGroup
{ "GetMemberGroup", &LuaGroup::GetMemberGroup },
{ "GetMemberGUID", &LuaGroup::GetMemberGUID },
{ "GetMembersCount", &LuaGroup::GetMembersCount },
{ "GetMemberFlags", &LuaGroup::GetMemberFlags },

// Setters
{ "SetLeader", &LuaGroup::SetLeader },
{ "SetMembersGroup", &LuaGroup::SetMembersGroup },
{ "SetTargetIcon", &LuaGroup::SetTargetIcon },
{ "SetMemberFlag", &LuaGroup::SetMemberFlag },

// Boolean
{ "IsLeader", &LuaGroup::IsLeader },
Expand Down
2 changes: 2 additions & 0 deletions VMangos/GroupMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ namespace LuaGroup
// Not implemented methods
{ "IsBFGroup", nullptr }, // not implemented
{ "ConvertToLFG", nullptr }, // not implemented
{ "GetMemberFlags", nullptr }, // not implemented
{ "SetMemberFlag", nullptr }, // not implemented

{ NULL, NULL }
};
Expand Down

0 comments on commit 8720eef

Please sign in to comment.