예제 #1
0
        private static void AddSpellShortcuts(PlayerActionShortcutDto shortcutDto, List <PlayerActionShortcut> results, Character player, List <Spell> spells)
        {
            foreach (Spell spell in spells)
            {
                if (spell.MorePowerfulWhenCastAtHigherLevels)
                {
                    int[] spellSlotLevels = player.GetSpellSlotLevels();
                    int   availableSlots  = 0;
                    if (spell.Level >= 0)
                    {
                        availableSlots = spellSlotLevels[spell.Level];
                    }

                    if (availableSlots > 0)
                    {
                        bool needToDisambiguateMultipleSpells = spell.Level < 9 && spellSlotLevels[spell.Level + 1] > 0;

                        for (int slotLevel = spell.Level; slotLevel <= 9; slotLevel++)
                        {
                            if (spellSlotLevels[slotLevel] == 0)
                            {
                                break;
                            }

                            string suffix = string.Empty;
                            if (needToDisambiguateMultipleSpells)
                            {
                                suffix = $" [{slotLevel}]";
                            }

                            results.Add(FromSpell(shortcutDto, player, spell, slotLevel, null, suffix));
                        }
                    }
                    else
                    {
                        results.Add(FromSpell(shortcutDto, player, spell, spell.Level));
                    }
                }
                else
                {
                    results.Add(FromSpell(shortcutDto, player, spell, spell.Level));
                }
            }
        }