public MonsterModel(CreatureModel creature, int rewardAmount, string category) : base(creature.Name, creature.Level, creature.Strength, creature.Dexterity, creature.Health, creature.Speed, creature.Image) { this.rewardAmount = rewardAmount; this.category = category; UpdateText(); }
// Determine hit or miss // Calculate chance by determining the difference in levels // between the character and monster and multiplying by 10. // Differences get added to 100. // Example, Character is level 1 and Monster is level 3. // Character would have an 80% chance of hitting the monster. // Monster would have 100% chance of hitting the character. // Being lower level than your opponent hurts your chances. public bool Hit(CreatureModel creature1, CreatureModel creature2) { int difference = (creature1.Level - creature2.Level) * 10; if (difference < 0) { difference = 100 + difference; } else { difference = 100; } Random rand = new Random(); if (rand.Next(0, difference + 1) < difference) { return true; } return false; }
//constructor public CharacterModel(CreatureModel creature, int experience, ItemModel item) : base(creature.Name, creature.Level, creature.Strength, creature.Dexterity, creature.Health, creature.Speed, creature.Image) { //this.level = level; Experience = experience; this.item = item; inventory = new List <ItemModel>(); if (item != null) { inventory.Add(item); } UpdateText(); }
public CreatureDetailPage(CreatureModel creature) { InitializeComponent(); if (creature is CharacterModel) { Title = "Charater Details"; } else { Title = "Monster Details"; } ImageIcon.Source = creature.Image; LabelTitle.Text = creature.TextTitle; LabelDesc.Text = creature.TextDesc; }
// Determine attack range // This method determines which set // of dice to use for damage // calculation based on creature strength public int DamageRange(CreatureModel creature) { int strength = creature.Strength; if (strength < 10) { return 4; } else if (strength < 15) { return 6; } else if (strength < 20) { return 8; } else if (strength < 25) { return 10; } else { return 12; } }
// Calculate damage public int GetDamage(CreatureModel creature1, CreatureModel creature2) { int damage = 0; if (Hit(creature1, creature2)) { // Get damage range first /*int range = DamageRange((creature1)); damage = dice.DiceRoll(1, range); // Check for critical miss if(damage == 1) { return 1; } // Check for critical hit if(damage == range) { this.CRITICALHIT = true; damage = damage * 2; }*/ } return damage * (rand.Next(4) + 1) + rand.Next(6); // For balance;
public void SetMonster(MonsterModel mm) { isCharacter = false; Creature = mm; CurHealth = mm.Health; }
public void SetCharacter(CharacterModel cm) { isCharacter = true; Creature = cm; CurHealth = cm.Health; }
public Tuple <string, int, List <CreatureModel> > UseMagic(string spell, List <CreatureModel> creatures) { List <CreatureModel> resultcreature = new List <CreatureModel>(); string msg = ""; int effect = 0; if (hero.Magic) { CharacterController HeroCtrl = new CharacterController(hero); HeroCtrl.buildMagicGrid(); MagicModel magic; HeroCtrl.magicList.TryGetValue(spell, out magic); msg = magic.AttribValues.ToString() + " (" + magic.AttribMod + ")"; effect = magic.AttribValues; if (magic.AttribMod == "MAGICALL") { foreach (CreatureModel c in creatures) { if (magic.AttribMod == "STRENGTH") { c.Strength += effect; } if (magic.AttribMod == "SPEED") { c.Speed += effect; } if (magic.AttribMod == "DEFENSE") { c.Dexterity += effect; } if (magic.AttribMod == "HP") { c.Health += effect; } resultcreature.Add(c); } } else { CreatureModel c = creatures[0]; if (magic.AttribMod == "STRENGTH") { c.Strength += effect; } if (magic.AttribMod == "SPEED") { c.Speed += effect; } if (magic.AttribMod == "DEFENSE") { c.Dexterity += effect; } if (magic.AttribMod == "HP") { c.Health += effect; } resultcreature.Add(c); } // Reduce usage bool removeitem = false; ItemModel removeme = null; foreach (ItemModel item in hero.inventory) { if (item.itemID == magic.Itemid) { item.usage -= 1; if (item.usage <= 0) { removeitem = true; removeme = item; HeroCtrl.buildMagicGrid(); if (HeroCtrl.magicList.Count == 0) { HeroCtrl.MagicToggle(false); } } } } if (removeitem) { hero.inventory.Remove(removeme); } } Tuple <string, int, List <CreatureModel> > result = new Tuple <string, int, List <CreatureModel> >(msg, effect, resultcreature); return(result); }