コード例 #1
0
        protected ItemUsable(ItemSheet.Row data, Guid id, long requiredBlockIndex) : base(data)
        {
            ItemId   = id;
            StatsMap = new StatsMap();

            switch (data)
            {
            case ConsumableItemSheet.Row consumableItemRow:
            {
                foreach (var statData in consumableItemRow.Stats)
                {
                    StatsMap.AddStatValue(statData.StatType, statData.Value);
                }

                break;
            }

            case EquipmentItemSheet.Row equipmentItemRow:
                StatsMap.AddStatValue(equipmentItemRow.Stat.Type, equipmentItemRow.Stat.Value);
                break;
            }

            Skills             = new List <Model.Skill.Skill>();
            BuffSkills         = new List <BuffSkill>();
            RequiredBlockIndex = requiredBlockIndex;
        }
コード例 #2
0
 protected ItemUsable(Dictionary serialized) : base(serialized)
 {
     StatsMap   = new StatsMap();
     Skills     = new List <Model.Skill.Skill>();
     BuffSkills = new List <BuffSkill>();
     if (serialized.TryGetValue((Text)"itemId", out var itemId))
     {
         ItemId = itemId.ToGuid();
     }
     if (serialized.TryGetValue((Text)"statsMap", out var statsMap))
     {
         StatsMap.Deserialize((Dictionary)statsMap);
     }
     if (serialized.TryGetValue((Text)"skills", out var skills))
     {
         foreach (var value in (List)skills)
         {
             var skill = (Dictionary)value;
             Skills.Add(SkillFactory.Deserialize(skill));
         }
     }
     if (serialized.TryGetValue((Text)"buffSkills", out var buffSkills))
     {
         foreach (var value in (List)buffSkills)
         {
             var buffSkill = (Dictionary)value;
             BuffSkills.Add((BuffSkill)SkillFactory.Deserialize(buffSkill));
         }
     }
     if (serialized.TryGetValue((Text)"requiredBlockIndex", out var requiredBlockIndex))
     {
         RequiredBlockIndex = requiredBlockIndex.ToLong();
     }
 }
コード例 #3
0
        public static StatsMap ToStats(this CharacterSheet.Row row, int level)
        {
            var hp  = row.HP;
            var atk = row.ATK;
            var def = row.DEF;
            var cri = row.CRI;
            var hit = row.HIT;
            var spd = row.SPD;

            if (level > 1)
            {
                var multiplier = level - 1;
                hp  += row.LvHP * multiplier;
                atk += row.LvATK * multiplier;
                def += row.LvDEF * multiplier;
                cri += row.LvCRI * multiplier;
                hit += row.LvHIT * multiplier;
                spd += row.LvSPD * multiplier;
            }

            var stats = new StatsMap();

            stats.AddStatValue(StatType.HP, hp);
            stats.AddStatValue(StatType.ATK, atk);
            stats.AddStatValue(StatType.DEF, def);
            stats.AddStatValue(StatType.CRI, cri);
            stats.AddStatValue(StatType.HIT, hit);
            stats.AddStatValue(StatType.SPD, spd);

            return(stats);
        }
コード例 #4
0
ファイル: ItemUsable.cs プロジェクト: x86chi/lib9c
 public override IValue Serialize() =>
 new Dictionary(new Dictionary <IKey, IValue>
 {
     [(Text)"itemId"]             = ItemId.Serialize(),
     [(Text)"statsMap"]           = StatsMap.Serialize(),
     [(Text)"skills"]             = new List(Skills.Select(s => s.Serialize())),
     [(Text)"buffSkills"]         = new List(BuffSkills.Select(s => s.Serialize())),
     [(Text)"requiredBlockIndex"] = RequiredBlockIndex.Serialize(),
 }.Union((Dictionary)base.Serialize()));
コード例 #5
0
 // FIXME: 기본 스탯을 복리로 증가시키고 있는데, 단리로 증가시켜야 한다.
 // 이를 위해서는 기본 스탯을 유지하면서 추가 스탯에 더해야 하는데, UI 표현에 문제가 생기기 때문에 논의 후 개선한다.
 // 장비가 보유한 스킬의 확률과 수치 강화가 필요한 상태이다.
 public void LevelUp()
 {
     level++;
     StatsMap.AddStatValue(UniqueStatType, GetIncrementAmountOfEnhancement());
     if (new[] { 4, 7, 10 }.Contains(level) &&
         GetOptionCount() > 0)
     {
         UpdateOptions();
     }
 }
コード例 #6
0
ファイル: CPHelper.cs プロジェクト: dahlia/lib9c
        public static int GetCP(Costume costume, CostumeStatSheet sheet)
        {
            var statsMap = new StatsMap();

            foreach (var r in sheet.OrderedList.Where(r => r.CostumeId == costume.Id))
            {
                statsMap.AddStatValue(r.StatType, r.Stat);
            }

            return(DecimalToInt(GetStatsCP(statsMap)));
        }
コード例 #7
0
        public List <object> GetOptions()
        {
            var options = new List <object>();

            options.AddRange(Skills);
            options.AddRange(BuffSkills);
            foreach (var statMapEx in StatsMap.GetAdditionalStats())
            {
                options.Add(new StatModifier(
                                statMapEx.StatType,
                                StatModifier.OperationType.Add,
                                statMapEx.AdditionalValueAsInt));
            }

            return(options);
        }
コード例 #8
0
        public override IValue Serialize() =>
#pragma warning disable LAA1002
        new Dictionary(new Dictionary <IKey, IValue>
        {
            [(Text)"itemId"]   = ItemId.Serialize(),
            [(Text)"statsMap"] = StatsMap.Serialize(),
            [(Text)"skills"]   = new List(Skills
                                          .OrderByDescending(i => i.Chance)
                                          .ThenByDescending(i => i.Power)
                                          .Select(s => s.Serialize())),
            [(Text)"buffSkills"] = new List(BuffSkills
                                            .OrderByDescending(i => i.Chance)
                                            .ThenByDescending(i => i.Power)
                                            .Select(s => s.Serialize())),
            [(Text)"requiredBlockIndex"] = RequiredBlockIndex.Serialize(),
        }.Union((Dictionary)base.Serialize()));
コード例 #9
0
ファイル: Equipment.cs プロジェクト: dahlia/lib9c
        private void UpdateOptionsV2(IRandom random, EnhancementCostSheetV2.Row row, bool isGreatSuccess)
        {
            foreach (var statMapEx in StatsMap.GetAdditionalStats())
            {
                var rand = isGreatSuccess
                    ? row.ExtraStatGrowthMax
                    : random.Next(row.ExtraStatGrowthMin, row.ExtraStatGrowthMax + 1);
                var ratio    = rand.NormalizeFromTenThousandths();
                var addValue = statMapEx.AdditionalValue * ratio;
                if (addValue > 0)
                {
                    addValue = Math.Max(1.0m, addValue);
                }

                StatsMap.SetStatAdditionalValue(statMapEx.StatType, statMapEx.AdditionalValue + addValue);
            }

            var skills = new List <Skill.Skill>();

            skills.AddRange(Skills);
            skills.AddRange(BuffSkills);
            foreach (var skill in skills)
            {
                var chanceRand = isGreatSuccess ? row.ExtraSkillChanceGrowthMax
                    : random.Next(row.ExtraSkillChanceGrowthMin, row.ExtraSkillChanceGrowthMax + 1);
                var chanceRatio = chanceRand.NormalizeFromTenThousandths();
                var addChance   = skill.Chance * chanceRatio;
                if (addChance > 0)
                {
                    addChance = Math.Max(1.0m, addChance);
                }

                var damageRand = isGreatSuccess ? row.ExtraSkillDamageGrowthMax
                    : random.Next(row.ExtraSkillDamageGrowthMin, row.ExtraSkillDamageGrowthMax + 1);
                var damageRatio = damageRand.NormalizeFromTenThousandths();
                var addPower    = skill.Power * damageRatio;
                if (addPower > 0)
                {
                    addPower = Math.Max(1.0m, addPower);
                }

                skill.Update(skill.Chance + (int)addChance, skill.Power + (int)addPower);
            }
        }
コード例 #10
0
        private void UpdateOptions()
        {
            foreach (var statMapEx in StatsMap.GetAdditionalStats())
            {
                StatsMap.SetStatAdditionalValue(
                    statMapEx.StatType,
                    statMapEx.AdditionalValue * 1.3m);
            }

            var skills = new List <Skill.Skill>();

            skills.AddRange(Skills);
            skills.AddRange(BuffSkills);
            foreach (var skill in skills)
            {
                var chance = decimal.ToInt32(skill.Chance * 1.3m);
                var power  = decimal.ToInt32(skill.Power * 1.3m);
                skill.Update(chance, power);
            }
        }
コード例 #11
0
ファイル: Equipment.cs プロジェクト: dahlia/lib9c
        public void LevelUpV2(IRandom random, EnhancementCostSheetV2.Row row, bool isGreatSuccess)
        {
            level++;
            var rand = isGreatSuccess ? row.BaseStatGrowthMax
                :random.Next(row.BaseStatGrowthMin, row.BaseStatGrowthMax + 1);
            var ratio    = rand.NormalizeFromTenThousandths();
            var baseStat = StatsMap.GetStat(UniqueStatType, true) * ratio;

            if (baseStat > 0)
            {
                baseStat = Math.Max(1.0m, baseStat);
            }

            StatsMap.AddStatValue(UniqueStatType, baseStat);

            if (GetOptionCount() > 0)
            {
                UpdateOptionsV2(random, row, isGreatSuccess);
            }
        }
コード例 #12
0
        private void UpdateStatsArea()
        {
            if (Model?.item.Value is null)
            {
                statsArea.root.gameObject.SetActive(false);

                return;
            }

            foreach (var stat in statsArea.stats)
            {
                stat.Hide();
            }

            var statCount = 0;

            if (Model.item.Value.ItemBase.Value is Equipment equipment)
            {
                descriptionArea.commonGameObject.SetActive(false);
                descriptionArea.dividerImageGameObject.SetActive(false);
                descriptionArea.levelLimitGameObject.SetActive(false);
                descriptionArea.combatPowerObject.SetActive(true);
                descriptionArea.combatPowerText.text = CPHelper.GetCP(equipment).ToString();

                var uniqueStatType = equipment.UniqueStatType;
                foreach (var statMapEx in equipment.StatsMap.GetStats())
                {
                    if (!statMapEx.StatType.Equals(uniqueStatType))
                    {
                        continue;
                    }

                    AddStat(statMapEx, true);
                    statCount++;
                }

                foreach (var statMapEx in equipment.StatsMap.GetStats())
                {
                    if (statMapEx.StatType.Equals(uniqueStatType))
                    {
                        continue;
                    }

                    AddStat(statMapEx);
                    statCount++;
                }
            }
            else if (Model.item.Value.ItemBase.Value is ItemUsable itemUsable)
            {
                descriptionArea.commonGameObject.SetActive(false);
                descriptionArea.dividerImageGameObject.SetActive(false);
                descriptionArea.levelLimitGameObject.SetActive(false);
                descriptionArea.combatPowerObject.SetActive(false);

                foreach (var statMapEx in itemUsable.StatsMap.GetStats())
                {
                    AddStat(statMapEx);
                    statCount++;
                }
            }
            else if (Model.item.Value.ItemBase.Value is Costume costume)
            {
                var costumeSheet = Game.Game.instance.TableSheets.CostumeStatSheet;
                descriptionArea.commonGameObject.SetActive(false);
                descriptionArea.dividerImageGameObject.SetActive(false);
                descriptionArea.levelLimitGameObject.SetActive(false);
                var statsMap = new StatsMap();
                foreach (var row in costumeSheet.OrderedList.Where(r => r.CostumeId == costume.Id))
                {
                    statsMap.AddStatValue(row.StatType, row.Stat);
                }

                foreach (var statMapEx in statsMap.GetStats())
                {
                    AddStat(statMapEx);
                    statCount++;
                }

                var cpEnable = statCount > 0;
                descriptionArea.combatPowerObject.SetActive(cpEnable);
                if (cpEnable)
                {
                    descriptionArea.combatPowerText.text = CPHelper.GetCP(costume, costumeSheet).ToString();
                }
            }
            else
            {
                descriptionArea.levelLimitGameObject.SetActive(false);
                descriptionArea.combatPowerObject.SetActive(false);
                descriptionArea.commonGameObject.SetActive(false);
                descriptionArea.dividerImageGameObject.SetActive(false);
            }

            if (statCount <= 0)
            {
                statsArea.root.gameObject.SetActive(false);

                return;
            }

            statsArea.root.gameObject.SetActive(true);
        }
コード例 #13
0
 public decimal GetIncrementAmountOfEnhancement()
 {
     return(Math.Max(1.0m, StatsMap.GetStat(UniqueStatType, true) * 0.1m));
 }
コード例 #14
0
 public int GetOptionCount()
 {
     return(StatsMap.GetAdditionalStats().Count()
            + Skills.Count
            + BuffSkills.Count);
 }