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); }
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; }
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>(); }
public PokemonViewModel(IFolderViewModel folderViewModel, PokemonCustomInfo model) { this.Folder = folderViewModel; this._model = model; InitializeCommand(); PropertyChangedEventManager.AddListener(Model, this, "PokemonTypeId"); }
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); }
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); }
public void Start(PokemonCustomInfo[] pokemons) { if (user.Role == UserRole.Player) { user.EnterSucceed += EnterSucceed; user.JoinGame(pokemons, 1); } }
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; }
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); }
public abstract void SetPokemon(int index, PokemonCustomInfo pm);
public abstract void AddPokemon(PokemonCustomInfo pm);
public abstract bool RemovePokemon(PokemonCustomInfo pm);
public void JoinGame(PokemonCustomInfo[] info, int teamId) { this.pokemons = info; this.teamId = teamId; sendCommand(new JoinGameCommand(info, teamId)); }
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; }
public static bool ValidateEv(PokemonCustomInfo pm) { return pm.HpEv + pm.AtkEv + pm.DefEv + pm.SpeedEv + pm.SpAtkEv + pm.SpDefEv <= 510; }
public void InsertPokemon(int index, PokemonCustomInfo pm) { internalPokemons.Insert(index, pm); Trim(); }
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); }
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; }
bool IGame.SetPlayer(int teamId, int userId, PokemonCustomInfo[] pokemons) { //TODO: Verify return Teams[teamId].AddPlayer(userId, pokemons); }
public void Start(PokemonCustomInfo[] pokemons) { user.EnterSucceed += EnterSucceed; user.JoinGame(pokemons, 0); }
public void AddPokemon(PokemonCustomInfo pm) { Contract.Requires(pm != null); Contract.Requires(CanAddPokemon); }
public void AddPokemon(PokemonCustomInfo pm) { internalPokemons.Add(pm); Trim(); }
public static bool ValidateMoves(PokemonCustomInfo pm) { return pm.MoveIds.Count() <= 4; }
public bool RemovePokemon(PokemonCustomInfo pm) { return internalPokemons.Remove(pm); }
public void Start(PokemonCustomInfo[] pokemons) { }
public void SetPokemon(int index, PokemonCustomInfo pm) { internalPokemons[index] = pm; }
public void InsertPokemon(int index, PokemonCustomInfo pm) { Contract.Requires(CanAddPokemon); }