[Rpgworldmodel-commits] SF.net SVN: rpgworldmodel: [19] src/RPGWorldModel.Abstracts
Status: Inactive
Brought to you by:
deadwood_pl
From: <dea...@us...> - 2006-07-16 09:16:04
|
Revision: 19 Author: deadwood_pl Date: 2006-07-16 02:15:26 -0700 (Sun, 16 Jul 2006) ViewCVS: http://svn.sourceforge.net/rpgworldmodel/?rev=19&view=rev Log Message: ----------- Reorganization in namespaces connected with damage. Modified Paths: -------------- src/RPGWorldModel.Abstracts/Club.cs src/RPGWorldModel.Abstracts/IDamagable.cs src/RPGWorldModel.Abstracts/IDamageInflictor.cs src/RPGWorldModel.Abstracts/ILiveEntity.cs src/RPGWorldModel.Abstracts/INamedEntity.cs src/RPGWorldModel.Abstracts/Initializable.cs src/RPGWorldModel.Abstracts/Knife.cs src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj src/RPGWorldModel.Abstracts/Sword.cs src/RPGWorldModel.Abstracts/Weapon.cs src/RPGWorldModel.Implementation/Clubs.cs src/RPGWorldModel.Implementation/Knifes.cs src/RPGWorldModel.Implementation/Swords.cs src/test_applications/tester/Form1.cs Added Paths: ----------- src/RPGWorldModel.Abstracts/DamageDescriptor.cs src/RPGWorldModel.Abstracts/InflictedDamage.cs Modified: src/RPGWorldModel.Abstracts/Club.cs =================================================================== --- src/RPGWorldModel.Abstracts/Club.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Club.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.Abstracts.Support.Equipment; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.Items { Added: src/RPGWorldModel.Abstracts/DamageDescriptor.cs =================================================================== --- src/RPGWorldModel.Abstracts/DamageDescriptor.cs (rev 0) +++ src/RPGWorldModel.Abstracts/DamageDescriptor.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using RPGWorldModel.Abstracts.Support.Misc; + +namespace RPGWorldModel.Abstracts.Support.Damage +{ + /// <summary> + /// Dictionary of DamageDescriptor object indexed by type + /// </summary> + public class DamageDescriptorDictionary : Dictionary<Type, DamageDescriptor> + { + } + + public abstract class DamageDescriptor : Initializable + { + private short minDamage = 0; + public short MinDamage + { + get { return minDamage; } + set { minDamage = value; } + } + + private short maxDamage = 0; + public short MaxDamage + { + get { return maxDamage; } + set { maxDamage = value; } + } + + /* + * Base values + */ + + private short baseMinDamage = 0; + public short BaseMinDamage + { + get { return baseMinDamage; } + set { baseMinDamage = value; } + } + + private byte minDamageMargin = 0; + public byte MinDamageMargin + { + get { return minDamageMargin; } + set { minDamageMargin = value; } + } + + private short baseMaxDamage = 0; + public short BaseMaxDamage + { + get { return baseMaxDamage; } + set { baseMaxDamage = value; } + } + + private byte maxDamageMargin = 0; + public byte MaxDamageMargin + { + get { return maxDamageMargin; } + set { maxDamageMargin = value; } + } + + /// <summary> + /// Creates an instance of specified inflicted damage type + /// </summary> + /// <returns></returns> + public abstract InflictedDamage CreateInflictedDamage(); + } + + /* + * Concrete types of damage + */ + + public class DamageDescriptorPhysical : DamageDescriptor + { + public override InflictedDamage CreateInflictedDamage() + { + return new InflictedDamagePhysical(); + } + } + + public class DamageDescriptorFire : DamageDescriptor + { + public override InflictedDamage CreateInflictedDamage() + { + return new InflictedDamageFire(); + } + } +} \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/IDamagable.cs =================================================================== --- src/RPGWorldModel.Abstracts/IDamagable.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/IDamagable.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Misc; namespace RPGWorldModel.Abstracts.Interfaces { Modified: src/RPGWorldModel.Abstracts/IDamageInflictor.cs =================================================================== --- src/RPGWorldModel.Abstracts/IDamageInflictor.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/IDamageInflictor.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Abstracts.Interfaces { @@ -17,148 +18,12 @@ /// Gets all types of inflicted damages along with values /// </summary> /// <returns></returns> - InflictedDamageResponse GetInflictedDamage(); + DamageInflictorInflictedDamageResponse GetInflictedDamage(); } - public abstract class DamageDescriptor : Initializable + public class DamageInflictorInflictedDamageResponse : InflictedDamageResponse { - private short minDamage = 0; - public short MinDamage - { - get { return minDamage; } - set { minDamage = value; } - } - - private short maxDamage = 0; - public short MaxDamage - { - get { return maxDamage; } - set { maxDamage = value; } - } - - /* - * Base values - */ - - private short baseMinDamage = 0; - public short BaseMinDamage - { - get { return baseMinDamage; } - set { baseMinDamage = value; } - } - - private byte minDamageMargin = 0; - public byte MinDamageMargin - { - get { return minDamageMargin; } - set { minDamageMargin = value; } - } - - private short baseMaxDamage = 0; - public short BaseMaxDamage - { - get { return baseMaxDamage; } - set { baseMaxDamage = value; } - } - - private byte maxDamageMargin = 0; - public byte MaxDamageMargin - { - get { return maxDamageMargin; } - set { maxDamageMargin = value; } - } - - /// <summary> - /// Creates an instance of specified inflicted damage type - /// </summary> - /// <returns></returns> - public abstract InflictedDamage CreateInflictedDamage(); } - /// <summary> - /// Dictionary of DamageDescriptor object indexed by type - /// </summary> - public class DamageDescriptorDictionary : Dictionary<Type, DamageDescriptor> - { - } - public class InflictedDamageResponse - { - protected InflictedDamageList inflictedDamages = new InflictedDamageList(); - - public void Add(InflictedDamage inflictedDamage) - { - inflictedDamages.Add(inflictedDamage); - } - - public IEnumerable<InflictedDamage> InflictedDamages - { - get { return inflictedDamages; } - } - } - - /// <summary> - /// Holds damage inflicted by an entity - /// </summary> - public abstract class InflictedDamage - { - private short minDamage = 0; - public virtual short MinDamage - { - get { return minDamage; } - } - - private short maxDamage = 0; - public virtual short MaxDamage - { - get { return maxDamage; } - } - - protected InflictedDamage() - { - } - - public virtual void SetDamage(short minDamage, short maxDamage) - { - if (minDamage > maxDamage) - throw new ArgumentException("minDamage must not be greater than maxDamage"); - - this.minDamage = minDamage; - this.maxDamage = maxDamage; - } - - - } - - public class InflictedDamageList : List<InflictedDamage> - { - } - - /* - * Concrete types of damage - */ - - public class DamageDescriptorPhysical : DamageDescriptor - { - public override InflictedDamage CreateInflictedDamage() - { - return new InflictedDamagePhysical(); - } - } - - public class InflictedDamagePhysical : InflictedDamage - { - } - - public class DamageDescriptorFire : DamageDescriptor - { - public override InflictedDamage CreateInflictedDamage() - { - return new InflictedDamageFire(); - } - } - - public class InflictedDamageFire : InflictedDamage - { - } } Modified: src/RPGWorldModel.Abstracts/ILiveEntity.cs =================================================================== --- src/RPGWorldModel.Abstracts/ILiveEntity.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/ILiveEntity.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Misc; namespace RPGWorldModel.Abstracts.Interfaces { Modified: src/RPGWorldModel.Abstracts/INamedEntity.cs =================================================================== --- src/RPGWorldModel.Abstracts/INamedEntity.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/INamedEntity.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using RPGWorldModel.Abstracts.Support.Misc; namespace RPGWorldModel.Abstracts.Interfaces { Added: src/RPGWorldModel.Abstracts/InflictedDamage.cs =================================================================== --- src/RPGWorldModel.Abstracts/InflictedDamage.cs (rev 0) +++ src/RPGWorldModel.Abstracts/InflictedDamage.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; + +namespace RPGWorldModel.Abstracts.Support.Damage +{ + /// <summary> + /// Holds damage inflicted by an entity + /// </summary> + public abstract class InflictedDamage + { + private short minDamage = 0; + public virtual short MinDamage + { + get { return minDamage; } + } + + private short maxDamage = 0; + public virtual short MaxDamage + { + get { return maxDamage; } + } + + protected InflictedDamage() + { + } + + public virtual void SetDamage(short minDamage, short maxDamage) + { + if (minDamage > maxDamage) + throw new ArgumentException("minDamage must not be greater than maxDamage"); + + this.minDamage = minDamage; + this.maxDamage = maxDamage; + } + + + } + + public class InflictedDamageList : List<InflictedDamage> + { + } + + public class InflictedDamageDictionaty : Dictionary<Type, InflictedDamage> + { + } + + public class InflictedDamageResponse + { + protected InflictedDamageDictionaty inflictedDamages = new InflictedDamageDictionaty(); + + public virtual void Set(InflictedDamage inflictedDamage) + { + inflictedDamages[inflictedDamage.GetType()] = inflictedDamage; + } + + public virtual void Sum(InflictedDamage inflictedDamage) + { + InflictedDamage existing = inflictedDamages[inflictedDamage.GetType()]; + + if (existing == null) + Set(inflictedDamage); + else + { + existing.SetDamage( + (short)(existing.MinDamage + inflictedDamage.MinDamage), + (short)(existing.MaxDamage + inflictedDamage.MaxDamage)); + } + } + + public IEnumerable<InflictedDamage> InflictedDamages + { + get { return inflictedDamages.Values; } + } + } + + public class InflictedDamagePhysical : InflictedDamage + { + } + + public class InflictedDamageFire : InflictedDamage + { + } +} \ No newline at end of file Modified: src/RPGWorldModel.Abstracts/Initializable.cs =================================================================== --- src/RPGWorldModel.Abstracts/Initializable.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Initializable.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace RPGWorldModel.Abstracts.Interfaces +namespace RPGWorldModel.Abstracts.Support.Misc { public class Initializable { Modified: src/RPGWorldModel.Abstracts/Knife.cs =================================================================== --- src/RPGWorldModel.Abstracts/Knife.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Knife.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.Abstracts.Support.Equipment; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.Items { Modified: src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj =================================================================== --- src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/RPGWorldModel.Abstracts.csproj 2006-07-16 09:15:26 UTC (rev 19) @@ -38,6 +38,7 @@ <Compile Include="Arachnid.cs" /> <Compile Include="Clothing.cs" /> <Compile Include="Club.cs" /> + <Compile Include="DamageDescriptor.cs" /> <Compile Include="EquipmentLocation.cs" /> <Compile Include="EquipmentSlot.cs" /> <Compile Include="GameEntity.cs" /> @@ -52,6 +53,7 @@ <Compile Include="IMagicEntity.cs" /> <Compile Include="INamedEntity.cs" /> <Compile Include="InAnimatedEntity.cs" /> + <Compile Include="InflictedDamage.cs" /> <Compile Include="Initializable.cs" /> <Compile Include="Item.cs" /> <Compile Include="Knife.cs" /> Modified: src/RPGWorldModel.Abstracts/Sword.cs =================================================================== --- src/RPGWorldModel.Abstracts/Sword.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Sword.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -4,6 +4,7 @@ using RPGWorldModel.Abstracts.Interfaces; using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.Abstracts.Support.Equipment; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.TopLevelImplementation.Entities.Items { Modified: src/RPGWorldModel.Abstracts/Weapon.cs =================================================================== --- src/RPGWorldModel.Abstracts/Weapon.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Abstracts/Weapon.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Text; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Misc; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Abstracts.Entities.Items { @@ -47,9 +49,10 @@ /// Default implementation with all damages beeing changed by durability /// </summary> /// <returns></returns> - public virtual InflictedDamageResponse GetInflictedDamage() + public virtual DamageInflictorInflictedDamageResponse GetInflictedDamage() { - InflictedDamageResponse response = new InflictedDamageResponse(); + DamageInflictorInflictedDamageResponse response = + new DamageInflictorInflictedDamageResponse(); short min = 0; short max = 0; @@ -63,7 +66,7 @@ damage.SetDamage(min, max); - response.Add(damage); + response.Set(damage); } Modified: src/RPGWorldModel.Implementation/Clubs.cs =================================================================== --- src/RPGWorldModel.Implementation/Clubs.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Implementation/Clubs.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.TopLevelImplementation.Entities.Items; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Implementation.Entities.Items.Clubs { Modified: src/RPGWorldModel.Implementation/Knifes.cs =================================================================== --- src/RPGWorldModel.Implementation/Knifes.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Implementation/Knifes.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.TopLevelImplementation.Entities.Items; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Implementation.Entities.Items.Knifes { Modified: src/RPGWorldModel.Implementation/Swords.cs =================================================================== --- src/RPGWorldModel.Implementation/Swords.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/RPGWorldModel.Implementation/Swords.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -2,6 +2,7 @@ using RPGWorldModel.Abstracts.Entities.Items; using RPGWorldModel.TopLevelImplementation.Entities.Items; using RPGWorldModel.Abstracts.Interfaces; +using RPGWorldModel.Abstracts.Support.Damage; namespace RPGWorldModel.Implementation.Entities.Items.Swords { Modified: src/test_applications/tester/Form1.cs =================================================================== --- src/test_applications/tester/Form1.cs 2006-07-15 16:39:03 UTC (rev 18) +++ src/test_applications/tester/Form1.cs 2006-07-16 09:15:26 UTC (rev 19) @@ -18,6 +18,7 @@ using RPGWorldModel.Implementation.Entities.Items.Pants; using RPGWorldModel.Implementation.Entities.Items.Clubs; using RPGWorldModel.Implementation.Entities.Items.Knifes; +using RPGWorldModel.Abstracts.Support.Damage; /* * This is a simple WinForms application for testing features added to the framework. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |