public static bool Init() { bool result; try { ConsortiaMgr.m_lock = new ReaderWriterLock(); ConsortiaMgr._ally = new Dictionary <string, int>(); if (!ConsortiaMgr.Load(ConsortiaMgr._ally)) { result = false; } else { ConsortiaMgr._consortia = new Dictionary <int, ConsortiaInfo>(); if (!ConsortiaMgr.LoadConsortia(ConsortiaMgr._consortia)) { result = false; } else { result = true; } } } catch (Exception e) { //if (ConsortiaMgr.log.IsErrorEnabled) { ConsortiaMgr.log.Error("ConsortiaMgr", e); } result = false; } return(result); }
public static int KillPlayer(GamePlayer win, GamePlayer lose, Dictionary <GamePlayer, Player> players, eRoomType roomType, eGameType gameClass) { if (roomType != eRoomType.Match) { return(-1); } int num = ConsortiaMgr.FindConsortiaAlly(win.PlayerCharacter.ConsortiaID, lose.PlayerCharacter.ConsortiaID); if (num == -1) { return(num); } int offer = ConsortiaMgr.GetOffer(num, gameClass); if (lose.PlayerCharacter.Offer < offer) { offer = lose.PlayerCharacter.Offer; } if (offer != 0) { players[win].GainOffer = offer; players[lose].GainOffer = -offer; } return(num); }
public static int KillPlayer(GamePlayer win, GamePlayer lose, Dictionary <GamePlayer, Player> players, eRoomType roomType, eGameType gameClass) { int result; if (roomType != eRoomType.Match) { result = -1; } else { int state = ConsortiaMgr.FindConsortiaAlly(win.PlayerCharacter.ConsortiaID, lose.PlayerCharacter.ConsortiaID); if (state == -1) { result = state; } else { int offer = ConsortiaMgr.GetOffer(state, gameClass); if (lose.PlayerCharacter.Offer < offer) { offer = lose.PlayerCharacter.Offer; } if (offer != 0) { players[win].GainOffer = offer; players[lose].GainOffer = -offer; } result = state; } } return(result); }
public static bool ReLoad() { try { Dictionary <string, int> ally = new Dictionary <string, int>(); Dictionary <int, ConsortiaInfo> consortia = new Dictionary <int, ConsortiaInfo>(); if (ConsortiaMgr.Load(ally) && ConsortiaMgr.LoadConsortia(consortia)) { ConsortiaMgr.m_lock.AcquireWriterLock(15000); try { ConsortiaMgr._ally = ally; ConsortiaMgr._consortia = consortia; return(true); } catch { } finally { ConsortiaMgr.m_lock.ReleaseWriterLock(); } } } catch (Exception exception) { if (ConsortiaMgr.log.IsErrorEnabled) { ConsortiaMgr.log.Error("ConsortiaMgr", exception); } } return(false); }
public static int CanConsortiaFight(int consortiaID1, int consortiaID2) { if (consortiaID1 == 0 || consortiaID2 == 0 || consortiaID1 == consortiaID2) { return(-1); } ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(consortiaID1); ConsortiaInfo consortiaInfo2 = ConsortiaMgr.FindConsortiaInfo(consortiaID2); if (consortiaInfo == null || consortiaInfo2 == null || consortiaInfo.Level < 3 || consortiaInfo2.Level < 3) { return(-1); } return(ConsortiaMgr.FindConsortiaAlly(consortiaID1, consortiaID2)); }
public static int CanConsortiaFight(int consortiaID1, int consortiaID2) { int result; if (consortiaID1 == 0 || consortiaID2 == 0 || consortiaID1 == consortiaID2) { result = -1; } else { ConsortiaInfo consortia = ConsortiaMgr.FindConsortiaInfo(consortiaID1); ConsortiaInfo consortia2 = ConsortiaMgr.FindConsortiaInfo(consortiaID2); if (consortia == null || consortia2 == null || consortia.Level < 3 || consortia2.Level < 3) { result = -1; } else { result = ConsortiaMgr.FindConsortiaAlly(consortiaID1, consortiaID2); } } return(result); }
public static bool ReLoad() { bool result; try { Dictionary <string, int> tempAlly = new Dictionary <string, int>(); Dictionary <int, ConsortiaInfo> tempConsortia = new Dictionary <int, ConsortiaInfo>(); if (ConsortiaMgr.Load(tempAlly) && ConsortiaMgr.LoadConsortia(tempConsortia)) { ConsortiaMgr.m_lock.AcquireWriterLock(-1); try { ConsortiaMgr._ally = tempAlly; ConsortiaMgr._consortia = tempConsortia; result = true; return(result); } catch { } finally { ConsortiaMgr.m_lock.ReleaseWriterLock(); } } } catch (Exception e) { //if (ConsortiaMgr.log.IsErrorEnabled) { ConsortiaMgr.log.Error("ConsortiaMgr", e); } } result = false; return(result); }
public static int GetOffer(int cosortiaID1, int consortiaID2, eGameType gameType) { return(ConsortiaMgr.GetOffer(ConsortiaMgr.FindConsortiaAlly(cosortiaID1, consortiaID2), gameType)); }