Exemplo n.º 1
0
        protected virtual bool DoIload(string rawParameters, params CommandParameter[] parameters)
        {
            if (parameters.Length == 0 || !parameters[0].IsNumber)
            {
                Send("Syntax: iload <id>");
                return(true);
            }

            ItemBlueprintBase itemBlueprint = DependencyContainer.Instance.GetInstance <IWorld>().GetItemBlueprint(parameters[0].AsNumber);

            if (itemBlueprint == null)
            {
                Send("No item with that id.");
                return(true);
            }

            IContainer container = itemBlueprint.WearLocation == WearLocations.None ? Impersonating.Room as IContainer : Impersonating as IContainer;
            IItem      item      = DependencyContainer.Instance.GetInstance <IWorld>().AddItem(Guid.NewGuid(), itemBlueprint, container);

            if (item == null)
            {
                Send("Item cannot be created.");
                DependencyContainer.Instance.GetInstance <IServer>().Wiznet($"DoIload: item with id {parameters[0].AsNumber} cannot be created", WiznetFlags.Bugs, AdminLevels.Implementor);
                return(true);
            }

            DependencyContainer.Instance.GetInstance <IServer>().Wiznet($"{DisplayName} loads {item.DebugName}.", WiznetFlags.Load);

            Impersonating.Act(ActOptions.ToAll, "{0:N} {0:h} created {1}!", Impersonating, item);
            Send("Ok.");

            return(true);
        }
Exemplo n.º 2
0
 public void AddItemBlueprint(ItemBlueprintBase blueprint)
 {
     if (_itemBlueprints.ContainsKey(blueprint.Id))
     {
         Log.Default.WriteLine(LogLevels.Error, $"Item blueprint duplicate {blueprint.Id}!!!");
     }
     else
     {
         _itemBlueprints.Add(blueprint.Id, blueprint);
     }
 }
Exemplo n.º 3
0
 public Quest(QuestBlueprint blueprint, ICharacter character, ICharacter giver)
 {
     _character            = character;
     Blueprint             = blueprint;
     Giver                 = giver;
     _killObjectivesKilled = blueprint.KillObjectives?.ToDictionary(x => x.CharacterBlueprintId, x => 0);
     _objectives           = new List <QuestObjectiveBase>();
     if (Blueprint.ItemObjectives != null)
     {
         foreach (QuestItemObjective itemObjective in Blueprint.ItemObjectives)
         {
             ItemBlueprintBase itemBlueprint = Repository.World.GetItemBlueprint(itemObjective.ItemBlueprintId);
             if (itemBlueprint != null)
             {
                 _objectives.Add(new ItemQuestObjective
                 {
                     Blueprint = itemBlueprint,
                     Count     = character.Content.Where(x => x.Blueprint != null).Count(x => x.Blueprint.Id == itemObjective.ItemBlueprintId), // should always be 0
                     Total     = itemObjective.Count
                 });
             }
             else
             {
                 Log.Default.WriteLine(LogLevels.Warning, $"Item objective {itemObjective.ItemBlueprintId} doesn't exist for quest {blueprint.Id}");
             }
         }
     }
     if (Blueprint.KillObjectives != null)
     {
         foreach (QuestKillObjective killObjective in Blueprint.KillObjectives)
         {
             CharacterBlueprint characterBlueprint = Repository.World.GetCharacterBlueprint(killObjective.CharacterBlueprintId);
             if (characterBlueprint != null)
             {
                 _objectives.Add(new KillQuestObjective
                 {
                     Blueprint = characterBlueprint,
                     Count     = 0,
                     Total     = killObjective.Count
                 });
             }
             else
             {
                 Log.Default.WriteLine(LogLevels.Warning, $"Item objective {killObjective.CharacterBlueprintId} doesn't exist for quest {blueprint.Id}");
             }
         }
     }
 }
Exemplo n.º 4
0
        public IItem AddItem(Guid guid, int blueprintId, IContainer container)
        {
            ItemBlueprintBase blueprint = GetItemBlueprint(blueprintId);

            if (blueprint == null)
            {
                Log.Default.WriteLine(LogLevels.Error, $"World.AddItem: unknown blueprintId {blueprintId}");
                return(null);
            }
            IItem item = AddItem(guid, blueprint, container);

            if (item == null)
            {
                Log.Default.WriteLine(LogLevels.Error, $"World.AddItem: Unknown blueprint id {blueprintId} or type {blueprint.GetType().FullName}");
            }
            return(item);
        }
Exemplo n.º 5
0
 public void AddItemBlueprint(ItemBlueprintBase blueprint)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public IItem AddItemLight(Guid guid, ItemBlueprintBase blueprint, IContainer container)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
        public IItem AddItem(Guid guid, ItemBlueprintBase blueprint, IContainer container)
        {
            var weaponBlueprint = blueprint as ItemWeaponBlueprint;

            if (weaponBlueprint != null)
            {
                return(AddItemWeapon(guid, weaponBlueprint, container));
            }
            var containerBlueprint = blueprint as ItemContainerBlueprint;

            if (containerBlueprint != null)
            {
                return(AddItemContainer(guid, containerBlueprint, container));
            }
            var armorBlueprint = blueprint as ItemArmorBlueprint;

            if (armorBlueprint != null)
            {
                return(AddItemArmor(guid, armorBlueprint, container));
            }
            var lightBlueprint = blueprint as ItemLightBlueprint;

            if (lightBlueprint != null)
            {
                return(AddItemLight(guid, lightBlueprint, container));
            }
            var furnitureBlueprint = blueprint as ItemFurnitureBlueprint;

            if (furnitureBlueprint != null)
            {
                return(AddItemFurniture(guid, furnitureBlueprint, container));
            }
            var jewelryBlueprint = blueprint as ItemJewelryBlueprint;

            if (jewelryBlueprint != null)
            {
                return(AddItemJewelry(guid, jewelryBlueprint, container));
            }
            var shieldBlueprint = blueprint as ItemShieldBlueprint;

            if (shieldBlueprint != null)
            {
                return(AddItemShield(guid, shieldBlueprint, container));
            }
            var keyBlueprint = blueprint as ItemKeyBlueprint;

            if (keyBlueprint != null)
            {
                return(AddItemKey(guid, keyBlueprint, container));
            }
            var portalBlueprint = blueprint as ItemPortalBlueprint;

            if (portalBlueprint != null)
            {
                IRoom destination = Rooms.FirstOrDefault(x => x.Blueprint?.Id == portalBlueprint.Destination);
                return(AddItemPortal(guid, portalBlueprint, destination, container));
            }
            // TODO: other blueprint
            Log.Default.WriteLine(LogLevels.Error, $"World.AddItem: Invalid blueprint type {blueprint.GetType().FullName}");
            return(null);
        }