public void SetAttribute(ulong value, AttributeEnum flags) { var attr = (ulong)flags; GUID &= ~attr; GUID |= value & attr; }
/// <summary> /// Display a String for the Enums /// </summary> /// <param name="value"></param> /// <returns></returns> public static string ToMessage(this AttributeEnum value) { // Default String var Message = "Unknown"; switch (value) { case AttributeEnum.Attack: Message = "Attack"; break; case AttributeEnum.CurrentHealth: Message = "Current Health"; break; case AttributeEnum.Defense: Message = "Defense"; break; case AttributeEnum.MaxHealth: Message = "Max Health"; break; case AttributeEnum.Speed: Message = "Speed"; break; case AttributeEnum.Unknown: default: break; } return(Message); }
private string GetTitleByAttrEnum(AttributeEnum attr) { switch (attr) { case AttributeEnum.Shooting: return(Form1.Lang == "ru" ? "Стрельба" : "Shooting"); case AttributeEnum.Melee: return(Form1.Lang == "ru" ? "Ближний бой" : "Melee"); case AttributeEnum.Social: return(Form1.Lang == "ru" ? "Общение" : "Social"); case AttributeEnum.Animals: return(Form1.Lang == "ru" ? "Животноводство" : "Animals"); case AttributeEnum.Medicine: return(Form1.Lang == "ru" ? "Медицина" : "Medicine"); case AttributeEnum.Cooking: return(Form1.Lang == "ru" ? "Кулинария" : "Cooking"); case AttributeEnum.Construction: return(Form1.Lang == "ru" ? "Строительство" : "Construction"); case AttributeEnum.Growing: return(Form1.Lang == "ru" ? "Фермерство" : "Growing"); case AttributeEnum.Mining: return(Form1.Lang == "ru" ? "Горное дело" : "Mining"); case AttributeEnum.Artistic: return(Form1.Lang == "ru" ? "Искусство" : "Artistic"); case AttributeEnum.Crafting: return(Form1.Lang == "ru" ? "Ремесло" : "Crafting"); case AttributeEnum.Research: return(Form1.Lang == "ru" ? "Исследование" : "Research"); } return(""); }
public GenericAdditiveModifier( AttributeEnum attributeType, float value) { this.attributeType = attributeType; this.value = value; }
public async Task HttpClientService_GetJsonPostAsync_InValid_Bogus_Should_Fail() { // Arrange var RestUrl = "bogus"; int number = 0; int level = 0; AttributeEnum attribute = AttributeEnum.Attack; ItemLocationEnum location = ItemLocationEnum.Feet; int category = 0; bool random = false; var dict = new Dictionary <string, string> { { "Number", number.ToString() }, { "Level", level.ToString() }, { "Attribute", ((int)attribute).ToString() }, { "Location", ((int)location).ToString() }, { "Random", random.ToString() }, { "Category", category.ToString() }, }; // Convert parameters to a key value pairs to a json object JObject finalContentJson = (JObject)JToken.FromObject(dict); // Act var result = await Service.GetJsonPostAsync(RestUrl, finalContentJson); // Reset // Assert Assert.AreEqual(null, result); }
public void RemoveStatModifer(StatModifer modifer, AttributeEnum attributeType) { switch (attributeType) { case AttributeEnum.MovementSpeed: this.MovementSpeed.RemoveModifer(modifer); break; case AttributeEnum.LightningResistance: this.LightningResistance.RemoveModifer(modifer); break; case AttributeEnum.FrostResistance: this.FrostResistance.RemoveModifer(modifer); break; case AttributeEnum.EarthResitance: this.EarthResitance.RemoveModifer(modifer); break; case AttributeEnum.FireResistance: this.FireResistance.RemoveModifer(modifer); break; case AttributeEnum.WaterResistance: this.WaterResistance.RemoveModifer(modifer); break; } UpdateStats(); }
static void Read() { string[] data = ReadData.OpenFile(DataManager.GetExcelPath(FileName)).Replace(" ", "").Split(new string[] { "\r\n" }, StringSplitOptions.None); List <int> _enum = new List <int>(); string[] EnumValue = data[0].Split(','); for (int i = 1; i < EnumValue.Length; i++) { _enum.Add((int)(DataEnum)Enum.Parse(typeof(DataEnum), EnumValue[i])); } for (int i = 1; i < data.Length; i++) { if (string.IsNullOrEmpty(data[i])) { continue; } string[] value = data[i].Split(','); AttributeEnum type = (AttributeEnum)Enum.Parse(typeof(AttributeEnum), value[0]); List <Addition> dataAry = new List <Addition>(); for (int j = 1; j < value.Length; j++) { if (string.IsNullOrEmpty(value[j])) { continue; } Addition model = new Addition(_enum[j - 1], i - 1, float.Parse(value[j])); dataAry.Add(model); } ModelAry.Add(type, dataAry); } }
public Stat GetStat(AttributeEnum atrributeType) { Stat stat = null; switch (atrributeType) { case AttributeEnum.MovementSpeed: stat = MovementSpeed; break; case AttributeEnum.LightningResistance: stat = LightningResistance; break; case AttributeEnum.FrostResistance: stat = FrostResistance; break; case AttributeEnum.EarthResitance: stat = EarthResitance; break; case AttributeEnum.FireResistance: stat = FireResistance; break; case AttributeEnum.WaterResistance: stat = WaterResistance; break; } return(stat); }
void SubtractAttribute <T>(AttributeEnum ae, ref Attributes a, List <T> effectList) where T : AbstractEffect { foreach (AbstractEffect e in effectList) { a[ae] -= e.AttributeValue(ae); } }
public static int GetRatio(StatEnum statEnum, AttributeEnum attributeEnum) { if (statAttRatio == null) { Setup(); } return(statAttRatio[statEnum][attributeEnum]); }
// Asks the server for items based on paramaters // Number is the number of items to return // Level is the Value max for the items // Random is to have the value random between 1 and the Level // Attribute is a filter to return only items for that attribute, else unknown is used for any // Location is a filter to return only items for that location, else unknown is used for any public async Task <List <Item> > GetItemsFromGame(int number, int level, AttributeEnum attribute, ItemLocationEnum location, bool random, bool updateDataBase) { // Needs to get items from the server // Parse them // Then update the database // Only update fields on existing items // Insert new items // Then notify the viewmodel of the change // Needs to get items from the server var URLComponent = "GetItemListPost/"; var dict = new Dictionary <string, string> { { "Number", number.ToString() }, { "Attribute", ((int)attribute).ToString() }, // Implement missing paramaters... { "Level", level.ToString() }, { "Location", ((int)location).ToString() }, { "Random", random.ToString() } }; // Convert parameters to a key value pairs to a json object JObject finalContentJson = (JObject)JToken.FromObject(dict); // Make a call to the helper. URL and Parameters var DataResult = await HttpClientService.Instance.GetJsonPostAsync(WebGlobals.WebSiteAPIURL + URLComponent, finalContentJson); // Parse them var myList = ParseJson(DataResult); if (myList == null) { // Error, no results, return empty list. return(new List <Item>()); } // Then update the database // Use a foreach on myList if (updateDataBase) { foreach (var item in myList) { // Call to the View Model (that is where the datasource is set, and have it then save // await abcdefg; // Implement await ItemsViewModel.Instance.InsertUpdateAsync(item); } // When foreach is done, call to the items view model to set needs refresh to true, so it can refetch the list... // Implement ItemsViewModel.Instance.SetNeedsRefresh(true); } return(myList); }
/// /// Basic Getters (readonly) /// public int AttributeEffect(AttributeEnum attEnum) { if (attributeEffects.ContainsKey(attEnum)) { return(attributeEffects[attEnum]); } return(0); }
public int GetCurrentAttribute(AttributeEnum attr) { if (CurrentAttributes.ContainsKey(attr)) { return(CurrentAttributes[attr]); } return(0); }
// Walk all the Items on the Character. // Add together all Items that modify the Attribute Enum Passed in // Return the sum public int GetItemBonus(AttributeEnum attributeEnum) { var myReturn = 0; Item myItem; // Implement return(myReturn); }
public uint this[AttributeEnum ae] { get{ switch (ae) { case AttributeEnum.strength: return(strength); case AttributeEnum.agility: return(agility); case AttributeEnum.intelligence: return(uintelligence); case AttributeEnum.endurance: return(endurance); case AttributeEnum.constitution: return(constitution); case AttributeEnum.dexterity: return(dexterity); } return(0); } set{ switch (ae) { case AttributeEnum.strength: strength = value; break; case AttributeEnum.agility: agility = value; break; case AttributeEnum.intelligence: uintelligence = value; break; case AttributeEnum.endurance: endurance = value; break; case AttributeEnum.constitution: constitution = value; break; case AttributeEnum.dexterity: dexterity = value; break; } } }
public bool CheckFlag(AttributeEnum flagId) { int One = 1; if (Convert.ToBoolean(One << Flags)) { return(true); } return(false); }
public void SetFlag(AttributeEnum flagId, bool value) { int One = 1; if (value) { Flags |= One << (int)flagId; } else { Flags &= ~(One << (int)flagId); } }
public Item(string name, string description, string imageUri, AttributeEnum attribute, ItemLocationEnum location, int value, int damage) { CreateDefaultItem(); Name = name; Description = description; ImageURI = imageUri; Attribute = attribute; Location = location; Value = value; Damage = damage; }
// Constructor for Item called if needed to create a new item with set values. public Item(string name, string description, string imageuri, string guid, int range, int value, ItemLocationEnum location, AttributeEnum attribute) { Name = name; Description = description; Guid = guid; ImageURI = imageuri; Range = range; Value = value; Location = location; Attribute = attribute; }
public Weapon CreateWeapon(int minRange, int range, int damage, string name, AttributeEnum attribute, int cost, bool availlable, Speed speed, ISession session) { var weapon = new Weapon(); weapon.Damage = damage; weapon.MinRange = minRange; weapon.MaxRange = range; weapon.Name = name; weapon.ScalingAttribute = attribute; weapon.Cost = cost; weapon.Available = availlable; weapon.Speed = speed; session.Save(weapon); return weapon; }
//Get Weapon damage public int WeaponDamage(AttributeEnum attribute) { Item temp; if (PrimaryHand != null) { temp = GetItem(PrimaryHand); if (temp.Attribute == AttributeEnum.Attack) { return(temp.Value); } } return(0); }
public async Task HttpClientService_GetJsonPostAsync_InValid_Moq_Bad_Response_Should_Fail() { // Arrange var MockHttpClient = new HttpClient(new MockHttpMessageHandler()); var RestUrl = "http://some.fake.url"; var OldHttpClient = Service.GetHttpClient(); Service.SetHttpClient(MockHttpClient); ResponseMessage.SetResponseMessageStringContent(ResponseMessage.NullStringContent); ResponseMessage.SetHttpStatusCode(ResponseMessage.HttpStatusCodeBadRequest); int number = 0; int level = 0; AttributeEnum attribute = AttributeEnum.Attack; ItemLocationEnum location = ItemLocationEnum.Feet; int category = 0; bool random = false; var dict = new Dictionary <string, string> { { "Number", number.ToString() }, { "Level", level.ToString() }, { "Attribute", ((int)attribute).ToString() }, { "Location", ((int)location).ToString() }, { "Random", random.ToString() }, { "Category", category.ToString() }, }; // Convert parameters to a key value pairs to a json object JObject finalContentJson = (JObject)JToken.FromObject(dict); // Act var result = await Service.GetJsonPostAsync(RestUrl, finalContentJson); // Parse them var resultList = ItemModelJsonHelper.ParseJson(result); // Reset Service.SetHttpClient(OldHttpClient); ResponseMessage.ResetResponseMessageStringContent(); ResponseMessage.ResetHttpStatusCode(); // Assert Assert.AreEqual(null, resultList); }
// Walk all the Items on the Character. // Add together all Items that modify the Attribute Enum Passed in // Return the sum public int GetItemBonus(AttributeEnum attributeEnum) { var res = 0; foreach (string loc in ItemLocationHelper.GetListForCharacter) { Enum.TryParse(loc, true, out ItemLocationEnum locEnum); Item item = GetItemByLocation(locEnum); if (item.Attribute.Equals(attributeEnum)) { res += item.Value; } } return(res); }
public static Item AddItemForAttribute(AttributeEnum attributeEnum, ItemLocationEnum itemLocationEnum, int value) { MockForms.Init(); var myItem = new Item { Attribute = attributeEnum, Location = itemLocationEnum, Value = value }; ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult(); // Register Item to DataSet return(myItem); }
// Constructor for Item called if needed to create a new item with set values. public Item(string name, string description, string imageuri, int range, int value, int damage, ItemLocationEnum location, AttributeEnum attribute) { // Create default, and then override... CreateDefaultItem(); Name = name; Description = description; ImageURI = imageuri; Range = range; Value = value; Damage = damage; Location = location; Attribute = attribute; }
public CharacterAttribute GetAttribute(AttributeEnum attribute) { switch (attribute) { case AttributeEnum.Jump: return(this.Jump); case AttributeEnum.Speed: return(this.Speed); case AttributeEnum.WeaponDamage: return(this.WeaponDamage); default: return(null); } }
// Asks the server for items based on parameters // Number: items to retrieve // Level: what max level the items should be // Random: random item // Attribute: which attribute the item should be for, or Unknown public async Task <List <Item> > GetItemsFromGame(int number, int level, AttributeEnum attribute, ItemLocationEnum location, bool random, bool updateDataBase) { // URL component for server post calls var URLComponent = "GetItemListPost"; // Create a dictionary object to store the requested parameters var dict = new Dictionary <string, string> { { "Number", number.ToString() }, { "Level", level.ToString() }, { "Attribute", ((int)attribute).ToString() }, { "Location", ((int)location).ToString() }, { "Random", random.ToString() } }; // Convert parameters to a key value pairs to a json object JObject finalContentJson = (JObject)JToken.FromObject(dict); // Make a call to the helper function to grab items var DataResult = await HttpClientService.Instance.GetJsonPostAsync(WebGlobals.WebSiteAPIURL + URLComponent, finalContentJson); // Parse items once returned var myList = ParseJson(DataResult); if (myList == null) { // Error, no results, return empty list. return(new List <Item>()); } // Update the db by inserting via viewmodel if (updateDataBase) { // Walk through the list and insertupdate foreach (var item in myList) { // Call to the ViewModel, so viewmodel can decide where to put data await ItemsViewModel.Instance.InsertUpdateAsync(item); } // Call viewmodel to refresh itself ItemsViewModel.Instance.ForceDataRefresh(); } return(myList); }
// Creates an Item for the Locatoin and Attribute public static Item ItemDefault(ItemLocationEnum itemLocation, AttributeEnum attribute) { Item myData; myData = new Item { Name = "Item for " + itemLocation.ToString(), Description = "Auto Created", ImageURI = null, Range = 1, Damage = 1, Value = 1, Attribute = attribute, Location = itemLocation }; return(myData); }
// User HAS TO choose and item before hitting save async void SaveButtonClicked(object sender, EventArgs e) { //consume item //pop item off list //heal character or whatever //pop modal page if (selectedItem == null) { Debug.WriteLine("Selected item was null and it should just pop the page"); await Navigation.PopModalAsync(); return; } Debug.WriteLine(selectedItem.Name + " was the item you ate."); //else //consume item //for now, all the consumables will jus trestore you to full health int value = selectedItem.Value; AttributeEnum modifiedAttr = selectedItem.Attribute; if (modifiedAttr == AttributeEnum.CurrentHealth) { _viewModel.BattleEngine.PlayerCurrent.RemainingHP = _viewModel.BattleEngine.PlayerCurrent.TotalHP; //also find current character in the character list and update it foreach (Models.Character character in _viewModel.BattleEngine.CharacterList) { if (character.Name == _viewModel.BattleEngine.PlayerCurrent.Name) { character.CharacterAttribute.CurrentHealth = character.CharacterAttribute.MaxHealth; Debug.WriteLine("Character has been healed to full health"); Debug.WriteLine("Character's new health is "); Debug.WriteLine(character.CharacterAttribute.CurrentHealth + " /" + character.CharacterAttribute.MaxHealth); } } } items.Remove(selectedItem); _viewModel.BattleEngine.ItemPool.Remove(selectedItem); await Navigation.PopModalAsync(); }
// This method handles when user click equip // Equip ALWAYS equip the selected item. // If there is already an item at the same slot, the currently // selected item will be added to the location, and the old item // will be dropped back to the Item Pool async void EquipClicked(object sender, EventArgs e) { if (e == null) { return; } Debug.WriteLine("You are equipping item...."); // Get Character var charName = _viewModel.BattleEngine.PlayerCurrent.Name; var currChar = _viewModel.GetByName(charName); // Get Item clicked int value = selectedItem.Value; AttributeEnum modifiedAttr = selectedItem.Attribute; ItemLocationEnum modifiedLocation = selectedItem.Location; string itemID = selectedItem.Id; // Equip item into that location, get back an item previously there // check if returned item is null var returnedItem = currChar.AddItem(modifiedLocation, itemID); // Printing debug output Debug.WriteLine("Trying to equip item " + selectedItem.Name + " at " + modifiedLocation); if (returnedItem != null) { Debug.WriteLine("Removed item: " + returnedItem.Name + " at " + returnedItem.Location); _viewModel.BattleEngine.ItemPool.Add(returnedItem); } else { Debug.WriteLine("There was no item there before equipping."); } // Remove equipped item from the pool var recentlyEquippedItem = currChar.GetItemByLocation(modifiedLocation); _viewModel.BattleEngine.ItemPool.Remove(recentlyEquippedItem); }
// Return a random item from the list of items... public string ChooseRandomItemString(ItemLocationEnum location, AttributeEnum attribute) { if (location == ItemLocationEnum.Unknown) { return(null); } if (Dataset.Count < 1) { return(null); } // Get all the items for that location var myList = Dataset.Where(a => a.Location == location).ToList(); // If an attribute is selected... if (attribute != AttributeEnum.Unknown) { // Filter down to the items that fit the attribute myList = myList.Where(a => a.Attribute == attribute).ToList(); } if (myList.Count < 1) { return(null); } // Pick a random item from the list var myRnd = HelperEngine.RollDice(1, myList.Count); // Return that item... // -1 because of 0 index list... var myReturn = myList[myRnd - 1]; return(myReturn.Guid); }