Beispiel #1
0
        /// <summary>
        /// Takes a description of the operation and stores it, and defaults the SuccessValue to true.
        /// </summary>
        /// <param name="description">A string describing the result of a operation.</param>
        public SuccessResponse(string description)
        {
            Description  = description;
            SuccessValue = true;

            TraceSourceSingleton.Ts().TraceEvent(TraceEventType.Information, 100, ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Takes a description of the operation and stores it, and defaults the SuccessValue to false.
        /// </summary>
        /// <param name="description">A string describing the result of a operation.</param>
        public FailureResponse(string description)
        {
            Description  = description;
            SuccessValue = false;

            TraceSourceSingleton.Ts().TraceEvent(TraceEventType.Information, 101, ToString());
        }
Beispiel #3
0
        public WorldObjectResponse(string description, bool successValue, IEnumerable <WorldObject> worldObjects)
        {
            Description  = description;
            SuccessValue = successValue;
            WorldObjects = worldObjects;

            TraceSourceSingleton.Ts().TraceEvent(TraceEventType.Information, 105, Description, WorldObjects);
        }
        /// <summary>
        /// Creates a DamageResponse object.
        /// </summary>
        /// <param name="description">Description of the operation.</param>
        /// <param name="successValue">Whether the operation was successful or not.</param>
        /// <param name="damage">How much damage was dealt.</param>
        /// <param name="origin">What entity dealt the damage.</param>
        /// <param name="damageSource">How did the entity deal the damage.</param>
        public DamageResponse(string description, bool successValue, double damage, WorldObject origin, IDamageDealing damageSource)
        {
            Description  = description;
            SuccessValue = successValue;
            Damage       = damage;
            Origin       = origin;
            DamageSource = damageSource;

            TraceSourceSingleton.Ts().TraceEvent(TraceEventType.Information, 104, Description, new object[] { Origin, Damage });
        }
Beispiel #5
0
        /// <summary>
        /// Constructor for setting the equipped item, the unequipped item and the slot, where the items are shifting.
        /// </summary>
        /// <param name="description">The description of the transaction.</param>
        /// <param name="equipped">The item to be equipped.</param>
        /// <param name="unEquipped">The item to be removed from it's slot.</param>
        /// <param name="slot">The slot in which the items are shifting position.</param>
        /// <param name="successValue">SuccessValue describes whether the operation was a success or not.</param>
        public EquipItemResponse(string description, IWearable equipped, IWearable unEquipped, string slot, bool successValue)
        {
            Description  = description;
            SuccessValue = successValue;
            Slot         = slot;
            Equipped     = equipped;
            UnEquipped   = unEquipped;

            TraceSourceSingleton.Ts().TraceEvent(TraceEventType.Information, 103, Description, new object[] { Equipped, UnEquipped, Slot });
        }
Beispiel #6
0
        /// <summary>
        /// Constructor to define description, who is receiving, who is sending, what items.
        /// Tracing Id 102.
        /// </summary>
        /// <param name="description">Describes the transaction of items.</param>
        /// <param name="origin">Origin represent who is sending items.</param>
        /// <param name="value">Value contains what items is being transferred.</param>
        public ItemsResponse(string description, string origin, IEnumerable <IItem> value = null)
        {
            if (value == null)
            {
                SuccessValue = false;
            }
            else
            {
                SuccessValue = true;
            }

            Description = description;
            Value       = value;
            Origin      = origin;

            TraceSourceSingleton.Ts().TraceEvent(TraceEventType.Information, 102, Description, Value);
        }
        static void Main(string[] args)
        {
            TraceSourceSingleton.Ts().Listeners.Add(new ConsoleTraceListener());
            TraceSourceSingleton.Ts().Listeners.Add(new TextWriterTraceListener(new StreamWriter("Tracing.txt")));
            TraceSourceSingleton.Ts().Listeners.Add(new DefaultTraceListener());
            TraceSourceSingleton.Ts().Listeners.Add(new XmlWriterTraceListener("XMLTracing.xml"));
            World    newWorld = new World(new WorldObjectManager());
            Creature human    = (new HumanoidConcreteFactory(1, "Man")).MakeCreature();

            newWorld.AddWorldObjectToWorld(human);
            WorldObject obj = newWorld.WorldObjectsManager.GetWorldObjects().WorldObjects.First();

            if (TypeComparer.IsSameOrVariant(typeof(Creature), obj.GetType()).SuccessValue)
            {
                ((Creature)obj).ItemManager.AddItems(new ItemsResponse("Adding item", "GOD", new [] { new Sword(new[] { new PhysicalDamageType() }, 5) }));
                ((Creature)obj).ItemManager.EquipGear((IAttackItem)((Creature)obj).ItemManager.GetItems().Value.First());
                while (true)
                {
                    IResponse response = ((Creature)obj).ReceiveHit(((Creature)obj).Hit());
                    if (response.SuccessValue == false && TypeComparer
                        .IsSameOrVariant(typeof(WorldObjectResponse), response.GetType()).SuccessValue)
                    {
                        Console.WriteLine("woops");
                        break;
                    }
                    if (response.SuccessValue)
                    {
                        Console.WriteLine("BONK");
                    }
                    Console.ReadLine();
                }
                Thread.Sleep(3000);
                ItemsResponse itemsLoot     = ((Creature)obj).Loot();
                string        collectedLoot = "";
                itemsLoot.Value.ToList().ForEach(a => collectedLoot += a.Name + " ");
                Console.WriteLine("WAUW you've looted : " + collectedLoot);
                Console.ReadLine();
                Console.WriteLine("now new dude with armor, and bigg sword vs small dude");

                Creature bigGuyCreature = (new HumanoidConcreteFactory(5, "BIGG GUY")).MakeCreature();
                Creature smoll          = (new HumanoidConcreteFactory(1)).MakeCreature();

                bigGuyCreature.ItemManager.Inventory.AddItems(new ItemsResponse("Adding startup items", "GOD",
                                                                                new IItem[]
                {
                    new BreastArmor(10, new[] { new PhysicalDamageType(), }),
                    new HeadArmor(5, new[] { new PhysicalDamageType(), }),
                    new Sword(new IDamageType[] { new PhysicalDamageType(), new FireDamageType(2) }, 10)
                }));
                bigGuyCreature.ItemManager.Inventory.GetItems().Value.Where(a => TypeComparer.IsSameOrVariant(typeof(IWearable), a.GetType()).SuccessValue).ToList().ForEach(a =>
                {
                    bigGuyCreature.ItemManager.GearLoadOut.EquipItem((IWearable)a);
                });

                smoll.ItemManager.AddItems(new ItemsResponse("Adding startup items", "GOD",
                                                             new IItem[]
                {
                    new BreastArmor(13, new IDamageType[] { new PhysicalDamageType(), new FireDamageType(), }),
                    new HeadArmor(15, new IDamageType[] { new PhysicalDamageType(), new FireDamageType() }),
                    new Sword(new IDamageType[] { new PhysicalDamageType() }, 5),
                }));


                smoll.ItemManager.Inventory.GetItems().Value.Where(a => TypeComparer.IsSameOrVariant(typeof(IWearable), a.GetType()).SuccessValue).ToList().ForEach(a =>
                {
                    smoll.ItemManager.GearLoadOut.EquipItem((IWearable)a);
                });

                Console.WriteLine("AIT FIGHT BOIS");
                bool oneAlive = true;
                while (oneAlive)
                {
                    oneAlive = smoll.ReceiveHit(bigGuyCreature.Hit()).SuccessValue&& oneAlive;
                    if (oneAlive)
                    {
                        oneAlive = bigGuyCreature.ReceiveHit(smoll.Hit()).SuccessValue&& oneAlive;
                    }
                }

                if (smoll.Hitpoints > 0)
                {
                    smoll.ItemManager.AddItems(bigGuyCreature.Loot());
                }
                else
                {
                    bigGuyCreature.ItemManager.AddItems(smoll.Loot());
                }
            }
        }