Exemple #1
0
 public static void PEvent(Person person)
 {
     Console.Clear();
     person.PrintCharacs();
     Console.ReadKey();
     Console.Clear();
 }
Exemple #2
0
 public static void CEvent(Person person)
 {
     Console.Clear();
     person.PrintStatus();
     Console.ReadKey();
     Console.Clear();
 }
Exemple #3
0
 public static void IEvent(Person person)
 {
     Console.Clear();
     person.PrintInventory();
     Console.ReadKey();
     Console.Clear();
 }
Exemple #4
0
 public int AcceptAction(Action action, Person person)
 {
     switch (TypeEvent)
     {
         case (int)eTypeEvent.Enemy:
             var enemy = (Enemy)Event;
             return enemy.AcceptAction(action, person);
         case (int)eTypeEvent.Rain:
             var rain = (Rain)Event;
             return rain.AcceptAction(action, person);
         case (int)eTypeEvent.Chest:
             var chest = (Chest) Event;
             return chest.AcceptAction(action, person);
         default:
             return 0;
     }
 }
Exemple #5
0
        public static void Start()
        {
            Console.WriteLine("Please, input Name:");
            var name = Console.ReadLine();
            Console.WriteLine("Please, choose a race!");

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("CHOOSE RACE!");
            Console.WriteLine("A) Human");
            Console.WriteLine("B) Orc");
            Console.WriteLine("C) Dwarf");
            Console.WriteLine("D) Elf");
            Console.WriteLine("E) Halffinger");
            Console.WriteLine("F) Troll");
            Console.ResetColor();

            var race = 0;

            do
            {
                var cki = Console.ReadKey(true);

                switch (cki.Key)
                {
                    case ConsoleKey.A:
                        race = 1;
                        break;
                    case ConsoleKey.B:
                        race = 2;
                        break;
                    case ConsoleKey.C:
                        race = 3;
                        break;
                    case ConsoleKey.D:
                        race = 4;
                        break;
                    case ConsoleKey.E:
                        race = 5;
                        break;
                    case ConsoleKey.F:
                        race = 6;
                        break;
                }

            } while (race == 0);

            var characs = new Characteristics(2, 2, 2, 2, 2, 2, 2);

            switch (race)
            {
                case (int)eTypeRace.Human:
                    characs = new Characteristics(4, 3, 3, 3, 3, 3, 3, 0.05, 0.05, 0.05, 0.05);
                    break;
                case (int)eTypeRace.Orc:
                    characs = new Characteristics(5, 2, 4, 2, 2, 2, 5, 0.1, 0, 0, 0.1);
                    break;
                case (int)eTypeRace.Dwarf:
                    characs = new Characteristics(4, 2, 5, 3, 3, 3, 2, 0, 0.1, 0.1, 0);
                    break;
                case (int)eTypeRace.Elf:
                    characs = new Characteristics(3, 5, 3, 4, 3, 3, 2, 0.1, 0.05, 0.05, 0);
                    break;
                case (int)eTypeRace.Halffinger:
                    characs = new Characteristics(3, 3, 2, 4, 4, 4, 2, 0.05, 0, 0.05, 0.1);
                    break;
                case (int)eTypeRace.Troll:
                    characs = new Characteristics(4, 2, 5, 2, 3, 2, 4, 0, 0.1, 0, 0.1);
                    break;
            }

            person = new Person(characs, name, race);
        }
Exemple #6
0
        public int Dmg(Person opp)
        {
            if (_actionstatus == (int)eTypeAction.Block) return 0;

            if (_actionstatus == (int)eTypeAction.Attack)
            {
                int dmg;

                var luckhit = false;
                var crithit = false;

                var rand1 = new Random();
                var luck = (double) (GetLuck() - opp.GetLuck());
                luck = luck > 0 ? (30 + Math.Pow(luck, 0.8))/100 - opp.GetOberegLuck() : 0;
                if (rand1.NextDouble() < luck)
                {
                    //Console.ForegroundColor = ConsoleColor.Blue;
                    //Console.WriteLine(Name + " hit " + opp.Name + " with Luck!");
                    //Console.ResetColor();

                    luckhit = true;
                    dmg = GetDamage().HighDmg;
                }
                else
                {
                    var rand2 = new Random();
                    dmg = (int)((double)(rand2.Next((int)(WeaponMastery * 100), 100))/100*(GetDamage().HighDmg - GetDamage().LowDmg)) + GetDamage().LowDmg;
                }

                rand1 = new Random();
                var rage = (double) (GetRage() - opp.GetRage());
                rage = rage > 0 ? (30 + Math.Pow(rage, 0.8))/100 - opp.GetOberegCrit() : 0;
                if (rand1.NextDouble() < rage)
                {
                    //Console.ForegroundColor = ConsoleColor.Red;
                    //Console.WriteLine(Name + " hit " + opp.Name + " with Crit!");
                    //Console.ResetColor();

                    crithit = true;
                    dmg = (int) (dmg*1.5);
                }

                var agility = (double) (opp.GetAgility() - GetAgility());
                agility = agility > 0
                              ? (30 + Math.Pow(agility, 0.8))/100 - (crithit ? 0.3 : 0) - (luckhit ? 0.7 : 0) -
                                GetOberegEvade()
                              : 0;

                if (rand1.NextDouble() < agility)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(opp.Name + " evade from " + Name);
                    Console.ResetColor();

                    dmg = 0;
                }
                else
                {
                    if (opp._actionstatus == (int) eTypeAction.Attack || luckhit || opp._actionstatus == (int) eTypeAction.Spellbook)
                    {
                        var rand = new Random();
                        var block = (int)((double)(rand.Next((int)(opp.ArmorMastery * 100), 100))/100 * opp.GetArmor());
                        dmg -= block;
                        opp.ArmorMastery += 0.00001 * block;
                        if (opp.ArmorMastery >= 1) opp.ArmorMastery = 1;
                        if (dmg < 0) dmg = 0;
                        opp.CurrHealth -= dmg;
                        WeaponMastery += 0.00001 * dmg;
                        if (WeaponMastery >= 1) WeaponMastery = 1;

                        if (!luckhit || opp._actionstatus == (int) eTypeAction.Attack || opp._actionstatus == (int) eTypeAction.Spellbook)
                        {
                            Console.Write(Name + " hit " + opp.Name + " for " + dmg + " damage");
                            if (crithit)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.Write(" with Crit!");
                                Console.ResetColor();
                            }
                            if (luckhit)
                            {
                                Console.ForegroundColor = ConsoleColor.Blue;
                                Console.Write(" with Luck!");
                                Console.ResetColor();
                            }
                            Console.WriteLine(" (" + opp.CurrHealth + ")");
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Blue;
                            Console.Write(Name + " hit " + opp.Name + " for " + dmg +
                                          " damage with Luck! through a block");
                            Console.ResetColor();
                            if (crithit)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.Write(" with Crit!");
                                Console.ResetColor();
                            }
                            Console.WriteLine(" (" + opp.CurrHealth + ")");
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.DarkMagenta;
                        Console.WriteLine(opp.Name + " blocks damage");
                        Console.ResetColor();
                    }
                }

                if (dmg > 0)
                {
                    rand1 = new Random();
                    Console.ForegroundColor = ConsoleColor.White;
                    var reaction = (double) (opp.GetReaction() - GetReaction());
                    reaction = reaction > 0 ? (30 + Math.Pow(reaction, 0.8))/100 - GetOberegAnswer() : 0;

                    if (rand1.NextDouble() < reaction)
                    {
                        var rtrndmg = (int) Math.Ceiling((double) dmg/2);
                        CurrHealth -= rtrndmg;
                        Console.WriteLine(Name + " gets " +
                                          rtrndmg + " in answer! (" + CurrHealth + ")");
                    }
                    Console.ResetColor();
                }

                if (opp.CurrHealth <= 0)
                {
                    return -1;
                }

                if (CurrHealth <= 0)
                {
                    return 1;
                }
            }

            if (_actionstatus == (int)eTypeAction.Spellbook)
            {
                Console.WriteLine("Choose a spell");
                for (var i = 0; i < spellbook.Spells.Count; i++)
                {
                    Console.WriteLine(KeyEvents.mListKeys[i] + ") " + spellbook.Spells[i].Name);
                }

                var done = false;

                do
                {
                    var cki = Console.ReadKey(true);

                    for (var i = 0; i < spellbook.Spells.Count; i++)
                    {
                        if (cki.Key == KeyEvents.mListKeys[i])
                        {
                            done = true;
                            spellbook.Spells[i].Effect(this, opp);
                            break;
                        }
                    }

                } while (!done);

                if (opp.CurrHealth <= 0)
                {
                    return -1;
                }

                if (CurrHealth <= 0)
                {
                    return 1;
                }
            }

            return 0;
        }
Exemple #7
0
        public int Fight(Person opp)
        {
            int status = 0;
            int st = 0;
            var rnd = 1;
            do
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Round {0} has begun", rnd);
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Please, choose your action:");
                Console.WriteLine("A) Attack");
                Console.WriteLine("B) Block");
                Console.WriteLine("C) Spellbook");
                Console.ResetColor();
                var done = false;

                do
                {
                    var cki = Console.ReadKey(true);
                    switch (cki.Key)
                    {
                        case ConsoleKey.A:
                            done = true;
                            opp._actionstatus = (int) eTypeAction.Attack;
                            break;
                        case ConsoleKey.B:
                            done = true;
                            opp._actionstatus = (int) eTypeAction.Block;
                            break;
                        case ConsoleKey.C:
                            if (opp.spellbook.Spells.Count == 0)
                            {
                                Console.WriteLine("Not available spells! Choose other action!");
                                break;
                            }
                            done = true;
                            opp._actionstatus = (int) eTypeAction.Spellbook;
                            break;
                    }
                } while (!done);

                var rand = new Random();
                //if (rand.NextDouble() > 0.5) _actionstatus = (int)eTypeAction.Attack;
                //else _actionstatus = (int) eTypeAction.Block;

                if ((GetReaction() + GetLuck()) > (GetStrength() + GetRage()) && GetReaction() > GetStrength())
                {
                    if (rand.NextDouble() > 0.2) _actionstatus = (int)eTypeAction.Block;
                    else _actionstatus = (int) eTypeAction.Attack;
                }
                else
                {
                    if (rand.NextDouble() > 0.2) _actionstatus = (int)eTypeAction.Attack;
                    else _actionstatus = (int) eTypeAction.Block;
                }

                if (opp._actionstatus == (int)eTypeAction.Block && _actionstatus == (int)eTypeAction.Block)
                {
                    Console.WriteLine("Pacifism! :)");
                }
                else
                {
                    st = opp.Dmg(this);
                    //PrintStatus();
                    status = Dmg(opp);
                    //opp.PrintStatus();
                    if (st < 0 || status > 0) Console.WriteLine(Name + " is died!!!");
                    if (st > 0 || status < 0) Console.WriteLine(opp.Name + " is died!!!");
                }
                rnd++;
                FinishRound();
                opp.FinishRound();
            } while (st == 0 && status == 0);

            var exp = MaxHealth + (new Random()).Next(-Rating(), Rating());
            if (status >= 0 && st <= 0)
            {
                var rand = new Random();
                if (rand.NextDouble() < 0.5*(1 - (opp.Rating() - Rating())/opp.Rating()))
                {
                    var slot = new Equipment("");
                    slot.Generate(opp.Rating());
                    opp.Inventory.Add(slot);

                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("You've found ");
                    Console.ForegroundColor = slot.Color;
                    Console.Write(slot.Name);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("!");
                    Console.ResetColor();
                }

                opp.Exp += exp;
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("You gain {0} experience!!!", exp);
                Console.ResetColor();

                while (opp.Exp >= (10 * opp._level * opp._level))
                {
                    opp.NewLevel();
                }
            }

            return status;
        }
Exemple #8
0
 public override void Effect(Person damager, Person aim)
 {
     var rand = new Random();
     var damage = rand.Next((int)(damager.AirMastery * damager.GetIntelligence() / 5), damager.GetIntelligence() / 4);
     aim.CurrHealth -= damage;
     aim.Characs.Agility = 0;
     Console.ForegroundColor = ConsoleColor.Cyan;
     Console.WriteLine(Name + " of " + damager.Name + " damages " + aim.Name + " for " +
         damage + " damages" + "(" + aim.CurrHealth + ")");
     Console.WriteLine(aim.Name + "'s agility is become 0");
     Console.ResetColor();
     damager.AirMastery += Up * damage;
     if (damager.AirMastery >= 1) damager.AirMastery = 1;
 }
Exemple #9
0
 public override void Effect(Person damager, Person aim)
 {
     var rand = new Random();
     var damage = rand.Next((int)(damager.WaterMastery * damager.GetIntelligence() / 2), damager.GetIntelligence());
     aim.CurrHealth -= damage;
     aim.Characs.Strength -= 1;
     aim.Characs.Agility -= 1;
     Console.ForegroundColor = ConsoleColor.Blue;
     Console.WriteLine(Name + " of " + damager.Name + " damages " + aim.Name + " for " +
         damage + " damages" + "(" + aim.CurrHealth + ")");
     Console.WriteLine(aim.Name + "'s strength is reduced by 1");
     Console.WriteLine(aim.Name + "'s agility is reduced by 1");
     Console.ResetColor();
     damager.WaterMastery += Up * damage;
     if (damager.WaterMastery >= 1) damager.WaterMastery = 1;
 }
Exemple #10
0
 public abstract void Effect(Person dealer, Person aim);
Exemple #11
0
 public override void Effect(Person damager, Person aim)
 {
     var rand = new Random();
     var damage = rand.Next((int)(damager.FireMastery * damager.GetIntelligence()), damager.GetIntelligence()*2);
     aim.CurrHealth -= damage;
     Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine(Name + " of " + damager.Name + " damages " + aim.Name + " for " +
         damage + " damages" + "(" + aim.CurrHealth + ")");
     Console.ResetColor();
     damager.FireMastery += Up * damage;
     if (damager.FireMastery >= 1) damager.FireMastery = 1;
 }
Exemple #12
0
 public override void Effect(Person damager, Person aim)
 {
     var rand = new Random();
     var areg = rand.Next((int)(damager.NecroMastery * damager.GetIntelligence())/5, damager.GetIntelligence()/5);
     aim.WarRegen -= areg;
     aim.Armor -= 1;
     Console.ForegroundColor = ConsoleColor.Green;
     Console.WriteLine(Name + " of " + damager.Name + " poisoned " + aim.Name + " for " + areg);
     Console.WriteLine(aim.Name + "'s armor is reduced by 1");
     Console.ResetColor();
     damager.NecroMastery += Up * areg;
     if (damager.NecroMastery >= 1) damager.NecroMastery = 1;
 }
Exemple #13
0
            public int AcceptAction(Action action, Person person)
            {
                person.CurrHealth -= Damage;

                if (person.CurrHealth <= 0) return -1;

                return 0;
            }
Exemple #14
0
 public int AcceptAction(Action action, Person person)
 {
     switch (action.Key)
     {
         case ConsoleKey.A:
             return Fight(person);
         case ConsoleKey.B:
             return Dmg(person);
         default:
             return 0;
     }
 }
Exemple #15
0
            public int AcceptAction(Action action, Person person)
            {
                person.Gold += Gold;

                return 0;
            }