/// <summary> /// Adds a new guild member /// Calls GuildMgr.OnJoinGuild /// </summary> /// <param name="chr">character to add</param> /// <param name="update">if true, sends event to the guild</param> /// <returns>GuildMember of new member</returns> public GuildMember AddMember(CharacterRecord chr) { GuildMember guildMember; lock (this) { if (this.Members.TryGetValue(chr.EntityLowId, out guildMember)) { return(guildMember); } guildMember = new GuildMember(chr, this, this.m_ranks.Last <GuildRank>()); this.Members.Add(guildMember.Id, guildMember); guildMember.Create(); } Singleton <GuildMgr> .Instance.RegisterGuildMember(guildMember); this.EventLog.AddJoinEvent(guildMember.Id); GuildHandler.SendEventToGuild(this, GuildEvents.JOINED, guildMember); Character characterByAccId = World.GetCharacterByAccId((uint)chr.AccountId); foreach (GuildSkill activeSkill in this.ActiveSkills) { activeSkill.ApplyToCharacter(characterByAccId); } characterByAccId.GuildMember = guildMember; Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.Joined, guildMember); Asda2GuildHandler.SendGuildMembersInfoResponse(characterByAccId.Client, this); this.AddHistoryMessage(Asda2GuildHistoryType.Joined, 0, chr.Name, DateTime.Now.ToLongTimeString()); return(guildMember); }
public LearnGuildSkillResult TryLearnSkill(GuildSkillId skillId, out GuildSkill skill) { skill = this.Skills[(int)skillId]; if (skill != null) { if (skill.IsMaxLevel) { return(LearnGuildSkillResult.ThisIsTheMaxLevelOfSkill); } if (!this.SubstractGuildPoints(skill.NextLearnCost)) { return(LearnGuildSkillResult.IncifitientPoints); } ++this.Skills[(int)skillId].Level; Asda2GuildHandler.SendGuildSkillStatusChangedResponse(skill, ClanSkillStatus.Learned); } else { if (!this.SubstractGuildPoints(GuildSkillTemplate.Templates[(int)skillId].LearnCosts[1])) { return(LearnGuildSkillResult.IncifitientPoints); } ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => { GuildSkill guildSkill = new GuildSkill(this, skillId); this.Skills[(int)skillId] = guildSkill; guildSkill.CreateLater(); Asda2GuildHandler.SendGuildSkillStatusChangedResponse(guildSkill, ClanSkillStatus.Learned); })); } return(LearnGuildSkillResult.Ok); }
private void ImpeachmentCallback() { float num = (float)((double)this._acceptedMembers.Count / (double)(this.MemberCount - 2) * 100.0); this.SendSystemMsg(string.Format("{0}% members accepted new leader.", (object)num)); if ((double)num > 70.0) { this.Leader.Asda2RankId = (byte)3; Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.RankChanged, this.Leader); this.Leader = this._newLeader; this.Leader.Asda2RankId = (byte)4; Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.ApointedAsNewGuildLeader, this.Leader); Asda2GuildHandler.SendImpeachmentResultResponse(this, Asda2GuildHandler.ImpeachmentResult.Success); Asda2GuildHandler.SendUpdateGuildInfoResponse(this, GuildInfoMode.Silent, (Character)null); this.AddHistoryMessage(Asda2GuildHistoryType.ApointedAsGuildLeaderThorowVote, 0, this.Leader.Name, DateTime.Now.ToLongTimeString()); } else { Asda2GuildHandler.SendImpeachmentResultResponse(this, Asda2GuildHandler.ImpeachmentResult.Failed); } this._acceptedMembers.Clear(); this._newLeader = (GuildMember)null; this._impeachmentStartTime = DateTime.MinValue; }
/// <summary> /// Adds a new guild member /// Calls GuildMgr.OnJoinGuild /// </summary> /// <param name="chr">character to add</param> /// <param name="update">if true, sends event to the guild</param> /// <returns>GuildMember of new member</returns> public GuildMember AddMember(CharacterRecord chr) { GuildMember newMember; /*using (syncRoot.Enter()) * {*/ lock (this) { if (Members.TryGetValue(chr.EntityLowId, out newMember)) { return(newMember); } newMember = new GuildMember(chr, this, m_ranks.Last()); Members.Add(newMember.Id, newMember); newMember.Create(); } /*}*/ GuildMgr.Instance.RegisterGuildMember(newMember); EventLog.AddJoinEvent(newMember.Id); GuildHandler.SendEventToGuild(this, GuildEvents.JOINED, newMember); var character = World.GetCharacterByAccId((uint)chr.AccountId); foreach (var activeSkill in ActiveSkills) { activeSkill.ApplyToCharacter(character); } character.GuildMember = newMember; Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.Joined, newMember); Asda2GuildHandler.SendGuildMembersInfoResponse(character.Client, this); AddHistoryMessage(Asda2GuildHistoryType.Joined, 0, chr.Name, DateTime.Now.ToLongTimeString()); return(newMember); }
private void ImpeachmentCallback() { float num = (float)(_acceptedMembers.Count / (double)(MemberCount - 2) * 100.0); SendSystemMsg(string.Format("{0}% members accepted new leader.", num)); if (num > 70.0) { Leader.Asda2RankId = 3; Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.RankChanged, Leader); Leader = _newLeader; Leader.Asda2RankId = 4; Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.ApointedAsNewGuildLeader, Leader); Asda2GuildHandler.SendImpeachmentResultResponse(this, Asda2GuildHandler.ImpeachmentResult.Success); Asda2GuildHandler.SendUpdateGuildInfoResponse(this, GuildInfoMode.Silent, null); AddHistoryMessage(Asda2GuildHistoryType.ApointedAsGuildLeaderThorowVote, 0, Leader.Name, DateTime.Now.ToLongTimeString()); } else { Asda2GuildHandler.SendImpeachmentResultResponse(this, Asda2GuildHandler.ImpeachmentResult.Failed); } _acceptedMembers.Clear(); _newLeader = null; _impeachmentStartTime = DateTime.MinValue; }
public bool AddGuildPoints(int points) { Points += (uint)points; Asda2GuildHandler.SendUpdateGuildInfoResponse(this); return(true); }
public LearnGuildSkillResult TryLearnSkill(GuildSkillId skillId, out GuildSkill skill) { skill = Skills[(int)skillId]; if (skill != null) { if (skill.IsMaxLevel) { return(LearnGuildSkillResult.ThisIsTheMaxLevelOfSkill); } //todo get real learn cost levelupSkill if (!SubstractGuildPoints(skill.NextLearnCost)) { return(LearnGuildSkillResult.IncifitientPoints); } Skills[(int)skillId].Level++; } else { if (!SubstractGuildPoints(GuildSkillTemplate.Templates[(int)skillId].LearnCosts[1])) { return(LearnGuildSkillResult.IncifitientPoints); } RealmServer.IOQueue.AddMessage(() => { var s = new GuildSkill(this, skillId); Skills[(int)skillId] = s; s.CreateLater(); }); } Asda2GuildHandler.SendGuildSkillStatusChangedResponse(skill, ClanSkillStatus.Learned); return(LearnGuildSkillResult.Ok); }
public void ToggleActivate(Character trigerer) { if (IsActivated) { IsActivated = false; foreach (Character character in Guild.GetCharacters()) { RemoveFromCharacter(character); } } else { if (!Guild.SubstractGuildPoints(ActivationCost)) { Asda2GuildHandler.SendGuildSkillActivatedResponse(trigerer, GuildSkillActivationStatus.IncefitientPoints, this); return; } IsActivated = true; LastMaintance = DateTime.Now; foreach (Character character in Guild.GetCharacters()) { ApplyToCharacter(character); } } Asda2GuildHandler.SendGuildSkillActivatedResponse(trigerer, GuildSkillActivationStatus.Ok, this); Asda2GuildHandler.SendGuildSkillStatusChangedResponse(this, ClanSkillStatus.Activation); Asda2GuildHandler.SendUpdateGuildInfoResponse(Guild, GuildInfoMode.Silent, null); Asda2GuildHandler.SendGuildSkillsInfoToGuild(Guild); }
public Asda2GuildHandler.CreateImpeachmentResult CreateImpeachment(GuildMember guildMember) { if (DateTime.Now - this._impeachmentStartTime < TimeSpan.FromMinutes(4.0)) { return(Asda2GuildHandler.CreateImpeachmentResult.AlreadyInProgress); } this._impeachmentStartTime = DateTime.Now; this._acceptedMembers.Clear(); this._newLeader = guildMember; Asda2GuildHandler.SendImpeachmentAnswerResponse(this, this._newLeader.Name); guildMember.Character.Map.CallDelayed(180000, new Action(this.ImpeachmentCallback)); return(Asda2GuildHandler.CreateImpeachmentResult.Success); }
public bool LevelUp() { if (!SubstractGuildPoints(CharacterFormulas.GuildLevelUpCost[Level])) { return(false); } Level++; AddHistoryMessage(Asda2GuildHistoryType.GuildLevelNowIs, Level, "system", DateTime.Now.ToLongTimeString()); Asda2GuildHandler.SendUpdateGuildInfoResponse(this, GuildInfoMode.GuildLevelChanged); foreach (var character in GetCharacters()) { GlobalHandler.SendCharactrerInfoClanNameToAllNearbyCharacters(character); } return(true); }
public static void RestoreGuildWaveCounter() { //List<Guild> guilds = new List<Guild>(Guild.FindAll()); foreach (var guild in GuildMgr.GuildsById.Values) { guild.WaveLimit = 0; Asda2GuildHandler.SendUpdateGuildInfoResponse(guild); guild.Update(); } //for (int i = 0; i < guilds.Count; ++i) //{ // guilds[i].WaveLimit = 0; // guilds[i].SaveAndFlush(); //} }
/// <summary> /// Removes GuildMember from the guild /// </summary> /// <param name="member">member to remove</param> /// <param name="update">if false, changes to the guild will not be promoted anymore (used when the Guild is being disbanded)</param> public bool RemoveMember(GuildMember member, bool update, bool kicked = false) { AddHistoryMessage(kicked ? Asda2GuildHistoryType.Kicked : Asda2GuildHistoryType.Left, 0, member.Name, DateTime.Now.ToLongTimeString()); if (member.Character != null) { foreach (var activeSkill in ActiveSkills) { activeSkill.RemoveFromCharacter(member.Character); } } if (update) { EventLog.AddLeaveEvent(member.Id); Asda2GuildHandler.SendGuildNotificationResponse(this, kicked ? GuildNotificationType.Kicked : GuildNotificationType.Left, member); //GuildHandler.SendEventToGuild(this, GuildEvents.LEFT, member); } OnRemoveMember(member); if (update && member == m_leader) { Disband(); return(true); } /*using (syncRoot.Enter()) * {*/ lock (this) { if (!Members.Remove(member.Id)) { return(false); } } //} RealmServer.IOQueue.AddMessage(() => { member.Delete(); if (update) { Update(); } }); return(true); }
/// <summary>Removes GuildMember from the guild</summary> /// <param name="member">member to remove</param> /// <param name="update">if false, changes to the guild will not be promoted anymore (used when the Guild is being disbanded)</param> public bool RemoveMember(GuildMember member, bool update, bool kicked = false) { this.AddHistoryMessage(kicked ? Asda2GuildHistoryType.Kicked : Asda2GuildHistoryType.Left, 0, member.Name, DateTime.Now.ToLongTimeString()); if (member.Character != null) { foreach (GuildSkill activeSkill in this.ActiveSkills) { activeSkill.RemoveFromCharacter(member.Character); } } if (update) { this.EventLog.AddLeaveEvent(member.Id); Asda2GuildHandler.SendGuildNotificationResponse(this, kicked ? GuildNotificationType.Kicked : GuildNotificationType.Left, member); } this.OnRemoveMember(member); if (update && member == this.m_leader) { this.Disband(); return(true); } lock (this) { if (!this.Members.Remove(member.Id)) { return(false); } } ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => { member.Delete(); if (!update) { return; } this.Update(); })); return(true); }
public bool AddGuildPoints(int points) { this.Points += (uint)points; Asda2GuildHandler.SendUpdateGuildInfoResponse(this, GuildInfoMode.Silent, (Character)null); return(true); }