Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
 public void SetPoints(PlayerMobile pm, double points)
 {
     if (PlayerTable.ContainsKey(pm))
     {
         PlayerTable[pm] = points;
     }
 }
Esempio n. 5
0
        /// <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));
        }
Esempio n. 6
0
        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;
            }
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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";
 }
Esempio n. 12
0
        public TEntry GetPlayerEntry <TEntry>(PlayerMobile pm) where TEntry : PointsEntry
        {
            if (pm == null)
            {
                return(null);
            }

            return(PlayerTable.FirstOrDefault(p => p.Player == pm) as TEntry);
        }
Esempio n. 13
0
        public double GetPoints(Mobile from)
        {
            if (from is PlayerMobile && PlayerTable.ContainsKey(from as PlayerMobile))
            {
                return(PlayerTable[(PlayerMobile)from]);
            }

            return(0.0);
        }
Esempio n. 14
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();
 }
Esempio n. 15
0
 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();
        }
Esempio n. 17
0
 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);
     }
 }
Esempio n. 18
0
        public virtual void Serialize(GenericWriter writer)
        {
            writer.Write((int)1);

            writer.Write(PlayerTable.Count);

            PlayerTable.ForEach(entry =>
            {
                writer.Write(entry.Player);
                entry.Serialize(writer);
            });
        }
Esempio n. 19
0
        public virtual PointsEntry AddEntry(PlayerMobile pm)
        {
            PointsEntry entry = GetSystemEntry(pm);

            if (!PlayerTable.Contains(entry))
            {
                PlayerTable.Add(entry);
                OnPlayerAdded(pm);
            }

            return(entry);
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        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());
        }
Esempio n. 22
0
        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());
        }
Esempio n. 23
0
        public int GetCitizenCount()
        {
            int count = 0;

            foreach (CityLoyaltyEntry entry in PlayerTable.OfType <CityLoyaltyEntry>())
            {
                if (entry.IsCitizen)
                {
                    count++;
                }
            }

            return(count);
        }
Esempio n. 24
0
        /// <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");
        }
Esempio n. 25
0
    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);
    }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        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;
            }
        }
Esempio n. 29
0
        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);
             * }*/
        }
Esempio n. 30
0
        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);
        }