public void updateStats(string lookupName, ClassStats updatedStats)
    {
        ClassStats updatedValue = getLevel(updatedStats);

        classes[lookupName] = updatedValue;
        SaveStats();
    }
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     KnightClass = (ClassStats)GD.Load("res://Classes/Knight.tres"); // resource is loaded when line is executed
     WizardClass = (ClassStats)GD.Load("res://Classes/Wizard.tres"); // resource is loaded when line is executed
     ThiefClass  = (ClassStats)GD.Load("res://Classes/Thief.tres");  // resource is loaded when line is executed
     UpdateClassDisplay(KnightClass);
 }
    public ClassStats[] dictToArray(Dictionary <string, ClassStats> dictionary)
    {
        string[] topicNames = { "WebDev", "GamesDevelopment", "WebDataBases", "SoftwareDevelopment", "ImageProcessing", "DataAnalytics" };

        ClassStats[] statsArray = new ClassStats[6];
        for (int count = 0; count < topicNames.Length; count++)
        {
            statsArray[count] = dictionary[topicNames[count]];
        }
        return(statsArray);
    }
示例#4
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        isOver = true;
        Debug.Log(this.gameObject.name + " was mouse over");
        displayText.enabled = true;
        //ClassStats stats = manager.getStats(this.gameObject.name);
        ClassStats stats = GameObject.Find("Player").GetComponent <Player>().getData(this.gameObject.name);

        //stats.xp += 10;
        // manager.updateStats(stats.className, stats);

        displayText.text = stats.getOutputText();
    }
    public ClassStats getLevel(ClassStats stats)
    {
        int xpTilNextLevel = stats.xpTilNextLevel;

        if (stats.xp >= xpTilNextLevel)
        {
            stats.level         += 1;
            stats.xpTilNextLevel = xpTilNextLevel + (stats.getBaseLevel() + stats.getBaseLevelIncrease() + (stats.level * 2));
            //getLevel(stats);
        }

        return(stats);
    }
    public void UpdateClassDisplay(ClassStats classStats)
    {
        ClassData        = (Label)GetNode("MarginContainer/HBoxContainer/VBoxContainer/Class/Data");
        HealthData       = (Label)GetNode("MarginContainer/HBoxContainer/VBoxContainer/Health/Data");
        StrengthData     = (Label)GetNode("MarginContainer/HBoxContainer/VBoxContainer/Strength/Data");
        IntelligenceData = (Label)GetNode("MarginContainer/HBoxContainer/VBoxContainer/Intelligence/Data");
        Profile          = (TextureRect)GetNode("MarginContainer/HBoxContainer/CenterContainer/TextureRect");

        Profile.Texture       = classStats.Profile;
        ClassData.Text        = classStats.Type;
        HealthData.Text       = classStats.Health.ToString();
        StrengthData.Text     = classStats.Strength.ToString();
        IntelligenceData.Text = classStats.Intelligence.ToString();
    }
示例#7
0
	public static void ResetPlayer () {
		//Debug.Log (SelectedClass);
	
		PlayerMoney = 0;
		PlayerClass = new ClassStats (SelectedClass);
		
		playerHealth = PlayerClass.vitality;
		playerAgility = PlayerClass.agility;
		playerVitality = PlayerClass.vitality;
		playerAccuracy = PlayerClass.acuracy;
		
		playerDamage = PlayerClass.weaponStat.damage;
		playerFireRate = PlayerClass.weaponStat.firerate;
		playerCritChance = PlayerClass.weaponStat.critChance;
		playerClipSize = PlayerClass.weaponStat.clipSize;
		playerReloadTime = PlayerClass.weaponStat.reloadTime;
	}
        private void CalculateFame()
        {
            int newFame = 0;

            if (Experience < 200 * 1000)
            {
                newFame = Experience / 1000;
            }
            else
            {
                newFame = 200 + (Experience - 200 * 1000) / 1000;
            }
            if (newFame != Fame)
            {
                Owner.BroadcastPacket(new NotificationPacket
                {
                    ObjectId = Id,
                    Color    = new ARGB(0xFFFF6600),
                    Text     = "+" + (newFame - Fame) + " Fame"
                }, null);
                Fame = newFame;
                int        newGoal;
                ClassStats state = psr.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
                if (state != null && state.BestFame > Fame)
                {
                    newGoal = GetFameGoal(state.BestFame);
                }
                else
                {
                    newGoal = GetFameGoal(Fame);
                }
                if (newGoal > FameGoal)
                {
                    Owner.BroadcastPacket(new NotificationPacket
                    {
                        ObjectId = Id,
                        Color    = new ARGB(0xFF00FF00),
                        Text     = "Class Quest Complete!"
                    }, null);
                    Stars = GetStars();
                }
                FameGoal = newGoal;
                UpdateCount++;
            }
        }
示例#9
0
    public static void ResetPlayer()
    {
        //Debug.Log (SelectedClass);

        PlayerMoney = 0;
        PlayerClass = new ClassStats(SelectedClass);

        playerHealth   = PlayerClass.vitality;
        playerAgility  = PlayerClass.agility;
        playerVitality = PlayerClass.vitality;
        playerAccuracy = PlayerClass.acuracy;

        playerDamage     = PlayerClass.weaponStat.damage;
        playerFireRate   = PlayerClass.weaponStat.firerate;
        playerCritChance = PlayerClass.weaponStat.critChance;
        playerClipSize   = PlayerClass.weaponStat.clipSize;
        playerReloadTime = PlayerClass.weaponStat.reloadTime;
    }
    public void checkToggle()
    {
        string     answer      = currentQuestions.answer;
        bool       wasFound    = false;
        ClassStats playerStats = player.GetComponent <Player>().getClasses()[currentClassName];

        for (int count = 0; count < toggleSet.Length; count++)
        {
            if (toggleSet[count].isOn)
            {
                if (toggleSet[count].GetComponentInChildren <Text>().text == answer)
                {
                    playerStats.setXP(playerStats.getXP() + 10);
                    player.GetComponent <Player>().updateStats(currentClassName, playerStats);
                    Debug.Log("yay you got it right");
                    feedbackCanvas.SetActive(true);
                    feedbackCanvas.transform.GetChild(0).gameObject.SetActive(true);
                    feedbackCanvas.transform.GetChild(1).gameObject.SetActive(false);
                    audio[0].mute = false;
                    audio[0].Play(0);
                    audio[1].mute = true;
                    Invoke("disableCanvas", 2.0f);
                    wasFound = true;
                }
            }
        }

        if (!wasFound)
        {
            Debug.Log("you got it wrong");
            feedbackCanvas.SetActive(true);
            feedbackCanvas.transform.GetChild(0).gameObject.SetActive(false);
            feedbackCanvas.transform.GetChild(1).gameObject.SetActive(true);
            audio[1].mute = false;
            audio[1].Play(0);
            audio[0].mute = true;
            this.GetComponent <AudioSource>().Play(0);
            Invoke("disableCanvas", 2.0f);
        }

        answerCanvas.SetActive(false);
        manager.GetComponent <GameManager>().canCameraMove = true;
    }
    void OnTriggerEnter(Collider collision)
    {
        if (manager == null)
        {
            Debug.Log("the manager is a lie");
        }
        manager.GetComponent <GameManager>().canCameraMove = false;

        player      = collision.gameObject;
        playerStats = player.GetComponent <Player>().getClasses()[currentClassName];
        if (collision.tag == "Player")
        {
            answerCanvas.SetActive(true);

            /*Player player = collision.gameObject.GetComponent<Player>();
             * ClassStats data = player.getData(this.gameObject.name);
             * data.setXP(data.xp + 10);
             * player.updateStats(this.gameObject.name, data);*/
            int randomNumber = Random.Range(0, questionSet.answers.Length);
            currentQuestions = questionSet.answers[randomNumber];
            collision.GetComponent <ControladorDePersonagem>().Anima_Personagem(0);
            toggleSet[0].isOn = true;

            // string

            /* for(int count = 0; count < questionSet.answers.Length; count++)
             * {
             *   Debug.Log("question is " + questionSet.answers[count].question);
             *   Debug.Log("option 1 is " + questionSet.answers[count].option1);
             *   Debug.Log("option 2 is " + questionSet.answers[count].option2);
             *   Debug.Log("answer is " + questionSet.answers[count].answer);
             * }*/

            questionText.text = currentQuestions.question;
            setToggleText();
            answerCanvas.SetActive(true);



            //Debug.Log(questionSet.answers[randomNumber].question);
        }
    }
示例#12
0
        private void CalculateFame()
        {
            int newFame = 0;

            if (Experience < 200 * 1000)
            {
                newFame = Experience / 1000;
            }
            else
            {
                newFame = 200 + (Experience - 200 * 1000) / 1000;
            }
            if (newFame != Fame && this != null && this.Owner != null)
            {
                Fame = newFame;
                int        newGoal;
                ClassStats state = client.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
                if (state != null && state.BestFame > Fame)
                {
                    newGoal = GetFameGoal(state.BestFame);
                }
                else
                {
                    newGoal = GetFameGoal(Fame);
                }
                if (newGoal > FameGoal)
                {
                    BroadcastSync(new NotificationPacket
                    {
                        ObjectId = Id,
                        Color    = new ARGB(0xFF00FF00),
                        Text     = "Class Quest Complete!"
                    }, p => this.Dist(p) < 25);
                    Stars = GetStars();
                }
                FameGoal = newGoal;
                UpdateCount++;
            }
        }
示例#13
0
 public Hero()
 {
     Stats = new ClassStats();
     RecalculateStats();
     InventoryClass.InventoryChangedEvent += RecalculateStats;
 }
示例#14
0
        public Player(Client client)
            : base(client.Manager, (ushort)client.Character.ObjectType, client.Random)
        {
            this.client = client;
            statsMgr    = new StatsManager(this);
            Name        = client.Account.Name;
            AccountId   = client.Account.AccountId;

            Name           = client.Account.Name;
            Level          = client.Character.Level;
            Experience     = client.Character.Exp;
            ExperienceGoal = GetExpGoal(client.Character.Level);
            Stars          = GetStars();
            Texture1       = client.Character.Tex1;
            Texture2       = client.Character.Tex2;
            Effect         = client.Character.Effect;
            XmlEffect      = "";
            Skin           = client.Character.Skin;
            PermaSkin      = client.Character.PermaSkin != 0;
            XpBoost        = client.Character.XpBoost;
            Credits        = client.Account.Credits;
            Souls          = client.Account.Souls;
            NameChosen     = client.Account.NameChosen;
            CurrentFame    = client.Account.Stats.Fame;
            Fame           = client.Character.CurrentFame;
            ClassStats state = client.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);

            FameGoal = GetFameGoal(state != null ? state.BestFame : 0);

            Glowing = -1;
            Manager.Data.AddPendingAction(db =>
            {
                if (db.IsUserInLegends(AccountId))
                {
                    Glowing = 0xFF0000;
                }
                if (client.Account.Admin)
                {
                    Glowing = 0xFF00FF;
                }
            });
            Guild            = client.Account.Guild.Name;
            GuildRank        = client.Account.Guild.Rank;
            HP               = client.Character.HitPoints;
            MP               = client.Character.MagicPoints;
            Floors           = client.Character.Floors;
            ConditionEffects = 0;
            OxygenBar        = 100;

            Party = Party.GetParty(this);
            if (Party != null)
            {
                if (Party.Leader.AccountId == AccountId)
                {
                    Party.Leader = this;
                }
                else
                {
                    Party.Members.Add(this);
                }
            }

            if (HP <= 0)
            {
                HP = client.Character.MaxHitPoints;
            }

            Locked  = client.Account.Locked ?? new List <int>();
            Ignored = client.Account.Ignored ?? new List <int>();
            try
            {
                Manager.Data.AddPendingAction(db =>
                {
                    Locked  = db.GetLockeds(AccountId);
                    Ignored = db.GetIgnoreds(AccountId);
                });
            }
            catch
            {
            }

            Inventory = new Inventory(this,
                                      client.Character.Equipment
                                      .Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_])
                                      .ToArray(),
                                      client.Character.EquipData);
            Inventory.InventoryChanged += (sender, e) => CalculateBoost();
            SlotTypes =
                Utils.FromCommaSepString32(
                    client.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new[]
            {
                client.Character.MaxHitPoints,
                client.Character.MaxMagicPoints,
                client.Character.Attack,
                client.Character.Defense,
                client.Character.Speed,
                client.Character.HpRegen,
                client.Character.MpRegen,
                client.Character.Dexterity
            };

            Pet = null;

            for (int i = 0; i < SlotTypes.Length; i++)
            {
                if (SlotTypes[i] == 0)
                {
                    SlotTypes[i] = 10;
                }
            }

            AddRecipes();
        }
示例#15
0
        //private int pingSerial;

        public Player(Client client)
            : base(client.Manager, (ushort)client.Character.ObjectType, client.Random)
        {
            this.client = client;
            statsMgr    = new StatsManager(this, client.Random.CurrentSeed);
            Name        = client.Account.Name;
            AccountId   = client.Account.AccountId;

            Name           = client.Account.Name;
            Level          = client.Character.Level;
            Experience     = client.Character.Exp;
            ExperienceGoal = GetExpGoal(client.Character.Level);
            Stars          = GetStars();
            switch (client.Account.Rank)
            {
            case 1: Stars = 200; break;

            case 2: Stars = 210; break;

            case 3: Stars = 220; break;

            case 4: Stars = 230; break;

            case 5: Stars = 240; break;

            case 6: Stars = 500; break;

            case 7: Stars = 1337; break;
            }
            Texture1    = client.Character.Tex1;
            Texture2    = client.Character.Tex2;
            Effect      = client.Character.Effect;
            XmlEffect   = "";
            Skin        = client.Character.Skin;
            PermaSkin   = client.Character.PermaSkin != 0;
            XpBoost     = client.Character.XpBoost;
            Credits     = client.Account.Credits;
            Keys        = client.Account.Keys;
            NameChosen  = client.Account.NameChosen;
            CurrentFame = client.Account.Stats.Fame;
            Fame        = client.Character.CurrentFame;
            ClassStats state = client.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);

            FameGoal = GetFameGoal(state != null ? state.BestFame : 0);

            Glowing = -1;
            switch (client.Account.Rank)
            {
            /*  if (client.Client.ClientDatabase.IsUserInLegends(AccountId))
             *  Glowing = 0xFF0000; */
            case 6: Glowing = 0xFFFFFF; break;

            case 7: Glowing = 0xFF0080; break;
            }
            Guild            = GuildManager.Add(this, client.Account.Guild);
            HP               = client.Character.HitPoints;
            MP               = client.Character.MagicPoints;
            ConditionEffects = 0;
            OxygenBar        = 100;

            Party = Party.GetParty(this);
            if (Party != null)
            {
                if (Party.Leader.AccountId == AccountId)
                {
                    Party.Leader = this;
                }
                else
                {
                    Party.Members.Add(this);
                }
            }

            if (HP <= 0)
            {
                HP = client.Character.MaxHitPoints;
            }

            Locked  = client.Account.Locked ?? new List <int>();
            Ignored = client.Account.Ignored ?? new List <int>();
            try
            {
                Locked  = Client.ClientDatabase.GetLockeds(AccountId);
                Ignored = Client.ClientDatabase.GetIgnoreds(AccountId);
            } catch { }

            Inventory = new Inventory(this,
                                      client.Character.Equipment
                                      .Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_])
                                      .ToArray(),
                                      client.Character.EquipData);
            Inventory.InventoryChanged += (sender, e) => CalculateBoost();
            SlotTypes =
                Utils.FromCommaSepString32(
                    Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new[]
            {
                client.Character.MaxHitPoints,
                client.Character.MaxMagicPoints,
                client.Character.Attack,
                client.Character.Defense,
                client.Character.Speed,
                client.Character.HpRegen,
                client.Character.MpRegen,
                client.Character.Dexterity,
                client.Character.Luck,
                client.Character.Crit
            };

            /* if (client.Character.Backpacks >= 1)
             * {
             *   Inventory.SetItems(Inventory.Concat(client.Character.Backpack1.Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_])).ToArray());
             *   SlotTypes = SlotTypes.Concat(new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 }).ToArray();
             * }
             * if (client.Character.Backpacks == 2)
             * {
             *   Inventory.SetItems(Inventory.Concat(client.Character.Backpack2.Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_])).ToArray());
             *   SlotTypes = SlotTypes.Concat(new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 }).ToArray();
             * } */

            Pet = null;

            for (int i = 0; i < SlotTypes.Length; i++)
            {
                if (SlotTypes[i] == 0)
                {
                    SlotTypes[i] = 10;
                }
            }

            AddRecipes();
        }
示例#16
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            ClassStats data = (ClassStats)AssetDatabase.LoadAssetAtPath(exportPath, typeof(ClassStats));
            if (data == null)
            {
                data = ScriptableObject.CreateInstance <ClassStats> ();
                AssetDatabase.CreateAsset((ScriptableObject)data, exportPath);
                data.hideFlags = HideFlags.NotEditable;
            }

            data.sheets.Clear();
            using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read)) {
                IWorkbook book = new HSSFWorkbook(stream);

                foreach (string sheetName in sheetNames)
                {
                    ISheet sheet = book.GetSheet(sheetName);
                    if (sheet == null)
                    {
                        Debug.LogError("[Data] sheet not found:" + sheetName);
                        continue;
                    }

                    ClassStats.Sheet s = new ClassStats.Sheet();
                    s.name = sheetName;

                    for (int i = 1; i <= sheet.LastRowNum; i++)
                    {
                        IRow  row  = sheet.GetRow(i);
                        ICell cell = null;

                        ClassStats.Param p = new ClassStats.Param();

                        cell        = row.GetCell(0); p.ID = (cell == null ? "" : cell.StringCellValue);
                        p.AimOffset = new float[1];
                        cell        = row.GetCell(1); p.AimOffset[0] = (float)(cell == null ? 0.0 : cell.NumericCellValue);
                        cell        = row.GetCell(4); p.ChangeCoverChance = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell        = row.GetCell(5); p.WeaponType = (cell == null ? "" : cell.StringCellValue);
                        cell        = row.GetCell(6); p.BulletDamage = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell        = row.GetCell(7); p.ShotRateFactor = (float)(cell == null ? 0 : cell.NumericCellValue);
                        cell        = row.GetCell(8); p.ShotErrorRate = (float)(cell == null ? 0 : cell.NumericCellValue);
                        cell        = row.GetCell(9); p.Effect_MuzzleFlash = (cell == null ? "" : cell.StringCellValue);
                        cell        = row.GetCell(10); p.Effect_Shot = (cell == null ? "" : cell.StringCellValue);
                        cell        = row.GetCell(11); p.Effect_Sparks = (cell == null ? "" : cell.StringCellValue);
                        cell        = row.GetCell(12); p.Effect_BulletHole = (cell == null ? "" : cell.StringCellValue);
                        s.list.Add(p);
                    }
                    data.sheets.Add(s);
                }
            }

            ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject;
            EditorUtility.SetDirty(obj);
        }
    }
示例#17
0
        public Player(Client client)
            : base(client.Manager, (ushort)client.Character.ObjectType, client.Random)
        {
            this.client = client;
            statsMgr    = new StatsManager(this, client.Random.CurrentSeed);
            Name        = client.Account.Name;
            AccountId   = client.Account.AccountId;

            Name           = client.Account.Name;
            Level          = client.Character.Level;
            Experience     = client.Character.Exp;
            ExperienceGoal = GetExpGoal(client.Character.Level);
            Stars          = GetStars();
            Texture1       = client.Character.Tex1;
            Texture2       = client.Character.Tex2;
            Effect         = client.Character.Effect;
            XmlEffect      = "";
            Skin           = client.Character.Skin;
            PermaSkin      = client.Character.PermaSkin != 0;
            XpBoost        = client.Character.XpBoost;
            Credits        = client.Account.Credits;
            Silver         = client.Account.Silver;
            UnlockedMoods  = client.Account.UnlockedMoods;
            NameChosen     = client.Account.NameChosen;
            CurrentFame    = client.Account.Stats.Fame;
            Fame           = client.Character.CurrentFame;
            ClassStats state = client.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);

            FameGoal      = GetFameGoal(state?.BestFame ?? 0);
            CameraOffsetX = CameraOffsetY = 0;
            CameraX       = CameraY = 0;
            CameraRot     = 0;
            FixedCamera   = FixedCameraRot = false;
            CameraUpdate  = false;
            warpUses      = 0;

            Locked  = client.Account.Locked ?? new List <int>();
            Ignored = client.Account.Ignored ?? new List <int>();

            Glowing = -1;
            Manager.Data.AddDatabaseOperation(db => //We dont need to await here
            {
                if (db.IsUserInLegends(AccountId))
                {
                    Glowing = 0xFF0000;
                }
                if (client.Account.Admin)
                {
                    Glowing = 0xFF00FF;
                }
            });
            Guild            = client.Account.Guild.Name;
            GuildRank        = client.Account.Guild.Rank;
            HP               = client.Character.HitPoints;
            MP               = client.Character.MagicPoints;
            Floors           = client.Character.Floors;
            ConditionEffects = 0;
            OxygenBar        = 100;

            Party = Party.GetParty(this);
            if (Party != null)
            {
                if (Party.Leader.AccountId == AccountId)
                {
                    Party.Leader = this;
                }
                else
                {
                    Party.Members.Add(this);
                }
            }

            if (HP <= 0)
            {
                HP = client.Character.MaxHitPoints;
            }

            Inventory = new Inventory(this,
                                      client.Character.Equipment
                                      .Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_])
                                      .ToArray(),
                                      client.Character.EquipData);
            Inventory.InventoryChanged += (sender, e) => CalculateBoost();
            SlotTypes =
                Utils.FromCommaSepString32(
                    client.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new[]
            {
                client.Character.MaxHitPoints,
                client.Character.MaxMagicPoints,
                client.Character.Attack,
                client.Character.Defense,
                client.Character.Speed,
                client.Character.Vitality,
                client.Character.Wisdom,
                client.Character.Dexterity,
                client.Character.Aptitude,
                client.Character.Resilience,
                client.Character.Penetration
            };
            CalculateBoost();
            Pet = null;

            for (int i = 0; i < SlotTypes.Length; i++)
            {
                if (SlotTypes[i] == 0)
                {
                    SlotTypes[i] = 10;
                }
            }

            Ability = new Ability[3] {
                null, null, null
            };
            CacheAbilities  = Ability;
            CacheAP         = 0;
            AbilityCooldown = new int[3] {
                3, 3, 3
            };
            AbilityActiveDurations = new int[3] {
                0, 0, 0
            };
            AbilityToggle = new bool[3] {
                false, false, false
            };
            AbilityToggleVar = 0;
            Specialization   = client.Character.Specialization;

            UpdateAbilities();

            Mood = client.Character.Mood;

            MaxLevel = client.Character.MaxLevel;

            AddRecipes();

            // "default_" is default and all the rest are normal.
            // red, orange, yellow, green, blue.
            if (/*criteria*/ false)
            {
                ChatBubbleColour = "purple";
            }
            else
            {
                ChatBubbleColour = "default_";
            }
        }
示例#18
0
文件: Bandit.cs 项目: DuHerb/BOTC
 public Bandit(int id)
 {
     Stats = new ClassStats();
     Id    = id;
 }
示例#19
0
        public ClassStats ClassStats(int classGroupId)
        {
            try
            {
                LoginController.checkOnAccess(this.Request.Headers);
            }
            catch (Exception ex)
            {
                throw ex;
            };

            var        db     = new DBModel();
            ClassStats cStats = new ClassStats
            {
                RDist = new List <LessonResDistribution>(),
                ADist = new List <LessonAttempts>()
            };

            try
            {
                //Get all the records of the results in the class grouped by lesson, then grouped by student
                var results = from lc in db.LessonsToClasses
                              where lc.ClassId == classGroupId
                              join l in db.Lessons on lc.LessonId equals l.Id
                              join rl in db.ResultInLessons on l.Id equals rl.LessonId
                              join sc in db.StudentsToClasses on lc.ClassId equals sc.ClassId
                              where sc.StudentId == rl.StudentId
                              group rl by l.SeqNum into lRes
                              select new {
                    lRes.Key,
                    studentsRes = from lrg in lRes
                                  group lrg by lrg.StudentId into studRes
                                  select studRes
                };

                if (results.Any())
                {
                    List <double> avgRes;
                    List <double> avgBestRes;

                    /*------------------------------------------------------------------------------------------
                     *                                 Lesson Results Distribution
                     *------------------------------------------------------------------------------------------*/
                    //Loop through each lesson
                    foreach (var lesson in results)
                    {
                        avgRes     = new List <double>();
                        avgBestRes = new List <double>();

                        //Create lesson object
                        cStats.RDist.Add(new LessonResDistribution
                        {
                            LNum = lesson.Key
                        });

                        //Loop through each student's results in the lesson and calc his average and max results
                        foreach (var res in lesson.studentsRes)
                        {
                            avgRes.Add(res.Average(x => x.Result));
                            avgBestRes.Add(res.Max(x => x.Result));
                        }
                        ;

                        //Calc overall 'average' and 'average best' results
                        cStats.RDist.Last().AvgRes     = avgRes.Average();
                        cStats.RDist.Last().AvgBestRes = avgBestRes.Average();
                    }
                    ;

                    //Adding empty lessons objects to fill up the list to 10
                    for (int i = cStats.RDist.Count; i < NUM_OF_LESSONS_IN_CLASS; i++)
                    {
                        cStats.RDist.Add(new LessonResDistribution()
                        {
                            LNum       = i + 1,
                            AvgRes     = 0,
                            AvgBestRes = 0
                        });
                    }
                    ;

                    /*------------------------------------------------------------------------------------------
                     *                               Lesson attempts and completion distribution
                     *------------------------------------------------------------------------------------------*/
                    int passed;

                    //Loop through each lesson
                    foreach (var lesson in results)
                    {
                        passed = 0;

                        //Create lesson object
                        cStats.ADist.Add(new LessonAttempts
                        {
                            LNum = lesson.Key
                        });

                        //Check each student's results to see if he passed the lesson
                        foreach (var res in lesson.studentsRes)
                        {
                            if (res.Max(x => x.Result >= StudyController.MIN_RES_TO_PASS))
                            {
                                passed++;
                            }
                            ;
                        }
                        ;

                        cStats.ADist.Last().StFinished = passed;
                        cStats.ADist.Last().StTried    = lesson.studentsRes.Count();
                    }
                    ;

                    //Adding empty lessons objects to fill up the list to 4
                    for (int i = cStats.ADist.Count; i < NUM_OF_LESSONS_IN_CLASS; i++)
                    {
                        cStats.ADist.Add(new LessonAttempts()
                        {
                            LNum       = i + 1,
                            StFinished = 0,
                            StTried    = 0
                        });
                    }
                    ;

                    /*-------------------------------------------------------------------------------------------
                    *                               Course average result
                    *------------------------------------------------------------------------------------------*/
                    var query = from pc in db.ProgressInClasses
                                where pc.ClassId == classGroupId
                                select pc.Result;
                    if (query.Any())
                    {
                        cStats.AvgRes = (double)query.Average();
                    }

                    else
                    {
                        cStats.AvgRes = 0;
                    };
                }

                else
                {
                    cStats.AvgRes = 0;
                };

                return(cStats);
            }
            catch (Exception ex)
            {
                throw ex;
            };
        }
示例#20
0
    public ClassStats getStats(string lookupName)
    {
        ClassStats stats = classes[lookupName];

        return(stats);
    }
示例#21
0
 public Hero()
 {
     Stats = new ClassStats();
     RecalculateStats();
     InventoryClass.InventoryChangedEvent += RecalculateStats;
 }