//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; } }
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(); }
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(); }