private bool Equals(ChordPattern other)
 {
     return(string.Equals(Name, other.Name) &&
            string.Equals(Abbreviation, other.Abbreviation) &&
            Ascent.SequenceEqual(other.Ascent) &&
            LetterOffsets.SequenceEqual(other.LetterOffsets));
 }
 public string GetAttributeValue()
 {
     return($"speed,{String.Join(",", SpeedConsumptionPairs.Select(s => s.GetAttributeValue()).ToArray())}" +
            $";ascent,{Ascent.ToString(HereAPISession.Culture)}" +
            $";descent,{Descent.ToString(HereAPISession.Culture)}" +
            $"{(TimePenalty != null ? "" : $";timePenalty,{TimePenalty.Value.ToString(HereAPISession.Culture)}")}" +
            $"{(AuxiliaryConsumption != null ? "" : $";auxiliaryConsumption,{AuxiliaryConsumption.Value.ToString(HereAPISession.Culture)}")}" +
            $"{(Acceleration != null ? "" : $";acceleration,{Acceleration.Value.ToString(HereAPISession.Culture)}")}" +
            $"{(Deceleration != null ? "" : $";deceleration,{Deceleration.Value.ToString(HereAPISession.Culture)}")}");
 }
 /// <summary>
 ///     Hash code.
 /// </summary>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Name?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (Abbreviation?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Ascent?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (LetterOffsets?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Example #4
0
        public void Init()
        {
            ship = new Ship(GridTerminalSystem, GridTerminalSystem.GetBlockWithName(controllerblockname) as IMyShipController, this);
            var comms = GridTerminalSystem.GetBlockWithName(commantenna) as IMyRadioAntenna;

            if (comms != null)
            {
                ship.Communications.Initialize(comms);
            }
            h = new Ascent(ship);
            h.Initialize();
            // h.Initialize(GridTerminalSystem.GetBlockWithName(dockingconnectorname) as IMyShipConnector);
            ship.CustomModules.Add(h);
            ship.Initialize();
        }
        public void TestInsert()
        {
            // Arrange
            var repo           = new ClimbingRoutesRepository <Ascent>(TestHelpers.GetNewContext());
            var initalExpected = 4;
            var finalExpected  = 5;
            var ascent         = new Ascent()
            {
                ClimberId = 2,
                RouteId   = 1,
                StyleId   = 2,
                Date      = new System.DateTime(year: 2019, month: 10, day: 18)
            };

            // Act
            var initial = repo.All().Count();

            repo.Insert(ascent);
            var final = repo.All().Count();

            // Assert
            Assert.Equal(initalExpected, initial);
            Assert.Equal(finalExpected, finalExpected);
        }
Example #6
0
        private Api.Common.DataEntities.Ascent HandleScore(Score score)
        {
            currentScoreId = Convert.ToInt32(score.Id);

            ind++;

            if (ind % 10000 == 0)
            {
                Console.Write(". " + (++logTimes * 10000).ToString("#,##0"));
                Console.WriteLine("crags: {0}, sectors: {1}, b: {2}, r: {3}, a: {4}", new object[] {
                    SeedStore.CragCount, SeedStore.SectorCount, SeedStore.BoulderCount, SeedStore.RouteCount,
                    SeedStore.AscentCount
                });
            }
            else if (ind % 10000 == 0)
            {
                Console.Write(".");
            }

            // todo: unicode crag name, look for &234 without ; and remove spaces
            // todo: only do the unicode check if we create a new one
            // todo: find out does old 8a get routes difficulty from the first ascent in score DB?

            Crag      crag    = null;
            Sector    sector  = null;
            Zlaggable thingie = null;

            var scoreHasCountry            = false;
            var scoreHasRouteOrBoulderName = false;
            var scoreHasCragName           = false;
            var scoreHasSectorName         = false;

            var cragName   = getValue(score.Crag, "Unknown Crag", out scoreHasCragName);
            var sectorName = getValue(score.CragSector, "Unknown Sector", out scoreHasSectorName);
            var routeName  = getValue(score.Name, "Unknown ", out scoreHasRouteOrBoulderName);

            if (!scoreHasRouteOrBoulderName)
            {
                var ending = score.What == 0 ? "route" : "boulder";
                routeName += ending;
            }
            var verticalCategory       = score.What == 0 ? SeedStore.CATEGORY_SPORTSCLIMBING : SeedStore.CATEGORY_BOULDERING;
            var verticalAscentCategory = score.What == 0 ? SeedStore.ASCENT_CATEGORY_ROUTE : SeedStore.ASCENT_CATEGORY_BOULDER;
            var scoreHasCrag           = false;
            var scoreHasSector         = false;
            var scoreHasRouteOrBoulder = false;
            var countryId = -1;

            // get user
            var user = SeedStore.GetUser(Convert.ToInt32(score.UserId));

            if (user == null)
            {
                Console.WriteLine("score id: " + score.Id.ToString() + " USER DatabaseId: " + score.UserId.ToString() + " NOT FOUND!");
                return(null);
            }

            //
            // get country - default to users country
            //
            var countryISO3 = score.Country;

            try
            {
                if (!string.IsNullOrEmpty(countryISO3))
                {
                    countryId       = SeedStore.GetCountryId(score.Country);
                    scoreHasCountry = true;
                }
                else
                {
                    // if scores country is null, get users country
                    // this will be used if we create new crag
                    countryId = user.CountryId;
                }
            }
            catch
            {
                Console.WriteLine("trouble getting country for score id: " + score.Id + " - countryISO3: " + countryISO3);
                countryId = user.CountryId;
            }

            if (scoreHasCragName)
            {
                // get crag by name only
                crag = SeedStore.GetCragOnlyByName(score.Crag, verticalCategory);
            }
            else
            {
                crag = SeedStore.GetCrag(cragName, verticalCategory, countryId);
            }

            /*
             * // get existing crag
             * if (scoreHasCountry && scoreHasCragName)
             * {
             *  // look for crag first by country
             *  crag = SeedStore.GetCrag(score.Crag, verticalCategory, countryId);
             *
             *  scoreHasCrag |= crag != null;
             *
             *  // todo:
             *  // optional: get existing crag with different category
             * }
             * else if (scoreHasCragName)
             * {
             *  // score has no country defined .. so we just look for the crag name
             *  crag = SeedStore.GetCragOnlyByName(score.Crag, verticalCategory);
             * }
             */


            // im here with my performance tests:
            // return null;

            // create crag if we still don't have one
            if (crag == null)
            {
                var cragId = ++SeedStore.MaxCragId;
                var now    = DateTime.Now;
                crag = new Crag
                {
                    Id           = cragId,
                    Slug         = cragName.ToSlug(postString: cragId.ToString()),
                    Category     = verticalCategory,
                    Name         = cragName,
                    CountryId    = countryId,
                    DateCreated  = now,
                    DateModified = now,
                    Published    = true
                };
                SeedStore.AddCrag(crag);
            }

            // get existing sector if score happens to have a crag
            //if (scoreHasCrag)
            //{
            sector          = SeedStore.GetSector(crag.Id.Value, sectorName);
            scoreHasSector |= sector != null;
            //}

            // create sector if nothing found
            if (sector == null)
            {
                var now = DateTime.Now;
                // create new sector
                var sectorId = ++SeedStore.MaxSectorId;
                sector = new Sector
                {
                    Id           = sectorId,
                    Slug         = "",
                    CragId       = crag.Id.Value,
                    Name         = sectorName,
                    Category     = verticalCategory,
                    DateCreated  = now,
                    DateModified = now
                };
                SeedStore.AddSector(sector);
            }

            // only try to get existing "climbablethingie" if there is already a sector
            //if (scoreHasSector)
            //{
            thingie = SeedStore.GetThingie(sector.Id.Value, routeName, score.What);
            scoreHasRouteOrBoulder |= thingie != null;
            //}

            // get grading system to be used for using with route/boulder and ascent
            var gradingSystem = getGradingSystem(score.Grade, score.What);

            // no thingie (route or boulder) so we make new one
            if (thingie == null)
            {
                var now = DateTime.Now;
                if (score.What == 0) // could check for category but let's speed things up
                {
                    //if (!scoreHasRouteOrBoulderName)
                    //{
                    //    routeName += "route";
                    //}

                    var routeId = ++SeedStore.MaxRouteId;
                    thingie = new Route
                    {
                        Id       = routeId,
                        Name     = routeName,
                        Slug     = "",
                        SectorId = sector.Id.Value
                    };
                    SeedStore.AddRoute(thingie);
                }
                else
                {
                    //if (!scoreHasRouteOrBoulderName)
                    //{
                    //    routeName += "boulder";
                    //}
                    var boulderId = ++SeedStore.MaxBoulderId;
                    thingie = new Boulder
                    {
                        Id       = boulderId,
                        Name     = routeName,
                        Slug     = "",
                        SectorId = sector.Id.Value
                    };
                    SeedStore.AddBoulder(thingie);
                }
                thingie.DateCreated   = now;
                thingie.DateModified  = now;
                thingie.Difficulty    = gradingSystem.Grade;   // 6a+
                thingie.Grade         = gradingSystem.VLGrade; // vl-1-39
                thingie.GradingSystem = gradingSystem.Type;    // french
            }

            SeedStore.AddGrade(thingie.Id.Value, gradingSystem, score.What == 0 ? ZlaggableCategoryEnum.Sportclimbing : ZlaggableCategoryEnum.Bouldering);


            var objectClassLength = score.ObjectClass.Length;
            // comparing lenghts so it's a bit faster
            // lengths
            // 14 = CLS_UserAscent
            // 22 = CLS_UserAscent_Project
            // 18 = CLS_UserAscent_Try


            var type = "";

            if (objectClassLength != 18)
            {
                type = getVerticalAscentType(score.How);
            }
            else
            {
                type = "go";
            }

            var isProject = objectClassLength == 22;

            // create ascent
            var ascent = new Ascent
            {
                Id                 = ++SeedStore.MaxAscentId,
                UserId             = user.Id.Value,
                Date               = ParseScoreDate(score.Date), // climbed that shit date
                Difficulty         = gradingSystem.Grade,        // eg. 8a+
                ZlaggableId        = thingie.Id,                 // ID of route or boulder
                ZlaggableType      = verticalAscentCategory,     // route / boulder
                Comment            = score.Comment,              // user comment
                Score              = score.TotalScore,
                Type               = type,                       // f, os, tr, rp, go
                Rating             = score.Rate,
                Repeat             = score.Repeat == 1 ? true : false,
                Project            = isProject,
                Chipped            = score.Chipped == 1,
                ExcludeFromRanking = score.ExcludeFromRanking == 1,
                Note               = Convert.ToInt32(score.Fa),
                DateCreated        = score.RecDate,
                DateModified       = score.RecDate,
                Recommended        = score.UserRecommended == 1,
                LegacyId           = (int)score.Id

                                     // todo: userRecommended to Route "likes"
                                     // todo: what to do with projectAscentDate?
                                     // todo: what to do with YellowId

                                     // variations -> not used
                                     // steepness -> not used
                                     // altgrade -> not used
            };

            //SeedStore.Ascents.Add(ascent);
            return(ascent);
        }
Example #7
0
 Ascent           = Max(Ascent, display.Ascent, ascender);
Example #8
0
 public static void AddAscent(Ascent ascent)
 {
     AscentCount++;
     Ascents.Add(ascent);
 }