コード例 #1
0
        /// <summary>
        /// Token Stats Request
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private static object GetTokenStats(HttpContextBase context)
        {
            var data       = GetPostData(context);
            var tokenStats = new TokenStats(data.category, data.token);

            return(tokenStats.GetStats());
        }
コード例 #2
0
    private void ResetBuildAndStartScene(SceneActor[] predefinedSceneActors)
    {
        // Reset the scene to blank
        ResetBoard();   // put the squares back in their reset position
        ReleaseBoard(); // Drop the squares
        actors           = new List <Actor>();
        playerCount      = 0;
        monsterCount     = 0;
        currentActorTurn = -1; // -1 so turns actually start a 0

        // Build scene objects from predefined
        foreach (SceneActor actorData in predefinedSceneActors)
        {
            // Create GameObject and place it in the correct square
            GameObject newGameObject;
            if (actorData.IsPlayer)
            {
                newGameObject = (GameObject)Instantiate(instance.PlayerPrefabList[actorData.PrefabIndex]);
                playerCount++;
            }
            else
            {
                newGameObject = (GameObject)Instantiate(instance.MonsterPrefabsList[actorData.PrefabIndex]);
                monsterCount++;
            }
            Space   spaceToPlace = spaces[actorData.x, actorData.z];
            Vector3 squareBasis  = spaceToPlace.gameSpace.transform.position;
            newGameObject.transform.position = new Vector3(squareBasis.x, DropFromHeight + 1, squareBasis.z);

            TokenStats stats    = newGameObject.GetComponent <TokenStats>();
            Actor      newActor = new Actor(newGameObject, actorData.x, actorData.z, actorData.ActorColor, actorData.IsPlayer, stats.characterName, stats.HP, stats.AC,
                                            stats.InitativeMod, stats.Speed, stats.AttackName, stats.AttackRange, stats.AttackMod, stats.DamageDiceNum,
                                            stats.DamageDiceMagnitude, stats.DamageMod);
            spaces[actorData.x, actorData.z].isBlocked = true;

            actors.Add(newActor);
        }

        // Show UI
        InGameCanvas.SetActive(true);

        // Roll init and sort
        RollInit();

        // Start the action!
        NextTurn();
    }
コード例 #3
0
    public TokenStats GetTokenStats(string word)
    {
        TokenStats tkn;
        string     lWord = word.ToLower();

        if (uniqueWords.ContainsKey(lWord))
        {
            tkn        = uniqueWords[lWord];
            tkn.Count += 1;
        }
        else
        {
            tkn = new TokenStats
            {
                LWord = lWord,
                Know  = Klass.UNDECIDED,
                Count = 1
            };
            uniqueWords.Add(lWord, tkn);
        }
        return(tkn);
    }
コード例 #4
0
        private void cbLangCompare_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.lvAnalyzeCharsetResult.BeginUpdate();
            this.lvAnalyzeCharsetResult.Items.Clear();
            this.lvAnalyzeNGramsResult.BeginUpdate();
            this.lvAnalyzeNGramsResult.Items.Clear();
            this.lvAnalyzeWordResult.BeginUpdate();
            this.lvAnalyzeWordResult.Items.Clear();

            if (this.cbLangCompare.SelectedIndex != -1)
            {
                TokenTable  testTable    = new TokenTable(this.tbSource.Text);
                ITokenTable compareTable = this.m_Model[((CultureInfo)cbLangCompare.SelectedItem).TwoLetterISOLanguageName];

                List <TokenStats> scores = new List <TokenStats>();
                int score = compareTable.Count * testTable.Count;

                foreach (ITokenStats test in testTable.Values)
                {
                    TokenStats newScore = new TokenStats(test.Token);

                    int otherRank = compareTable.RankOf(test.Token);
                    if (otherRank == -1)
                    {
                        newScore.Occurences = compareTable.Count;
                        score -= compareTable.Count;
                    }
                    else
                    {
                        int val = System.Math.Abs(test.Rank - otherRank);
                        newScore.Occurences = val;
                        // abuse the ran field to store the occurences...
                        newScore.Rank = test.Occurences;
                        score        -= val;
                        scores.Add(newScore);
                    }
                }
                tbSumTokens.Text = score.ToString();

                scores.Sort();
                for (int i = scores.Count - 1; i > -1; i--)
                {
                    TokenStats   stats = scores[i];
                    ListViewItem item  = new ListViewItem(stats.Token);
                    item.SubItems.Add(stats.Occurences.ToString());
                    item.SubItems.Add(stats.Rank.ToString());
                    lvAnalyzeNGramsResult.Items.Add(item);
                }



                scores = new List <TokenStats>();
                score  = compareTable.WordTable.Count * testTable.WordTable.Count;

                foreach (ITokenStats test in testTable.WordTable.Values)
                {
                    TokenStats newScore = new TokenStats(test.Token);

                    int otherRank = compareTable.WordTable.RankOf(test.Token);
                    if (otherRank == -1)
                    {
                        newScore.Occurences = compareTable.Ranks;
                    }
                    else
                    {
                        int val = System.Math.Abs(test.Rank - otherRank);
                        newScore.Occurences = val;
                        newScore.Rank       = test.Occurences;
                        score -= val;
                        scores.Add(newScore);
                    }
                }
                int    hits    = 0;
                Double wsScore = compareTable.WordComparisonScore(testTable, 0, ref hits);

                tbSumWords.Text = wsScore.ToString("0.00") + " (" + hits + ")";

                scores.Sort();
                for (int i = scores.Count - 1; i > -1; i--)
                {
                    TokenStats   stats = scores[i];
                    ListViewItem item  = new ListViewItem(stats.Token);
                    item.SubItems.Add(stats.Occurences.ToString());
                    item.SubItems.Add(stats.Rank.ToString());
                    lvAnalyzeWordResult.Items.Add(item);
                }



                scores = new List <TokenStats>();
                score  = compareTable.CharsetTable.Count * testTable.CharsetTable.Count;

                foreach (ITokenStats test in testTable.CharsetTable.Values)
                {
                    TokenStats newScore = new TokenStats(test.Token);

                    int otherRank = compareTable.CharsetTable.RankOf(test.Token);
                    if (otherRank == -1)
                    {
                        newScore.Occurences = compareTable.Ranks;
                    }
                    else
                    {
                        int val = System.Math.Abs(test.Rank - otherRank);
                        newScore.Occurences = val;
                        newScore.Rank       = test.Occurences;
                        score -= val;
                        scores.Add(newScore);
                    }
                }
                textBox1.Text = score.ToString();

                scores.Sort();
                for (int i = scores.Count - 1; i > -1; i--)
                {
                    TokenStats   stats = scores[i];
                    ListViewItem item  = new ListViewItem(stats.Token);
                    item.SubItems.Add(stats.Occurences.ToString());
                    item.SubItems.Add(stats.Rank.ToString());
                    lvAnalyzeCharsetResult.Items.Add(item);
                }
            }

            this.lvAnalyzeNGramsResult.EndUpdate();
            this.lvAnalyzeWordResult.EndUpdate();
            this.lvAnalyzeCharsetResult.EndUpdate();
        }