Example #1
0
    public ScoreDetails CalculateScore()
    {
        // TODO return Score objects with detailed statistical information
        var score = new ScoreDetails();

        return(score);
    }
        private static ScoreDetails GetScoreDetails(WorldFootballScore wfscore, ScoreParameter[] parameters)
        {
            string competition = ScoreCenter.GetParameter(parameters, "WF.Competition", KEY_COMPETITION);
            string home        = Tools.ParseUrl(String.Format("{0}{2}/{1}/", WF_URL, wfscore.FullLeagueName, competition), parameters);
            string html        = s_cache.GetScore(home, "", true);

            ScoreDetails details = new ScoreDetails(wfscore, parameters);

            // get round
            string regex = ScoreCenter.GetParameter(parameters, "WF.RoundRegEx", ROUND_REGEX);
            Regex  re    = new Regex(regex);
            Match  fm    = re.Match(html);
            int    round = 0;

            int.TryParse(fm.Groups["round"].Value, out round);
            details.Round = round;

            // get items
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.OptionReadEncoding = false;
            doc.LoadHtml(html);
            HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//div[@class='navibox2']//li/a");

            if (nodes == null)
            {
                throw new ArgumentException("div with class 'navibox2' not found, check site adress and WF.Competition parameter.");
            }
            foreach (var node in nodes)
            {
                details.AddDetail(node.InnerHtml, node.GetAttributeValue("href", ""));
            }

            return(details);
        }
        public static ScoreDetails operator +(ScoreDetails scoreDetails1, ScoreDetails scoreDetails2)
        {
            ScoreDetails scoreDetails = new ScoreDetails();

            scoreDetails.ImmediatelyPoints           = scoreDetails1.ImmediatelyPoints + scoreDetails2.ImmediatelyPoints;
            scoreDetails.WallLength                  = scoreDetails1.WallLength + scoreDetails2.WallLength;
            scoreDetails.Pavilion                    = scoreDetails1.Pavilion + scoreDetails2.Pavilion;
            scoreDetails.Seraglio                    = scoreDetails1.Seraglio + scoreDetails2.Seraglio;
            scoreDetails.Arcades                     = scoreDetails1.Arcades + scoreDetails2.Arcades;
            scoreDetails.Chambers                    = scoreDetails1.Chambers + scoreDetails2.Chambers;
            scoreDetails.Garden                      = scoreDetails1.Garden + scoreDetails2.Garden;
            scoreDetails.Tower                       = scoreDetails1.Tower + scoreDetails2.Tower;
            scoreDetails.BuildingsBonuses            = scoreDetails1.BuildingsBonuses + scoreDetails2.BuildingsBonuses;
            scoreDetails.TheCityWatch                = scoreDetails1.TheCityWatch + scoreDetails2.TheCityWatch;
            scoreDetails.Camps                       = scoreDetails1.Camps + scoreDetails2.Camps;
            scoreDetails.StreetTraders               = scoreDetails1.StreetTraders + scoreDetails2.StreetTraders;
            scoreDetails.TreasureChamber             = scoreDetails1.TreasureChamber + scoreDetails2.TreasureChamber;
            scoreDetails.Invaders                    = scoreDetails1.Invaders + scoreDetails2.Invaders;
            scoreDetails.Bazaars                     = scoreDetails1.Bazaars + scoreDetails2.Bazaars;
            scoreDetails.ArtOfTheMoors               = scoreDetails1.ArtOfTheMoors + scoreDetails2.ArtOfTheMoors;
            scoreDetails.Falconers                   = scoreDetails1.Falconers + scoreDetails2.Falconers;
            scoreDetails.Watchtowers                 = scoreDetails1.Watchtowers + scoreDetails2.Watchtowers;
            scoreDetails.Medina                      = scoreDetails1.Medina + scoreDetails2.Medina;
            scoreDetails.BuildingsWithoutServantTile = scoreDetails1.BuildingsWithoutServantTile + scoreDetails2.BuildingsWithoutServantTile;
            scoreDetails.Orchards                    = scoreDetails1.Orchards + scoreDetails2.Orchards;
            scoreDetails.Bathhouses                  = scoreDetails1.Bathhouses + scoreDetails2.Bathhouses;
            scoreDetails.WishingWells                = scoreDetails1.WishingWells + scoreDetails2.WishingWells;
            scoreDetails.CompletedProjects           = scoreDetails1.CompletedProjects + scoreDetails2.CompletedProjects;
            scoreDetails.Animals                     = scoreDetails1.Animals + scoreDetails2.Animals;
            scoreDetails.BlackDices                  = scoreDetails1.BlackDices + scoreDetails2.BlackDices;
            scoreDetails.Handymen                    = scoreDetails1.Handymen + scoreDetails2.Handymen;
            scoreDetails.Treasures                   = scoreDetails1.Treasures + scoreDetails2.Treasures;
            scoreDetails.Mission1                    = scoreDetails1.Mission1 + scoreDetails2.Mission1;
            scoreDetails.Mission2                    = scoreDetails1.Mission2 + scoreDetails2.Mission2;
            scoreDetails.Mission3                    = scoreDetails1.Mission3 + scoreDetails2.Mission3;
            scoreDetails.Mission4                    = scoreDetails1.Mission4 + scoreDetails2.Mission4;
            scoreDetails.Mission5                    = scoreDetails1.Mission5 + scoreDetails2.Mission5;
            scoreDetails.Mission6                    = scoreDetails1.Mission6 + scoreDetails2.Mission6;
            scoreDetails.Mission7                    = scoreDetails1.Mission7 + scoreDetails2.Mission7;
            scoreDetails.Mission8                    = scoreDetails1.Mission8 + scoreDetails2.Mission8;
            scoreDetails.Mission9                    = scoreDetails1.Mission9 + scoreDetails2.Mission9;
            scoreDetails.MoatLength                  = scoreDetails1.MoatLength + scoreDetails2.MoatLength;
            scoreDetails.Arena                       = scoreDetails1.Arena + scoreDetails2.Arena;
            scoreDetails.BathHouse                   = scoreDetails1.BathHouse + scoreDetails2.BathHouse;
            scoreDetails.Library                     = scoreDetails1.Library + scoreDetails2.Library;
            scoreDetails.Hostel                      = scoreDetails1.Hostel + scoreDetails2.Hostel;
            scoreDetails.Hospital                    = scoreDetails1.Hospital + scoreDetails2.Hospital;
            scoreDetails.Market                      = scoreDetails1.Market + scoreDetails2.Market;
            scoreDetails.Park                = scoreDetails1.Park + scoreDetails2.Park;
            scoreDetails.School              = scoreDetails1.School + scoreDetails2.School;
            scoreDetails.ResidentialArea     = scoreDetails1.ResidentialArea + scoreDetails2.ResidentialArea;
            scoreDetails.WallMoatCombination = scoreDetails1.WallMoatCombination + scoreDetails2.WallMoatCombination;
            return(scoreDetails);
        }
Example #4
0
    public void RetrySelectedPlatform(ScoreDetails _platform)
    {
        print("Retry platform:");
        print("Score: " + _platform.score);
        print("PuzzleNum: " + _platform.puzzleNum);

        //Generate new platform and move camera to that position
        GameObject newPlatform = CreateAndPopulateNewPlatform(_platform.score, _platform.puzzleNum);

        //Position the platform
        newPlatform.transform.position = GetNextPlatformPos(currPlatform, newPlatform);
        //newPlatform.transform.Rotate (0, 0, Random.Range (-90.0f, 0f));

        newPlatform.GetComponent <PlatformManager> ().ShowMenuFlag = false;

        //Set RetrySelectedPlatform Flag
        ShowHomeScreenFlag        = false;
        RetrySelectedPlatformFlag = true;
        StartGameFlag             = true;
        retryScore = _platform.score;

        ScoreCompleteFlag = false;
//		//Destroy Selection Screen
//		DestroyPlatform(currPlatform);


        int zoomType = 1;

        if (_platform.score < 10)
        {
            zoomType = 1;
        }
        else if (_platform.score < 100)
        {
            zoomType = 2;
        }
        else if (_platform.score < 1000)
        {
            zoomType = 3;
        }

        float zoomOffSet = 0;

        if (_platform.puzzleNum == 2)
        {
            zoomOffSet = 3;
        }


        FindObjectOfType <CameraBehaviour> ().MoveCamera(newPlatform, currPlatform, zoomType, zoomOffSet, _platform.puzzleNum);
        currPlatform = newPlatform;
    }
        /// <summary>
        /// Defines a Cup.
        /// </summary>
        /// <param name="wfscore">The Worldfootball definition.</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private static List <BaseScore> DefineCup(WorldFootballScore wfscore, ScoreParameter[] parameters)
        {
            int index = 0;
            List <BaseScore> scores = new List <BaseScore>();

            // add last results score
            GenericScore sc          = CreateNewScore(wfscore.Id, "last", "Last Results", IMG_RESULTS, "2", index++);
            string       competition = ScoreCenter.GetParameter(parameters, "WF.Competition", KEY_COMPETITION);

            sc.Url        = String.Format("{0}{2}/{1}/", WF_URL, wfscore.FullLeagueName, competition);
            sc.Sizes      = ScoreCenter.GetParameter(parameters, "WF.CupResults", SIZES_CUP_RESULTS);
            sc.Dictionary = "WF.last";
            sc.AddRule(3, Operation.IsNull, "", RuleAction.MergeCells, "Header");
            sc.AddHighlightRule(wfscore.Highlights, 0, RuleAction.FormatCell);
            scores.Add(sc);

            string fullname = wfscore.FullLeagueName;

            if (String.IsNullOrEmpty(wfscore.Season) == false)
            {
                fullname += "-" + wfscore.Season;
            }

            // add rounds if any
            if (!String.IsNullOrEmpty(wfscore.Details))
            {
                string[] rounds = wfscore.Details.Split(',');
                foreach (string round in rounds)
                {
                    sc       = CreateNewScore(wfscore.Id, round, round, IMG_RESULTS, "0", index++);
                    sc.Url   = String.Format("{0}spielplan/{1}-{2}/0/", WF_URL, fullname, round);
                    sc.Sizes = wfscore.TwoLegs && round != "finale"
                        ? ScoreCenter.GetParameter(parameters, "WF.CupLevel2", SIZES_CUP_LEVEL2)
                        : ScoreCenter.GetParameter(parameters, "WF.CupLevel1", SIZES_CUP_LEVEL1);
                    sc.AddRule(3, Operation.IsNull, "", RuleAction.MergeCells, "Header");
                    scores.Add(sc);
                }
            }

            // add details
            ScoreDetails details = GetScoreDetails(wfscore, parameters);

            details.AddTopScorerScore(scores, fullname, index++);
            details.AddAssistsScore(scores, fullname, index++);
            details.AddStadiumScore(scores, fullname, index++);
            details.AddRefereeScore(scores, fullname, index++);
            details.AddHistoryScore(scores, index++);
            details.AddTopScorerHistScore(scores, index++);

            return(scores);
        }
 public Dashboard_VM(DashBoard i_objDashboard)
 {
     clsCrickBuzzData.GetCrickbuzzIstance();
     objCurrentWindow = i_objDashboard;
     SetColorToDashBoard(i_objDashboard);
     objNotification       = new NotifyIcon();
     _objScoreDetailsForUI = new ScoreDetails();
     objPlayerDetailsUI    = new PlayerDetails();
     objStartUpMessaage    = objCustomMessage;
     StrAutoHidePath       = _strHorizontalPinPath;
     DisplayCustomMessages(enumMessageType.WelcomeUser);
     TasksToRunOnBackGroundRecursively();
     objSelectedMatch  = new RelayCommand(GetSelectedMatchScore, DefaultCanExecute);
     objSelectedPlayer = new RelayCommand(GetSelectedPlayerDetails, DefaultCanExecute);
     cmdAutoHide       = new RelayCommand(SetAutoHide, DefaultCanExecute);
 }
Example #7
0
        public WinDialogPopup(int movesLeft) : base(SkiaRoot.ScreenWidth * 0.7f, SkiaRoot.ScreenHeight * 0.4f, false)
        {
            Popup.Title      = $"Congratulation !";
            Popup.ActionName = "Next level";

            _starEffects = new List <StarEffect>();
            var container = new Container();

            for (int i = 0; i < 3; i++)
            {
                var starEffect = new StarEffect((i - 1) * Width * 0.2f, SkiaRoot.ScreenHeight * 0.1f);
                container.AddContent(starEffect);
                _starEffects.Add(starEffect);
            }

            Popup.AddContent(container);

            var scoreDetails = new ScoreDetails(container.X, container.Y, Width, ContentHeight * 0.5f);

            Popup.AddContent(scoreDetails);


            Task.Run(async() =>
            {
                var scoreMovesLeft    = movesLeft * 100;
                var scoreLevelCleared = 50;
                await Task.Delay(1000);
                await scoreDetails.Push($"Level Cleared : {scoreLevelCleared}");

                await Task.Delay(500);
                await scoreDetails.Push($"Moves left : {scoreMovesLeft}");


                await Task.Delay(500);

                var scoreText = new IncrementalText(0, scoreMovesLeft + scoreLevelCleared, 0, 0, SkiaRoot.ScreenHeight * 0.05f, CreateColor(255, 255, 255));
                Popup.AddContent(scoreText);
                await scoreText.Start();

                await Task.Delay(200);
                for (int i = 0; i < 3; i++)
                {
                    _starEffects[i].Start();
                    await Task.Delay(300);
                }
            });
        }
        public async Task <IActionResult> Get(string id)
        {
            Documents.Score       score;
            Documents.TableLayout tableLayout;
            Documents.TableType   tableType;

            try
            {
                score = await documentClient.ReadDocumentAsync <Documents.Score>(UriFactory.CreateDocumentUri(documentDbOptions.DatabaseName, documentDbOptions.ScoresCollectionName, id));
            }
            catch (DocumentClientException)
            {
                return(NotFound($"Score with id {id} was not found"));
            }

            try
            {
                tableLayout = await documentClient.ReadDocumentAsync <Documents.TableLayout>(UriFactory.CreateDocumentUri(documentDbOptions.DatabaseName, documentDbOptions.TableLayoutsCollectionName, score.TableLayoutId));
            }
            catch (DocumentClientException)
            {
                return(NotFound($"Table Layout with id {score.TableLayoutId} was not found"));
            }

            try
            {
                tableType = await documentClient.ReadDocumentAsync <Documents.TableType>(UriFactory.CreateDocumentUri(documentDbOptions.DatabaseName, documentDbOptions.TableTypesCollectionName, score.TableTypeId));
            }
            catch (DocumentClientException)
            {
                return(NotFound($"Table Type with id {score.TableTypeId} was not found"));
            }

            var scoreDetails = new ScoreDetails
            {
                Id          = score.Id,
                StartTime   = score.StartTime,
                EndTime     = score.EndTime,
                Sequence    = score.Sequence,
                TableLayout = tableLayout,
                TableType   = tableType
            };

            return(Ok(scoreDetails));
        }
    void Awake()
    {
        MyDictionary  = FindObjectOfType <DictionaryManager>();
        ColourManager = FindObjectOfType <ColourManager>();
        CameraManager = FindObjectOfType <CameraBehaviour>();
        TimeManager   = FindObjectOfType <TimeManager>();
        GameManager   = FindObjectOfType <GameManager>();

        hintDict   = MyDictionary.PopulateHintDictionary();
        colourDict = ColourManager.PopulateColourDictionary();

        LevelColour      = colourDict ["LevelColour"];
        InProgressColour = colourDict ["InProgressColour"];
        NextColour       = colourDict ["NextColour"];
        ScoreColour      = colourDict ["ScoreColour"];

        currPlatformData = new ScoreDetails();
    }
        /// <summary>
        /// Defines a League.
        /// </summary>
        /// <param name="wfscore">The Worldfootball definition.</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private static List <BaseScore> DefineLeague(WorldFootballScore wfscore, ScoreParameter[] parameters)
        {
            int index = 0;
            List <BaseScore> scores   = new List <BaseScore>();
            string           fullname = wfscore.FullLeagueName + "-" + wfscore.Season;

            ScoreDetails details = GetScoreDetails(wfscore, parameters);
            int          round   = details.Round;

            // add results
            details.AddResults(scores, round, IMG_RESULTS, fullname, index++);

            // Standings
            string element  = "0";
            string nbLeague = wfscore.Details.Split(',').FirstOrDefault(x => x.Contains(";"));

            if (!String.IsNullOrEmpty(nbLeague))
            {
                element = nbLeague;
            }

            GenericScore sc = CreateNewScore(wfscore.Id, "table", "Standings", IMG_STANDINGS, element, index++);

            sc.BetweenElts = BetweenElements.RepeatHeader;
            sc.Url         = String.Format("{0}spielplan/{1}-spieltag/{2}/tabelle/", WF_URL, fullname, round);
            sc.Skip        = 1;
            sc.Sizes       = ScoreCenter.GetParameter(parameters, "WF.LeagueStandings", SIZES_STANDINGS);
            sc.Dictionary  = "WF.table";
            sc.Headers     = ScoreCenter.GetParameter(parameters, "WF.HeaderStandings", HEADERS_STANDINGS);
            sc.AddLevelsRule(wfscore.Levels);
            sc.AddHighlightRule(wfscore.Highlights, 3, RuleAction.FormatLine);
            scores.Add(sc);

            details.AddTopScorerScore(scores, fullname, index++);
            details.AddAssistsScore(scores, fullname, index++);
            details.AddStadiumScore(scores, fullname, index++);
            details.AddRefereeScore(scores, fullname, index++);
            details.AddHistoryScore(scores, index++);
            details.AddTopScorerHistScore(scores, index++);

            return(scores);
        }
        private static ScoringOutput GetScores(List <string> scaleNames, List <ItemInformation> itemInformationList, List <string> personNames, List <UserAnswers> answersInput,
                                               CATParameters catParameters)
        {
            List <ScoreDetails>         scores           = new List <ScoreDetails>();
            List <List <QuestionInfo> > questionInfoList = new List <List <QuestionInfo> >();

            foreach (var scaleName in scaleNames)
            {
                List <ItemInformation> itemInfoForScale = itemInformationList.Where(x => x.ScaleName.Equals(scaleName)).ToList();
                IQuestionLoader        questionLoader   = new ExcelQuestionLoader(itemInfoForScale, catParameters.MistakeProbability);
                foreach (var personName in personNames)
                {
                    UserAnswers        personAnswers     = answersInput.Single(x => x.PersonName.Equals(personName));
                    ScaleAnswers       answers           = personAnswers.ScaleAnswers.Single(x => x.ScaleName.Equals(scaleName));
                    IAnswerSheetLoader answerSheetLoader = new ExcelAnswerSheetLoader(answers);

                    LocationEstimator   locationEstimator = new LocationEstimator(questionLoader, answerSheetLoader, catParameters);
                    List <QuestionInfo> output            = locationEstimator.EstimatePersonLocation();
                    questionInfoList.Add(output);

                    ScoreDetails scoreDetails = new ScoreDetails()
                    {
                        PersonName = personName,
                        ScaleName  = scaleName,
                        Score      = (double)output.Last().ThetaEstimate
                    };
                    scores.Add(scoreDetails);
                }
            }

            ScoringOutput scoringOutput = new ScoringOutput()
            {
                FirstPersonQuestionInfo = questionInfoList.First(),
                ScoreDetails            = scores
            };

            return(scoringOutput);
        }
    public static void SavePlatformData(ScoreDetails _platformData)
    {
        print("Save Platform Data: " + _platformData.score);

        if (ScoreDetailsDict.ContainsKey(_platformData.score))
        {
            if (_platformData.scoreStar > ScoreDetailsDict [_platformData.score].scoreStar)
            {
                //Update score details
                print("Update score details for: " + _platformData.score);

                ScoreDetailsDict.Remove(_platformData.score);
            }
            else
            {
                print("New time is more than best time, not updating");

                return;
            }
        }

        ScoreDetails newPlatform = new ScoreDetails();

        newPlatform.score       = _platformData.score;
        newPlatform.scoreStar   = _platformData.scoreStar;
        newPlatform.scoreTime   = _platformData.scoreTime;
        newPlatform.scoreString = _platformData.scoreString;
        newPlatform.puzzleNum   = _platformData.puzzleNum;

        ScoreDetailsDict.Add(_platformData.score, newPlatform);

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/scoreDetailsList.data");

        bf.Serialize(file, ScoreDetailsDict);
        file.Close();
    }
        /// <summary>
        /// Defines a Qualification Tournament.
        /// </summary>
        /// <param name="wfscore">The Worldfootball definition.</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private static List <BaseScore> DefineQualification(WorldFootballScore wfscore, ScoreParameter[] parameters)
        {
            int index = 0;
            List <BaseScore> scores = new List <BaseScore>();
            GenericScore     sc     = null;

            string fullname = wfscore.FullLeagueName;

            if (String.IsNullOrEmpty(wfscore.Season) == false)
            {
                fullname += "-" + wfscore.Season;
            }

            // add results scores
            sc = CreateNewScore(wfscore.Id, "results", "Results", IMG_RESULTS, "2", index++);
            string competition = ScoreCenter.GetParameter(parameters, "WF.Competition", KEY_COMPETITION);

            sc.Url   = String.Format("{0}{2}/{1}/", WF_URL, wfscore.FullLeagueName, competition);
            sc.Sizes = ScoreCenter.GetParameter(parameters, "WF.Results", SIZES_RESULTS);
            sc.AddRule(3, Operation.IsNull, "", RuleAction.MergeCells, "Header");
            sc.LiveConfig = LiveConfig.Copy(wfscore.LiveConfig, ScoreCenter.GetParameter(parameters, "WF.LiveFormat", "{2} {5} {4}"));
            sc.SetCanLive(true);
            sc.Element = "0";
            scores.Add(sc);

            // retrieve details: first element is the list of groups
            List <string> items = wfscore.Details.Split(',').ToList();

            char[] groups = items[0].ToCharArray();
            foreach (char g in groups)
            {
                // add group results
                sc       = CreateNewScore(wfscore.Id, "gr" + g, String.Format("Group {0}", Char.ToUpper(g)), "", "0", index++);
                sc.Url   = String.Format("{0}spielplan/{1}-gruppe-{2}/0/", WF_URL, fullname, g);
                sc.Sizes = ScoreCenter.GetParameter(parameters, "WF.GroupResults", SIZES_GROUP_RESULTS);
                sc.Image = String.Format(@"Groups\Group{0}", Char.ToUpper(g));
                sc.AddRule(3, Operation.IsNull, "", RuleAction.MergeCells, "Header");
                sc.AddHighlightRule(wfscore.Highlights, 0, RuleAction.FormatCell);
                scores.Add(sc);

                // add group standings
                sc         = CreateNewScore(wfscore.Id, "resgr" + g, "Standings", "", "1", index++);
                sc.Url     = String.Format("{0}spielplan/{1}-gruppe-{2}/0/", WF_URL, fullname, g);
                sc.Skip    = 1;
                sc.Headers = ScoreCenter.GetParameter(parameters, "WF.HeaderStandings", HEADERS_STANDINGS);
                sc.Sizes   = ScoreCenter.GetParameter(parameters, "WF.GroupStandings", SIZES_GROUP_STANDINGS);
                sc.Image   = String.Format(@"Groups\Table{0}", Char.ToUpper(g));
                sc.AddHighlightRule(wfscore.Highlights, 3, RuleAction.FormatLine);
                scores.Add(sc);
            }

            // add rounds
            foreach (string round in items)
            {
                if (round == items[0])
                {
                    continue;
                }
                if (round == "stadium" || round == "referee")
                {
                    continue;
                }
                sc       = CreateNewScore(wfscore.Id, round, round, IMG_RESULTS, "0", index++);
                sc.Url   = String.Format("{0}spielplan/{1}-{2}/0/", WF_URL, fullname, round);
                sc.Sizes = wfscore.TwoLegs && round != "finale"
                    ? ScoreCenter.GetParameter(parameters, "WF.QualificationLevel2", SIZES_QUALIFICATION_LEVEL2)
                    : ScoreCenter.GetParameter(parameters, "WF.QualificationLevel1", SIZES_QUALIFICATION_LEVEL1);
                sc.AddRule(3, Operation.IsNull, "", RuleAction.MergeCells, "Header");
                sc.AddRule(0, Operation.Contains, "{Rückspiel},", RuleAction.ReplaceText, "");
                scores.Add(sc);
            }

            // add details
            ScoreDetails details = GetScoreDetails(wfscore, parameters);

            details.AddTopScorerScore(scores, fullname, index++);
            details.AddAssistsScore(scores, fullname, index++);
            details.AddStadiumScore(scores, fullname, index++);
            details.AddRefereeScore(scores, fullname, index++);
            details.AddHistoryScore(scores, index++);
            details.AddTopScorerHistScore(scores, index++);

            return(scores);
        }
Example #14
0
        /// <summary>
        /// 签到
        /// </summary>
        /// <param name="openId">微信openId</param>
        /// <returns></returns>
        public bool User_Sign()
        {
            var user   = CookieHelper.GetCurrentWxUser();
            var person = CookieHelper.GetCurrentPeople();

            if (user == null || person == null)
            {
                return(false);
            }
            using (DbRepository entities = new DbRepository())
            {
                var userEntity = entities.User.Find(user.openid);
                if (userEntity == null)
                {
                    return(false);
                }
                var yesterday = DateTime.Now.AddDays(-1).Date;
                var lastSign  = entities.UserSign.Where(x => x.OpenId.Equals(user.openid) && x.PersonId.Equals(person.UNID)).OrderByDescending(x => x.SignDate).FirstOrDefault();


                //判断是否连续签到
                if (lastSign != null)
                {
                    //判断今天是否已签到
                    if (lastSign.SignDate > yesterday)
                    {
                        return(false);
                    }

                    var todaySign = new UserSign()
                    {
                        UNID     = Guid.NewGuid().ToString("N"),
                        SignDate = DateTime.Now,
                        OpenId   = user.openid,
                        PersonId = person.UNID
                    };
                    if (lastSign.SignDate == yesterday)
                    {
                        todaySign.SignNum = lastSign.SignNum + 1;

                        //签到10天判断
                        if (todaySign.SignNum % 10 == 0 && todaySign.SignNum >= 10)
                        {
                            var tenScoreDetials = new ScoreDetails()
                            {
                                UNID        = Guid.NewGuid().ToString("N"),
                                OpenId      = user.openid,
                                CreatedTime = DateTime.Now,
                                Description = "连续签到10天获得积分",
                                IsAdd       = (int)YesOrNoCode.Yes,
                                Value       = Params.TendayScore,
                                Type        = (int)ScoreType.Sign,
                                PersonId    = person.UNID
                            };
                            entities.ScoreDetails.Add(tenScoreDetials);

                            //是否初次签到
                            var userScore = entities.UserScore.FirstOrDefault(x => x.OpenId.Equals(user.openid) && x.PersonId.Equals(person.UNID));
                            if (userScore == null)
                            {
                                var addUserScore = new UserScore()
                                {
                                    UNID     = Guid.NewGuid().ToString("N"),
                                    OpenId   = user.openid,
                                    PersonId = person.UNID,
                                    Score    = Params.TendayScore
                                };
                                entities.UserScore.Add(addUserScore);
                            }
                            else
                            {
                                userScore.Score += Params.TendayScore;
                            }
                        }
                    }
                    else
                    {
                        todaySign.SignNum = 1;
                    }


                    entities.UserSign.Add(todaySign);
                }
                else
                {
                    var todaySign = new UserSign()
                    {
                        UNID     = Guid.NewGuid().ToString("N"),
                        SignDate = DateTime.Now,
                        SignNum  = 1,
                        OpenId   = user.openid,
                        PersonId = person.UNID
                    };
                    entities.UserSign.Add(todaySign);
                }

                //日常签到积分
                var scoreDetials = new ScoreDetails()
                {
                    UNID        = Guid.NewGuid().ToString("N"),
                    OpenId      = user.openid,
                    CreatedTime = DateTime.Now,
                    Description = "签到获得积分",
                    IsAdd       = (int)YesOrNoCode.Yes,
                    Value       = Params.SignScore,
                    Type        = (int)ScoreType.Sign,
                    PersonId    = person.UNID
                };
                //用户积分增加
                var updateUserScore = entities.UserScore.FirstOrDefault(x => x.OpenId.Equals(user.openid) && x.PersonId.Equals(person.UNID));
                if (updateUserScore == null)
                {
                    var addUserScore = new UserScore()
                    {
                        UNID     = Guid.NewGuid().ToString("N"),
                        OpenId   = user.openid,
                        PersonId = person.UNID,
                        Score    = Params.SignScore
                    };
                    entities.UserScore.Add(addUserScore);
                }
                else
                {
                    updateUserScore.Score += Params.SignScore;
                }
                entities.ScoreDetails.Add(scoreDetials);

                return(entities.SaveChanges() > 0 ? true : false);
            }
        }
Example #15
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string Add_Order(GoodsOrder model)
        {
            if (model == null ||
                !model.GoodsId.IsNotNullOrEmpty() ||
                model.Count == 0
                )
            {
                return("数据错误");
            }
            var user   = CookieHelper.GetCurrentWxUser();
            var person = CookieHelper.GetCurrentPeople();

            if (user == null || person == null)
            {
                return("身份验证过期");
            }
            using (DbRepository entities = new DbRepository())
            {
                var userEntity = entities.User.Find(user.openid);
                if (userEntity == null)
                {
                    return("用户不存在");
                }

                var goods = entities.Goods.Find(model.GoodsId);
                if (goods == null)
                {
                    return("数据错误");
                }

                if (goods.OngoingTime > DateTime.Now)
                {
                    return("还没到活动时间");
                }
                if (goods.OverTime < DateTime.Now)
                {
                    return("已过活动时间");
                }

                if (goods.SurplusNum < model.Count)
                {
                    return("商品库存不足");
                }

                //商品库存减少
                goods.SurplusNum -= (int)model.Count;
                //积分总计
                model.ScoreNum = model.Count * goods.ScoreNum;

                var userScore = entities.UserScore.FirstOrDefault(x => x.OpenId.Equals(user.openid) && x.PersonId.Equals(person.UNID));
                if (userScore == null || userScore.Score < model.ScoreNum)
                {
                    return("用户积分不足");
                }

                //扣减用户积分
                userScore.Score -= (int)model.ScoreNum;

                //消费积分
                var scoreDetials = new ScoreDetails()
                {
                    UNID        = Guid.NewGuid().ToString("N"),
                    OpenId      = user.openid,
                    CreatedTime = DateTime.Now,
                    Description = string.Format("购买商品:{0},数量{1},消费积分{2}", goods.Name, model.Count, model.Count * goods.ScoreNum),
                    IsAdd       = (int)YesOrNoCode.No,
                    Value       = (int)(model.Count * goods.ScoreNum),
                    Type        = (int)ScoreType.Mall,
                    PersonId    = person.UNID
                };
                entities.ScoreDetails.Add(scoreDetials);


                model.UNID        = Guid.NewGuid().ToString("N");
                model.OpenId      = user.openid;
                model.PersonId    = person.UNID;
                model.AllPrice    = model.Count * goods.SellingPrice;
                model.CreatedTime = DateTime.Now;

                entities.GoodsOrder.Add(model);

                return(entities.SaveChanges() > 0 ? "" : "保存出错");
            }
        }
Example #16
0
    void Update()
    {
        //If escape is pressed
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            print("Pressed Escape");
            if (StartGameFlag)
            {
                StartGameFlag = false;
                GoToHomePlatform();
            }
            else
            {
                print("Quit game");
                Application.Quit();
            }
        }

        if (ShowHomeScreenFlag)
        {
            if (CameraManager.IsLandscapeMode && !homeScreen.CompareTag("landscape"))
            {
                Destroy(homeScreen);
                GoToHomePlatform();
            }
            if (!CameraManager.IsLandscapeMode && homeScreen.CompareTag("landscape"))
            {
                Destroy(homeScreen);
                GoToHomePlatform();
            }
        }

        if (!StartGameFlag)
        {
            return;
        }

        if (RetrySelectedPlatformFlag || RetryCurrentPlatformFlag)
        {
            currScore = retryScore;
            //ScoreCompleteFlag = false;
        }

        if (GoToNextPlatform)
        {
//			ScoreCompleteFlag = false;
            ShowHomeScreenFlag = false;

            puzzleNum = GetPuzzleNum(currScore);

            //Generate new platform and move camera to that position
            GameObject newPlatform = CreateAndPopulateNewPlatform(currScore, puzzleNum);

            //Position the platform
            newPlatform.transform.position = GetNextPlatformPos(currPlatform, newPlatform);
            //newPlatform.transform.Rotate (0, 0, Random.Range (-90.0f, 0f));


            if (currScore == 0 || currScore == 1)
            {
                newPlatform.GetComponent <PlatformManager> ().ShowHint();
            }
            newPlatform.GetComponent <PlatformManager> ().ShowMenuFlag = false;

            int zoomType = 1;
            if (currScore < 10)
            {
                zoomType = 1;
            }
            else if (currScore < 100)
            {
                zoomType = 2;
            }
            else if (currScore < 1000)
            {
                zoomType = 3;
            }

            float zoomOffSet = 0;
            if (puzzleNum == 2)
            {
                zoomOffSet = 3;
            }


            FindObjectOfType <CameraBehaviour> ().MoveCamera(newPlatform, currPlatform, zoomType, zoomOffSet, puzzleNum);
            currPlatform = newPlatform;

            //Destroy previous Platform
            //DestroyPlatform(currPlatform);

            //Asign new platform as currPlatform


            GoToNextPlatform = false;
        }

        tileString  = "";
        ScoreString = GetScoreString(currScore);

        //Get current tile code to compare
        tileString = GetTileString(currPlatform);

//		print ("Score: " + currScore);
//		print ("Tile String: " + tileString);
//		print ("Score String: " + ScoreString);
        if (tileString == ScoreString)
        {
            tileString = "";

            if (!ScoreCompleteFlag)
            {
                print("Score completed!");

                currPlatform.GetComponent <PlatformManager> ().ScoreComplete();

                //save current platform details
                ScoreDetails _platformData = currPlatform.GetComponent <PlatformManager>().currPlatformData;
                print("Add Details to File: " + "Score: " + _platformData.score + ",  ScoreStar: " + _platformData.scoreStar + ", ScoreTime: " + _platformData.scoreTime);
                ScoreHistoryManager.SavePlatformData(_platformData);

//				if (RetrySelectedPlatformFlag) {
//					currScore = nextScore - 1;
//					RetrySelectedPlatformFlag = false;
//				}
//
                if (!RetryCurrentPlatformFlag && !RetrySelectedPlatformFlag)
                {
                    //Increment next score
                    print("Increment next score");
                    nextScore++;
                    currScore = nextScore;
                    PlayerPrefs.SetInt("score", nextScore);
                }

                ScoreCompleteFlag = true;
            }
        }
    }
Example #17
0
 public bool AddMatchScore(ScoreDetails sd)
 {
     return(games.AddMatchScore(sd));
 }
        public static List <ResultHistory> GetResults()
        {
            List <ResultHistory> results = new List <ResultHistory>();

            if (File.Exists(settingsFileName))
            {
                XmlDocument document = new XmlDocument();
                document.Load(settingsFileName);
                XmlNode bodyElement    = document.SingleChildNode("body");
                XmlNode resultsElement = bodyElement.SingleChildNode("results");
                string  version        = bodyElement.SingleChildNode("version").InnerText;
                foreach (XmlNode result in resultsElement.GetChildNodes("result"))
                {
                    ResultHistory resultHistory = new ResultHistory();

                    resultHistory.StartDateTime     = DateTime.Parse(result.SingleChildNode("startTime").InnerText);
                    resultHistory.EndDateTime       = DateTime.Parse(result.SingleChildNode("endTime").InnerText);
                    resultHistory.Modules           = new List <ExpansionModule>();
                    resultHistory.NewScoreCards     = new List <NewScoreCard>();
                    resultHistory.CaliphsGuidelines = new List <CaliphsGuidelinesMission>();
                    resultHistory.Players           = new List <ResultPlayerHistory>();
                    resultHistory.ScoreRound        = Enum.Parse <ScoringRound>(result.SingleChildNode("scoreRound").InnerText);
                    XmlNode modulesElement           = result.SingleChildNode("modules");
                    XmlNode newScoreCardsElement     = result.SingleChildNode("newScoreCards");
                    XmlNode caliphsGuidelinesElement = result.SingleChildNode("caliphsGuidelines");
                    foreach (XmlNode module in modulesElement.GetChildNodes("module"))
                    {
                        resultHistory.Modules.Add(Enum.Parse <ExpansionModule>(module.SingleChildNode("value").InnerText));
                    }
                    resultHistory.GranadaOption = Enum.Parse <GranadaOption>(result.SingleChildNode("granadaOption").InnerText);
                    foreach (XmlNode module in newScoreCardsElement.GetChildNodes("newScoreCard"))
                    {
                        resultHistory.NewScoreCards.Add(Enum.Parse <NewScoreCard>(module.SingleChildNode("value").InnerText));
                    }
                    foreach (XmlNode module in caliphsGuidelinesElement.GetChildNodes("caliphsGuideline"))
                    {
                        resultHistory.CaliphsGuidelines.Add(Enum.Parse <CaliphsGuidelinesMission>(module.SingleChildNode("value").InnerText));
                    }
                    XmlNode playersElement = result.SingleChildNode("players");
                    foreach (XmlNode player in playersElement.GetChildNodes("player"))
                    {
                        ResultPlayerHistory resultPlayerHistory = new ResultPlayerHistory();
                        string playerName = player.SingleChildNode("name").InnerText;

                        ScoreDetails GetScoreDetails(string name)
                        {
                            ScoreDetails result           = new ScoreDetails();
                            XmlNode      scoreDetailsNode = player.SingleChildNode(name);

                            result.ImmediatelyPoints           = Int32.Parse(scoreDetailsNode.SingleChildNode("ImmediatelyPoints").InnerText);
                            result.WallLength                  = Int32.Parse(scoreDetailsNode.SingleChildNode("WallLength").InnerText);
                            result.Pavilion                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Pavilion").InnerText);
                            result.Seraglio                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Seraglio").InnerText);
                            result.Arcades                     = Int32.Parse(scoreDetailsNode.SingleChildNode("Arcades").InnerText);
                            result.Chambers                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Chambers").InnerText);
                            result.Garden                      = Int32.Parse(scoreDetailsNode.SingleChildNode("Garden").InnerText);
                            result.Tower                       = Int32.Parse(scoreDetailsNode.SingleChildNode("Tower").InnerText);
                            result.BuildingsBonuses            = Int32.Parse(scoreDetailsNode.SingleChildNode("BuildingsBonuses").InnerText);
                            result.TheCityWatch                = Int32.Parse(scoreDetailsNode.SingleChildNode("TheCityWatch").InnerText);
                            result.Camps                       = Int32.Parse(scoreDetailsNode.SingleChildNode("Camps").InnerText);
                            result.StreetTraders               = Int32.Parse(scoreDetailsNode.SingleChildNode("StreetTraders").InnerText);
                            result.TreasureChamber             = Int32.Parse(scoreDetailsNode.SingleChildNode("TreasureChamber").InnerText);
                            result.Invaders                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Invaders").InnerText);
                            result.Bazaars                     = Int32.Parse(scoreDetailsNode.SingleChildNode("Bazaars").InnerText);
                            result.ArtOfTheMoors               = Int32.Parse(scoreDetailsNode.SingleChildNode("ArtOfTheMoors").InnerText);
                            result.Falconers                   = Int32.Parse(scoreDetailsNode.SingleChildNode("Falconers").InnerText);
                            result.Watchtowers                 = Int32.Parse(scoreDetailsNode.SingleChildNode("Watchtowers").InnerText);
                            result.Medina                      = Int32.Parse(scoreDetailsNode.SingleChildNode("Medina").InnerText);
                            result.BuildingsWithoutServantTile = Int32.Parse(scoreDetailsNode.SingleChildNode("BuildingsWithoutServantTile").InnerText);
                            result.Orchards                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Orchards").InnerText);
                            result.Bathhouses                  = Int32.Parse(scoreDetailsNode.SingleChildNode("Bathhouses").InnerText);
                            result.WishingWells                = Int32.Parse(scoreDetailsNode.SingleChildNode("WishingWells").InnerText);
                            result.CompletedProjects           = Int32.Parse(scoreDetailsNode.SingleChildNode("CompletedProjects").InnerText);
                            result.Animals                     = Int32.Parse(scoreDetailsNode.SingleChildNode("Animals").InnerText);
                            result.BlackDices                  = Int32.Parse(scoreDetailsNode.SingleChildNode("BlackDices").InnerText);
                            result.Handymen                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Handymen").InnerText);
                            result.Treasures                   = Int32.Parse(scoreDetailsNode.SingleChildNode("Treasures").InnerText);
                            result.Mission1                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission1").InnerText);
                            result.Mission2                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission2").InnerText);
                            result.Mission3                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission3").InnerText);
                            result.Mission4                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission4").InnerText);
                            result.Mission5                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission5").InnerText);
                            result.Mission6                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission6").InnerText);
                            result.Mission7                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission7").InnerText);
                            result.Mission8                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission8").InnerText);
                            result.Mission9                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Mission9").InnerText);
                            result.MoatLength                  = Int32.Parse(scoreDetailsNode.SingleChildNode("MoatLength").InnerText);
                            result.Arena                       = Int32.Parse(scoreDetailsNode.SingleChildNode("Arena").InnerText);
                            result.BathHouse                   = Int32.Parse(scoreDetailsNode.SingleChildNode("BathHouse").InnerText);
                            result.Library                     = Int32.Parse(scoreDetailsNode.SingleChildNode("Library").InnerText);
                            result.Hostel                      = Int32.Parse(scoreDetailsNode.SingleChildNode("Hostel").InnerText);
                            result.Hospital                    = Int32.Parse(scoreDetailsNode.SingleChildNode("Hospital").InnerText);
                            result.Market                      = Int32.Parse(scoreDetailsNode.SingleChildNode("Market").InnerText);
                            result.Park                = Int32.Parse(scoreDetailsNode.SingleChildNode("Park").InnerText);
                            result.School              = Int32.Parse(scoreDetailsNode.SingleChildNode("School").InnerText);
                            result.ResidentialArea     = Int32.Parse(scoreDetailsNode.SingleChildNode("ResidentialArea").InnerText);
                            result.WallMoatCombination = Int32.Parse(scoreDetailsNode.SingleChildNode("WallMoatCombination").InnerText);
                            return(result);
                        }

                        resultPlayerHistory.Name          = playerName;
                        resultPlayerHistory.ScoreDetails1 = GetScoreDetails("scoreDetails1");
                        resultPlayerHistory.ScoreDetails2 = GetScoreDetails("scoreDetails2");
                        resultPlayerHistory.ScoreDetails3 = GetScoreDetails("scoreDetails3");
                        resultPlayerHistory.ScoreMeantime = GetScoreDetails("scoreMeantime");

                        resultHistory.Players.Add(resultPlayerHistory);
                    }

                    results.Add(resultHistory);
                }
            }

            return(results);
        }
Example #19
0
        /// <summary>
        /// 完成拼图结果
        /// </summary>
        /// <returns>操作结果  提示语句  是否绑定平台活动  平台活动名 绑定地址</returns>
        public Tuple <bool, string, bool, string, string> Complete(string unid)
        {
            var user   = CookieHelper.GetCurrentWxUser();
            var person = CookieHelper.GetCurrentPeople();

            if (user == null || person == null)
            {
                return(new Tuple <bool, string, bool, string, string>(false, "身份过期", false, "", ""));
            }
            using (DbRepository entities = new DbRepository())
            {
                var puzzle = entities.Puzzle.Find(unid);
                if (puzzle == null)
                {
                    return(new Tuple <bool, string, bool, string, string>(false, "参数错误", false, "", ""));
                }
                var dateTime = DateTime.Now.Date;

                if (entities.UserPuzzle.FirstOrDefault(x => x.PuzzleId.Equals(unid) && x.PuzzleDate == dateTime) != null)
                {
                    return(new Tuple <bool, string, bool, string, string>(false, "该拼图已玩过", false, "", ""));
                }
                var userPuzzle = new UserPuzzle()
                {
                    UNID       = Guid.NewGuid().ToString("N"),
                    OpenId     = user.openid,
                    PuzzleDate = dateTime,
                    PuzzleId   = unid
                };
                entities.UserPuzzle.Add(userPuzzle);

                if (puzzle.IsBindScore == (int)YesOrNoCode.Yes)
                {
                    //日常签到积分
                    var scoreDetials = new ScoreDetails()
                    {
                        UNID        = Guid.NewGuid().ToString("N"),
                        OpenId      = user.openid,
                        CreatedTime = DateTime.Now,
                        Description = "完成拼图获得积分",
                        IsAdd       = (int)YesOrNoCode.Yes,
                        Value       = puzzle.Score,
                        Type        = (int)ScoreType.Puzzle,
                        PersonId    = person.UNID,
                        TargetId    = unid
                    };

                    entities.ScoreDetails.Add(scoreDetials);
                    //用户积分增加
                    var updateUserScore = entities.UserScore.FirstOrDefault(x => x.OpenId.Equals(user.openid) && x.PersonId.Equals(person.UNID));
                    if (updateUserScore == null)
                    {
                        var addUserScore = new UserScore()
                        {
                            UNID     = Guid.NewGuid().ToString("N"),
                            OpenId   = user.openid,
                            PersonId = person.UNID,
                            Score    = puzzle.Score
                        };
                        entities.UserScore.Add(addUserScore);
                    }
                    else
                    {
                        updateUserScore.Score += puzzle.Score;
                    }

                    return(entities.SaveChanges() > 0?new Tuple <bool, string, bool, string, string>(true, string.Format("恭喜你获得:{0}积分", puzzle.Score), false, "", ""):new Tuple <bool, string, bool, string, string>(false, "保存出错", false, "", ""));
                }
                else
                {
                    return(entities.SaveChanges() > 0?new Tuple <bool, string, bool, string, string>(true, puzzle.BindTitle, true, puzzle.BindName, puzzle.BindUrl): new Tuple <bool, string, bool, string, string>(false, "保存出错", false, "", ""));
                }
            }
        }
Example #20
0
 public ScoreDetails CalculateScore()
 {
     // TODO return Score objects with detailed statistical information
     var score = new ScoreDetails();
     return score;
 }