Exemple #1
0
        public static List <PlayerActionShortcut> From(PlayerActionShortcutDto shortcutDto)
        {
            List <PlayerActionShortcut> results = new List <PlayerActionShortcut>();
            string cleanName = DndUtils.GetCleanItemName(shortcutDto.name);
            Weapon weapon    = AllWeapons.Get(cleanName);

            if (weapon == null && cleanName.IndexOf(" of ") > 0)
            {
                // Try again with the weapon...
                cleanName = cleanName.EverythingBefore(" of ");
                weapon    = AllWeapons.Get(cleanName);
            }
            Character player = AllPlayers.GetFromId(PlayerID.FromName(shortcutDto.player));

            if (weapon != null)
            {
                AddWeaponShortcuts(shortcutDto, results, weapon, player);
            }
            else
            {
                List <Spell> spells = AllSpells.GetAll(cleanName, player);
                if (spells != null && spells.Count > 0)
                {
                    AddSpellShortcuts(shortcutDto, results, player, spells);
                }
                else                 // Not a weapon or a spell.
                {
                    PlayerActionShortcut shortcut = FromAction(shortcutDto);
                    results.Add(shortcut);
                    shortcut.AddEffect(shortcutDto, "", player);
                }
            }

            return(results);
        }
Exemple #2
0
        public static List <PlayerActionShortcut> FromItemSpellEffect(string spellName, ItemEffect spellEffect, Character player)
        {
            List <PlayerActionShortcut> results = new List <PlayerActionShortcut>();

            List <Spell> spells = AllSpells.GetAll(spellName);

            foreach (Spell spell in spells)
            {
                PlayerActionShortcutDto dto = new PlayerActionShortcutDto();
                dto.name   = spell.Name;
                dto.player = player.name;

                //dto.effectAvailableWhen = weaponEffect.effectAvailableWhen;

                SetDtoFromEffect(dto, spellEffect);
                dto.type = GetDiceRollTypeStr(spell);
                SetSpellCastingTime(dto, spell);
                List <Spell> oneSpell = new List <Spell>();
                oneSpell.Add(spell);
                AddSpellShortcuts(dto, results, player, oneSpell);
            }

            AddItemEffect(results, spellEffect);

            return(results);
        }
Exemple #3
0
        public static List <PlayerActionShortcut> FromItemSpellEffect(string spellName, ItemEffect spellEffect, Character player)
        {
            List <PlayerActionShortcut> results = new List <PlayerActionShortcut>();

            List <Spell> spells = AllSpells.GetAll(spellName);

            foreach (Spell spell in spells)
            {
                PlayerActionShortcutDto dto = new PlayerActionShortcutDto();
                dto.name   = spell.Name;
                dto.player = player.name;

                //dto.effectAvailableWhen = weaponEffect.effectAvailableWhen;

                SetDtoFromEffect(dto, spellEffect);
                if (spell.SpellType == SpellType.RangedSpell || spell.SpellType == SpellType.MeleeSpell)
                {
                    if (spell.Name == "Chaos Bolt")
                    {
                        dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.ChaosBolt);
                    }
                    else
                    {
                        dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.Attack);
                    }
                }
                else if (spell.SpellType == SpellType.SavingThrowSpell)
                {
                    dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.DamageOnly);
                }
                else if (spell.SpellType == SpellType.OtherSpell)
                {
                    dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.None);
                }
                else if (spell.SpellType == SpellType.HpCapacitySpell)
                {
                    dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.ExtraOnly);
                }
                else
                {
                    dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.None);
                }

                SetSpellCastingTime(dto, spell);
                List <Spell> oneSpell = new List <Spell>();
                oneSpell.Add(spell);
                AddSpellShortcuts(dto, results, player, oneSpell);
            }

            AddItemEffect(results, spellEffect);

            return(results);
        }
        public void TestEvaluateAllExpressions(Character player)
        {
            ShouldActivateNow();
            StartGame(player);
            Activate(true);
            CastedSpell castedSpell = new CastedSpell(AllSpells.Get("Magic Missile"), player);

            SpellJustCast(player, castedSpell);
            AfterPlayerSwings(player);
            PlayerStartsTurn(player);
            RollIsComplete(player);
            Deactivate(true);
        }
Exemple #5
0
 public static void Invalidate()
 {
     AllActionShortcuts.Invalidate();
     AllDieRollEffects.Invalidate();
     AllFeatures.Invalidate();
     AllFunctions.Invalidate();
     AllPlayers.Invalidate();
     AllProperties.Invalidate();
     AllSpellEffects.Invalidate();
     AllSpells.Invalidate();
     AllTables.Invalidate();
     AllTrailingEffects.Invalidate();
     AllWeaponEffects.Invalidate();
     AllWeapons.Invalidate();
 }