Added all the base code for managing world-scope groups.

This commit is contained in:
Filip Maj 2016-12-12 19:03:25 -05:00
parent 09e1e31e79
commit 31b13300ac
20 changed files with 940 additions and 4 deletions

View file

@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FFXIVClassic_World_Server.DataObjects;
using FFXIVClassic_World_Server.DataObjects.Group;
namespace FFXIVClassic_World_Server
{
@ -49,5 +51,137 @@ namespace FFXIVClassic_World_Server
return 0;
}
}
public static Dictionary<uint, RetainerGroupMember> GetRetainers(uint charaId)
{
throw new NotImplementedException();
}
public static Linkshell GetLinkshell(ulong groupIndex, ulong id)
{
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT name, crestIcon, master FROM server_linkshells WHERE id = @lsId", conn);
cmd.Parameters.AddWithValue("@lsId", id);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
string name = Reader.GetString("name");
ushort crest = Reader.GetUInt16("crestIcon");
uint master = Reader.GetUInt32("master");
Linkshell linkshell = new Linkshell(id, groupIndex, name, crest, master, 0xa);
return linkshell;
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return null;
}
public static Dictionary<ulong, LinkshellMember> GetLSMembers(ulong lsId)
{
Dictionary<ulong, LinkshellMember> memberList = new Dictionary<ulong, LinkshellMember>();
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT characterId, linkshellId, slot, rank FROM characters_linkshells WHERE linkshellId = @lsId", conn);
cmd.Parameters.AddWithValue("@lsId", lsId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
uint characterId = Reader.GetUInt32("characterId");
ulong linkshellId = Reader.GetUInt64("linkshellId");
ushort slot = Reader.GetUInt16("slot");
ushort rank = Reader.GetUInt16("rank");
LinkshellMember member = new LinkshellMember(characterId, linkshellId, slot, rank);
memberList.Add(characterId, member);
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return memberList;
}
public static List<LinkshellMember> GetPlayerLSMembership(uint charaId)
{
List<LinkshellMember> memberList = new List<LinkshellMember>();
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT characterId, linkshellId, slot, rank FROM characters_linkshells WHERE characterid = @charaId", conn);
cmd.Parameters.AddWithValue("@lsId", charaId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
uint characterId = Reader.GetUInt32("characterId");
ulong linkshellId = Reader.GetUInt64("linkshellId");
ushort slot = Reader.GetUInt16("slot");
ushort rank = Reader.GetUInt16("rank");
LinkshellMember member = new LinkshellMember(characterId, linkshellId, slot, rank);
memberList.Add(member);
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return memberList;
}
public static ulong CreateLinkshell(string name, ushort crest, uint master)
{
throw new NotImplementedException();
}
public static bool DeleteLinkshell(ulong lsId)
{
throw new NotImplementedException();
}
public static bool LinkshellAddPlayer(ulong dbId, uint charaId)
{
throw new NotImplementedException();
}
public static bool LinkshellRemovePlayer(ulong lsId, uint charaId)
{
throw new NotImplementedException();
}
}
}