Example #1
0
        public Pokemon(Player owner, PokemonCustomInfo custom, GameSettings settings)
        {
            Id = settings.NextId();
              Owner = owner;
              TeamId = owner.TeamId;

              Name = custom.Name;
              PokemonType = DataService.GetPokemonType(custom.PokemonTypeId);
              Gender = custom.Gender;
              Lv = custom.Lv;
              Ability = DataService.GetAbility(custom.AbilityId);
              Nature = custom.Nature;

              {
            Moves = new Move[4];
            int i = 0;
            foreach (int moveId in custom.MoveIds)
              if (i < 4) Moves[i++] = new Move(moveId, settings);
            StruggleId = settings.NextId();
            SwitchId = settings.NextId();
              }

              Base = new ReadOnly6D(PokemonType.BaseHp, PokemonType.BaseAtk, PokemonType.BaseDef, PokemonType.BaseSpAtk, PokemonType.BaseSpDef, PokemonType.BaseSpeed);
              Iv = new ReadOnly6D(custom.HpIv, custom.AtkIv, custom.DefIv, custom.SpAtkIv, custom.SpDefIv, custom.SpeedIv);
              Ev = new ReadOnly6D(custom.HpEv, custom.AtkEv, custom.DefEv, custom.SpAtkEv, custom.SpDefEv, custom.SpeedEv);
              Static = new ReadOnly6D(GetState(StatType.Hp), GetState(StatType.Atk), GetState(StatType.Def), GetState(StatType.SpAtk), GetState(StatType.SpDef), GetState(StatType.Speed));

              if (custom.ItemId.HasValue) Item = DataService.GetItem(custom.ItemId.Value);
              State = PokemonState.Normal;
              Hp = new PairValue(Static.Hp, Static.Hp, 48);
        }
Example #2
0
 public static bool Validate(PokemonCustomInfo pm)
 {
     PokemonType pmType = DataService.GetPokemonType(pm.PokemonTypeId);
     if (pmType == null)
         return false;
     if (!pmType.Abilities.Contains(pm.AbilityId))
         return false;
     if (!ValidateEv(pm))
         return false;
     if (!ValidateLv(pm.Lv))
         return false;
     if (!ValidateIv(pm.HpIv))
         return false;
     if (!ValidateIv(pm.AtkIv))
         return false;
     if (!ValidateIv(pm.DefIv))
         return false;
     if (!ValidateIv(pm.SpeedIv))
         return false;
     if (!ValidateIv(pm.SpAtkIv))
         return false;
     if (!ValidateIv(pm.SpDefIv))
         return false;
     if (!ValidateMoves(pm))
         return false;
     return true;
 }
Example #3
0
 public SimGame(int userId, int teamId, PokemonCustomInfo[] pms, GameSettings settings)
 {
     Team = new Team(teamId, settings);
       Team.AddPlayer(userId, pms);
       Player = Team.GetPlayer(userId);
       Pokemons = new SimPokemon[settings.XBound];
       pokemons = new List<SimPokemon>();
 }
Example #4
0
        public PokemonViewModel(IFolderViewModel folderViewModel, PokemonCustomInfo model)
        {
            this.Folder = folderViewModel;
              this._model = model;
              InitializeCommand();

              PropertyChangedEventManager.AddListener(Model, this, "PokemonTypeId");
        }
Example #5
0
File: Player.cs Project: sunoru/PBO
 public Player(int userId, int teamId, PokemonCustomInfo[] pokemons, GameSettings settings)
 {
     Id = userId;
       TeamId = teamId;
       Pokemons = new Pokemon[pokemons.Length];
       for (int i = 0; i < pokemons.Length; i++)
     Pokemons[i] = new Pokemon(this, pokemons[i], settings);
 }
Example #6
0
 public MoveLearnItemViewModel(PokemonCustomInfo pm, MoveLearnItem model)
 {
     this.Pokemon = pm;
     this.Model = model;
     this.MoveType = DataService.GetMoveType(Model.MoveId);
     this._isSelected = Pokemon.MoveIds.Contains(Model.MoveId);
     this.Name = DataService.DataString.GetLocalizedString(MoveType.Name);
 }
Example #7
0
 public void Start(PokemonCustomInfo[] pokemons)
 {
   if (user.Role == UserRole.Player)
   {
     user.EnterSucceed += EnterSucceed;
     user.JoinGame(pokemons, 1);
   }
 }
Example #8
0
File: Team.cs Project: sunoru/PBO
 internal bool AddPlayer(int userId, PokemonCustomInfo[] pokemons)
 {
     if (Players.Count < PlayerCount)
       {
     Players.Add(new Player(userId, this.Id, pokemons, settings));
     if (Players.Count == PlayerCount)
       foreach (Player p in Players)
     foreach (Pokemon pm in p.Pokemons)
       Pokemons.Add(pm.Id, pm);
     return true;
       }
       return false;
 }
Example #9
0
File: Host.cs Project: sunoru/PBO
 void IRoomManager.JoinGame(int userId, PokemonCustomInfo[] pokemons, int teamId)
 {
   bool canStartGame = CanStartGame;
   if (game.SetPlayer(teamId, userId, pokemons))
   {
     players.Add(userId);
     users.Add(userId);
     InformEnterSucceed(userId);
     if (CanStartGame != canStartGame) OnPropertyChanged(CAN_START_GAME);
   }
   else
     InformEnterFailed("debug.failed", userId);
 }
Example #10
0
 public abstract void SetPokemon(int index, PokemonCustomInfo pm);
Example #11
0
 public abstract void AddPokemon(PokemonCustomInfo pm);
Example #12
0
 public abstract bool RemovePokemon(PokemonCustomInfo pm);
Example #13
0
File: Player.cs Project: sunoru/PBO
 public void JoinGame(PokemonCustomInfo[] info, int teamId)
 {
     this.pokemons = info;
       this.teamId = teamId;
       sendCommand(new JoinGameCommand(info, teamId));
 }
Example #14
0
 public bool Challenge(int target, PokemonCustomInfo[] pokemons, GameSettings settings)
 {
   User u = GetUser(target);
   if (u != null && u.State != UserState.Battling && pokemons != null && pokemons.Length > 0) //it's impossible for a client to get UserState.Invalid
     lock (roomLock)
     {
       if (challengingPms == null)
       {
         SendMessage(CHALLENGE, writer => settings.WriteToMessage(writer), target);
         challengingPms = pokemons;
         currentSettings = settings;
         return true;
       }
     }
   return false;
 }
Example #15
0
 public static bool ValidateEv(PokemonCustomInfo pm)
 {
     return pm.HpEv + pm.AtkEv + pm.DefEv + pm.SpeedEv +
         pm.SpAtkEv + pm.SpDefEv <= 510;
 }
Example #16
0
 public void InsertPokemon(int index, PokemonCustomInfo pm)
 {
     internalPokemons.Insert(index, pm);
     Trim();
 }
Example #17
0
 private void StartGame(PokemonCustomInfo[] pokemonsTeam)
 {
   //roomLock is already locked
   battleClient.EnterSucceed += EnterSucceed;
   battleClient.MessageSent += (sender, e) =>
     SendMessage(GAME_MESSAGE, writer =>
     {
       writer.Write(e.Message.Header);
       writer.Write(e.Message.Content);
     }, e.Receivers);
   battleClient.Start(pokemonsTeam);
 }
Example #18
0
 public bool AcceptChallenge(int challenger, PokemonCustomInfo[] pokemons)
 {
   if (pokemons != null && pokemons.Length > 0)
   lock (roomLock)
     if (battleClient == null)
     {
       SendMessage(ACCEPT_CHALLENGE, challenger);
       //假如对方房间还没设好怎么办...测试了似乎没问题?
       battleClient = new SingleClient(challenger, currentSettings);
       StartGame(pokemons);
       challengingPms = null;
       return true;
     }
   return false;
 }
Example #19
0
File: Game.cs Project: sunoru/PBO
 bool IGame.SetPlayer(int teamId, int userId, PokemonCustomInfo[] pokemons)
 {
     //TODO: Verify
       return Teams[teamId].AddPlayer(userId, pokemons);
 }
Example #20
0
 public void Start(PokemonCustomInfo[] pokemons)
 {
     user.EnterSucceed += EnterSucceed;
       user.JoinGame(pokemons, 0);
 }
Example #21
0
 public void AddPokemon(PokemonCustomInfo pm)
 {
     Contract.Requires(pm != null);
     Contract.Requires(CanAddPokemon);
 }
Example #22
0
 public void AddPokemon(PokemonCustomInfo pm)
 {
     internalPokemons.Add(pm);
     Trim();
 }
Example #23
0
 public static bool ValidateMoves(PokemonCustomInfo pm)
 {
     return pm.MoveIds.Count() <= 4;
 }
Example #24
0
 public bool RemovePokemon(PokemonCustomInfo pm)
 {
     return internalPokemons.Remove(pm);
 }
Example #25
0
 public void Start(PokemonCustomInfo[] pokemons)
 {
 }
Example #26
0
 public void SetPokemon(int index, PokemonCustomInfo pm)
 {
     internalPokemons[index] = pm;
 }
Example #27
0
 public void InsertPokemon(int index, PokemonCustomInfo pm)
 {
     Contract.Requires(CanAddPokemon);
 }