Exemplo n.º 1
0
        public IActionResult Create(VaultItem item)
        {
            _context.VaultItems.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetVault", new { id = item.Id }, item));
        }
Exemplo n.º 2
0
        public void MergeFrom(ActiveBuffSource other)
        {
            if (other == null)
            {
                return;
            }
            switch (other.TypeCase)
            {
            case TypeOneofCase.VaultItem:
                if (VaultItem == null)
                {
                    VaultItem = new global::WUProtos.Data.VaultItemActiveBuffSource();
                }
                VaultItem.MergeFrom(other.VaultItem);
                break;

            case TypeOneofCase.Profession:
                if (Profession == null)
                {
                    Profession = new global::WUProtos.Data.Profession.ProfessionActiveBuffSource();
                }
                Profession.MergeFrom(other.Profession);
                break;

            case TypeOneofCase.MapAbility:
                if (MapAbility == null)
                {
                    MapAbility = new global::WUProtos.Map.MapAbilityActiveBuffSource();
                }
                MapAbility.MergeFrom(other.MapAbility);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the value of a property in a vault item
        /// </summary>
        /// <typeparam name="T">The value type</typeparam>
        /// <param name="vaultItem">The vault item</param>
        /// <param name="property">The property</param>
        public T GetValueIfExists <T>(VaultItem vaultItem, string property)
        {
            if (vaultItem.Contains(property))
            {
                if (vaultItem[property] is T)
                {
                    return((T)vaultItem[property]);
                }
            }

            return(default(T));
        }
Exemplo n.º 4
0
        public static VaultItem TestVaultItem()
        {
            var value = new VaultItem
            {
                Id  = 1,
                Key = "123"
            };

            FillTrackedEntity(value);
            value.VaultId = TestVault().Id;

            return(value);
        }
Exemplo n.º 5
0
        public IActionResult Update(long id, VaultItem item)
        {
            var vault = _context.VaultItems.Find(id);

            if (vault == null)
            {
                return(NotFound());
            }

            vault.Description = item.Description;

            _context.VaultItems.Update(vault);
            _context.SaveChanges();
            return(NoContent());
        }
Exemplo n.º 6
0
        public async Task AddItem()
        {
            if (!Business.Vault.Itens.Any(item =>
                                          item.Key.Equals(NewVaultItem.Key,
                                                          System.StringComparison.InvariantCultureIgnoreCase)))
            {
                Business.Vault.Itens.Add(NewVaultItem);
                await Business.SaveVault();

                NewVaultItem = new VaultItem();
                await InvokeAsync(() => StateHasChanged());
            }
            else
            {
                KeyExistsModal = true;
            }
        }
Exemplo n.º 7
0
        public void SetShouldCreateVaultItem()
        {
            SQLiteDatabase      db    = GetVaultDatabase();
            VaultItemCollection items = VaultItem.LoadAll(db);

            Expect.AreEqual(0, items.Count);

            string password       = "******";
            string sensitiveValue = "Sensitive Value";
            string keyName        = "SensitiveInformation";
            Vault  v = Vault.Retrieve(db, "EncryptedData", password);

            v.Set(keyName, sensitiveValue);

            items = VaultItem.LoadAll(db);
            Expect.AreEqual(1, items.Count);
            Message.PrintLine(items.ToJsonSafe().ToJson());
        }
Exemplo n.º 8
0
        public void CanLoadVault()
        {
            SQLiteDatabase db             = GetVaultDatabase();
            string         password       = "******";
            string         sensitiveValue = "Sensitive Value";
            string         keyName        = "SensitiveInformation";
            Vault          v = Vault.Retrieve(db, "EncryptedData", password);

            v.Set(keyName, sensitiveValue);

            VaultItemCollection items = VaultItem.LoadAll(db);

            Expect.AreEqual(1, items.Count);
            foreach (VaultItem item in items)
            {
                OutLineFormat("Should be gibberish: Key={0}, Value={1}", item.Key, item.Value);
                Expect.IsFalse(item.Value.Equals(sensitiveValue));
                Expect.AreEqual(sensitiveValue, v[keyName]);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Loads all shop items owned
        /// </summary>
        public VaultShopItem[] LoadPlayerItems()
        {
            m_Client.PayVault.Refresh();
            VaultItem[]     vaultItems = m_Client.PayVault.Items;
            VaultShopItem[] shopItems  = new VaultShopItem[vaultItems.Length];
            for (int i = 0; i < vaultItems.Length; i++)
            {
                VaultItem     cur      = vaultItems[i];
                VaultShopItem shopItem = new VaultShopItem()
                {
                    ID                 = cur.Id,
                    Type               = cur.ItemKey,
                    PriceCoins         = m_Toolbelt.GetValueIfExists <int>(cur, "PriceCoins"),
                    Enabled            = m_Toolbelt.GetValueIfExists <bool>(cur, "Enabled"),
                    IsFeatured         = m_Toolbelt.GetValueIfExists <bool>(cur, "IsFeatured"),
                    Span               = m_Toolbelt.GetValueIfExists <int>(cur, "Span"),
                    BitmapSheetOffset  = m_Toolbelt.GetValueIfExists <int>(cur, "BitmapSheetOffset"),
                    HeaderText         = m_Toolbelt.GetValueIfExists <string>(cur, "Header"),
                    BodyText           = m_Toolbelt.GetValueIfExists <string>(cur, "Body"),
                    IsGridFeatured     = m_Toolbelt.GetValueIfExists <bool>(cur, "IsGridFeatured"),
                    PriceUSD           = m_Toolbelt.GetValueIfExists <int>(cur, "PriceUSD"),
                    PriceEnergy        = m_Toolbelt.GetValueIfExists <int>(cur, "PriceEnergy"),
                    EnergyPerClick     = m_Toolbelt.GetValueIfExists <int>(cur, "EnergyPerClick"),
                    InPlayerWorldsOnly = m_Toolbelt.GetValueIfExists <bool>(cur, "PWOnly"),
                    MinimumClass       = m_Toolbelt.GetValueIfExists <int>(cur, "MinClass"),
                    IsClassic          = m_Toolbelt.GetValueIfExists <bool>(cur, "IsClassic"),
                    OnSale             = m_Toolbelt.GetValueIfExists <bool>(cur, "OnSale"),
                    BetaOnly           = m_Toolbelt.GetValueIfExists <bool>(cur, "BetaOnly"),
                    BitmapSheetID      = m_Toolbelt.GetValueIfExists <string>(cur, "BitmapSheetId"),
                    Reusable           = m_Toolbelt.GetValueIfExists <bool>(cur, "Reusable"),
                    IsNew              = m_Toolbelt.GetValueIfExists <bool>(cur, "IsNew"),
                    IsDevOnly          = m_Toolbelt.GetValueIfExists <bool>(cur, "DevOnly")
                };

                shopItems[i] = shopItem;
            }

            return(shopItems);
        }
Exemplo n.º 10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (typeCase_ == TypeOneofCase.VaultItem)
            {
                hash ^= VaultItem.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Profession)
            {
                hash ^= Profession.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.MapAbility)
            {
                hash ^= MapAbility.GetHashCode();
            }
            hash ^= (int)typeCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 11
0
 public async Task UpdateAsync(VaultItem item)
 {
     await _vaultItemRepository.UpdateAsync(item);
 }
Exemplo n.º 12
0
 public async Task <VaultItem> CreateAsync(VaultItem item)
 {
     return(await _vaultItemRepository.CreateAsync(item));
 }
    protected internal override void Evaluate()
    {
        base.Evaluate();
        AILayer_ResourceManager layer = base.AIEntity.GetLayer <AILayer_ResourceManager>();

        layer.BoostersInUse.Clear();
        if (!base.AIEntity.Empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1))
        {
            for (int i = 0; i < this.departmentOfEducation.VaultCount; i++)
            {
                BoosterDefinition boosterDefinition = this.departmentOfEducation.VaultItems[i].Constructible as BoosterDefinition;
                if (boosterDefinition != null && boosterDefinition.Name == "BoosterScience")
                {
                    layer.BoostersInUse.Add(this.departmentOfEducation.VaultItems[i].GUID.ToString());
                    break;
                }
            }
        }
        this.boosterNeedsMessages.Clear();
        this.boosterNeedsMessages.AddRange(base.AIEntity.AIPlayer.Blackboard.GetMessages <CityBoosterNeeds>(BlackboardLayerID.Empire));
        for (int j = 0; j < this.boosterNeedsMessages.Count; j++)
        {
            if (this.boosterNeedsMessages[j].BoosterGuid.IsValid)
            {
                VaultItem vaultItem = this.departmentOfEducation[this.boosterNeedsMessages[j].BoosterGuid];
                if (vaultItem != null)
                {
                    StaticString staticString = vaultItem.Constructible.Name;
                    if (staticString == AIBoosterManager_CityResources.boosterCadavers)
                    {
                        staticString = AIBoosterManager_CityResources.boosterFood;
                    }
                    if (staticString == "FlamesIndustryBooster")
                    {
                        staticString = "BoosterIndustry";
                    }
                    if (this.availableBoosterByDefinitionName.ContainsKey(staticString))
                    {
                        this.availableBoosterByDefinitionName[staticString].Remove(vaultItem.GUID);
                        if (this.availableBoosterByDefinitionName[staticString].Count == 0)
                        {
                            this.availableBoosterByDefinitionName.Remove(staticString);
                        }
                    }
                    this.boosterNeedsMessages[j].AvailabilityState = CityBoosterNeeds.CityBoosterState.Available;
                }
            }
        }
        this.boosterNeedsMessages.RemoveAll((CityBoosterNeeds match) => match.AvailabilityState > CityBoosterNeeds.CityBoosterState.Pending);
        this.boosterNeedsMessages.Sort((CityBoosterNeeds left, CityBoosterNeeds right) => - 1 * left.BoosterPriority.CompareTo(right.BoosterPriority));
        for (int k = 0; k < this.boosterNeedsMessages.Count; k++)
        {
            CityBoosterNeeds cityBoosterNeeds      = this.boosterNeedsMessages[k];
            StaticString     boosterDefinitionName = cityBoosterNeeds.BoosterDefinitionName;
            if (this.availableBoosterByDefinitionName.ContainsKey(cityBoosterNeeds.BoosterDefinitionName))
            {
                int            num         = this.availableBoosterByDefinitionName[cityBoosterNeeds.BoosterDefinitionName].Count - 1;
                GameEntityGUID boosterGuid = this.availableBoosterByDefinitionName[cityBoosterNeeds.BoosterDefinitionName][num];
                this.availableBoosterByDefinitionName[cityBoosterNeeds.BoosterDefinitionName].RemoveAt(num);
                if (num == 0)
                {
                    this.availableBoosterByDefinitionName.Remove(cityBoosterNeeds.BoosterDefinitionName);
                }
                cityBoosterNeeds.BoosterGuid       = boosterGuid;
                cityBoosterNeeds.AvailabilityState = CityBoosterNeeds.CityBoosterState.Available;
                layer.BoostersInUse.Add(boosterGuid.ToString());
                this.boosterNeedsMessages.RemoveAt(k);
                k--;
            }
        }
        this.evaluableMessages.Clear();
        this.evaluableMessages.AddRange(base.AIEntity.AIPlayer.Blackboard.GetMessages <EvaluableMessage_CityBooster>(BlackboardLayerID.Empire));
        this.evaluableMessages.RemoveAll((EvaluableMessage_CityBooster match) => match.State != BlackboardMessage.StateValue.Message_InProgress || match.EvaluationState != EvaluableMessage.EvaluableMessageState.Pending || match.EvaluationState != EvaluableMessage.EvaluableMessageState.Obtaining);
        this.evaluableMessages.Sort((EvaluableMessage_CityBooster left, EvaluableMessage_CityBooster right) => - 1 * left.Interest.CompareTo(right.Interest));
        for (int l = 0; l < this.evaluableMessages.Count; l++)
        {
            EvaluableMessage_CityBooster cityBoosterEvaluableMessage = this.evaluableMessages[l];
            int num2 = this.boosterNeedsMessages.FindIndex((CityBoosterNeeds match) => match.BoosterDefinitionName == cityBoosterEvaluableMessage.BoosterDefinitionName);
            if (num2 >= 0)
            {
                CityBoosterNeeds cityBoosterNeeds2 = this.boosterNeedsMessages[num2];
                cityBoosterEvaluableMessage.Refresh(this.globalPriority, cityBoosterNeeds2.BoosterPriority, cityBoosterNeeds2.CityGuid);
                this.boosterNeedsMessages.RemoveAt(num2);
            }
            else if (cityBoosterEvaluableMessage.EvaluationState == EvaluableMessage.EvaluableMessageState.Obtaining)
            {
                cityBoosterEvaluableMessage.Refresh(0f, 0f, cityBoosterEvaluableMessage.CityGuid);
            }
            else
            {
                base.AIEntity.AIPlayer.Blackboard.CancelMessage(this.evaluableMessages[l]);
                this.evaluableMessages.RemoveAt(l);
                l--;
            }
        }
        for (int m = 0; m < this.boosterNeedsMessages.Count; m++)
        {
            CityBoosterNeeds           cityBoosterNeeds3 = this.boosterNeedsMessages[m];
            BoosterGeneratorDefinition boosterGenerator  = this.constructibleElementHelper.GetBoosterGenerator(base.AIEntity.Empire, cityBoosterNeeds3.BoosterDefinitionName);
            if (boosterGenerator != null)
            {
                EvaluableMessage_CityBooster evaluableMessage_CityBooster = new EvaluableMessage_CityBooster(cityBoosterNeeds3.CityGuid, cityBoosterNeeds3.BoosterDefinitionName, boosterGenerator.Name, 1, AILayer_AccountManager.EconomyAccountName);
                evaluableMessage_CityBooster.SetInterest(this.globalPriority, cityBoosterNeeds3.BoosterPriority);
                base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_CityBooster);
            }
        }
    }
Exemplo n.º 14
0
        public void MergeFrom(AtlasInventoryItem other)
        {
            if (other == null)
            {
                return;
            }
            switch (other.TypeCase)
            {
            case TypeOneofCase.Profile:
                if (Profile == null)
                {
                    Profile = new global::WUProtos.Data.Player.PlayerProfile();
                }
                Profile.MergeFrom(other.Profile);
                break;

            case TypeOneofCase.VaultItem:
                if (VaultItem == null)
                {
                    VaultItem = new global::WUProtos.Inventory.InventoryVaultItem();
                }
                VaultItem.MergeFrom(other.VaultItem);
                break;

            case TypeOneofCase.CollectionItem:
                if (CollectionItem == null)
                {
                    CollectionItem = new global::WUProtos.Inventory.InventoryCollectionItem();
                }
                CollectionItem.MergeFrom(other.CollectionItem);
                break;

            case TypeOneofCase.CollectionFamily:
                if (CollectionFamily == null)
                {
                    CollectionFamily = new global::WUProtos.Inventory.InventoryCollectionFamily();
                }
                CollectionFamily.MergeFrom(other.CollectionFamily);
                break;

            case TypeOneofCase.Walkbox:
                if (Walkbox == null)
                {
                    Walkbox = new global::WUProtos.Inventory.InventoryWalkboxItem();
                }
                Walkbox.MergeFrom(other.Walkbox);
                break;

            case TypeOneofCase.PlayerFlags:
                if (PlayerFlags == null)
                {
                    PlayerFlags = new global::WUProtos.Inventory.InventoryFeatureFlags();
                }
                PlayerFlags.MergeFrom(other.PlayerFlags);
                break;

            case TypeOneofCase.Portkey:
                if (Portkey == null)
                {
                    Portkey = new global::WUProtos.Inventory.InventoryPortkeyItem();
                }
                Portkey.MergeFrom(other.Portkey);
                break;

            case TypeOneofCase.PlayerActiveBuffList:
                if (PlayerActiveBuffList == null)
                {
                    PlayerActiveBuffList = new global::WUProtos.Data.Buff.ActiveBuffList();
                }
                PlayerActiveBuffList.MergeFrom(other.PlayerActiveBuffList);
                break;

            case TypeOneofCase.CollectionPage:
                if (CollectionPage == null)
                {
                    CollectionPage = new global::WUProtos.Inventory.InventoryCollectionPage();
                }
                CollectionPage.MergeFrom(other.CollectionPage);
                break;

            case TypeOneofCase.VaultCapacity:
                if (VaultCapacity == null)
                {
                    VaultCapacity = new global::WUProtos.Inventory.InventoryVaultCapacity();
                }
                VaultCapacity.MergeFrom(other.VaultCapacity);
                break;

            case TypeOneofCase.Cauldron:
                if (Cauldron == null)
                {
                    Cauldron = new global::WUProtos.Inventory.InventoryCauldron();
                }
                Cauldron.MergeFrom(other.Cauldron);
                break;

            case TypeOneofCase.EscrowedRewards:
                if (EscrowedRewards == null)
                {
                    EscrowedRewards = new global::WUProtos.Inventory.InventoryEscrowedRewards();
                }
                EscrowedRewards.MergeFrom(other.EscrowedRewards);
                break;

            case TypeOneofCase.ProfessionsProgressV3:
                if (ProfessionsProgressV3 == null)
                {
                    ProfessionsProgressV3 = new global::WUProtos.Data.Player.PlayerProfessionsProgressV3();
                }
                ProfessionsProgressV3.MergeFrom(other.ProfessionsProgressV3);
                break;

            case TypeOneofCase.QuestLog:
                if (QuestLog == null)
                {
                    QuestLog = new global::WUProtos.Inventory.InventoryQuestLog();
                }
                QuestLog.MergeFrom(other.QuestLog);
                break;

            case TypeOneofCase.Achievement:
                if (Achievement == null)
                {
                    Achievement = new global::WUProtos.Data.Player.PlayerAchievement();
                }
                Achievement.MergeFrom(other.Achievement);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Exemplo n.º 15
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (typeCase_ == TypeOneofCase.Profile)
            {
                hash ^= Profile.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.VaultItem)
            {
                hash ^= VaultItem.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.CollectionItem)
            {
                hash ^= CollectionItem.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.CollectionFamily)
            {
                hash ^= CollectionFamily.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Walkbox)
            {
                hash ^= Walkbox.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.PlayerFlags)
            {
                hash ^= PlayerFlags.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Portkey)
            {
                hash ^= Portkey.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.PlayerActiveBuffList)
            {
                hash ^= PlayerActiveBuffList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.CollectionPage)
            {
                hash ^= CollectionPage.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.VaultCapacity)
            {
                hash ^= VaultCapacity.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Cauldron)
            {
                hash ^= Cauldron.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.EscrowedRewards)
            {
                hash ^= EscrowedRewards.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.ProfessionsProgressV3)
            {
                hash ^= ProfessionsProgressV3.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.QuestLog)
            {
                hash ^= QuestLog.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Achievement)
            {
                hash ^= Achievement.GetHashCode();
            }
            hash ^= (int)typeCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 16
0
        internal void LoadVaultTree()
        {
            List <VaultItem> tree = new List <VaultItem>();

            // populate registrations
            var registration = new VaultItem {
                Name = "Registrations"
            };

            registration.Children = new List <VaultItem>();

            var reg = certifyManager.GetRegistrations();

            foreach (var r in reg)
            {
                r.ItemType = "registration";
                registration.Children.Add(r);
            }

            this.PrimaryContactEmail = registration.Children.FirstOrDefault()?.Name;

            tree.Add(registration);

            // populate identifiers
            var identifiers = new VaultItem {
                Name = "Identifiers"
            };

            identifiers.Children = new List <VaultItem>();

            var ids = certifyManager.GetIdentifiers();

            foreach (var i in ids)
            {
                i.ItemType = "identifier";
                identifiers.Children.Add(i);
            }

            tree.Add(identifiers);

            // populate identifiers
            var certs = new VaultItem {
                Name = "Certificates"
            };

            certs.Children = new List <VaultItem>();

            var certlist = certifyManager.GetCertificates();

            foreach (var i in ids)
            {
                i.ItemType = "certificate";
                certs.Children.Add(i);
            }

            tree.Add(certs);

            VaultTree = tree;

            this.ACMESummary  = certifyManager.GetAcmeSummary();
            this.VaultSummary = certifyManager.GetVaultSummary();

            RaisePropertyChanged(nameof(VaultTree));
        }
Exemplo n.º 17
0
        private static int updateRank(Player pl, bool playerWon, ArrayList otherPlayers)
        {
            int currentProgress = pl.PlayerObject.GetInt(DBProperties.RANK_PROGRESS);
            int currentRank = pl.PlayerObject.GetInt(DBProperties.RANK_NUMBER);
            int newRankProtectionCount = pl.getRankProtectionCount();

            if (pl.isGuest)
                return newRankProtectionCount;

            if (playerWon)
            {
                int amountToAdd = 1;
                int rankSum = 0;
                int plCount = 0;
                foreach (Player pla in otherPlayers)
                {
                    if (pla != pl && !(pla is NPCPlayer))
                    {
                        rankSum += pla.PlayerObject.GetInt(DBProperties.RANK_NUMBER);
                        plCount++;
                    }
                }
                int avgRank = rankSum/(plCount > 0 ? plCount : 1);
                // if (avgRank > currentRank + 5) //player defeated dude who is 5 rank points higher
                // {
                if (pl.roomLink.rand.Next(10) > 7) //30% chance to receive double progress
                {
                    amountToAdd = 2;
                }
                // }

                currentProgress += amountToAdd;
                if (currentProgress > 5)
                {
                    currentRank++;
                    currentProgress = GameConfig.RANK_PROGRESS_START;
                }
            }
            else
            {
                if (!(currentRank == 1 && currentProgress == 0)) //do nothing for 1st rank (that is absolute bottom)
                {
                    if (newRankProtectionCount > 0)
                    {
                        newRankProtectionCount--; //variable for the sake of returning result
                        var toConsume = new VaultItem[1];
                        foreach (VaultItem it in pl.PayVault.Items)
                        {
                            if (it.ItemKey == ShopItemsInfo.ARMOR_ITEM)
                            {
                                toConsume[0] = it;
                                break;
                            }
                        }
                        pl.PayVault.Consume(toConsume, delegate { Console.WriteLine("Protection item consumed!"); },
                            pl.roomLink.handleError);
                    }
                    else
                    {
                        if (currentProgress == 0)
                        {
                            currentProgress = GameConfig.RANK_PROGRESS_START;
                            currentRank--;
                        }
                        else
                        {
                            currentProgress--;
                        }
                    }
                }
            }

            pl.PlayerObject.Set(DBProperties.RANK_NUMBER, currentRank);
            pl.PlayerObject.Set(DBProperties.RANK_PROGRESS, currentProgress);

            return newRankProtectionCount;
        }