Пример #1
0
        /// <summary>
        /// Gets the village at the specified location
        /// </summary>
        public Village GetVillage(Point location)
        {
            Village village;

            Villages.TryGetValue(location, out village);
            return(village);
        }
Пример #2
0
 public void Include(EntityData otherData)
 {
     Alerts.AddRange(otherData.Alerts);
     EmailAlertRecipients.AddRange(otherData.EmailAlertRecipients);
     SmsAlertRecipients.AddRange(otherData.SmsAlertRecipients);
     AlertReports.AddRange(otherData.AlertReports);
     AlertRules.AddRange(otherData.AlertRules);
     ApplicationLanguages.AddRange(otherData.ApplicationLanguages);
     ContentLanguages.AddRange(otherData.ContentLanguages);
     Countries.AddRange(otherData.Countries);
     DataCollectors.AddRange(otherData.DataCollectors);
     Districts.AddRange(otherData.Districts);
     GatewaySettings.AddRange(otherData.GatewaySettings);
     HeadManagerConsents.AddRange(otherData.HeadManagerConsents);
     HealthRisks.AddRange(otherData.HealthRisks);
     HealthRiskLanguageContents.AddRange(otherData.HealthRiskLanguageContents);
     Localizations.AddRange(otherData.Localizations);
     LocalizedTemplates.AddRange(otherData.LocalizedTemplates);
     NationalSocieties.AddRange(otherData.NationalSocieties);
     Notifications.AddRange(otherData.Notifications);
     Projects.AddRange(otherData.Projects);
     SupervisorUserProjects.AddRange(otherData.SupervisorUserProjects);
     ProjectHealthRisks.AddRange(otherData.ProjectHealthRisks);
     RawReports.AddRange(otherData.RawReports);
     Regions.AddRange(otherData.Regions);
     Reports.AddRange(otherData.Reports);
     Users.AddRange(otherData.Users);
     UserNationalSocieties.AddRange(otherData.UserNationalSocieties);
     Villages.AddRange(otherData.Villages);
     Zones.AddRange(otherData.Zones);
 }
Пример #3
0
    //Activates/displays loading panel while villages are being loaded into a list
    void Start()
    {
        loadingPanel.SetActive(true);
        // Set up the Editor before calling into the realtime database.
        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://finalprojectunity-31171.firebaseio.com//");
        // Get the root reference location of the database.
        reference = FirebaseDatabase.DefaultInstance.RootReference;

        locationStringsAL = new List <Villages>();
        FirebaseDatabase.DefaultInstance.GetReference("villages").GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                // Handle the error...
            }
            else if (task.IsCompleted)
            {
                DataSnapshot dataSnapshot = task.Result;
                // Do something with snapshot...
                foreach (DataSnapshot s in dataSnapshot.Children)
                {
                    //Debug.Log("Here: " + s.Child("email").Value + " " + s.Child("lat").Value + " " + s.Child("lng").Value);
                    //Villages vil = new Villages(s.Child("email").Value.ToString(), s.Child("lat").Value.ToString(), s.Child("lng").Value.ToString(), s.Child("id").Value.ToString());
                    Villages vil = new Villages(s.Child("email").Value.ToString(), s.Child("lat").Value.ToString(), s.Child("lng").Value.ToString(), s.Child("id").Value.ToString(), s.Child("size").Value.ToString());
                    locationStringsAL.Add(vil);
                }
                Debug.Log("Done Inside Firebase !!");
                loadDone = true;
            }
        });
    }
Пример #4
0
        private void VillagesJoined(CocApi cocApi, ClanApiModel downloadedClan)
        {
            List <ClanVillageApiModel> newVillages = new List <ClanVillageApiModel>();

            if (downloadedClan.Villages == null)
            {
                return;
            }

            //if (Villages == null)
            //{
            //    Villages = new List<ClanVillageApiModel>();
            //}

            foreach (ClanVillageApiModel clanVillage in downloadedClan.Villages)
            {
                if (!Villages?.Any(m => m.VillageTag == clanVillage.VillageTag) == true)
                {
                    newVillages.Add(clanVillage);

                    //Villages.Add(clanVillage);
                }
            }

            cocApi.VillagesJoinedEvent(this, newVillages);
        }
Пример #5
0
 public Company(CompanyParam companyParam)
 {
     this.Name     = companyParam.Name;
     this.Address  = companyParam.Address;
     this.Username = companyParam.Username;
     this.Password = companyParam.Password;
     this.villages = companyParam.villages;
 }
Пример #6
0
 /// <summary>
 ///     Gets the village by searching it's id value.
 /// </summary>
 /// <param name="id">Village id.</param>
 /// <returns>Return the village if that village is found with given id value.</returns>
 public Village GetVillage(int id)
 {
     if (Villages.ContainsKey(id))
     {
         return(Villages[id]);
     }
     return(null);
 }
Пример #7
0
 public virtual void Update(CompanyParam companyParam)
 {
     this.Id       = companyParam.Id;
     this.Name     = companyParam.Name;
     this.Address  = companyParam.Address;
     this.Username = companyParam.Username;
     this.Password = companyParam.Password;
     this.villages = companyParam.villages;
 }
Пример #8
0
    //Method to create a village for the player, this is attached a button that is only available if the player does not have a village
    //Once village is created (and database updated) the edit village scene is loaded
    public void CreateVillage()
    {
        if (PlayerCheck.isCollidingNow())
        {
            //Show Toast
            WorldSceneToastMaker.showToast("You cannot build here as you are in an enemy zone", 2);
            return;
        }
        String id = vilRef.Push().Key;

        //Debug.Log(reference);
        //Debug.Log(reference.Child("villages"));
        //Debug.Log(id);
        String[] loc = location.text.Split(',');//lng then lat
        double   lat = Convert.ToDouble(loc[1]);
        double   lng = Convert.ToDouble(loc[0]);
        Villages vil = new Villages(user.Email, lat, lng, id);
        //reference.Child("villages").Child(key).Child("User").SetValueAsync(email);
        //vilRef.Child(id).Child("User").SetValueAsync(email);

        /*
         *  string json = JsonUtility.ToJson(user);
         *
         * mDatabaseRef.Child("users").Child(userId).SetRawJsonValueAsync(json);
         */
        String json = JsonUtility.ToJson(vil);

        vilRef.Child(id).SetRawJsonValueAsync(json);


        FirebaseDatabase.DefaultInstance.GetReference("users").GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                // Handle the error...
            }
            else if (task.IsCompleted)
            {
                DataSnapshot dataSnapshot = task.Result;
                // Do something with snapshot...
                foreach (DataSnapshot s in dataSnapshot.Children)
                {
                    if (user.Email.Equals(s.Child("email").Value.ToString()))
                    {
                        //Debug.Log("Here: " + s.Child("email").Value + " " + s.Child("id").Value + " " + s.Child("villageID").Value + " " + s.Child("balance").Value);
                        //Villages vil = new Villages(s.Child("email").Value.ToString(), s.Child("lat").Value.ToString(), s.Child("lng").Value.ToString());
                        Accounts acc = new Accounts(s.Child("email").Value.ToString(), s.Child("id").Value.ToString(), int.Parse(s.Child("balance").Value.ToString()), id);
                        json         = JsonUtility.ToJson(acc);
                        reference.Child("users").Child(s.Child("id").Value.ToString()).SetRawJsonValueAsync(json);
                    }
                }
            }
        });

        //Change scene
        //SceneManager.LoadSceneAsync(2);
        Scenes.Load("BuildScene - Copy", "villageID", id);
    }
Пример #9
0
 public CompanyParam(Company company)
 {
     Id       = company.Id;
     Name     = company.Name;
     Address  = company.Address;
     Username = company.Username;
     Password = company.Password;
     villages = company.villages;
 }
Пример #10
0
        public bool Add(string token, int UserID, Villages vil)
        {
            User us = _db.Users.SingleOrDefault(m => m.token == token);

            if (CheckOutUser(token, UserID, us))
            {
                us.Villages.Add(vil);
                _db.Users.Update(us);
                _db.SaveChanges();
                return(true);
            }
            return(false);
        }
Пример #11
0
        /// <summary>
        ///     Adds a new village to player's villages.
        ///     Fires a new village added event.
        /// </summary>
        /// <param name="id">Village id.</param>
        public void AddVillage(Village v)
        {
            if (Villages.ContainsKey(v.Id))
            {
                return;
            }

            Villages.Add(v.Id, v);
            Logger.Trace("{0}, new village added to me.", this);

            if (VillageAdded != null)
            {
                VillageAdded.Invoke(v);
            }
        }
Пример #12
0
        /// <summary>
        /// Removes a village.
        /// </summary>
        /// <param name="id">Village id.</param>
        public void RemoveVillage(int id)
        {
            if (!Villages.ContainsKey(id))
            {
                return;
            }

            Village v = Villages[id];

            Villages.Remove(id);

            if (VillageRemoved != null)
            {
                VillageRemoved.Invoke(v);
            }
        }
 public VVillages Add(VVillages village)
 {
     using (_context)
     {
         var newvillage = new Villages()
         {
             WardID  = village.Wardid,
             Village = village.Village,
             Active  = true
         };
         _context.Villages.Add(newvillage);
         _context.SaveChanges();
         village.ID = newvillage.ID;
         //village.Subcountyid = newvillage.Wards.SubCountyID;
         //village.Countyid = newvillage.Wards.SubCounties.CountyID;
         return(village);
     }
 }
Пример #14
0
        public string BbCodeExtended(int minFilter, Village selectedVillage, bool showTribe)
        {
            List <Village> villages = Villages.FindAll(vil => vil.Points > minFilter);

            // Build it
            var str = new StringBuilder(100);

            str.Append(BbCode());
            if (HasTribe && showTribe)
            {
                str.Append(Environment.NewLine + string.Format("{0}", Tribe.BbCode()));
            }
            if (villages.Count > 1)
            {
                str.Append(Environment.NewLine + "[b]Villages[/b][quote]");
            }
            villages.Sort();
            bool isFirst = true;

            foreach (Village vil in villages)
            {
                if (!isFirst || Villages.Count == 1)
                {
                    str.AppendLine();
                }
                else
                {
                    isFirst = false;
                }
                if (selectedVillage != null && vil == selectedVillage)
                {
                    str.AppendFormat("---> {0} <---", vil.BbCode());
                }
                else
                {
                    str.Append(vil.BbCode());
                }
            }
            if (villages.Count > 1)
            {
                str.Append("[/quote]");
            }
            return(str.ToString());
        }
Пример #15
0
        private void CalculateConquers(Player previous)
        {
            GainedVillages.Clear();
            foreach (Village vil in Villages)
            {
                if (!previous.Villages.Contains(vil))
                {
                    GainedVillages.Add(vil);
                }
            }

            LostVillages.Clear();
            foreach (Village vil in previous.Villages)
            {
                if (!Villages.Contains(vil))
                {
                    LostVillages.Add(vil);
                }
            }
        }
Пример #16
0
        public INyssContext GetNyssContextMock()
        {
            var nyssContextMock = Substitute.For <INyssContext>();

            var nationalSocietiesDbSet  = NationalSocieties.AsQueryable().BuildMockDbSet();
            var healthRisksDbSet        = HealthRisks.AsQueryable().BuildMockDbSet();
            var alertRulesDbSet         = AlertRules.AsQueryable().BuildMockDbSet();
            var projectsDbSet           = Projects.AsQueryable().BuildMockDbSet();
            var projectHealthRisksDbSet = ProjectHealthRisks.AsQueryable().BuildMockDbSet();
            var dataCollectorsDbSet     = DataCollectors.AsQueryable().BuildMockDbSet();
            var reportsDbSet            = Reports.AsQueryable().BuildMockDbSet();
            var rawReportsDbSet         = RawReports.AsQueryable().BuildMockDbSet();
            var usersDbSet = Users.AsQueryable().BuildMockDbSet();
            var supervisorUserProjectsDbSet = SupervisorUserProjects.AsQueryable().BuildMockDbSet();
            var userNationalSocietiesDbSet  = UserNationalSocieties.AsQueryable().BuildMockDbSet();
            var regionsDbSet   = Regions.AsQueryable().BuildMockDbSet();
            var districtsDbSet = Districts.AsQueryable().BuildMockDbSet();
            var villagesDbSet  = Villages.AsQueryable().BuildMockDbSet();
            var zonesDbSet     = Zones.AsQueryable().BuildMockDbSet();
            var alertsDbSet    = Alerts.AsQueryable().BuildMockDbSet();

            nyssContextMock.NationalSocieties.Returns(nationalSocietiesDbSet);
            nyssContextMock.HealthRisks.Returns(healthRisksDbSet);
            nyssContextMock.AlertRules.Returns(alertRulesDbSet);
            nyssContextMock.Projects.Returns(projectsDbSet);
            nyssContextMock.ProjectHealthRisks.Returns(projectHealthRisksDbSet);
            nyssContextMock.DataCollectors.Returns(dataCollectorsDbSet);
            nyssContextMock.Reports.Returns(reportsDbSet);
            nyssContextMock.RawReports.Returns(rawReportsDbSet);
            nyssContextMock.Users.Returns(usersDbSet);
            nyssContextMock.SupervisorUserProjects.Returns(supervisorUserProjectsDbSet);
            nyssContextMock.UserNationalSocieties.Returns(userNationalSocietiesDbSet);
            nyssContextMock.Regions.Returns(regionsDbSet);
            nyssContextMock.Districts.Returns(districtsDbSet);
            nyssContextMock.Villages.Returns(villagesDbSet);
            nyssContextMock.Zones.Returns(zonesDbSet);
            nyssContextMock.Alerts.Returns(alertsDbSet);

            return(nyssContextMock);
        }
Пример #17
0
        //private void UpdateVillages(ClanApiModel downloadedClan)
        //{
        //    foreach (ClanVillageApiModel oldClanVillage in Villages.EmptyIfNull())
        //    {
        //        ClanVillageApiModel newClanVillage = downloadedClan.Villages.FirstOrDefault(m => m.VillageTag == oldClanVillage.VillageTag);

        //        if (newClanVillage == null) { continue; }

        //        oldClanVillage.League = newClanVillage.League;

        //        oldClanVillage.Name = newClanVillage.Name;

        //        oldClanVillage.Role = newClanVillage.Role;

        //        oldClanVillage.ExpLevel = newClanVillage.ExpLevel;

        //        oldClanVillage.ClanRank = newClanVillage.ClanRank;

        //        oldClanVillage.PreviousClanRank = newClanVillage.PreviousClanRank;

        //        oldClanVillage.Donations = newClanVillage.Donations;

        //        oldClanVillage.DonationsReceived = newClanVillage.DonationsReceived;

        //        oldClanVillage.Trophies = newClanVillage.Trophies;

        //        oldClanVillage.VersusTrophies = newClanVillage.VersusTrophies;
        //    }

        //}

        private void AnnounceDonations(CocApi cocApi, ClanApiModel downloadedClan)
        {
            Dictionary <string, Tuple <ClanVillageApiModel, int> > receiving = new Dictionary <string, Tuple <ClanVillageApiModel, int> >();

            Dictionary <string, Tuple <ClanVillageApiModel, int> > donating = new Dictionary <string, Tuple <ClanVillageApiModel, int> >();

            foreach (ClanVillageApiModel oldClanVillage in Villages.EmptyIfNull())
            {
                ClanVillageApiModel?newClanVillage = downloadedClan.Villages.FirstOrDefault(m => m.VillageTag == oldClanVillage.VillageTag);

                if (newClanVillage == null)
                {
                    continue;
                }

                if (oldClanVillage.DonationsReceived < newClanVillage.DonationsReceived)
                {
                    receiving.Add(oldClanVillage.VillageTag, Tuple.Create(oldClanVillage, newClanVillage.DonationsReceived));
                }

                if (oldClanVillage.Donations < newClanVillage.Donations)
                {
                    donating.Add(oldClanVillage.VillageTag, Tuple.Create(oldClanVillage, newClanVillage.Donations));
                }

                bool resetSent = false;

                if (!resetSent && oldClanVillage.DonationsReceived > newClanVillage.DonationsReceived || oldClanVillage.Donations > newClanVillage.Donations)
                {
                    cocApi.ClanDonationsResetEvent(this, downloadedClan);

                    resetSent = true;
                }
            }

            cocApi.ClanDonationsEvent(receiving, donating);
        }
Пример #18
0
        private void AnnounceVillageChanges(CocApi cocApi, ClanApiModel downloadedClan)
        {
            Dictionary <string, Tuple <ClanVillageApiModel, VillageLeagueApiModel> > leagueChanges = new Dictionary <string, Tuple <ClanVillageApiModel, VillageLeagueApiModel> >();

            Dictionary <string, Tuple <ClanVillageApiModel, Role> > roleChanges = new Dictionary <string, Tuple <ClanVillageApiModel, Role> >();


            foreach (ClanVillageApiModel oldClanVillage in Villages.EmptyIfNull())
            {
                ClanVillageApiModel newClanVillage = downloadedClan.Villages.FirstOrDefault(m => m.VillageTag == oldClanVillage.VillageTag);

                if (newClanVillage == null)
                {
                    continue;
                }

                if ((oldClanVillage.League == null && newClanVillage.League != null) || (oldClanVillage.League != null && newClanVillage.League != null && oldClanVillage.League.Id != newClanVillage.League.Id))
                {
                    leagueChanges.Add(oldClanVillage.VillageTag, Tuple.Create(oldClanVillage, newClanVillage.League));
                }

                if (oldClanVillage.Name != newClanVillage.Name)
                {
                    cocApi.ClanVillageNameChangedEvent(oldClanVillage, newClanVillage.Name);
                }

                if (oldClanVillage.Role != newClanVillage.Role)
                {
                    roleChanges.Add(oldClanVillage.VillageTag, Tuple.Create(oldClanVillage, newClanVillage.Role));
                }
            }

            cocApi.ClanVillagesLeagueChangedEvent(leagueChanges);

            cocApi.ClanVillagesRoleChangedEvent(roleChanges);
        }
Пример #19
0
        private void VillagesLeft(CocApi cocApi, ClanApiModel downloadedClan)
        {
            List <ClanVillageApiModel> leftVillages = new List <ClanVillageApiModel>();

            //if (Villages == null)
            //{
            //    return;
            //}

            foreach (ClanVillageApiModel clanVillage in Villages.EmptyIfNull())
            {
                if (!downloadedClan.Villages.Any(m => m.VillageTag == clanVillage.VillageTag))
                {
                    leftVillages.Add(clanVillage);
                }
            }

            foreach (ClanVillageApiModel clanVillage in leftVillages)
            {
                //Villages.Remove(clanVillage);
            }

            cocApi.VillagesLeftEvent(this, leftVillages);
        }
Пример #20
0
 /// <summary>
 /// Adds a village to the player
 /// </summary>
 public void AddVillage(Village village)
 {
     Villages.Add(village);
 }
Пример #21
0
        public string BbCodeMatt()
        {
            // TODO: not translated
            // Build it
            var str = new StringBuilder(100);

            str.Append("[b]");
            if (HasTribe)
            {
                str.AppendFormat("[ally]{0}[/ally] " + ControlsRes.PlayerOperation_Target + ": {1}", Tribe.Tag, BbCode());
            }
            else
            {
                str.Append(BbCode());
            }

            //http://nl.twstats.com/image.php?type=playerssgraph&id=661959&s=nl10&graph=points
            str.AppendLine();
            string link = string.Format(World.Default.Settings.TwStats.Player, Id);

            str.AppendFormat("[url={0}]TWStats Link[/url]", link);

            str.AppendLine();
            str.AppendLine();

            link = string.Format(World.Default.Settings.TwStats.PlayerGraph, Id, World.TwStatsLinks.Graphs.points);
            str.AppendFormat("[img]{0}[/img]", link);

            link = string.Format(World.Default.Settings.TwStats.PlayerGraph, Id, World.TwStatsLinks.Graphs.rank);
            str.AppendFormat("[img]{0}[/img]", link);

            str.AppendLine();

            link = string.Format(World.Default.Settings.TwStats.PlayerGraph, Id, World.TwStatsLinks.Graphs.odd);
            str.AppendFormat("[img]{0}[/img]", link);

            link = string.Format(World.Default.Settings.TwStats.PlayerGraph, Id, World.TwStatsLinks.Graphs.villages);
            str.AppendFormat("[img]{0}[/img]", link);

            str.AppendLine();
            str.AppendLine();

            Villages.Sort(new Village.VillageComparer());
            int cnt = 0;

            string[] players   = { }; // "rogier1986;edgile;kezmania;floris 5;ruuuler;belgium4ever;hoendroe;sjarlowitsky;unusually talented".Split(';');
            int      seperator = 0;

            if (players.Length > 0)
            {
                seperator = Convert.ToInt32(Math.Floor((decimal)Villages.Count / players.Length));
            }

            int currentPlayer = 0;

            foreach (Village vil in Villages)
            {
                if (cnt != 0 || Villages.Count == 1)
                {
                    str.AppendLine();
                }
                if (seperator > 0 && cnt % seperator == 0 && players.Length > currentPlayer + 1)
                {
                    currentPlayer++;
                    str.AppendLine();
                    str.AppendLine();
                    str.AppendLine(players[currentPlayer]);
                }

                cnt++;
                str.AppendFormat("{0} {1}: ", cnt, vil.BbCode());

                if (cnt % 240 == 0)
                {
                    str.AppendLine("[/b]");
                    str.AppendLine();
                    str.AppendLine();
                    str.AppendLine();
                    str.AppendLine(ControlsRes.PlayerOperation_NextPart);

                    if (players.Length > currentPlayer)
                    {
                        str.AppendLine("[b]" + players[currentPlayer]);
                    }
                    else
                    {
                        str.AppendLine("[b]");
                    }
                }
            }
            str.AppendLine();
            str.Append("[/b]");
            return(str.ToString());
        }