예제 #1
0
 //Create and add a character
 public bool addCharacter()
 {
     while (true)
     {
         Character rookie = new Character(charClass);
         if (addCharacter(rookie))
             return true;
         Console.WriteLine("Teams must contain unique names.  Please select a different name");
     }
 }
예제 #2
0
 //Add existing character
 public bool addCharacter(Character guy)
 {
     //Check for identical character name
     //if (roster.Exists(x => (x.getName() == guy.getName())))
     //{
     //    return false;
     //}
     roster.Add(guy);
     return true;
 }
예제 #3
0
        public void testAttack()
        {
            Armor WoodenSheild = new Armor("Wooden Sheild", 10, "Normal", 10, "Fire");
            Weapon RustySword = new Weapon("Rusty Sword", 30, "Normal", 40, "Fire");

            Character Joe = new Character("Joe", 100, 20, 2.0, 2.0, 1.0, RustySword, WoodenSheild);
            Character Bob = new Character("Bob", 100, 20, 1.0, 2.0, 1.0, RustySword, WoodenSheild);
            Bob.Attack(Joe);

            Assert.AreEqual(40, Joe.getHP());
        }
예제 #4
0
        //single target and AoE?
        //won't need a character in the latter case
        public void CastSpell(Character character, Spell spell)
        {
            int damage = spell.getDamage();
            string type = spell.getType();

            damage = checkResist(damage, type, character.armor.getMagicType());

            int totalDam = damage - character.magResist;

            if (spell.getEffect() != null)
            {
                character.activeEffects.Add(spell.getEffect());
            }

            takeDamage(character, totalDam);
        }
예제 #5
0
        //hurting the character being passed in
        public void Attack(Character character)
        {
            //local variable to calc magic damage
            int magDamage = this.magDamage;

            //type of damage
            //probably remove magic from most weapons
            string magicAtkType = weapon.getMagicType();

            magDamage = checkResist(magDamage, magicAtkType, character.armor.getMagicType());

            //calc total damage
            int totalDam = (this.physDamage - character.physResist) + (magDamage - character.magResist);

            takeDamage(character, totalDam);
        }
예제 #6
0
        static void Main(string[] args)
        {
            //Build and create a 3d board
            //Application.Run(new Board());

            Armor WoodenShield = new Armor ("Wooden Sheild", 10, "Normal", 10, "Fire");
            Weapon RustySword = new Weapon ("Rusty Sword", 30, "Normal", 40, "Fire");

            Weapon BetterSword = new Weapon("Better Sword", 50, "Normal", 60, "Electric");
            Armor BetterArmor = new Armor("Better Armor", 50, "Normal", 20, "Electric");

            SpellEffect poison = new SpellEffect("Poison", "Normal", 2, 3);

            Spell NewSpell = new Spell("testSpell", 5, 20, "Fire", poison);
            Spell NextSpell = new Spell("nextSpell", 2, 5, "Fire");

            Character Joe = new Character("Joe", 5, 5, 5, 5, 5, RustySword, WoodenShield);
            Character Bob = new Character ("Bob", 10, 10, 5, 2, 2, RustySword, WoodenShield);

            Bob.LevelCharacter(3);

            Console.WriteLine(Bob.getWeapon().getName());
            Bob.changeWeapon(BetterSword);
            Console.WriteLine(Bob.getWeapon().getName());
            Bob.changeWeapon(RustySword);

            Console.WriteLine(Joe.getHP());
            //Joe.hurt(Bob);
            Console.WriteLine(Joe.getHP());
            Joe.heal(100F);
            Console.WriteLine(Joe.getHP());

            //change weapon test
            Bob.changeWeapon(BetterSword);
            Bob.Attack(Joe);
            Console.WriteLine(Joe.getHP());
            Joe.heal(100F);
            Console.WriteLine(Joe.getHP());

            Joe.changeArmor(BetterArmor);
            Bob.Attack(Joe);
            Console.WriteLine(Joe.getHP());
            Joe.heal(100F);
            Console.WriteLine(Joe.getHP());

            //string path = serializer(Joe);
            //Character Joe2 = deserializer(path);

            Joe.LearnSpell(NewSpell);
            Joe.LearnSpell(NewSpell);

            Joe.CastSpell(Bob);

            List<SpellEffect> effectList = new List<SpellEffect>();
            effectList = SpellEffect.ImportEffects("../../ImportFiles/effect-list.csv", effectList);

            List<Spell> spellList = new List<Spell>();
            spellList = Spell.ImportSpells("../../ImportFiles/spell-list.csv", spellList, effectList);

            foreach (Spell spell in spellList)
            {
                Console.WriteLine(spell.getName());
            }

            //StartMenu game = new StartMenu();
            StartMenu menu = new StartMenu();

            menu.startMenu();

            //Wait
            Console.ReadKey();
        }
예제 #7
0
 private static void takeTurn(Character character)
 {
     if (character.getTeam() == 1)
     {
         //int r = rnd.Next(bTeam.roster.Count); //Randomly pick opponent
         //while (bTeam.roster[r].getHP() <= 0)
         //{
         //    r = rnd.Next(bTeam.roster.Count);
         //}
         int r = pickEnemy(character);
         takeAction(character, r);
         //character.Attack(bTeam.roster[r]);
         Console.WriteLine(bTeam.roster[r].getName() + ": " + bTeam.roster[r].getHP());
     }
     else if (character.getTeam() == 2)
     {
         //int r = rnd.Next(aTeam.roster.Count); //Randomly pick opponent
         //while (aTeam.roster[r].getHP() <= 0)
         //{
         //    r = rnd.Next(aTeam.roster.Count);
         //}
         int r = pickEnemy(character);
         takeAction(character, r);
         //character.Attack(aTeam.roster[r]); //teamMember hurts aTeam.roster[r]
         Console.WriteLine(aTeam.roster[r].getName() + ": " + aTeam.roster[r].getHP());
     }
     else
     {
         Console.WriteLine("You're on the wrong team!");
     }
 }
예제 #8
0
        private static void takeAction(Character character, int enemy)
        {
            int position = 0;
            int posMax = 2;
            bool turnTaken = false;

            while (!turnTaken)
            {
                Console.Clear();
                Console.WriteLine("    Attacking: {0}", character.getName());

                if (position == 0)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("    Attack");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else { Console.WriteLine("    Attack"); }
                if (position == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("    Cast Spell");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else { Console.WriteLine("    Cast Spell"); }
                if (position == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("    Defend");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else { Console.WriteLine("    Defend"); }

                //Read Key Input
                ConsoleKeyInfo keypressed = Console.ReadKey(false);
                if ((int)keypressed.Key == (char)ConsoleKey.DownArrow && position < posMax)
                {
                    position += 1;
                }
                else if ((int)keypressed.Key == (char)ConsoleKey.UpArrow && position > 0)
                {
                    position -= 1;
                }
                else if ((int)keypressed.Key == (char)ConsoleKey.Enter)
                {
                    if (position == 0)
                    {
                        character.Attack(bTeam.roster[enemy]);
                        turnTaken = true;
                    }
                    else if (position == 1)
                    {
                        bool success = character.CastSpell(bTeam.roster[enemy]);
                        if (success)
                        {
                            turnTaken = true;
                        }
                        else
                        {
                            turnTaken = false;
                        }
                    }
                    else if (position == 2)
                    {
                        character.setDefenseFlag(true);
                        turnTaken = true;
                    }
                }
            }
        }
예제 #9
0
        private static int pickEnemy(Character character)
        {
            int position = 0;
            int posMax = 0;
            if (character.getTeam() == 1)
            {
                posMax = bTeam.roster.Count();
            }
            else if (character.getTeam() == 2)
            {
                posMax = aTeam.roster.Count();
            }
            while (true)
            {
                Console.Clear();
                Console.WriteLine("    Attacking: {0}", character.getName());
                if (character.getTeam() == 1)
                {
                    int i = 0;
                    foreach (Character enemy in bTeam.roster)
                    {
                        if (position == i)
                        {
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("    Name: {0}, HP: {1}", bTeam.roster[i].getName(), bTeam.roster[i].getHP());
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        else { Console.WriteLine("    Name: {0}, HP: {1}", bTeam.roster[i].getName(), bTeam.roster[i].getHP()); }
                        i++;
                    }
                }

                if (character.getTeam() == 2)
                {
                    int i = 0;
                    foreach (Character enemy in aTeam.roster)
                    {
                        if (position == i)
                        {
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("    Name: {0}, HP: {1}", aTeam.roster[i].getName(), aTeam.roster[i].getHP());
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        else { Console.WriteLine("    Name: {0}, HP: {1}", aTeam.roster[i].getName(), aTeam.roster[i].getHP()); }
                        i++;
                    }
                }

                //Read Key Input
                ConsoleKeyInfo keypressed = Console.ReadKey(false);
                if ((int)keypressed.Key == (char)ConsoleKey.DownArrow && position < posMax)
                {
                    position += 1;
                }
                else if ((int)keypressed.Key == (char)ConsoleKey.UpArrow && position > 0)
                {
                    position -= 1;
                }
                else if ((int)keypressed.Key == (char)ConsoleKey.Enter)
                {
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.CursorVisible = true;
                    Console.Clear();
                    return position;
                }
            }
        }
예제 #10
0
        static string serializer(Character character, string path)
        {
            //Path to Desktop
            path = path + "\\" + character.getName() + ".bin";
            Console.WriteLine(path);

            //Serialize
            IFormatter formatter = new BinaryFormatter();
            Stream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
            formatter.Serialize(stream, character);
            stream.Close();

            return path;
        }
예제 #11
0
 public void takeDamage(Character character, int damage)
 {
     //making sure HP doesn't go negative
     if (damage > 0)
     {
         if (character.HP > damage)
         {
             character.HP -= damage;
         }
         else
         {
             character.HP = 0;
         }
     }
 }
예제 #12
0
        //Character passed hurts this character
        public void hurt(Character character)
        {
            int physDamage = character.physDamage;
            int magDamage = character.magDamage;
            int physResist = this.physResist;
            int magResist = this.magResist;

            string magicDefType = this.armor.getMagicType();
            string magicAtcType = character.getWeapon().getMagicType();

            string physDefType = this.armor.getPhysicalType();
            string physAtcType = character.getWeapon().getPhysicalType();

            //cout << "Magic Damage Before Armor: " << magDamage << endl;

            //Modify Damage
            if (0 == string.Compare(magicDefType, magicAtcType))
            { //Matching
                magDamage = (int)(magDamage * .5);
            }
            else if (0 == string.Compare(magicDefType, "Ice"))
            {
                if (0 == string.Compare(magicAtcType, "Electric"))
                    magDamage = (int)(magDamage * 1.5);
            }
            else if (0 == string.Compare(magicDefType, "Fire"))
            {
                if (0 == string.Compare(magicAtcType, "Ice"))
                    magDamage = (int)(magDamage * 1.5);
            }
            else if (0 == string.Compare(magicDefType, "Electric"))
            {
                if (0 == string.Compare(magicAtcType, "Fire"))
                    magDamage = (int)(magDamage * 1.5);
            }

            //cout << "Magic Damage After Armor: " << magDamage << endl;
            //cout << "Magic Damage After Resist: " << magDamage - magResist << endl;

            int actDamage = (physDamage - physResist) + (magDamage - magResist);

            //cout << actDamage << endl;

            //prevent Negative Health
            if (actDamage > 0)
            {
                if (this.HP > actDamage)
                    this.HP -= actDamage;
                else
                    this.HP = 0;
            }
        }
예제 #13
0
        public void getXP(Character character)
        {
            double xpToGet = XPBASE * Math.Pow((double)(this.level + 1), XPFACTOR);

            XP += (character.XPValue / (level / character.level));
            Console.WriteLine("You gained {0} XP!", character.XPValue);

            if (XP > xpToGet)
            {
                LevelCharacter(SKILLPOINTS);
            }
        }
예제 #14
0
        //single target and AoE?
        //won't need a character in the latter case
        public bool CastSpell(Character character)
        {
            if (knownSpells.Count == 0)
            {
                Console.WriteLine("You don't know any spells!");
                Console.ReadLine();
                return false;
            }

            Spell chosenSpell = null;

            int position = 0;
            int posMax = knownSpells.Count - 1;

            bool spellChosen = false;

            while (!spellChosen)
            {
                int i = 0;
                foreach (Spell spell in knownSpells)
                {
                    if (position == i)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("    Spell: {0}, Damage: {1}, Type: {2}, Effect: {3}", knownSpells[i].getName(), knownSpells[i].getDamage(), knownSpells[i].getType(), knownSpells[i].getEffect().getName());
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    else { Console.WriteLine("    Spell: {0}, Damage: {1}, Type: {2}, Effect: {3}", knownSpells[i].getName(), knownSpells[i].getDamage(), knownSpells[i].getType(), knownSpells[i].getEffect().getName()); }
                    i++;
                }
                //Read Key Input
                ConsoleKeyInfo keypressed = Console.ReadKey(false);
                if ((int)keypressed.Key == (char)ConsoleKey.DownArrow && position < posMax)
                {
                    position += 1;
                }
                else if ((int)keypressed.Key == (char)ConsoleKey.UpArrow && position > 0)
                {
                    position -= 1;
                }
                else if ((int)keypressed.Key == (char)ConsoleKey.Enter)
                {
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.CursorVisible = true;
                    Console.Clear();
                    spellChosen = true;
                    chosenSpell = knownSpells[position];
                }
            }

            int damage = chosenSpell.getDamage();
            string type = chosenSpell.getType();

            damage = checkResist(damage, type, character.armor.getMagicType());

            if (character.getHP() != 0)
            {
                int totalDam = damage - character.magResist;

                if (chosenSpell.getEffect() != null)
                {
                    character.activeEffects.Add(chosenSpell.getEffect());
                }
                takeDamage(character, totalDam);
                if (character.getHP() == 0)
                {
                    getXP(character);
                }
                return true;
            }
            else
            {
                Console.WriteLine("That character is already dead!");
                return false;
            }
        }
예제 #15
0
        //Character passed hurts this character
        /*public void hurt(Character character)
        {
            int physDamage = character.physDamage;
            int magDamage = character.magDamage;
            int physResist = this.physResist;
            int magResist = this.magResist;

            string magicDefType = this.armor.getMagicType();
            string magicAtcType = character.getWeapon().getMagicType();

            string physDefType = this.armor.getPhysicalType();
            string physAtcType = character.getWeapon().getPhysicalType();

            //cout << "Magic Damage Before Armor: " << magDamage << endl;

            //Modify Damage
            if (0 == string.Compare(magicDefType, magicAtcType))
            { //Matching
                magDamage = (int)(magDamage * .5);
            }
            else if (0 == string.Compare(magicDefType, "Ice"))
            {
                if (0 == string.Compare(magicAtcType, "Electric"))
                    magDamage = (int)(magDamage * 1.5);
            }
            else if (0 == string.Compare(magicDefType, "Fire"))
            {
                if (0 == string.Compare(magicAtcType, "Ice"))
                    magDamage = (int)(magDamage * 1.5);
            }
            else if (0 == string.Compare(magicDefType, "Electric"))
            {
                if (0 == string.Compare(magicAtcType, "Fire"))
                    magDamage = (int)(magDamage * 1.5);
            }

            //cout << "Magic Damage After Armor: " << magDamage << endl;
            //cout << "Magic Damage After Resist: " << magDamage - magResist << endl;

            if (physResist > physDamage)
            {
                physResist = physDamage;
            }

            if (magResist > magDamage)
            {
                magResist = magDamage;
            }

            int actDamage = (physDamage - physResist) + (magDamage - magResist);

            //cout << actDamage << endl;

            //prevent Negative Health
            if (actDamage > 0)
            {
                if (this.HP > actDamage)
                    this.HP -= actDamage;
                else
                    this.HP = 0;
            }
        }*/
        //hurting the character being passed in
        public void Attack(Character character)
        {
            //local variable to calc magic damage
            int magDamage = this.magDamage;
            int magResist = character.magResist;

            //type of damage
            //probably remove magic from most weapons
            string magicAtkType = weapon.getMagicType();

            magDamage = checkResist(magDamage, magicAtkType, character.armor.getMagicType());

            //ensure that you aren't doing negative damage
            if (physResist > physDamage)
            {
                physResist = physDamage;
            }

            if (magResist > magDamage)
            {
                magResist = magDamage;
            }

            if (character.getHP() != 0)
            {
                //calc total damage
                int totalDam = (this.physDamage - character.physResist) + (magDamage - magResist);

                takeDamage(character, totalDam);
                if (character.getHP() == 0)
                {
                    getXP(character);
                }
            }
            else
            {
                Console.WriteLine("That character is already dead!");
            }
        }
예제 #16
0
        static void Main(string[] args)
        {
            Armor WoodenSheild = new Armor ("Wooden Sheild", 10, "Normal", 10, "Fire");
            Weapon RustySword = new Weapon ("Rusty Sword", 30, "Normal", 40, "Fire");

            Weapon BetterSword = new Weapon("Better Sword", 50, "Normal", 60, "Electric");
            Armor BetterArmor = new Armor("Better Armor", 50, "Normal", 20, "Electric");

            SpellEffect poison = new SpellEffect("Poison", "Normal", 2, 3);

            Spell NewSpell = new Spell("testSpell", 5, 20, "Fire", poison);
            Spell NextSpell = new Spell("nextSpell", 2, 5, "Fire");

            Character Joe = new Character ("Joe", 100, 20, 2.0, 2.0, 1.0, RustySword, WoodenSheild);
            Character Bob = new Character ("Bob", 100, 20, 1.0, 2.0, 1.0, RustySword, WoodenSheild);

            Console.WriteLine(Bob.getWeapon().getName());
            Bob.changeWeapon(BetterSword);
            Console.WriteLine(Bob.getWeapon().getName());
            Bob.changeWeapon(RustySword);

            Console.WriteLine(Joe.getHP());
            Joe.hurt(Bob);
            Console.WriteLine(Joe.getHP());
            Joe.heal(100F);
            Console.WriteLine(Joe.getHP());

            //change weapon test
            Bob.changeWeapon(BetterSword);
            Bob.Attack(Joe);
            Console.WriteLine(Joe.getHP());
            Joe.heal(100F);
            Console.WriteLine(Joe.getHP());

            Joe.changeArmor(BetterArmor);
            Bob.Attack(Joe);
            Console.WriteLine(Joe.getHP());
            Joe.heal(100F);
            Console.WriteLine(Joe.getHP());

            string path = serializer(Joe);
            Character Joe2 = deserializer(path);

            Joe.LearnSpell(NewSpell);
            Joe.LearnSpell(NewSpell);

            List<SpellEffect> effectList = new List<SpellEffect>();
            effectList = SpellEffect.ImportEffects("../../ImportFiles/effect-list.csv", effectList);

            List<Spell> spellList = new List<Spell>();
            spellList = Spell.ImportSpells("../../ImportFiles/spell-list.csv", spellList, effectList);

            foreach (Spell spell in spellList)
            {

                Console.WriteLine(spell.getName());
            }
            Console.WriteLine(Environment.CurrentDirectory);

            PlayGame game = new PlayGame();

            //Wait
            Console.ReadKey();
        }