Ejemplo n.º 1
0
        public static StatHolder getRandomStatsByLevel(IStatHolder statsToFill, byte level)
        {
            var statsToAccrue = 0;

            for (byte i = 0; i++ <= level;)
            {
                statsToAccrue += RegionConstants.GetConstants(ConstantType.STAT_POINTS_PER_LEVEL)[i];
            }

            while (statsToAccrue > 0)
            {
                switch (RngUtil.intRange(0, 3))
                {
                case (0):
                    statsToFill.AddToStat <Strength>(1);
                    break;

                case (1):
                    statsToFill.AddToStat <Dexterity>(1);
                    break;

                case (2):
                    statsToFill.AddToStat <Instinct>(1);
                    break;

                case (3):
                    statsToFill.AddToStat <Stamina>(1);
                    break;
                }
                statsToAccrue--;
            }
            statsToFill.SetStat <CurrHealth>(statsToFill.GetStat <MaxHealth>());
            return((StatHolder)statsToFill);
        }
Ejemplo n.º 2
0
        public void LevelUp()
        {
            int newLevel = (int)Stats.GetStat <Level>() + 1;

            if (newLevel > RegionConstants.GetConstants(ConstantType.EXPERIENCE_FOR_LEVEL).Count - 1)
            {
                return;                                                                                         //send event congratulating with max level
            }
            Stats.SetStat <Level>(newLevel);

            GetCharData <GeneralStats>().NextLevelExperience = RegionConstants.GetConstants(ConstantType.EXPERIENCE_FOR_LEVEL)[(byte)newLevel];
            GetCharData <GeneralStats>().Gold += RegionConstants.GetConstants(ConstantType.CURRENCY_PER_LEVEL)[(byte)newLevel];; //TODO: rewrite to Currency.AddGold(gold);
            Stats.SetStat <StatPoints>(RegionConstants.GetConstants(ConstantType.STAT_POINTS_PER_LEVEL)[(byte)newLevel]);
            //Stats.AddToStat<MaxHealth>(Stats.GetStatBase(new MaxHealth())*0.15f);
            Stats.Dirty = true;

            var cplayer = this as CPlayerInstance;

            if (cplayer != null)
            {
                cplayer.Store();
                cplayer.SendPacket(new LevelUpPacket(this));
            }
        }
Ejemplo n.º 3
0
        public void execute()
        {
            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var character = session.QueryOver <ComplexCharacter>().Where(cc => cc.Id == player.ObjectId).List().FirstOrDefault();
                    if (character != null)
                    {
                        transaction.Commit();                         //close connection
                        player.Name = character.Name;

                        //Appearance

                        //Level
                        //player.Stats.SetStat<Level>(character.Level); is set in Stats

                        //Position
                        if (!string.IsNullOrEmpty(character.Position))
                        {
                            player.Position = Position.Deserialize(character.Position);
                        }
                        else
                        {
                            player.Position = new Position();
                        }

                        //Guild
                        //Titles
                        //Timers

                        var GenStats = player.GetCharData <GeneralStats>();
                        if (!string.IsNullOrEmpty(character.GenStats))
                        {
                            GenStats.DeserializeStats(character.GenStats);
                            ((ItemHolder)player.Items).SetInventorySlots(GenStats.InventorySlots);
                        }
                        else
                        {
                            GenStats.Experience          = RegionConstants.GetConstants(ConstantType.EXPERIENCE_FOR_LEVEL)[0];
                            GenStats.NextLevelExperience = RegionConstants.GetConstants(ConstantType.EXPERIENCE_FOR_LEVEL)[1];
                            GenStats.Battles             = 0;
                            GenStats.Win            = 0;
                            GenStats.Loss           = 0;
                            GenStats.Tie            = 0;
                            GenStats.Gold           = 0;
                            GenStats.Skulls         = 0;
                            GenStats.InventorySlots = 20;
                            ((ItemHolder)player.Items).SetInventorySlots(GenStats.InventorySlots);
                        }

                        player.GetCharData <EloKeeper>().UpdateElo(character.Elo);

                        if (!string.IsNullOrEmpty(character.Stats))
                        {
                            player.Stats.DeserializeStats(character.Stats);
                        }

                        //equipment
                        if (!string.IsNullOrEmpty(character.Items))
                        {
                            player.Items.DeserializeItems(character.Items);
                        }
                        else
                        {
                            player.Client.Log.DebugFormat("{0}", player.Items.AddItem(1));
                            player.Client.Log.DebugFormat("{0}", player.Items.AddItem(4));
                            player.Client.Log.DebugFormat("{0}", player.Items.AddItem(5));
                            player.Client.Log.DebugFormat("{0}", player.Items.AddItem(6));
                            player.Items.EquipItem(1);
                            player.Items.EquipItem(2);
                            player.Items.EquipItem(2);
                            player.Client.Log.DebugFormat("{0}", player.Items.AddItem(2));
                            player.Client.Log.DebugFormat("{0}", player.Items.AddItem(3));
                            player.Client.Log.DebugFormat("{0}", player.Items.AddItem(7));
                            player.Client.Log.DebugFormat("{0}", player.Items.AddItem(2));
                        }
                        player.Stats.SetStat <CurrHealth>(player.Stats.GetStat <MaxHealth>());
                    }
                    else
                    {
                        transaction.Commit();
                        player.Client.Log.FatalFormat("{0} - Should not reach - Character not found in database", CLASSNAME);
                    }
                }
            }
        }