コード例 #1
0
ファイル: ModVMFactory.cs プロジェクト: Primalpat-/Zelus
        private static ModVM GetModVM(PlayerMod mod, bool showCheckbox)
        {
            var model = new ModVM();

            model.IsInModSet   = mod.IsInModSet();
            model.ShowCheckbox = showCheckbox;
            model.Id           = mod.Id;
            model.Pips         = mod.Pips;

            model.Set    = (ModSets)mod.SetId;
            model.Slot   = (ModSlots)mod.SlotId;
            model.ModImg = GetModImg(model.Set, model.Slot);

            model.CharacterId   = mod.PlayerCharacter?.Unit?.Id ?? 0;
            model.CharacterName = mod.PlayerCharacter?.Unit?.Name ?? "Unassigned";
            model.CharacterUrl  = GetCharacterUrl(mod);
            model.CharacterImg  = mod.PlayerCharacter?.Unit?.Image ?? "/Content/Images/unassigned.jpg";

            model.PrimaryType = mod.PrimaryTypeId;

            if (mod.PrimaryType != null)
            {
                model.Primary = $"+{GetModStatValue(mod.PrimaryValue, (ModStatUnits)mod.PrimaryUnitsId)} {GetPrimaryModStatTypeName(mod.PrimaryType)}";
            }

            if (mod.Secondary1Type != null)
            {
                model.Secondary1 = $"+{GetModStatValue(mod.Secondary1Value, (ModStatUnits)mod.Secondary1UnitsId)} {GetModStatTypeName(mod.Secondary1Type)}";
            }

            if (mod.Secondary2Type != null)
            {
                model.Secondary2 = $"+{GetModStatValue(mod.Secondary2Value, (ModStatUnits)mod.Secondary2UnitsId)} {GetModStatTypeName(mod.Secondary2Type)}";
            }

            if (mod.Secondary3Type != null)
            {
                model.Secondary3 = $"+{GetModStatValue(mod.Secondary3Value, (ModStatUnits)mod.Secondary3UnitsId)} {GetModStatTypeName(mod.Secondary3Type)}";
            }

            if (mod.Secondary4Type != null)
            {
                model.Secondary4 = $"+{GetModStatValue(mod.Secondary4Value, (ModStatUnits)mod.Secondary4UnitsId)} {GetModStatTypeName(mod.Secondary4Type)}";
            }

            model.Speed             = mod.Speed();
            model.CritChance        = mod.CritChance();
            model.CritDamage        = mod.CritDamage();
            model.FlatOffense       = mod.FlatOffense();
            model.PercentageOffense = mod.PercentageOffense();
            model.Potency           = mod.Potency();
            model.Accuracy          = mod.Accuracy();

            model.FlatProtection       = mod.FlatProtection();
            model.PercentageProtection = mod.PercentageProtection();
            model.FlatHealth           = mod.FlatHealth();
            model.PercentageHealth     = mod.PercentageHealth();
            model.FlatDefense          = mod.FlatDefense();
            model.PercentageDefense    = mod.PercentageDefense();
            model.Tenacity             = mod.Tenacity();
            model.CritAvoidance        = mod.CritAvoid();

            return(model);
        }
コード例 #2
0
ファイル: ModVMFactory.cs プロジェクト: Primalpat-/Zelus
        private static ModVM GetModVM(PlayerModsWithStat mod, List <PlayerCharacter> playerCharacters, bool showCheckbox)
        {
            var model = new ModVM();

            model.IsInModSet   = mod.IsInPlayerSet == 1;
            model.ShowCheckbox = showCheckbox;
            model.Id           = mod.Id;
            model.Pips         = mod.Pips;

            model.Set    = (ModSets)mod.SetId;
            model.Slot   = (ModSlots)mod.SlotId;
            model.ModImg = GetModImg(model.Set, model.Slot);

            var playerCharacter = playerCharacters.FirstOrDefault(pc => pc.Id == mod.PlayerCharacterId);

            model.CharacterId   = playerCharacter?.Unit?.Id ?? 0;
            model.CharacterName = playerCharacter?.Unit?.Name ?? "Unassigned";
            model.CharacterUrl  = "";
            model.CharacterImg  = "/Content/Images/unassigned.jpg";

            if (playerCharacter.IsNotNull())
            {
                model.CharacterImg = playerCharacter.Unit?.Image;

                if (playerCharacter.Unit.LocalImage.IsNotNullOrEmpty())
                {
                    var base64String = Convert.ToBase64String(playerCharacter.Unit.LocalImage, 0, playerCharacter.Unit.LocalImage.Length);
                    var imageSource  = "data:image/jpg;base64," + base64String;
                    model.CharacterImg = imageSource;
                }
            }

            model.PrimaryType = mod.PrimaryTypeId;
            model.Primary     = mod.PrimaryText();

            var secondaries = mod.GetSecondaries();

            if (secondaries.Count > 0)
            {
                model.Secondary1 = secondaries[0];
            }

            if (secondaries.Count > 1)
            {
                model.Secondary2 = secondaries[1];
            }

            if (secondaries.Count > 2)
            {
                model.Secondary3 = secondaries[2];
            }

            if (secondaries.Count > 3)
            {
                model.Secondary4 = secondaries[3];
            }

            model.Speed             = (decimal)mod.Speed;
            model.CritChance        = (decimal)mod.CritChance;
            model.CritDamage        = (decimal)mod.CritDamage;
            model.FlatOffense       = (decimal)mod.FlatOffense;
            model.PercentageOffense = (decimal)mod.PercentageOffense;
            model.Potency           = (decimal)mod.Potency;
            model.Accuracy          = (decimal)mod.Accuracy;

            model.FlatProtection       = (decimal)mod.FlatProtection;
            model.PercentageProtection = (decimal)mod.PercentageProtection;
            model.FlatHealth           = (decimal)mod.FlatHealth;
            model.PercentageHealth     = (decimal)mod.PercentageHealth;
            model.FlatDefense          = (decimal)mod.FlatDefense;
            model.PercentageDefense    = (decimal)mod.PercentageDefense;
            model.Tenacity             = (decimal)mod.Tenacity;
            model.CritAvoidance        = (decimal)mod.CritAvoidance;

            return(model);
        }