public List<character> getCharactersForCampaign(campaign cmp) { List<character> character_list = new List<character>(); if (String.IsNullOrEmpty(cmp.id)) return character_list; string url = String.Format(URL_GET_CHARACTERS_FOR_CAMPAIGN, cmp.id); string str_characters = auth.ExecuteOAuth(ObsidianOAuth.HttpMethod.GET, url, ""); Object o = serializer.Deserialize<Object>(str_characters); System.Object[] olist = (System.Object[])o; foreach (Object obj in olist) { Dictionary<string, object> chr_data = (Dictionary<string, object>)obj; character chr = new character(); chr.id = (string)chr_data["id"]; chr.name = (string)chr_data["name"]; Dictionary<string, object> campaign = (Dictionary<string, object>)chr_data["campaign"]; chr.campaign_id = (string)campaign["id"]; character_list.Add(chr); } return character_list; }
public override void SetUpdateData(ContextObsidian context, character chr) { context.uploadedCharacterData = chr; // Status prüfen: Wenn alle Daten vorhanden sind, bereit für Update. if ((!String.IsNullOrEmpty(context.selectedCampaign.id)) && (!String.IsNullOrEmpty(context.selectedCharacter.id))) context.state = new ObsidianStateUpdateDataComplete(); else context.state = new ObsidianStateLoggedIn(); }
public void createNewCharakter(character charakterData) { string url = String.Format(URL_CREATE_CHARACTER, charakterData.campaign_id); string str_character = serializer.Serialize(charakterData); str_character = str_character.Replace("e4class", "class"); //str_character = Regex.Replace(str_character, @"""campaign_id"":""[a-z,0-9]*"",", "", RegexOptions.None); str_character = Regex.Replace(str_character, @"""id"":null,", "", RegexOptions.None); str_character = Regex.Replace(str_character, @"null", @"""""", RegexOptions.None); str_character = @"{""character"" : " + str_character + "}"; File.WriteAllText("jsonout.txt", str_character); str_character = File.ReadAllText("jsonin.txt"); //str_character = str_character.Replace('"','\''); auth.ExecuteOAuth(ObsidianOAuth.HttpMethod.POST, url, str_character); }
// ToDo: Intern Liste mit Kampagnen und Charakteren vorhalten. public void setCharacter(string characterName) { List<character> chrs = getCharacters(); foreach (character chr in chrs) { if (chr.name == characterName) { this.selectedCharacter = chr; break; } } }
public void updateCharakter(character characterData) { string url = String.Format(URL_UPDATE_CHARACTER, characterData.campaign_id, characterData.id); string str_character = serializer.Serialize(characterData); //str_character = File.ReadAllText("jsonin.txt"); str_character = @"{""character"":" + str_character + "}"; url = "http://api.obsidianportal.com/v1/campaigns/80c7c818f24411dfba8140403656340d/characters/ef04f3086d2511e0b36340403656340d.json"; auth.ExecuteOAuth(ObsidianOAuth.HttpMethod.PUT, url, str_character); }
public character getCharakterData() { dynamicSheet dynSheet = new dynamicSheet(); character chr = new character(); chr.name = _e4charakterData.Element("CharacterSheet").Element("Details").Element("name").Value; var Details = _e4charakterData.Element("CharacterSheet").Element("Details").Elements(); var RulesElements = _e4charakterData.Element("CharacterSheet").Element("RulesElementTally").Elements("RulesElement"); dynSheet.race = RulesElements.First(rl => rl.Attribute("type").Value == "Race").Attribute("name").Value; dynSheet.e4class = RulesElements.First(rl => rl.Attribute("type").Value == "Class").Attribute("name").Value; dynSheet.level = Details.First(elem => elem.Name == "Level").Value; dynSheet.xp = Details.First(elem => elem.Name == "Experience").Value; dynSheet.speed = getStatValue("Speed"); dynSheet.passive_perception = getStatValue("Passive Perception"); dynSheet.passive_insight = getStatValue("Passive Insight"); dynSheet.action_points = getStatValue("_BaseActionPoints"); // Ability Scores dynSheet.strength = getStatValue("Strength"); dynSheet.constitution = getStatValue("Constitution"); dynSheet.dexterity = getStatValue("Dexterity"); dynSheet.intelligence = getStatValue("Intelligence"); dynSheet.wisdom = getStatValue("Wisdom"); dynSheet.charisma = getStatValue("Charisma"); dynSheet.strength_mod_plus_half = getStatValue("Strength modifier"); dynSheet.constitution_mod_plus_half = getStatValue("Constitution modifier"); dynSheet.dexterity_mod_plus_half = getStatValue("Dexterity modifier"); dynSheet.intelligence_mod_plus_half = getStatValue("Intelligence modifier"); dynSheet.wisdom_mod_plus_half = getStatValue("Wisdom modifier"); dynSheet.charisma_mod_plus_half = getStatValue("Charisma modifier"); // Defenses dynSheet.ac = getStatValue("AC"); dynSheet.fortitude = getStatValue("Fortitude"); dynSheet.reflex = getStatValue("Reflex"); dynSheet.will = getStatValue("Will"); // Skills dynSheet.acrobatics = getStatValue("Acrobatics"); dynSheet.arcana = getStatValue("Arcana"); dynSheet.athletics = getStatValue("Athletics"); dynSheet.bluff = getStatValue("Bluff"); dynSheet.diplomacy = getStatValue("Diplomacy"); dynSheet.dungeoneering = getStatValue("Dungeoneering"); dynSheet.endurance = getStatValue("Endurance"); dynSheet.heal = getStatValue("Heal"); dynSheet.history = getStatValue("History"); dynSheet.insight = getStatValue("Insight"); dynSheet.intimidate = getStatValue("Intimidate"); dynSheet.nature = getStatValue("Nature"); dynSheet.perception = getStatValue("Perception"); dynSheet.religion = getStatValue("Religion"); dynSheet.stealth = getStatValue("Stealth"); dynSheet.streetwise = getStatValue("Streetwise"); dynSheet.thievery = getStatValue("Thievery"); chr.dynamic_sheet = dynSheet; return chr; }
public override void SetUpdateData(ContextObsidian context, character chr) { context.uploadedCharacterData = chr; // Status prüfen: Nicht erforderlich, da bereits im Ready-Zustand }
public virtual void SetUpdateData(ContextObsidian context, character chr) { }