static void AddWeaponShortcutsFor(Character player, CarriedWeapon carriedWeapon)
        {
            List <PlayerActionShortcut> lastShortcuts = null;

            List <ItemEffect> weaponEffects = AllWeaponEffects.GetAll(carriedWeapon.Weapon.Name).OrderBy(x => x.index).ToList();;

            if (weaponEffects.Count == 0)
            {
                lastShortcuts = PlayerActionShortcut.FromWeapon(carriedWeapon, null, player);
            }
            else
            {
                for (int i = 0; i < weaponEffects.Count; i++)
                {
                    ItemEffect itemEffect = weaponEffects[i];
                    if (i == 0)
                    {
                        lastShortcuts = PlayerActionShortcut.FromWeapon(carriedWeapon, itemEffect, player);
                    }
                    else
                    {
                        foreach (PlayerActionShortcut playerActionShortcut in lastShortcuts)
                        {
                            playerActionShortcut.Windups.Add(WindupDto.FromItemEffect(itemEffect, PlayerActionShortcut.WeaponWindupPrefix + playerActionShortcut.Name));
                        }
                    }
                }
            }

            if (lastShortcuts != null)
            {
                AllShortcuts.AddRange(lastShortcuts);
            }
        }
Example #2
0
        public static List <PlayerActionShortcut> FromWeapon(CarriedWeapon carriedWeapon, ItemEffect weaponEffect, Character player)
        {
            List <PlayerActionShortcut> results = new List <PlayerActionShortcut>();
            //Weapon weapon = AllWeapons.Get(weaponEffect.name);
            Weapon weapon = AllWeapons.Get(carriedWeapon.Weapon.Name);
            PlayerActionShortcutDto dto = new PlayerActionShortcutDto();

            if (!string.IsNullOrWhiteSpace(carriedWeapon.Name))
            {
                dto.name = carriedWeapon.Name;
            }
            else
            {
                dto.name = weapon.Name;
            }

            //dto.effectAvailableWhen = weaponEffect.effectAvailableWhen;

            dto.player = player.name;
            SetDtoFromEffect(dto, weaponEffect);
            dto.type = DndUtils.DiceRollTypeToStr(DiceRollType.Attack);

            SetWeaponHitTime(dto, weapon);
            dto.plusModifier = carriedWeapon.HitDamageBonus.ToString();
            AddWeaponShortcuts(dto, results, weapon, player);
            foreach (PlayerActionShortcut playerActionShortcut in results)
            {
                playerActionShortcut.CarriedWeapon = carriedWeapon;
                playerActionShortcut.PlusModifier  = carriedWeapon.HitDamageBonus;
                playerActionShortcut.UsesMagic     = carriedWeapon.HitDamageBonus > 0;
            }

            AddItemEffect(results, weaponEffect);
            return(results);
        }