Register for your free account! | Forgot your password?

You last visited: Today at 00:34

  • Please register to post and access all features, it's quick, easy and FREE!


Pokémon System

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 754
Pokémon System

I don't want to help you implement it and I just did it for fun. It's really simple and can be improved a lot, but just to give an idea.

The object in PokemonTrainer is supposed to be your GameClient, where you invoke the event and then send whatever info to the Conquer Client.

Code:
namespace ConquerPokemonSystem
{
    public class PokemonTrainer
    {
        public Action<object, string> OnReceiveMessage;
        public Action<object, string> OnLearnReplaceSkillRequest;
        public Action<Skill, sbyte> OnLearnReplaceSkill;
        public Action<object, Pokemon> OnDie;
        public object Client;

        public List<Pokemon> Pokemons = new List<Pokemon>(6);
        public Dictionary<byte, Badge> Badges = new Dictionary<byte, Badge>();
    }

    public class Pokemon
    {
        PokemonTrainer Owner;
        public Pokemon()
        {
            Owner.OnLearnReplaceSkill = new Action<Skill, sbyte>(LearnReplaceSkill);
        }

        public List<Skill>Skills = new List<Skill>(4);
        public ulong Experience = 0;
        public List<TypeElement> Type = new List<TypeElement>();
        public bool Alive = true;
        public sbyte Level = 1;
        public string Name;
        public uint HP;
        public uint GiveExp;

        public bool Strong(TypeElement Against)
        {
            switch (Against)
            {
                case TypeElement.Dark:
                    return this.Type.Contains(TypeElement.Light);

                case TypeElement.Light:
                    return this.Type.Contains(TypeElement.Dark);

                case TypeElement.Nature:
                    return this.Type.Contains(TypeElement.Fire);

                case TypeElement.Fire:
                    {
                        if (this.Type.Contains(TypeElement.Water) || this.Type.Contains(TypeElement.Ice))
                            return true;
                        else
                            return false;
                    }

                case TypeElement.Water:
                    {
                        if (this.Type.Contains(TypeElement.Lightning) || this.Type.Contains(TypeElement.Nature))
                            return true;
                        else
                            return false;
                    }

                case TypeElement.Ground:
                    {
                        if (this.Type.Contains(TypeElement.Water) || this.Type.Contains(TypeElement.Nature))
                            return true;
                        else
                            return false;
                    }

                case TypeElement.Lightning:
                    return this.Type.Contains(TypeElement.Ground);

                case TypeElement.Flying:
                    return this.Type.Contains(TypeElement.Lightning);

                case TypeElement.Ice:
                    return this.Type.Contains(TypeElement.Fire);

                case TypeElement.Normal:
                default:
                    return false;
            }
        }

        public void GetHit(Pokemon Attacker, Skill skill)
        {
            uint Damage = (Attacker.Level > (Level * 2)) ? 
                ((skill.MaxDamage / 2) > skill.MinDamage) ? (uint)(new Random().Next((int)skill.MinDamage, (int)(skill.MaxDamage / 2))) :
                (uint)1 : (uint)(new Random().Next((int)skill.MinDamage, (int)skill.MaxDamage));

            foreach (TypeElement Type in this.Type)
            {
                if (Attacker.Strong(Type) || skill.Strong(Type))
                {
                    Damage *= 2;
                    break;
                }
            }

            if (new Random().Next(skill.CritChance) == skill.CritHit)
            {
                Damage += (Damage / 2);
                Owner.OnReceiveMessage.Invoke(Owner.Client, "Critical hit!!");
            }

            Owner.OnReceiveMessage.Invoke(Owner.Client, Name + " got hit with a total damage of " + Damage);

            if (HP > Damage)
            {
                HP = 0;
                Alive = false;
                Owner.OnDie.Invoke(Owner.Client, this);
                Owner.OnReceiveMessage.Invoke(Owner.Client, Name + " has fainted...");

                ulong Exp = (Attacker.Level > Level) ? (uint)((new Random().Next((int)GiveExp)) % 2) : (uint)(new Random().Next((int)GiveExp));
                Attacker.Experience += Exp;
                Owner.OnReceiveMessage.Invoke(Owner.Client, Name + " has received a total amount of experience on " + Exp);
            }
            else
            {
                HP -= Damage;
                Owner.OnReceiveMessage.Invoke(Owner.Client, Name + " got hit with a total damage of " + Damage);
            }
        }

        public void Learn(Skill skill)
        {
            if (Skills.Contains(skill))
            {
                Owner.OnReceiveMessage.Invoke(Owner.Client, Name + " does already know this move.");
                return;
            }

            if (Skills.Count > Skills.Capacity)
            {
                Owner.OnLearnReplaceSkillRequest.Invoke(Owner.Client, "Which move are you interested in replace with " + skill.Name + "?");
                return;
            }

            Skills.Add(skill);
            Owner.OnReceiveMessage.Invoke(Owner.Client, "Congratulations " + Name + " has learned " + skill.Name + ".");
        }

        private void LearnReplaceSkill(Skill NewSkill, sbyte ReplaceSkill)
        {
            Skills[ReplaceSkill] = NewSkill;
            Owner.OnReceiveMessage.Invoke(Owner.Client, "Congratulations " + Name + " has learned " + NewSkill.Name + ".");
        }
    }

    public class Skill
    {
        public TypeElement Type;
        public uint MinDamage, MaxDamage;
        public string Name;
        public sbyte ReqLevel;
        public sbyte Power;
        public int CritChance, CritHit;

        public bool Strong(TypeElement Against)
        {
            switch (Against)
            {
                case TypeElement.Dark:
                    return (Type == TypeElement.Light);

                case TypeElement.Light:
                    return (Type == TypeElement.Dark);

                case TypeElement.Nature:
                    return (Type == TypeElement.Fire);

                case TypeElement.Fire:
                    {
                        if (Type == TypeElement.Water || Type == TypeElement.Ice)
                            return true;
                        else
                            return false;
                    }

                case TypeElement.Water:
                    {
                        if (Type == TypeElement.Lightning || Type == TypeElement.Nature)
                            return true;
                        else
                            return false;
                    }

                case TypeElement.Ground:
                    {
                        if (Type == TypeElement.Water || Type == TypeElement.Nature)
                            return true;
                        else
                            return false;
                    }

                case TypeElement.Lightning:
                    return (Type == TypeElement.Ground);

                case TypeElement.Flying:
                    return (Type == TypeElement.Lightning);

                case TypeElement.Ice:
                    return (Type == TypeElement.Fire);

                case TypeElement.Normal:
                default:
                    return false;
            }
        }
    }

    public enum TypeElement
    {
        Normal,
        Light,
        Dark,
        Fire,
        Water,
        Lightning,
        Ice,
        Dragon,
        Fighting,
        Ground,
        Flying,
        Nature,
        Psychic
    }

    public class Badge
    {
        public string GymLeader, Name, Description;
    }
}



BaussHacker is offline  
Thanks
2 Users
Old 09/27/2011, 20:55   #2
 
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 210
LOL. this is priceless (:


killersub is offline  
Old 09/27/2011, 20:56   #3
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 754
Quote:
Originally Posted by killersub View Post
LOL. this is priceless (:
LOL I was so bored and didn't know what to do.
BaussHacker is offline  
Old 09/27/2011, 21:01   #4
 
elite*gold: 0
Join Date: Jul 2010
Posts: 102
Received Thanks: 77
pokeman naice naice


Benguin is offline  
Old 09/27/2011, 21:02   #5
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 754
Quote:
Originally Posted by Benguin View Post
pokeman naice naice
Benguin is the best pokemon.
BaussHacker is offline  
Old 09/27/2011, 21:04   #6
 
elite*gold: 0
Join Date: Jul 2010
Posts: 102
Received Thanks: 77
Quote:
Originally Posted by BaussHacker View Post
Benguin is the best pokemon.
A wild Benguin appears!
Benguin is offline  
Thanks
1 User
Old 09/27/2011, 21:05   #7
 
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 210
Quote:
Originally Posted by Benguin View Post
A wild Benguin appears!
A wild snorlax awakens from his slumber.
killersub is offline  
Old 09/27/2011, 21:07   #8
 
elite*gold: 0
Join Date: Jul 2010
Posts: 102
Received Thanks: 77
Quote:
Originally Posted by killersub View Post
A wild snorlax awakens from his slumber.
it cant move anyway
Benguin is offline  
Old 09/27/2011, 21:08   #9
 
elite*gold: 0
Join Date: Nov 2009
Posts: 785
Received Thanks: 405
Lol, epic...
F i n c h i is offline  
Old 09/27/2011, 21:11   #10
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 754
Quote:
Originally Posted by Benguin View Post
A wild Benguin appears!
This is going in my quote.
BaussHacker is offline  
Thanks
1 User
Old 09/27/2011, 21:11   #11
 
elite*gold: 0
Join Date: Jul 2010
Posts: 1,517
Received Thanks: 559
I don't know what to say...
Captivate is offline  
Old 09/27/2011, 21:27   #12
 
elite*gold: 12
Join Date: Jul 2011
Posts: 7,015
Received Thanks: 3,370
I think Conquer Offline should implement.
Spirited is offline  
Old 09/27/2011, 21:33   #13
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 754
Quote:
Originally Posted by Fаng View Post
I think Conquer Offline should implement.
I was thinking of making a source for it actually. Should be so inefficient, hmmm try/catch, synchronous sockets, threads with more threads and more ****. Maybe some random invalid packets?
BaussHacker is offline  
Old 09/28/2011, 08:14   #14
 
elite*gold: 0
Join Date: May 2011
Posts: 648
Received Thanks: 411
Quote:
Originally Posted by BaussHacker View Post
This is going in my quote.
STEALING MY IDEA?! **** YOU MOTHERFUCKYOUBITCH <3

Quote:
Originally Posted by BaussHacker View Post
I was thinking of making a source for it actually. Should be so inefficient, hmmm try/catch, synchronous sockets, threads with more threads and more ****. Maybe some random invalid packets?
LOL, didnt we say, UDP sockets, because the client wont work with them?
Also, some random valid packets every century, everything else invalid.
Oh wait, wouldnt matter since we use UDP xD
Y u k i is offline  
Thanks
1 User
Old 09/28/2011, 08:19   #15
 
elite*gold: 0
Join Date: Sep 2006
Posts: 248
Received Thanks: 117
Quote:
Originally Posted by BaussHacker View Post
I was thinking of making a source for it actually. Should be so inefficient, hmmm try/catch, synchronous sockets, threads with more threads and more ****. Maybe some random invalid packets?
I think it'd be a bit better for Eudemons, since they have pets already... o.O


EviL|Shepherd is offline  
Reply




All times are GMT +2. The time now is 00:34.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.