Esempio n. 1
0
        public void AttackOther(Humanoid other, int damage)
        {
            if (damage < 0)
            {
                damage = 0;
            }

            damage = other.CompressDamage(damage);

            var xp = damage * 4;

            CombatLevel.AddXP(xp);

            if (this == Program.ActiveWorld.MainCharacter)
            {
                WriteLineColor($"You did {damage} damage to {(string.IsNullOrWhiteSpace(other.Name) ? "the enemy" : other.Name)}", ConsoleColor.Red, ConsoleColor.Black);
                if (xp > 0)
                {
                    WriteLineColor($"You received {xp} xp", ConsoleColor.DarkCyan, ConsoleColor.Black);
                }
            }
            else if (other == Program.ActiveWorld.MainCharacter)
            {
                WriteLineColor($"You received {damage} damage from {(string.IsNullOrWhiteSpace(this.Name) ? "the enemy" : this.Name)}", ConsoleColor.Red, ConsoleColor.Black);
            }
            else
            {
                WriteLineColor($"{(string.IsNullOrWhiteSpace(this.Name) ? "the enemy 1" : this.Name)} did {damage} damage to {(string.IsNullOrWhiteSpace(other.Name) ? "the enemy 2" : other.Name)}", ConsoleColor.Red, ConsoleColor.Black);
            }

            other.AddHealth(-damage);

            if (other == Program.ActiveWorld.MainCharacter)
            {
                WriteLineColor($"{(string.IsNullOrWhiteSpace(this.Name) ? "the enemy" : this.Name)}'s health is now {this.Health}", ConsoleColor.Red, ConsoleColor.Black);
            }

            Program.UpdateStats(Program.ActiveWorld.MainCharacter);
        }
Esempio n. 2
0
        public void Equipt()
        {
            if (dataInventory.SelectedRows.Count == 0)
            {
                return;
            }

            var item = (Item)dataInventory.SelectedRows[0].Cells["Item"].Value;

            if (ActiveHuman.Inventory.Items.Contains(item))
            {
                if (ToSellSomething)
                {
                    int price = 0;
                    if (item is UseItem)
                    {
                        var itemU = (UseItem)item;

                        price = itemU.Price;
                    }
                    else if (item is ToolItem)
                    {
                        var itemU = (ToolItem)item;

                        price = itemU.Price;
                    }
                    else if (item is ResourceItem)
                    {
                        var itemU = (ResourceItem)item;

                        price = itemU.Price * itemU.Quantity;
                    }
                    else if (item is WearableItem)
                    {
                        var itemW = (WearableItem)item;

                        price = (itemW.Power.Strength + 1) * (itemW.Power.Inteligence + 1) * (itemW.Power.Defence + 1);
                    }

                    ActiveHuman.Orens += price;

                    ActiveHuman.Inventory.Items.Remove(item);

                    ToSellSomething = false;

                    Program.WriteLineColor($"You have sold the item for {World.GetOrenLabel(price)}.", ConsoleColor.Yellow, ConsoleColor.Black);
                    Program.WriteLineColor($"You now have {World.GetOrenLabel(ActiveHuman.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black);

                    UpdateStats(ActiveHuman);

                    WriteLineProcess("yes");


                    // then we need to set the value of ToSellSomething to false. // (we set the value to false when we create the variable ToSellSomething)
                }
                else
                {
                    if (item is WearableItem)
                    {
                        var typeofValue = item.GetType();
                        if (item is HeadItem)
                        {
                            if (ActiveHuman.Head != null)
                            {
                                ActiveHuman.Inventory.Items.Add(ActiveHuman.Head);
                                ActiveHuman.Head = null;
                            }

                            ActiveHuman.Head = (HeadItem)item;
                        }
                        else if (item is ChestItem)
                        {
                            if (ActiveHuman.Chest != null)
                            {
                                ActiveHuman.Inventory.Items.Add(ActiveHuman.Chest);
                                ActiveHuman.Chest = null;
                            }
                            ActiveHuman.Chest = (ChestItem)item;
                        }
                        else if (item is LegsItem)
                        {
                            if (ActiveHuman.Legs != null)
                            {
                                ActiveHuman.Inventory.Items.Add(ActiveHuman.Legs);
                                ActiveHuman.Legs = null;
                            }
                            ActiveHuman.Legs = (LegsItem)item;
                        }
                        else if (item is FeetItem)
                        {
                            if (ActiveHuman.Feet != null)
                            {
                                ActiveHuman.Inventory.Items.Add(ActiveHuman.Feet);
                                ActiveHuman.Feet = null;
                            }
                            ActiveHuman.Feet = (FeetItem)item;
                        }
                        else if (item is WeaponItem)
                        {
                            if (ActiveHuman.Hands != null)
                            {
                                ActiveHuman.Inventory.Items.Add(ActiveHuman.Hands);
                                ActiveHuman.Hands = null;
                            }
                            ActiveHuman.Hands = (WeaponItem)item;
                        }
                        else if (item is ToolItem)
                        {
                            if (ActiveHuman.Belt != null)
                            {
                                if (!(item is QuestItem))
                                {
                                    ActiveHuman.Inventory.Items.Add(ActiveHuman.Belt);
                                    ActiveHuman.Belt = null;
                                }
                            }
                            if (ActiveHuman.GetWearablePower().Inteligence >= ((ToolItem)item).Requirements)
                            {
                                if (!(item is QuestItem))
                                {
                                    ActiveHuman.Belt = (ToolItem)item;
                                }
                                else
                                {
                                    ActiveHuman.ActivatedQuests.Add(ActiveWorld.GetRandomQuestion());
                                }
                            }
                            else
                            {
                                Program.WriteLineColor($"You do not meet the requirements to wear {item.Name} you require {((ToolItem)item).Requirements} Inteligence.", ConsoleColor.Red, ConsoleColor.Black);

                                UpdateStats(ActiveHuman);
                                return;
                            }
                        }
                        ActiveHuman.Inventory.Items.Remove(item);

                        UpdateStats(ActiveHuman);
                    }
                    else if (item is Fish)
                    {
                        if (ActiveHuman.Inventory.CanIUseResource(typeof(Fish), 1))
                        {
                            ActiveHuman.Inventory.AddOrRemoveResourceItem(typeof(Fish), -1);

                            ActiveHuman.AddHealth(10);

                            Program.WriteLineColor("You just ate a fish and you healed 10 health.", ConsoleColor.Green, ConsoleColor.Black);

                            UpdateStats(ActiveHuman);
                        }
                        else if (ActiveHuman.Belt is QuestItem)
                        {
                            // do we have tree seeds to complete quest
                            if (ActiveHuman.Inventory.CanIUseResource(typeof(TreeSeeds), 25))
                            {
                                ActiveHuman.Inventory.AddOrRemoveResourceItem(typeof(TreeSeeds), -25);

                                ActiveHuman.Power.Defence     += 1;
                                ActiveHuman.Power.Inteligence += 1;
                                ActiveHuman.Power.Strength    += 1;

                                Program.WriteLineColor("Congratulations you have completed this quest.", ConsoleColor.Green, ConsoleColor.Black);

                                UpdateStats(ActiveHuman);
                            }
                        }
                    }
                }
            }
            else
            {
                UpdateStats(ActiveHuman);
            }
        }