private List<int> CalculateItemStats(ExistingItem item) { int STR = 0, DEX = 0, INT = 0, CON = 0, CHA = 0; if (item != null) { STR += (int)(_context.Items.FirstOrDefault(i => i.ItemId == item.ItemId).StrBonus + _context.ItemTypes.FirstOrDefault(i => i.ItemTypeId == item.ItemTypeId).StrModifier); DEX += (int)(_context.Items.FirstOrDefault(i => i.ItemId == item.ItemId).DexBonus + _context.ItemTypes.FirstOrDefault(i => i.ItemTypeId == item.ItemTypeId).DexModifier); INT += (int)(_context.Items.FirstOrDefault(i => i.ItemId == item.ItemId).IntBonus + _context.ItemTypes.FirstOrDefault(i => i.ItemTypeId == item.ItemTypeId).IntModifier); CON += (int)(_context.Items.FirstOrDefault(i => i.ItemId == item.ItemId).ConBonus + _context.ItemTypes.FirstOrDefault(i => i.ItemTypeId == item.ItemTypeId).ConModifier); CHA += (int)(_context.Items.FirstOrDefault(i => i.ItemId == item.ItemId).ChaBonus + _context.ItemTypes.FirstOrDefault(i => i.ItemTypeId == item.ItemTypeId).ChaModifier); } List<int> stats = new List<int> { STR, DEX, INT, CON, CHA }; return stats; }
public bool InitCharacter(int? id) { var curent_character_info = _context.CharacterInfos.FirstOrDefault(i => i.CharacterId == id); var curent_character_state = _context.CharacterStates.FirstOrDefault(i => i.CharacterId == id); if (curent_character_info == null) { CharacterInfo newInfo = new CharacterInfo { CharacterId = (int)id, Cha = 1, Con = 1, Str = 1, Dex = 1, Int = 1, Exp = 0, Level = 1, Gold = 0, StatPoints = 0, Race = "Human", Sex = "male" }; _context.CharacterInfos.AddAsync(newInfo); _context.SaveChangesAsync(); } if (curent_character_state == null) { curent_character_info = _context.CharacterInfos.FirstOrDefault(i => i.CharacterId == id); CharacterState newState = new CharacterState { CharacterId = (int)id, MaxHp = curent_character_info.Con * 10, MaxMp = curent_character_info.Int * 10, MaxStamina = curent_character_info.Dex * 5 + curent_character_info.Str * 5 + curent_character_info.Con * 5, XPos = 5, YPos = 5 }; newState.Hp = newState.MaxHp; newState.Mp = newState.MaxMp; newState.Stamina = newState.MaxStamina; int existing_item_id; if (_context.ExistingItems.Count() != 0) existing_item_id = _context.ExistingItems.Max(i => i.ExistingItemId) + 1; else existing_item_id = 1; var baseWeapon = new ExistingItem { ExistingItemId = existing_item_id, CharacterId = id, ItemId = 2, ItemTypeId = 2 }; _context.ExistingItems.AddAsync(baseWeapon); _context.CharacterStates.AddAsync(newState); _context.SaveChangesAsync(); return true; } return false; }
public void Verify_object_can_be_updated() { EditItem(ExistingItem); Context.SaveChanges(); Repository.Update(ExistingItem); ExistingItem.VerifyAuditModifiedPropertiesAreFilledIn(base.TestStartedDatTime); }
private int CalculateItemArmor(ExistingItem item) { int armor = 0; if (item != null) { armor += (int)(_context.Items.FirstOrDefault(i => i.ItemId == item.ItemId).Armor + _context.ItemTypes.FirstOrDefault(i => i.ItemTypeId == item.ItemTypeId).ArmorModifier); //weapon armor } return armor; }
//start of batlle logic #region battle #region Damage And Armor private int CalculateItemDamage(ExistingItem item) { int damage = 0; if (item != null) { damage += (int)(_context.Items.FirstOrDefault(i => i.ItemId == item.ItemId).Damage + _context.ItemTypes.FirstOrDefault(i => i.ItemTypeId == item.ItemTypeId).DamageModifier); //weapon dmg } return damage; }
public bool populate(int x, int y, ExistingItem item) { if (grid[y, x] == null) { grid[y, x] = item; return(true); } else { return(false); } }
public JsonResult WinBattle(int id, int monster_id) { var monsterid = _context.ExistingMonsters.FirstOrDefault(m => m.ExistingMonsterId == monster_id).MonsterId; var character = _context.Characters.Include(c => c.CharacterInfo).Include(c => c.CharacterState).FirstOrDefault(c => c.CharacterId == id); var exp = GainExp(id, monster_id); var loot = GetLoot(id, exp); string itemName = null; if (loot != -1) { ExistingItem lootItem = _context.ExistingItems.FirstOrDefault(i => i.ExistingItemId == loot); itemName = lootItem.ItemType.ItemTypeName + ' ' + lootItem.Item.Name; } return Json(new {exp, itemName}); }
long GetOrAddEmbed(EmbedDictDbSet embed , long?dict_id, DictDbSet.DictKind dict_kind, string word, LangLabel lang) { long?inx = null; if (dict_id.HasValue) { inx = embed.FindInxById(dict_id.Value, dict_kind); } if (inx.HasValue) { var item = new ExistingItem { FreqAdd = 0 }; lock (SetOfDirtyLock) { if (SetOfDirty.ContainsKey(inx.Value)) { item = SetOfDirty[inx.Value]; } item.FreqAdd++; SetOfDirty[inx.Value] = item; } } else { var item = new NewItem { DictKind = dict_kind, DictId = dict_id, Freq = 0 }; lock (SetOfNewLock) { var set_of_new = GetSetOfNew(lang); if (set_of_new.ContainsKey(word)) { item = set_of_new[word]; } else { item.Inx = GetNextEmbedInx(embed); } inx = item.Inx; item.Freq++; set_of_new[word] = item; } } return(inx.Value); }
public override bool ShouldDeleteFromDb() { return((ExistingItem != null && RequiredItem == null) || (ExistingItem != null && !ExistingItem.Equals(RequiredItem))); }
public override bool ShouldAlterInDb() { return(ExistingItem != null && RequiredItem != null && !ExistingItem.Equals(RequiredItem)); }