示例#1
0
        public ActionResult Unplanned(int id)
        {
            var db     = new ZelusDbContext();
            var player = db.Players.FirstOrDefault(p => p.Id == id);

            if (player.IsNull())
            {
                return(View("Error"));
            }

            var mods = db.PlayerModsWithStats
                       .Where(PlayerModsWithStat.BelongsToPlayer(player.Id))
                       .ToList();

            var modVMs  = ModVMFactory.GetModVMs(mods, player.Id, true);
            var charVMs = ModVMFactory.GetCharacterVMs(db);

            var model = new ModPlannerVM
            {
                PlayerId          = player.Id,
                LastSyncDateTime  = player.LastModSync,
                LastSyncHumanized = player.LastModSync.Humanize(),
                Mods       = modVMs,
                Characters = charVMs
            };

            return(View(model));
        }
示例#2
0
        private static string GetPrimaryText(PlayerModsWithStat mod, ModStatTypes type)
        {
            switch (type)
            {
            case ModStatTypes.Offense:
                return($"{FormatPercentageValue(mod.PercentageOffense)} Offense");

            case ModStatTypes.Defense:
                return($"{FormatPercentageValue(mod.PercentageDefense)} Defense");

            case ModStatTypes.Health:
                return($"{FormatPercentageValue(mod.PercentageHealth)} Health");

            case ModStatTypes.Protection:
                return($"{FormatPercentageValue(mod.PercentageProtection)} Prot");

            case ModStatTypes.Speed:
                return($"{decimal.ToInt32((decimal)mod.Speed)} Speed");

            case ModStatTypes.Critical_Avoidence:
                return($"{FormatPercentageValue(mod.CritAvoidance)} Avoidance");

            case ModStatTypes.Accuracy:
                return($"{FormatPercentageValue(mod.Accuracy)} Accuracy");

            case ModStatTypes.Critical_Damage:
                return($"{FormatPercentageValue(mod.CritDamage)} CD");

            case ModStatTypes.Critical_Chance:
                return($"{FormatPercentageValue(mod.CritChance)} CC");

            case ModStatTypes.Potency:
                return($"{FormatPercentageValue(mod.Potency)} Potency");

            case ModStatTypes.Tenacity:
                return($"{FormatPercentageValue(mod.Tenacity)} Tenacity");

            default:
                return($"Unknown");
            }
        }
示例#3
0
        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);
        }
示例#4
0
        public static List <string> GetSecondaries(this PlayerModsWithStat mod)
        {
            var result = new List <string>();

            if (mod.Speed.HasValue && mod.Speed > 0.00m)
            {
                result.Add($"{decimal.ToInt32((decimal)mod.Speed)} Speed");
            }

            if (mod.CritChance.HasValue && mod.CritChance > 0.00m)
            {
                result.Add($"{FormatPercentageValue(mod.CritChance)} Critical Chance");
            }

            if (mod.FlatOffense.HasValue && mod.FlatOffense > 0.00m)
            {
                result.Add($"{decimal.ToInt32((decimal)mod.FlatOffense)} Offense");
            }

            if (mod.PercentageOffense.HasValue && mod.PercentageOffense > 0.00m)
            {
                result.Add($"{FormatPercentageValue(mod.PercentageOffense)} Offense");
            }

            if (mod.Potency.HasValue && mod.Potency > 0.00m)
            {
                result.Add($"{FormatPercentageValue(mod.Potency)} Potency");
            }

            if (mod.FlatProtection.HasValue && mod.FlatProtection > 0.00m)
            {
                result.Add($"{decimal.ToInt32((decimal)mod.FlatProtection)} Protection");
            }

            if (mod.PercentageProtection.HasValue && mod.PercentageProtection > 0.00m)
            {
                result.Add($"{FormatPercentageValue(mod.PercentageProtection)} Protection");
            }

            if (mod.FlatHealth.HasValue && mod.FlatHealth > 0.00m)
            {
                result.Add($"{decimal.ToInt32((decimal)mod.FlatHealth)} Health");
            }

            if (mod.PercentageHealth.HasValue && mod.PercentageHealth > 0.00m)
            {
                result.Add($"{FormatPercentageValue(mod.PercentageHealth)} Health");
            }

            if (mod.FlatDefense.HasValue && mod.FlatDefense > 0.00m)
            {
                result.Add($"{decimal.ToInt32((decimal)mod.FlatDefense)} Defense");
            }

            if (mod.PercentageDefense.HasValue && mod.PercentageDefense > 0.00m)
            {
                result.Add($"{FormatPercentageValue(mod.PercentageDefense)} Defense");
            }

            if (mod.Tenacity.HasValue && mod.Tenacity > 0.00m)
            {
                result.Add($"{FormatPercentageValue(mod.Tenacity)} Tenacity");
            }

            return(result);
        }
示例#5
0
 public static string PrimaryText(this PlayerModsWithStat mod)
 {
     return(GetPrimaryText(mod, (ModStatTypes)mod.PrimaryTypeId));
 }