Example #1
0
    protected override Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item)
    {
        switch (itemTypeString)
        {
        case "weapon":
            item = new Weapon(itemNameString, itemLocation);
            break;

        case "wood":
            item = new WoodItem(itemNameString, itemLocation);
            break;

        case "iron":
            item = new IronItem(itemNameString, itemLocation);
            break;

        default:
            break;
        }

        if (item == null)
        {
            item = base.CreateItem(itemTypeString, itemNameString, itemLocation, item);
        }
        return(item);
    }
Example #2
0
    private void HandleGatherInteraction(string[] commandWords, Person actor)
    {
        bool hasWeapon = false;
        bool hasArmor  = false;

        foreach (var item in actor.ListInventory())
        {
            if (item is Weapon)
            {
                hasWeapon = true;
            }

            if (item is Armor)
            {
                hasArmor = true;
            }
        }

        Location currentLocation = DetermineActorLocation(actor);

        if (hasWeapon && actor.Location.LocationType == LocationType.Forest)
        {
            Item gatheredItem = new WoodItem(commandWords[2], currentLocation);
            actor.AddToInventory(gatheredItem);
            this.AddToPerson(actor, gatheredItem);
        }

        if (hasArmor && actor.Location.LocationType == LocationType.Mine)
        {
            Item gatheredItem = new IronItem(commandWords[2], currentLocation);
            actor.AddToInventory(gatheredItem);
            this.AddToPerson(actor, gatheredItem);
        }
    }
Example #3
0
    private void HandleGatherInteraction(string[] commandWords, Person actor)
    {
        bool hasWeapon = false;
        bool hasArmor = false;

        foreach (var item in actor.ListInventory())
        {
            if (item is Weapon)
            {
                hasWeapon = true;
            }

            if (item is Armor)
            {
                hasArmor = true;
            }
        }

        Location currentLocation = DetermineActorLocation(actor);

        if (hasWeapon && actor.Location.LocationType == LocationType.Forest)
        {
            Item gatheredItem = new WoodItem(commandWords[2], currentLocation);
            actor.AddToInventory(gatheredItem);
            this.AddToPerson(actor, gatheredItem);
        }

        if (hasArmor && actor.Location.LocationType == LocationType.Mine)
        {
            Item gatheredItem = new IronItem(commandWords[2], currentLocation);
            actor.AddToInventory(gatheredItem);
            this.AddToPerson(actor, gatheredItem);
        }
    }
Example #4
0
    protected override Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item)
    {
        switch (itemTypeString)
        {
            case "weapon":
                item = new Weapon(itemNameString, itemLocation);
                break;
            case "wood":
                item = new WoodItem(itemNameString, itemLocation);
                break;
            case "iron":
                item = new IronItem(itemNameString, itemLocation);
                break;
            default:
                break;
        }

        if (item == null)
        {
            item = base.CreateItem(itemTypeString, itemNameString, itemLocation, item);
        }
        return item;
    }