示例#1
0
 /// <summary>
 /// Loads all Factions that this Character already knows from the DB
 /// </summary>
 public void Load()
 {
     foreach (ReputationRecord record in ReputationRecord.Load(this.m_owner.Record.Guid))
     {
         Faction faction = FactionMgr.Get(record.ReputationIndex);
         if (faction != null)
         {
             if (this.m_byIndex.ContainsKey(record.ReputationIndex))
             {
                 ReputationCollection.log.Warn("Character {0} had Reputation with Faction {1} more than once.",
                                               (object)this.m_owner, (object)record.ReputationIndex);
             }
             else
             {
                 Reputation reputation = new Reputation(record, faction);
                 this.m_byIndex.Add(record.ReputationIndex, reputation);
             }
         }
         else
         {
             ReputationCollection.log.Warn("Character {0} has saved Reputation with invalid Faction: {1}",
                                           (object)this.m_owner, (object)record.ReputationIndex);
         }
     }
 }
        /// <summary>
        /// Loads all Factions that this Character already knows from the DB
        /// </summary>
        public void Load()
        {
            foreach (var record in ReputationRecord.Load(m_owner.Record.Guid))
            {
                var fac = FactionMgr.Get(record.ReputationIndex);
                if (fac != null)
                {
                    if (m_byIndex.ContainsKey(record.ReputationIndex))
                    {
                        log.Warn("Character {0} had Reputation with Faction {1} more than once.", m_owner, record.ReputationIndex);
                    }
                    else
                    {
                        var rep = new Reputation(record, fac);
                        m_byIndex.Add(record.ReputationIndex, rep);
                    }
                }
                else
                {
                    log.Warn("Character {0} has saved Reputation with invalid Faction: {1}", m_owner, record.ReputationIndex);

                    // record.DeleteAndFlush();
                }
            }
        }
示例#3
0
        public void ModValue(Reputation rep, int value)
        {
            if (rep.SetValue(rep.Value + value))
            {
                if (rep.StandingLevel >= StandingLevel.Honored)
                {
                    this.Owner.Achievements.CheckPossibleAchievementUpdates(
                        AchievementCriteriaType.GainHonoredReputation, 0U, 0U, (Unit)null);
                }
                if (rep.StandingLevel >= StandingLevel.Revered)
                {
                    this.Owner.Achievements.CheckPossibleAchievementUpdates(
                        AchievementCriteriaType.GainReveredReputation, 0U, 0U, (Unit)null);
                }
                if (rep.StandingLevel >= StandingLevel.Exalted)
                {
                    this.Owner.Achievements.CheckPossibleAchievementUpdates(
                        AchievementCriteriaType.GainExaltedReputation, 0U, 0U, (Unit)null);
                }
                if (value > 0)
                {
                    this.Owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.GainReputation, 0U,
                                                                            0U, (Unit)null);
                }
            }

            FactionHandler.SendReputationStandingUpdate((IPacketReceiver)this.m_owner.Client, rep);
        }
 public void SetValue(Reputation rep, int value)
 {
     if (rep.SetValue(value))
     {
         //UpdateHostile(rep, rep.Hostile);
     }
     FactionHandler.SendReputationStandingUpdate(m_owner.Client, rep);
 }
示例#5
0
        public bool IsHostile(Faction faction)
        {
            Reputation reputation = this.GetOrCreate(faction.ReputationIndex);

            if (reputation != null)
            {
                return(reputation.Hostile);
            }
            return(false);
        }
        public Reputation SetValue(FactionReputationIndex reputationIndex, int value)
        {
            Reputation rep = GetOrCreate(reputationIndex);

            if (rep != null)
            {
                SetValue(rep, value);
            }
            return(rep);
        }
示例#7
0
        public void SetInactive(FactionReputationIndex reputationIndex, bool inactive)
        {
            Reputation reputation = this.GetOrCreate(reputationIndex);

            if (reputation == null)
            {
                return;
            }
            reputation.IsInactive = true;
        }
示例#8
0
        public Reputation ModValue(FactionReputationIndex reputationIndex, int value)
        {
            Reputation rep = this.GetOrCreate(reputationIndex);

            if (rep != null)
            {
                this.ModValue(rep, value);
            }
            return(rep);
        }
示例#9
0
 public Reputation(ReputationRecord record, Faction faction, int defaultValue, ReputationFlags defaultFlags)
 {
     this.m_record = record;
     this.m_record.ReputationIndex = faction.ReputationIndex;
     this.m_record.Value           = defaultValue;
     this.m_record.Flags           = defaultFlags;
     this.Faction    = faction;
     this.m_standing = Reputation.GetStanding(defaultValue);
     this.m_record.Save();
 }
示例#10
0
        public bool CanAttack(Faction faction)
        {
            Reputation reputation = this.GetOrCreate(faction.ReputationIndex);

            if (reputation != null)
            {
                return(reputation.Hostile);
            }
            return(true);
        }
示例#11
0
        /// <summary>
        /// Creates a Reputation object that represents the relation to the given faction, or null
        /// </summary>
        /// <param name="faction">The Faction which the Reputation should be with</param>
        private Reputation Create(Faction faction)
        {
            int             defaultReputationValue = this.GetDefaultReputationValue(faction);
            ReputationFlags defaultReputationFlags = this.GetDefaultReputationFlags(faction);
            Reputation      rep = new Reputation(this.m_owner.Record.CreateReputationRecord(), faction,
                                                 defaultReputationValue, defaultReputationFlags);

            this.m_byIndex.Add(faction.ReputationIndex, rep);
            FactionHandler.SendReputationStandingUpdate((IPacketReceiver)this.m_owner.Client, rep);
            return(rep);
        }
示例#12
0
        /// <summary>
        /// Lets player know they are at war with a certain faction.
        /// </summary>
        public static void SendSetAtWar(IPacketReceiver client, Reputation rep)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SET_FACTION_ATWAR, 5))
			{
				packet.Write((int)rep.Faction.ReputationIndex);

				packet.Write((byte)rep.Flags); // rep flags

				client.Send(packet);
			}
		}
示例#13
0
        /// <summary>
        /// Creates a Reputation object that represents the relation to the given faction, or null
        /// </summary>
        /// <param name="faction">The Faction which the Reputation should be with</param>
        private Reputation Create(Faction faction)
        {
            var defaultValue = GetDefaultReputationValue(faction);
            var defaultFlags = GetDefaultReputationFlags(faction);
            var newRecord    = m_owner.Record.CreateReputationRecord();
            var rep          = new Reputation(newRecord, faction, defaultValue, defaultFlags);

            m_byIndex.Add(faction.ReputationIndex, rep);

            // For some reason, this also makes the faction visible ...
            FactionHandler.SendReputationStandingUpdate(m_owner.Client, rep);
            return(rep);
        }
示例#14
0
        public void TestInitialReputations()
        {
            Setup.EnsureDBSetup();
            FactionMgr.Initialize();

            var stormWind = FactionMgr.Get(FactionId.Stormwind);
            var bootyBay = FactionMgr.Get(FactionId.BootyBay);

            Assert.IsNotNull(bootyBay);

            var reputation = new Reputation(new ReputationRecord(), bootyBay, 1000, ReputationFlags.None);

            Asser.FlatNotSet(reputation.Flags, ReputationFlags.AtWar);
        }
示例#15
0
        /// <summary>Only called if the player declared war</summary>
        public void DeclareWar(FactionReputationIndex reputationIndex, bool hostile, bool sendUpdate)
        {
            Reputation rep = this.GetOrCreate(reputationIndex);

            if (rep.IsForcedAtPeace || rep.Faction.Group == this.m_owner.Faction.Group || rep.DeclaredWar == hostile)
            {
                return;
            }
            rep.DeclaredWar = hostile;
            if (!sendUpdate || !rep.DeclaredWar)
            {
                return;
            }
            FactionHandler.SendSetAtWar((IPacketReceiver)this.m_owner.Client, rep);
        }
示例#16
0
        /// <summary>
        /// Changes the reputation value with a specific Faction.
        /// Is called by ReputationCollect.SetValue
        /// </summary>
        /// <param name="value"></param>
        /// <returns>Whether hostility changed due to the stending change</returns>
        internal bool SetValue(int value)
        {
            Standing standing = this.m_standing;
            bool     hostile1 = this.Hostile;

            this.m_standing = Reputation.GetStanding(value);
            bool hostile2 = this.Hostile;

            this.m_record.Value = value;
            if (standing != this.m_standing)
            {
                return(hostile1 != hostile2);
            }
            return(false);
        }
示例#17
0
        /// <summary>Called when interacting with an NPC.</summary>
        public void OnTalkWith(NPC npc)
        {
            FactionReputationIndex reputationIndex = npc.Faction.ReputationIndex;

            if (reputationIndex < FactionReputationIndex.None || reputationIndex >= FactionReputationIndex.End)
            {
                return;
            }
            Reputation reputation = this.GetOrCreate(reputationIndex);

            if (reputation.IsForcedInvisible)
            {
                return;
            }
            reputation.IsVisible = true;
            this.Owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.KnownFactions, 0U, 0U,
                                                                    (Unit)null);
            FactionHandler.SendVisible((IPacketReceiver)this.m_owner.Client, reputationIndex);
        }
示例#18
0
        /// <summary>
        /// Called when interacting with an NPC.
        /// </summary>
        public void OnTalkWith(NPC npc)
        {
            var reputationIndex = npc.Faction.ReputationIndex;

            // Does this faction even have a rep?
            if (reputationIndex < 0 || reputationIndex >= FactionReputationIndex.End)
            {
                return;
            }

            Reputation rep = GetOrCreate(reputationIndex);

            // Faction is now visible
            if (!rep.IsForcedInvisible)
            {
                rep.IsVisible = true;

                Owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.KnownFactions);

                // Let the client know the Faction is visible
                FactionHandler.SendVisible(m_owner.Client, reputationIndex);
            }
        }
示例#19
0
		/// <summary>
		/// Loads all Factions that this Character already knows from the DB
		/// </summary>
		public void Load()
		{
			foreach (var record in ReputationRecord.Load(m_owner.Record.Guid))
			{
				var fac = FactionMgr.Get(record.ReputationIndex);
				if (fac != null)
				{
					if (m_byIndex.ContainsKey(record.ReputationIndex))
					{
						log.Warn("Character {0} had Reputation with Faction {1} more than once.", m_owner, record.ReputationIndex);
					}
					else
					{
						var rep = new Reputation(record, fac);
						m_byIndex.Add(record.ReputationIndex, rep);
					}
				}
				else
				{
					log.Warn("Character {0} has saved Reputation with invalid Faction: {1}", m_owner, record.ReputationIndex);

					// record.DeleteAndFlush();
				}
			}
		}
示例#20
0
		public void ModValue(Reputation rep, int value)
		{
			if (rep.SetValue(rep.Value + value))
			{
				//UpdateHostile(rep, rep.Hostile);
			}
			FactionHandler.SendReputationStandingUpdate(m_owner.Client, rep);
		}
示例#21
0
		/// <summary>
		/// Creates a Reputation object that represents the relation to the given faction, or null
		/// </summary>
		/// <param name="faction">The Faction which the Reputation should be with</param>
		private Reputation Create(Faction faction)
		{
		    var defaultValue = GetDefaultReputationValue(faction);
		    var defaultFlags = GetDefaultReputationFlags(faction);
		    var newRecord = m_owner.Record.CreateReputationRecord();
		    var rep = new Reputation(newRecord, faction, defaultValue, defaultFlags);
			m_byIndex.Add(faction.ReputationIndex, rep);
            
            // For some reason, this also makes the faction visible ...
		    FactionHandler.SendReputationStandingUpdate(m_owner.Client, rep);
			return rep;
		}
示例#22
0
 public void SetValue(Reputation rep, int value)
 {
     rep.SetValue(value);
     FactionHandler.SendReputationStandingUpdate(m_owner.Client, rep);
 }
示例#23
0
 /// <summary>Loads an existing Reputation from the given Record.</summary>
 public Reputation(ReputationRecord record, Faction faction)
 {
     this.m_record   = record;
     this.Faction    = faction;
     this.m_standing = Reputation.GetStanding(record.Value);
 }
示例#24
0
 public void ModValue(Reputation rep, int value)
 {
     if (rep.SetValue(rep.Value + value))
     {
         if (rep.StandingLevel >= StandingLevel.Honored)
         {
             Owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.GainHonoredReputation);
         }
         if (rep.StandingLevel >= StandingLevel.Revered)
         {
             Owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.GainReveredReputation);
         }
         if (rep.StandingLevel >= StandingLevel.Exalted)
         {
             Owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.GainExaltedReputation);
         }
         if (value > 0)
         {
             Owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.GainReputation);
         }
     }
     FactionHandler.SendReputationStandingUpdate(m_owner.Client, rep);
 }
示例#25
0
 public void SetValue(Reputation rep, int value)
 {
     rep.SetValue(value);
     FactionHandler.SendReputationStandingUpdate((IPacketReceiver)this.m_owner.Client, rep);
 }
示例#26
0
        /// <summary>
        /// Returns the cost of this item after the reputation discount has been applied.
        /// </summary>
        public uint GetDiscountedCost(FactionReputationIndex reputationIndex, uint cost)
        {
            var lvl = GetStandingLevel(reputationIndex);

            return((cost * (100 - Reputation.GetReputationDiscountPct(lvl))) / 100);
        }
示例#27
0
        /// <summary>
        /// Returns the cost of this item after the reputation discount has been applied.
        /// </summary>
        public uint GetDiscountedCost(FactionReputationIndex reputationIndex, uint cost)
        {
            StandingLevel standingLevel = this.GetStandingLevel(reputationIndex);

            return(cost * (100U - Reputation.GetReputationDiscountPct(standingLevel)) / 100U);
        }
示例#28
0
		/// <summary>
		/// Sends a reputation update.
		/// </summary>
		public static void SendReputationStandingUpdate(IPacketReceiver client, Reputation rep)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SET_FACTION_STANDING, 16))
			{
				packet.Write(0f); // Refer-A-Friend bonus reputation
				packet.Write((byte)0);
				packet.Write(1);							// count (we only ever send 1)
				packet.Write((uint)rep.Faction.ReputationIndex);
				packet.Write(rep.Value);

				client.Send(packet);
			}
		}