public virtual void AwardPoints(Mobile from, double points, bool quest = false, bool message = true) { if (!(from is PlayerMobile) || points <= 0) { return; } PlayerMobile pm = from as PlayerMobile; if (!PlayerTable.ContainsKey(pm)) { if (!AutoAdd) { return; } PlayerTable[pm] = 0; OnPlayerAdded(pm); } double old = PlayerTable[pm]; SendMessage(pm, old, points, quest); SetPoints(pm, Math.Min(MaxPoints, PlayerTable[pm] + points)); }
public virtual void Deserialize(GenericReader reader) { int version = reader.ReadInt(); switch (version) { case 0: case 1: int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PlayerMobile player = reader.ReadMobile() as PlayerMobile; PointsEntry entry = GetSystemEntry(player); if (version > 0) { entry.Deserialize(reader); } else { entry.Points = reader.ReadDouble(); } if (player != null) { if (!PlayerTable.Contains(entry)) { PlayerTable.Add(entry); } } } break; } }
/// <summary> /// Метод проверяет окончена ли игра /// Method checks whethe game is over /// </summary> /// <returns>True если игра окончена/Returns true if game is over</returns> public bool IsGameEnded() { var predecates = GameoverPredicate.GetInvocationList(); bool result = false; foreach (var p in predecates) { if (((GameLogicsAttributes.GameoverPredicate)p)()) { result = true; } } if (result) { SnakesTable snakesTable = new SnakesTable(); PlayerTable playerTable = new PlayerTable(); foreach (var s in SnakesForLogic.Snakes) { snakesTable.UpdateStatistics(s); if (s.SnakeName.Contains("Player")) { playerTable.AddNewRow(s.SnakeName, GameType, s.Statistics.EatenFood); } } } return(result); }
public void SetPoints(PlayerMobile pm, double points) { if (PlayerTable.ContainsKey(pm)) { PlayerTable[pm] = points; } }
/// <summary> /// Reads the player information from a row /// </summary> /// <param name="row">The row to read from</param> /// <param name="type">The type of row</param> /// <returns></returns> public Player ReadPlayerRow(IWebElement row, PlayerTable type) { int pBioBoxDivNum = 0; int projDivNum = 0; bool isMovable = false; switch (type) { case PlayerTable.FreeAgent: pBioBoxDivNum = 1; projDivNum = 6; isMovable = IsFreeAgentClickable(row, true); break; case PlayerTable.Roster: pBioBoxDivNum = 2; projDivNum = 6; isMovable = IsRosterClickable(row); break; } var pBioBox = row.FindElement(By.XPath($"td[{pBioBoxDivNum}]/div/div/div[2]/div")); var pBio = ReadPlayerBioBox(pBioBox); string proj = row.FindElement(By.XPath($"./td[{projDivNum}]/div/span")).Text; Double.TryParse(proj, out double projected); return(new Player(pBio.Item1, pBio.Item2, pBio.Item3, pBio.Item4, projected, isMovable)); }
public virtual void Deserialize(GenericReader reader) { Version = reader.ReadInt(); switch (Version) { case 2: // added serialize/deserialize in all base classes. Poor implementation on my part, should have had from the get-go case 1: case 0: int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PlayerMobile player = reader.ReadMobile() as PlayerMobile; PointsEntry entry = GetSystemEntry(player); if (Version > 0) { entry.Deserialize(reader); } else { entry.Points = reader.ReadDouble(); } if (player != null) { if (!PlayerTable.Contains(entry)) { PlayerTable.Add(entry); } } } break; } }
public void OnNewTradeDeal(TradeDeal newtradedeal) { if (ActiveTradeDeal == TradeDeal.None) { NextTradeDealCheck = DateTime.UtcNow + TimeSpan.FromDays(TradeDealCostPeriod); } else if (newtradedeal == TradeDeal.None) { NextTradeDealCheck = DateTime.MinValue; TradeDealStart = DateTime.MinValue; } else { TradeDealStart = DateTime.UtcNow; } ActiveTradeDeal = newtradedeal; if (Stone != null) { Stone.InvalidateProperties(); } foreach (CityLoyaltyEntry player in PlayerTable.OfType <CityLoyaltyEntry>()) { if (player.UtilizingTradeDeal) { player.UtilizingTradeDeal = false; } } }
private void UpdateTable() { foreach (var row in Rows) { Destroy(row); } if (table == null) { table = new PlayerTable(); } table.UpdatePlayerInfo(); var statistics = table.GameInfo; foreach (var element in statistics) { var tempRow = Instantiate(RowPrefab); tempRow.SetActive(true); tempRow.transform.parent = Content.transform; tempRow.transform.name = name; tempRow.transform.GetChild(0).GetComponent <UnityEngine.UI.Text>().text = element.ID.ToString(); tempRow.transform.GetChild(1).GetComponent <UnityEngine.UI.Text>().text = element.Date.ToString(); tempRow.transform.GetChild(2).GetComponent <UnityEngine.UI.Text>().text = element.PlayerType; tempRow.transform.GetChild(3).GetComponent <UnityEngine.UI.Text>().text = element.GameType; tempRow.transform.GetChild(4).GetComponent <UnityEngine.UI.Text>().text = element.Score.ToString(); Rows.Add(tempRow); } }
private static void AppendConnect(CMsgConnect connect, GameClient client) { client.CreatedUID = connect.Identifier; GameClient confirmationClient; // Prevent logged on clients to login again. if (client.MyServer.ConfirmationPool.TryRemove(connect.Identifier, out confirmationClient) || client.MyServer.GamePool.TryRemove(connect.Identifier, out confirmationClient)) { confirmationClient.Disconnect(); client.Send(new CMsgTalk(Color.Orange, ChatType.Dialog, "You're already logged in.", "", "ALLUSERS")); client.Disconnect(); return; } if (!client.IsCreating) { client.MyServer.ConfirmationPool.TryAdd(connect.Identifier, client); } else { client.IsCreating = false; } if (!PlayerTable.Load(client.CreatedUID, ref client.Player, client.MyServer)) { client.IsCreating = true; client.Send(new CMsgTalk(Color.Orange, ChatType.Dialog, "NEW_ROLE", "", "ALLUSERS")); return; } // BELOW IS ONLY IF THE ACCOUNT IS VALID client.Send(new CMsgTalk(Color.Orange, ChatType.Dialog, "ANSWER_OK", "", "ALLUSERS")); client.Send(new CMsgUserInfo(client.Player)); client.MyServer.ConfirmationPool.TryRemove(connect.Identifier, out confirmationClient); }
private FileInfo CreateGameDatabaseFiles(Game game, DirectoryInfo dir) { FileInfo gameFile = GameTableFile(game); var db = CreateSQLLiteConnection.Create(gameFile); db.CreateTable <GameTable>(); db.CreateTable <PlayersTable>(); db.CreateTable <PlayerTable>(); GameTable gametable = new GameTable(); gametable.ID = game.ID; int turnID = 0; foreach (Player player in game.Players) { PlayerTable playerTable = new PlayerTable(); playerTable.ID = player.ID; playerTable.Name = player.Name; playerTable.Email = player.EMail; PlayersTable playersTable = new PlayersTable(); playersTable.GameID = game.ID; playersTable.PlayerID = player.ID; playersTable.Turn = turnID; turnID++; } return(gameFile); }
// Token: 0x06000056 RID: 86 RVA: 0x0000644C File Offset: 0x0000464C private void InfoTabUpdate(SteamData.Lobby Lobby, int CheckResult) { if (CheckResult != 2 || !InternalConfig.Restricted) { this.LabelIdValue.Text = Lobby.id.ToString(); } else { this.LabelIdValue.Text = "Private"; } this.LabelTypeValue.Text = SteamData.lobbyTypes[(int)Lobby.typeId]; this.LabelCreatorValue.Text = Lobby.creator; this.LabelPlayerCountValue.Text = Lobby.playerCount.ToString(); if (Lobby.state != 4) { this.LabelActivityValue.Text = SteamData.GetActivity(Lobby); this.LabelEventValue.Text = PlayerTable.GetEvent(Lobby.typeId, Lobby.matchModeId, false); string[] array = PlayerTable.GetTrack(Lobby.typeId, Lobby.matchModeId, false).Split(" ".ToCharArray(), 2); this.LabelTrack.Text = array[0]; this.LabelTrackValue.Text = array[1]; this.LabelDifficultyValue.Text = PlayerTable.GetDifficulty(Lobby.difficultyId, false); return; } this.LabelActivityValue.Text = "Unknown"; this.LabelEventValue.Text = "Unknown"; this.LabelTrackValue.Text = "Unknown"; this.LabelDifficultyValue.Text = "Unknown"; }
public TEntry GetPlayerEntry <TEntry>(PlayerMobile pm) where TEntry : PointsEntry { if (pm == null) { return(null); } return(PlayerTable.FirstOrDefault(p => p.Player == pm) as TEntry); }
public double GetPoints(Mobile from) { if (from is PlayerMobile && PlayerTable.ContainsKey(from as PlayerMobile)) { return(PlayerTable[(PlayerMobile)from]); } return(0.0); }
public void Start() { Console.WriteLine("\t\tВаше поле"); PlayerTable.Show(PlayerShips); Console.SetCursorPosition(60, 0); Console.WriteLine("\t\tПоле компьютера"); ComputerTable.ShowWithCursorParametr(PlayerShips, 60, 0); ProccessArrangement(); }
public LocalDB(string dbPath) : base(dbPath) { SetTables( (Sounds = new SoundTable(this)), (GameDataUrls = new GameDataUrlTable(this)), (Games = new GameTable(this)), (Teams = new TeamTable(this)), (Players = new PlayerTable(this))); }
public void ClearData() { if (table == null) { table = new PlayerTable(); } table.ClearTable(); UpdateTable(); }
private void Awake() { instance = this; playerTable = new PlayerTable(); playerTable.Load(csv); foreach (var iter in playerTable.GetRowList()) { PlayerInfo info = new PlayerInfo(iter.Level, iter.MaxExp, iter.MissileCount); playerInfoList.Add(info); } }
public virtual void Serialize(GenericWriter writer) { writer.Write((int)1); writer.Write(PlayerTable.Count); PlayerTable.ForEach(entry => { writer.Write(entry.Player); entry.Serialize(writer); }); }
public virtual PointsEntry AddEntry(PlayerMobile pm) { PointsEntry entry = GetSystemEntry(pm); if (!PlayerTable.Contains(entry)) { PlayerTable.Add(entry); OnPlayerAdded(pm); } return(entry); }
public void AddPlayer(int personId, bool isRightHanded, bool isTwoHandedBackhand) { var player = new PlayerTable { Id = personId, IsRightHanded = isRightHanded, IsTwoHandedBackhand = isTwoHandedBackhand }; dynamic db = this.GetDatabase(); db.Player.Insert(player); }
public Task SetPlayerCoach(int playerId, int?newCoachId, int?previousCoachId) { var player = new PlayerTable { Id = playerId }; this.PlayerTable.Attach(player); this.Entry(player).Property(p => p.CoachId).OriginalValue = previousCoachId; player.CoachId = newCoachId; return(this.SaveChangesAsync()); }
public Task AddPlayer(int personId, bool isRightHanded, bool isTwoHandedBackhand) { var player = new PlayerTable { Id = personId, IsRightHanded = isRightHanded, IsTwoHandedBackhand = isTwoHandedBackhand }; this.PlayerTable.Add(player); return(this.SaveChangesAsync()); }
public int GetCitizenCount() { int count = 0; foreach (CityLoyaltyEntry entry in PlayerTable.OfType <CityLoyaltyEntry>()) { if (entry.IsCitizen) { count++; } } return(count); }
/// <summary> /// Gets the row from a table by searching for a player /// </summary> /// <param name="table">The table to search</param> /// <param name="player">The player to find</param> /// <param name="type">The type of tabler</param> /// <returns></returns> public IWebElement GetRow(IWebElement table, Player player, PlayerTable type) { var rows = table.FindElements(By.XPath($"./tr")); foreach (var row in rows) { Player p = ReadPlayerRow(row, type); if (p.name == player.name) { return(row); } } logger.Error("Player " + player + " not found in table"); throw new NotFoundException("Player " + player + " not found in table"); }
public static PlayerTable Load(string[] parts) { int i = 0; PlayerTable p = new PlayerTable(); p._Index = int.Parse(parts[i++]); p._Name = parts[i++]; p._Damage = float.Parse(parts[i++]); p._Hp = float.Parse(parts[i++]); p._Speed = float.Parse(parts[i++]); p._Armor = float.Parse(parts[i++]); p._HandCount = int.Parse(parts[i++]); p._DeckCount = int.Parse(parts[i++]); return(p); }
public virtual PointsEntry AddEntry(PlayerMobile pm, bool existed = false) { PointsEntry entry = GetSystemEntry(pm); if (!PlayerTable.Contains(entry)) { PlayerTable.Add(entry); if (!existed) { OnPlayerAdded(pm); } } return(entry); }
public PointsEntry GetEntry(Mobile from, bool create = false) { if (from == null) { return(null); } PointsEntry entry = PlayerTable.FirstOrDefault(e => e.Player == from); if (entry == null && AutoAdd && from is PlayerMobile) { entry = AddEntry((PlayerMobile)from); } return(entry); }
public virtual void ConvertFromOldSystem(PlayerMobile from, double points) { if (!PlayerTable.ContainsKey(from)) { if (points > MaxPoints) { points = MaxPoints; } Utility.PushColor(ConsoleColor.Green); Console.WriteLine("Converted {0} points for {1} to {2}!", (int)points, from.Name, this.GetType().Name); Utility.PopColor(); PlayerTable[from] = points; } }
public virtual void Deserialize(GenericReader reader) { int version = reader.ReadInt(); switch (version) { case 0: case 1: int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PlayerMobile player = reader.ReadMobile() as PlayerMobile; PointsEntry entry = GetSystemEntry(player); if (version > 0) { entry.Deserialize(reader); } else { entry.Points = reader.ReadDouble(); } if (player != null) { PlayerTable.Add(entry); } } break; } //Old player data, not uses the above /*PlayerTable = new Dictionary<PlayerMobile, double>(); * * int count = reader.ReadInt(); * * for (int i = 0; i < count; i++) * { * PlayerMobile pm = reader.ReadMobile() as PlayerMobile; * double points = reader.ReadDouble(); * * if (pm != null) * PlayerTable.Add(pm, points); * }*/ }
public TEntry GetPlayerEntry <TEntry>(Mobile mobile, bool create = false) where TEntry : PointsEntry { PlayerMobile pm = mobile as PlayerMobile; if (pm == null) { return(null); } TEntry e = PlayerTable.FirstOrDefault(p => p.Player == pm) as TEntry; if (e == null && (AutoAdd || create)) { e = AddEntry(pm) as TEntry; } return(e); }