mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-09 22:14:39 +02:00
Added all the base code for managing world-scope groups.
This commit is contained in:
parent
09e1e31e79
commit
31b13300ac
20 changed files with 940 additions and 4 deletions
85
FFXIVClassic World Server/PartyManager.cs
Normal file
85
FFXIVClassic World Server/PartyManager.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
using FFXIVClassic_World_Server.DataObjects.Group;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FFXIVClassic_World_Server
|
||||
{
|
||||
class PartyManager
|
||||
{
|
||||
private Server mServer;
|
||||
private Object mGroupLockReference;
|
||||
private Dictionary<ulong, Group> mCurrentWorldGroupsReference;
|
||||
private Dictionary<ulong, Party> mPartyList = new Dictionary<ulong, Party>();
|
||||
|
||||
public PartyManager(Server server, Object groupLock, Dictionary<ulong, Group> worldGroupList)
|
||||
{
|
||||
mServer = server;
|
||||
mGroupLockReference = groupLock;
|
||||
mCurrentWorldGroupsReference = worldGroupList;
|
||||
}
|
||||
|
||||
public void CreateParty(uint leaderCharaId)
|
||||
{
|
||||
lock (mGroupLockReference)
|
||||
{
|
||||
ulong groupId = mServer.GetGroupIndex();
|
||||
Party party = new Party(groupId, leaderCharaId);
|
||||
mPartyList.Add(groupId, party);
|
||||
mCurrentWorldGroupsReference.Add(groupId, party);
|
||||
mServer.IncrementGroupIndex();
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteParty(ulong groupId)
|
||||
{
|
||||
if (mCurrentWorldGroupsReference.ContainsKey(groupId))
|
||||
mCurrentWorldGroupsReference.Remove(groupId);
|
||||
if (mPartyList.ContainsKey(groupId))
|
||||
mPartyList.Remove(groupId);
|
||||
}
|
||||
|
||||
public bool AddToParty(ulong groupId, uint charaId)
|
||||
{
|
||||
if (mPartyList.ContainsKey(groupId))
|
||||
{
|
||||
Party party = mPartyList[groupId];
|
||||
if (!party.members.Contains(charaId))
|
||||
party.members.Add(charaId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int RemoveFromParty(ulong groupId, uint charaId)
|
||||
{
|
||||
if (mPartyList.ContainsKey(groupId))
|
||||
{
|
||||
Party party = mPartyList[groupId];
|
||||
if (party.members.Contains(charaId))
|
||||
{
|
||||
party.members.Remove(charaId);
|
||||
|
||||
//If current ldr, make a new ldr if not empty pt
|
||||
if (party.leader == charaId && party.members.Count != 0)
|
||||
party.leader = party.members[0];
|
||||
}
|
||||
return party.members.Count;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool ChangeLeader(ulong groupId, uint charaId)
|
||||
{
|
||||
if (mPartyList.ContainsKey(groupId))
|
||||
{
|
||||
Party party = mPartyList[groupId];
|
||||
if (party.members.Contains(charaId))
|
||||
{
|
||||
party.leader = charaId;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue