private void OnDeleteRecordButtonClick(object sender, EventArgs e) { int selected; if (DataDeleteWarning() == false) { return; } Model.Delete(); //repopulate the spell list selected = SpellListBox.SelectedIndex - 1; if (selected < 0) { selected = 0; } SpellListBox.Items.Clear(); SpellNames = SpellModel.GetNames(); foreach (string name in SpellNames) { SpellListBox.Items.Add(name); } SpellListBox.SelectedIndex = selected; }
/// <summary> /// Save the data from the model into the database /// </summary> private void SaveScreen() { Guid spellId; SaveFeedbackLabel.Text = "Saving Record..."; SaveFeedbackLabel.Refresh(); Model.Save(); //clear the detail model in the database to make sure we save the correct data spellId = SpellModel.GetIdFromName(Model.SpellName); SpellDetailsModel.DeleteBySpell(spellId); for (int i = 0; i < DetailModel.Count; i++) { //note: It is possible the detail models don't yet have the correct spell ID. Make sure they do before saving DetailModel[i].SpellId = spellId; DetailModel[i].Save(); } DataHasChanged = false; //repopulate the spell list (in case any of the names have changed or new ones added) PopulateSpellListBox(); //update the modification fields ModDateLabel.Text = Model.LastUpdatedDate.ToString(); ModVersionLabel.Text = Model.LastUpdatedVersion; SaveFeedbackLabel.Text = "Record Saved"; DatabaseName = Model.SpellName; }
private void ImportSpells() { foreach (SpellModel spellModel in _spells) { if (_addAllEntries) { _compendium.AddSpell(spellModel); } else if (_skipDuplicateEntries) { if (!_compendium.Spells.Any(x => x.Name.Equals(spellModel.Name, StringComparison.CurrentCultureIgnoreCase))) { _compendium.AddSpell(spellModel); } } else if (_replaceExistingEntries) { SpellModel existing = _compendium.Spells.FirstOrDefault(x => x.Name.Equals(spellModel.Name, StringComparison.CurrentCultureIgnoreCase)); if (existing == null) { _compendium.AddSpell(spellModel); } else { spellModel.Id = existing.Id; _compendium.UpdateSpell(spellModel); } } } }
public ApiResponse Update(SpellModel spell, string userId) { try { Spell old = _ctx.Spells.Where(c => c.Campaign.AppUserId == userId).Single(c => c.ID == spell.ID); _mapper.Map(spell, old); old = MapValues(old, userId); _ctx.SaveChanges(); return(new ApiResponse { StatusCode = ApiCodes.Ok }); } catch (Exception e) { _logger.LogError(e.Message); return(new ApiResponse { StatusCode = ApiCodes.Error }); } }
public SpellLevel(int level, string data, SpellModel engine) { this.Level = level; this.Data = data; this.SpellCache = engine; this.LoadLevel(); }
/// <summary> /// Updates the compendium spell with id matching the parameter's id /// </summary> public void UpdateSpell(SpellModel model) { SpellModel currentModel = _spells.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { _spells[_spells.IndexOf(currentModel)] = model; List <Guid> characterIDs = new List <Guid>(); foreach (CharacterModel character in _characters) { foreach (SpellbookModel spellbook in character.Spellbooks) { foreach (SpellbookEntryModel spellbookEntry in spellbook.Spells) { if (spellbookEntry.Spell != null && spellbookEntry.Spell.Id == model.Id) { spellbookEntry.Spell = model; characterIDs.Add(character.Id); } } } } if (characterIDs.Any()) { CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct())); } } }
public static void Load() { Cache.Clear(); var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM spells"); while (reader.Read()) { var spell = new SpellModel() { ID = reader.GetInt32("id"), Name = reader.GetString("nom"), SpriteID = reader.GetInt32("sprite"), SpriteInfos = reader.GetString("spriteInfos"), Level1 = reader.GetString("lvl1"), Level2 = reader.GetString("lvl2"), Level3 = reader.GetString("lvl3"), Level4 = reader.GetString("lvl4"), Level5 = reader.GetString("lvl5"), Level6 = reader.GetString("lvl6"), EffectTargets = reader.GetString("effectTarget"), }; spell.Initialize(); Cache.Add(spell.ID, spell); } reader.Close(); Logger.Info("Loaded @'" + Cache.Count + "'@ Spells"); }
public ApiResponse Add(SpellModel spell, string userId) { try { spell.ID = default; var newSpell = MapValues(spell, userId); _ctx.Spells.Add(newSpell); _ctx.SaveChanges(); return(new ApiResponse { StatusCode = ApiCodes.Ok, InsertedID = newSpell.ID, ParentID = newSpell.CampaignID }); } catch (Exception e) { _logger.LogError(e.Message); return(new ApiResponse { StatusCode = ApiCodes.Error }); } }
/// <summary> /// Creates an instance of <see cref="SpellListItemViewModel"/> /// </summary> public SpellListItemViewModel(SpellModel spellModel, StringService stringService) { _spellModel = spellModel; _stringService = stringService; Initialize(); }
// Update is called once per frame void Update() { // If the is KeyPressed and is off Cooldown // Rotate player and cast spell at mouse direction if ((Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.E)) && timeStamp <= Time.time) { SpellModel spell = null; if (Input.GetKeyDown(KeyCode.Q)) { spell = new Model.SpellModel("fire", 10.0f, "MyFlare", "fire", 3.0f, 1.5f); } if (Input.GetKeyDown(KeyCode.W)) { spell = new Model.SpellModel("teleport", 7.5f, null, null, 3.0f, 0); } if (Input.GetKeyDown(KeyCode.E)) { spell = new Model.SpellModel("homing", 5.0f, "MyHoming", "homing", 1.0f, 10.0f); } MousePosition(); RotateToPoint(); CreateSpell(spell); } }
public DataInputSpellScreenClass() { AllowChangeEvents = false; InitializeComponent(); Model = new SpellModel(); DetailModel = new List <SpellDetailsModel>(); SpellNames = new List <string>(); SpellSchoolNames = new List <string>(); ClassNames = new List <string>(); //lists for spell detail controls SpellDetailClassComboBox = new List <ComboBox>(); SpellDetailLevelComboBox = new List <ComboBox>(); SpellDetailCoolDownTextBox = new List <TextBox>(); SpellDetailSPCostUpDownBox = new List <NumericUpDown>(); SpellDetailDeleteButton = new List <Button>(); SpellMaxLevelByClass = ClassModel.GetMaxSpellLevels(); PopulateSpellListBox(); PopulateSpellSchoolComboBoxList(); PopulateSpellClassComboBoxList(); PopulateSpellLevelComboBoxList(); SpellListBox.SelectedIndex = 0; PopulateFields(SpellNames[0]); DataHasChanged = false; AllowChangeEvents = true; SpellDetailRecordCount = 0; }
/// <summary> /// Adds a spell model /// </summary> public void AddSpell(SpellModel spellModel) { if (spellModel != null && !_spells.Any(x => x.Id == spellModel.Id)) { _spells.Add(spellModel); } }
/// <summary> /// Updates the model /// </summary> public void UpdateModel(SpellModel spellModel) { _spellModel = spellModel; Initialize(); OnPropertyChanged(""); }
/// <summary> /// True if the search applies to the model /// </summary> public bool SearchInputApplies(SpellSearchInput searchInput, SpellModel spellModel) { return(HasSearchText(spellModel, searchInput.SearchText) && IsLevel(spellModel, searchInput.Level.Key) && IsSchool(spellModel, searchInput.School.Key) && HasClass(spellModel, searchInput.Class.Key) && MatchesConcentration(spellModel, searchInput.Concentration.Key) && MatchesRitual(spellModel, searchInput.Ritual.Key)); }
public DockSpellDocument(Project project, string text, Image icon, FileInfo file) : this(file) { _project = project; DockText = text; Icon = icon; _spell = _project.LoadSpell(file.FullName); this.txtName.Text = _spell.Name; this.txtCastTime.Text = _spell.CastTime.ToString(); this.txtCooldownTime.Text = _spell.CooldownTime.ToString(); this.txtActiveTime.Text = _spell.ActiveTime.ToString(); this.txtReqStr.Text = _spell.ReqStats.Strength.ToString(); this.txtReqInt.Text = _spell.ReqStats.Intelligence.ToString(); this.txtReqDef.Text = _spell.ReqStats.Defense.ToString(); this.txtReqHealth.Text = _spell.ReqStats.Vitality.ToString(); this.txtReqDex.Text = _spell.ReqStats.Dexterity.ToString(); this.txtStrMod.Text = _spell.StatModifiers.Strength.ToString(); this.txtDefMod.Text = _spell.StatModifiers.Defense.ToString(); this.txtIntMod.Text = _spell.StatModifiers.Intelligence.ToString(); this.txtDexMod.Text = _spell.StatModifiers.Dexterity.ToString(); this.txtHealthMod.Text = _spell.StatModifiers.Vitality.ToString(); this.txtHealthCost.Text = _spell.HealthCost.ToString(); this.txtManaCost.Text = _spell.ManaCost.ToString(); _regularDockText = _spell.Name + EngineConstants.SCRIPT_FILE_EXT; this.DockText = _regularDockText; _unsavedDockText = _regularDockText + "*"; if (File.Exists(_project.ClientRootDirectory + "/" + _spell.DisplaySprite.TextureName)) { this.picTexture.Load(_project.ClientRootDirectory + "/" + _spell.DisplaySprite.TextureName); } if (!string.IsNullOrEmpty(_spell.CasterAnimationPath)) { _casterAnimation = _project.LoadAnimation(_project.ClientRootDirectory + "/" + _spell.CasterAnimationPath); } if (!string.IsNullOrEmpty(_spell.TargetAnimationPath)) { _targetAnimation = _project.LoadAnimation(_project.ClientRootDirectory + "/" + _spell.TargetAnimationPath); } // Hook up UI display view handlers for animation rendering this.targetAnimView.OnDraw = OnTargetAnimationDraw; this.casterAnimView.OnDraw = OnCasterAnimationDraw; this.casterAnimView.OnUpdate = OnCasterAnimationUpdate; this.targetAnimView.OnUpdate = OnTargetAnimationUpdate; }
static void createIcon(SpellModel spell) { Transform icon = ((GameObject)Instantiate(Resources.Load(spell.spellName, typeof(GameObject)))).transform; icon.SetParent(GameObject.FindWithTag("Canvas").transform); RectTransform rt = (RectTransform)icon; rt.anchoredPosition = Vector3.zero; Destroy(icon.gameObject, spell.cooldown); }
/// <summary> /// Gets formatted xml of object /// </summary> public string GetXML(SpellModel model) { string xml = String.Empty; if (model != null) { xml = $"<spell><id>{model.Id}</id>{model.XML}</spell>"; } return(xml); }
private void FillcomboModifier() { string categoryName; categoryName = comboCategory.SelectedItem.ToString(); ModifierNames.Clear(); comboModifier.Items.Clear(); if (categoryName == "Ability") { labelModifier.Text = "Select an Ability"; ModifierNames = AbilityModel.GetNames(); } else if (categoryName == "Attribute") { labelModifier.Text = "Select an Attribute"; ModifierNames = AttributeModel.GetNames(); } else if (categoryName == "Feat") { labelModifier.Text = "Select a Feat"; ModifierNames = FeatModel.GetNames(); } else if (categoryName == "Save") { labelModifier.Text = "Select a Save"; ModifierNames = SaveModel.GetNames(); } else if (categoryName == "Skill") { labelModifier.Text = "Select a Skill"; ModifierNames = SkillModel.GetNames(); } else if (categoryName == "Spell") { labelModifier.Text = "Select a Spell"; ModifierNames = SpellModel.GetNames(); } else { //We should never reach this, if so, we need to add a category of fix one. Debug.WriteLine("Error: no category exist for the selected. ModifierDialogClass::FillcomboModifier()"); return; } foreach (string name in ModifierNames) { comboModifier.Items.Add(name); } }
private void OnNewSpellButtonClick(object sender, EventArgs e) { if (DataChangeWarning() == false) { return; } AllowChangeEvents = false; Model = new SpellModel(); SpellListBox.SelectedIndex = -1; PopulateFields(""); SpellNameInputBox.Focus(); DataHasChanged = false; AllowChangeEvents = true; }
private bool CheckForUniqueness(string newValue, InputType type) { switch (type) { case InputType.SpellName: { if (SpellModel.DoesNameExist(newValue) == true) { return(false); } break; } } return(true); }
public void AddNewSpell(SpellModel spell) { using (var ctxt = GetContext()) { ctxt.Spells.Add(new Spell { SpellName = spell.SpellName, SpellDescription = spell.SpellDescription, SpellText = spell.SpellDescription, SpellAddedDescription = spell.SpellAddedDescription, SpellTypeId = spell.SpellTypeId }); ctxt.SaveChanges(); } }
public ApiResponse Save(SpellModel value) { var user = _userManager.GetUserId(HttpContext.User); ApiResponse response; if (value.ID == -1) { response = _service.Add(value, user); } else { response = _service.Update(value, user); } return(response); }
private void OnSpellListBoxSelectedIndexChanged(object sender, EventArgs e) { if (DataChangeWarning() == false) { return; } AllowChangeEvents = false; Model = new SpellModel(); DetailModel.Clear(); if (SpellListBox.SelectedIndex != -1) { Model.Initialize(SpellListBox.SelectedItem.ToString()); DetailModel = SpellDetailsModel.GetAll(Model.Id); } PopulateFields(Model.SpellName); AllowChangeEvents = true; }
private void CategoryComboBox_SelectedIndexChanged(object sender, EventArgs e) { string category; category = CategoryComboBox.SelectedItem.ToString(); ApplyToNames.Clear(); if (category == "Ability") { ApplyToLabel.Text = "Select an Ability"; ApplyToNames = AbilityModel.GetNames(); } else if (category == "Attribute") { ApplyToLabel.Text = "Select an Attribute"; ApplyToNames = AttributeModel.GetNames(); } else if (category == "Feat") { ApplyToLabel.Text = "Select a Feat"; ApplyToNames = FeatModel.GetNames(); } else if (category == "Save") { ApplyToLabel.Text = "Select a Save"; ApplyToNames = SaveModel.GetNames(); } else if (category == "Skill") { ApplyToLabel.Text = "Select a Skill"; ApplyToNames = SkillModel.GetNames(); } else if (category == "Spell") { ApplyToLabel.Text = "Select a spell"; ApplyToNames = SpellModel.GetNames(); } else { Debug.WriteLine("Error: No category exists for the one selected. NewModifierDialogClass : CategoryComboBox_SelectedIndexChanged()"); return; } FillApplyToComboBox(); UpdateNameField(); }
private void AddSpell(SpellModel spellModel) { if (!_spells.Any(x => x.Spell.Id == spellModel.Id)) { SpellbookEntryModel spellbookEntryModel = new SpellbookEntryModel(); spellbookEntryModel.Spell = spellModel; int level = Math.Max(spellModel.Level, 0); SpellsByLevelViewModel spellsByLevelViewModel = _spellsByLevel.FirstOrDefault(x => x.Level == level); if (spellsByLevelViewModel != null) { spellsByLevelViewModel.AddSpell(spellbookEntryModel); } else { spellsByLevelViewModel = new SpellsByLevelViewModel(level, _spellSlots.Count > level ? _spellSlots[level] : 0, _spellbookModel.BasedOnClass, _spellbookModel.BasedOnRace); spellsByLevelViewModel.AddSpell(spellbookEntryModel); bool added = false; if (_spellsByLevel.Count > 0) { for (int i = 0; i < _spellsByLevel.Count; ++i) { if (_spellsByLevel[i].Level > level) { _spellsByLevel.Insert(i, spellsByLevelViewModel); added = true; break; } } } if (!added) { _spellsByLevel.Add(spellsByLevelViewModel); } } _spells.Add(new SpellbookEntryViewModel(spellbookEntryModel)); _spellbookModel.Spells.Add(spellbookEntryModel); } }
void ActivateSpell(SpellModel spell) { Vector3 forward = transform.TransformDirection(Vector3.forward); if (spell.spellName == "fire") { // Load spell particle from folder "Resources" GameObject flame = (GameObject)Instantiate(Resources.Load(spell.particlePath, typeof(GameObject)), transform.position + forward, Quaternion.identity); FireSpell fs = flame.GetComponent <FireSpell>(); fs.forward = forward; fs.spellModel = spell; createIcon(spell); } if (spell.spellName == "teleport") { transform.position = spellPosition; // Find enemies within reach GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject go in gameObjects) { float distance = Vector3.Distance(go.transform.position, transform.position); if (distance <= 4.0f) { // Direction of the movement Vector3 spellDir = (go.transform.position - transform.position).normalized; // Aplly force to close enemies go.GetComponent <Rigidbody> ().AddForce(spellDir * 300); } } } if (spell.spellName == "homing") { // Load spell particle from folder "Resources" GameObject homing = (GameObject)Instantiate(Resources.Load(spell.particlePath, typeof(GameObject)), transform.position + forward, Quaternion.identity); HomingSpell homingSpell = homing.GetComponent <HomingSpell>(); homingSpell.forward = forward; homingSpell.spellPosition = spellPosition; homingSpell.spellModel = spell; createIcon(spell); } }
protected static bool InsertSpelling(SpellModel Spell) { string query = string.Format(InsertSQL + "'{1}', '{2}', {3})", Model.Spell.ToDesc(), Spell.Text, Spell.Importance, Spell.IsActive); if (!SendQuery(query)) { return(false); } var inserted = GetLast(Model.Spell.ToDesc()); Spellings.Add(inserted.Tables[0].AsEnumerable(). Select(GetDatarowSpelling()).First().ToVM()); return(true); }
public static EmbedBuilder SpellOutput(SpellModel spell) { var embedBuilder = EmbedBuilderHelpers.BaseEmbedBuilderSuccess(); embedBuilder.Description = spell.Description; embedBuilder.Title = spell.Name; embedBuilder.AddField(nameof(spell.Level), spell.Level, true); embedBuilder.AddField(nameof(spell.Range), spell.Range, true); embedBuilder.AddField(nameof(spell.Save), spell.Save, true); embedBuilder.AddField(nameof(spell.Duration), spell.Duration, true); embedBuilder.AddField(nameof(spell.Components), spell.Components, true); embedBuilder.AddField(nameof(spell.AoE), spell.AoE, true); embedBuilder.AddField(nameof(spell.CastingTime), spell.CastingTime, true); embedBuilder.AddField(nameof(spell.Spheres), spell.Spheres, true); embedBuilder.AddField(nameof(spell.Class), spell.Class, true); return(embedBuilder); }
private Guid GetApplyToId() { Guid applyToId; string tableName; applyToId = Guid.Empty; tableName = comboCategory.SelectedItem.ToString(); if (tableName == "Ability") { applyToId = AbilityModel.GetIdFromName(comboModifier.SelectedItem.ToString()); } else if (tableName == "Attribute") { applyToId = AttributeModel.GetIdFromName(comboModifier.SelectedItem.ToString()); } else if (tableName == "Feat") { applyToId = FeatModel.GetIdFromName(comboModifier.SelectedItem.ToString()); } else if (tableName == "Save") { applyToId = SaveModel.GetIdFromName(comboModifier.SelectedItem.ToString()); } else if (tableName == "Skill") { applyToId = SkillModel.GetIdFromName(comboModifier.SelectedItem.ToString()); } else if (tableName == "Spell") { applyToId = SpellModel.GetIdFromName(comboModifier.SelectedItem.ToString()); } else { //We should never reach this, if so, we need to add a category of fix one. Debug.WriteLine("Error: no category exists for the selected. ModifierDialogClass::GetApplyToId()"); return(applyToId); } return(applyToId); }
private void PopulateSpellListBox() { string currentSelection; if (SpellListBox.SelectedIndex == -1) { currentSelection = "<none>"; } else { currentSelection = SpellListBox.SelectedItem.ToString(); } SpellListBox.Items.Clear(); SpellNames = SpellModel.GetNames(); foreach (string name in SpellNames) { SpellListBox.Items.Add(name); } SpellListBox.SelectedIndex = SpellListBox.FindStringExact(currentSelection); }
protected override void Because() { _result = Mapper.Map<SpellCard, SpellModel>(_card); }