Exemple #1
0
		public Player(FightEngine engine, PlayerProfile profile, Team team)
			: base(engine)
		{
			if (profile == null) throw new ArgumentNullException("profile");
			if (team == null) throw new ArgumentNullException("team");

			m_profile = profile;
			m_spritemanager = Engine.GetSubSystem<Drawing.SpriteSystem>().CreateManager(Profile.SpritePath);
			m_animationmanager = Engine.GetSubSystem<Animations.AnimationSystem>().CreateManager(Profile.AnimationPath);
			m_soundmanager = Engine.GetSubSystem<Audio.SoundSystem>().CreateManager(Profile.SoundPath);
			m_statemanager = Engine.GetSubSystem<StateMachine.StateSystem>().CreateManager(this, Profile.StateFiles);
			m_commandmanager = Engine.GetSubSystem<Commands.CommandSystem>().CreateManager(Profile.CommandPath);
			m_constants = new PlayerConstants(this, Engine.GetSubSystem<IO.FileSystem>().OpenTextFile(Profile.ConstantsPath));
			m_dimensions = new CharacterDimensions(Constants);
			m_palettes = BuildPalettes();
			m_palettenumber = 0;
			m_power = 0;
			m_palfx = new PaletteFx();
			m_team = team;
			m_helpers = new Dictionary<Int32, List<Helper>>();

			if (Engine.GetSubSystem<InitializationSettings>().PreloadCharacterSprites == true)
			{
				SpriteManager.LoadAllSprites();
			}

			SpriteManager.UseOverride = true;

			SetLocalAnimation(0, 0);

			CurrentScale = Constants.Scale;
			PushFlag = true;
		}
	/*
	 * Turn this shit into a singleton
	 */
	void Awake() {
		if (profile == null) {
			DontDestroyOnLoad (gameObject);
			profile = this;
			profile.savePath = Application.persistentDataPath + "/playerprofile.save";
		} else if (profile != this) {
			Destroy (gameObject);
		}
	}
Exemple #3
0
		public void ShowScorePanel(PlayerProfile.PlayerProfile profile, FractionDifficulty? newDifficulty, bool playerHasWon)
		{
			btnPause.IsEnabled = false;
			btnSpeed.IsEnabled = false;

			GDOwner.GameSpeedMode = GameSpeedModes.NORMAL;

			AddElement(new HUDScorePanel(profile, newDifficulty, playerHasWon));
		} 
 public InformationController(InformationServiceClient service, 
         PlayerProfile profile, 
         PlayerStats stats, 
         List<GameInformation> gameList)
 {
     _service = service;
     this.stats = stats;
     this.profile = profile;
     this.gameList = gameList;
 }
    public static void Clear()
    {
        if (current == null)
        {
            current = new PlayerProfile();

            PlayerPrefs.SetString("PlayerProfile", "");
            PlayerPrefs.Save();
        }
    }
		public HUDScorePanel(PlayerProfile.PlayerProfile playerprofile, FractionDifficulty? newDifficulty, bool playerHasWon)
		{
			gainLevel = newDifficulty;
			successScreen = playerHasWon;
			profile = playerprofile;

			RelativePosition = FPoint.Zero;
			Size = new FSize(WIDTH, HEIGHT);
			Alignment = HUDAlignment.CENTER;
			Background = FlatColors.BackgroundHUD;
		}
    public static void Save()
    {
        if (current == null)
        {
            current = new PlayerProfile();
        }

        string xml = XmlManager.SerializeObject(typeof(PlayerProfile), current);
        PlayerPrefs.SetString("PlayerProfile", xml);
        PlayerPrefs.Save();
    }
Exemple #8
0
 public override void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile)
 {
     if (Motd.IsEnabled)
     {
         Motd.Send(_cInfo);
     }
     if (ClanManager.IsEnabled)
     {
         ClanManager.CheckforClantag(_cInfo);
     }
 }
Exemple #9
0
        public VersusData(String prefix, TextSection textsection)
        {
            if (prefix == null) throw new ArgumentNullException("prefix");
            if (textsection == null) throw new ArgumentNullException("textsection");

            m_profile = null;
            m_portraitlocation = textsection.GetAttribute<Point>(prefix + "pos");
            m_portraitscale = textsection.GetAttribute<Vector2>(prefix + "scale");
            m_portraitflip = (textsection.GetAttribute<Int32>(prefix + "facing") < 0) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
            m_namelocation = textsection.GetAttribute<Point>(prefix + "name.pos");
            m_printdata = textsection.GetAttribute<PrintData>(prefix + "name.font");
        }
Exemple #10
0
    // Use this for initialization
    public void Launch()
    {
        PROFILE = Resources.Load("Tuning/PlayerProfile") as PlayerProfile;
        SETUP = Resources.Load("Tuning/GameSetup") as GameSetup;
        INPUT = Resources.Load("Tuning/InputManager") as InputManager;
        DontDestroyOnLoad(this);

        GameEventManager.GameStart += GameStart;
        GameEventManager.GameOver += GameOver;
        GameEventManager.Respawn += Respawn;
        GameEventManager.EndGame += EndGame;
    }
Exemple #11
0
        static Program()
        {
            var profile = new PlayerProfile();
            var stats = new PlayerStats();
            var gameList = new List<GameInformation>();
            var gameService = new GameServiceClient();
            var infoService = new InformationServiceClient();
            var state = new BasicObservable<MatchState>(new MatchState());
            infoController = new InformationController(infoService, profile, stats, gameList);
            gameController = new GameController(gameService, state);

            infoController.GetGameList();
        }
	// Use this for initialization
	void Start () {
		profile = GetComponent<PlayerProfile>();
		Levels= GetComponentsInChildren<LevelItemController>();
		int total = 0;
		foreach(LevelItemController level in Levels)
		{
			level.LevelSelector = this;
			total+=profile.GetProfitForLevel(level.SceneName);
		}

		TotalProfit.Value = total;

	}
    public PlayerInformation()
    {
		NakedArmorInventory = new Inventory();
        MainInventory = new Inventory();
		ArmoryInventory = new Inventory();
		jukeBox = new Jukebox();
		playerShopInventory = new Inventory();
        Equip = new Equipment();
		questLog = new QuestLog();
		profile = new PlayerProfile();
		playerData = new ParseObject("PlayerData");
		parseObjectID = " ";
		PlayerName = " ";
	}
    public static void Load()
    {
        if (current == null)
        {
            current = new PlayerProfile();
        }

        string xml = PlayerPrefs.GetString("PlayerProfile");
        if (string.IsNullOrEmpty(xml.Trim()) == false)
        {
            //Debug.Log(xml);
            current = (PlayerProfile)XmlManager.DeserializeObject(typeof(PlayerProfile), xml);
        }
    }
		public EngineInitialization(CombatMode mode, PlayerProfile p1, Int32 p1palette, PlayerProfile p2, Int32 p2palette, StageProfile stage, Int32 seed)
		{
			if (mode == CombatMode.None) throw new ArgumentOutOfRangeException("mode");
			if (p1 == null) throw new ArgumentNullException("p1");
			if (p1palette < 0 || p1palette > 11) throw new ArgumentOutOfRangeException("p1palette");
			if (p2 == null) throw new ArgumentNullException("p2");
			if (p2palette < 0 || p2palette > 11) throw new ArgumentOutOfRangeException("p2palette");
			if (stage == null) throw new ArgumentNullException("stage");

			m_mode = mode;
			m_p1 = new PlayerCreation(p1, p1.GetValidPaletteIndex(p1palette));
			m_p2 = new PlayerCreation(p2, p2.GetValidPaletteIndex(p2palette));
			m_stage = stage;
			m_seed = seed;
		}
        public static void RequestToSpawnPlayer(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile)
        {
            try {
                Log.Out ("Player connected" +
                    ", entityid=" + _cInfo.entityId +
                    ", name=" + _cInfo.playerName +
                    ", steamid=" + _cInfo.playerId +
                    ", ip=" + _cInfo.ip
                );

                PersistentContainer.Instance.Players [_cInfo.playerId, true].SetOnline (_cInfo);
                PersistentData.PersistentContainer.Instance.Save ();
            } catch (Exception e) {
                Log.Out ("Error in AllocsLogFunctions.RequestToSpawnPlayer: " + e);
            }
        }
Exemple #17
0
    public void Init()
    {
        this.TargetableObjects = new List<GameTarget>();

        this._playerOneProfile = new PlayerProfile();
        this._playerTwoProfile = new PlayerProfile();
        this._playerOneGeneral.Setup(new CardGameGeneral(13805062));
        this._playerTwoGeneral.Setup(new CardGameGeneral(1813937494));

        Debug.Log("Adding the two generals to the target list");
        this.TargetableObjects.Add(new GameTarget(Enumerations.Player.PlayerOne, this._playerOneGeneral));
        this.TargetableObjects.Add(new GameTarget(Enumerations.Player.PlayerTwo, this._playerTwoGeneral));

        DisplayCards();

        //Hide the Card Profile
        HideCardProfile();
    }
Exemple #18
0
 public abstract void ShowScorePanel(LevelBlueprint lvl, PlayerProfile profile, HashSet <FractionDifficulty> newDifficulties, bool playerHasWon, int addPoints, int time);
Exemple #19
0
 private void Awake()
 {
     instance = this;
 }
Exemple #20
0
 public MicProfile GetMicProfile(PlayerProfile playerProfile)
 {
     sceneData.PlayerProfileToMicProfileMap.TryGetValue(playerProfile, out MicProfile micProfile);
     return(micProfile);
 }
Exemple #21
0
    /// <summary>
    /// Requests de profile data reset
    /// </summary>
    public void ResetProfile()
    {
        _dataManager.ResetProfile();

        LocalPlayerData = new PlayerProfile();
    }
        private async void OnJoinServerButtonPressed()
        {
            var overlay = new LoadingOverlay();

            Alex.GuiManager.AddScreen(overlay);

            try
            {
                var       entry = SelectedItem.SavedServerEntry;
                var       ips   = Dns.GetHostAddresses(entry.Host).ToArray();
                IPAddress ip    = ips[Rnd.Next(0, ips.Length - 1)];

                if (ip == null)
                {
                    return;
                }

                IPEndPoint target = new IPEndPoint(ip, entry.Port);

                var authenticationService = GetService <IPlayerProfileService>();
                //var currentProfile        = authenticationService.CurrentProfile;

                if (Alex.ServerTypeManager.TryGet(entry.ServerType, out var typeImplementation))
                {
                    var           profiles       = authenticationService.GetProfiles(entry.ServerType);
                    PlayerProfile currentProfile = null;

                    if (profiles.Length == 1)
                    {
                        currentProfile = profiles[0];
                    }

                    void Connect(PlayerProfile profile)
                    {
                        Alex.ConnectToServer(
                            typeImplementation, new ServerConnectionDetails(target, entry.Host),
                            profile);

                        Alex.GuiManager.RemoveScreen(overlay);
                        overlay = null;
                    }

                    if (currentProfile == null || !await typeImplementation.VerifyAuthentication(currentProfile))
                    {
                        await typeImplementation.Authenticate(
                            _skyBox, currentProfile, result =>
                        {
                            if (result)
                            {
                                Connect(authenticationService.CurrentProfile);
                            }
                        });
                    }
                    else
                    {
                        Connect(currentProfile);
                    }
                }
            }
            finally
            {
                if (overlay != null)
                {
                    Alex.GuiManager.RemoveScreen(overlay);
                }
            }
        }
Exemple #23
0
        public void StartTradingGrind()
        {
            _loginController.AuthenticateLogin();

            SetAllControllerCookies(_loginController._authResponse.data.session);

            _profileController.SelectPMCProfile();
            PlayerProfile profile = _profileController.GetLatestPlayerProfile();

            LinkManager.CurrentRoubles = _profileController.GetCurrentRoubles();
            _profileController.GetSellableFromInventory();
            long currentRoubles = LinkManager.CurrentRoubles;

            while (true)
            {
                Log("Running main loop!");

                CheckBotTime();

                LinkManager.AllBoughtItems.Clear();

                //TODO: Handle error 201 (Need to login again)
                //TODO: Maybe a check to exit the bot once we've filled all of our slots? Otherwise we're just spamming their API for no reason - too obvious

                foreach (var itemsToBuy in _marketController.GetBuyableItems(profile))
                {
                    profile = _profileController.GetLatestPlayerProfile();

                    currentRoubles = (LinkManager.CurrentRoubles = _profileController.GetCurrentRoubles());
                    bool haveBoughtItems = _marketController.BuyBulk(itemsToBuy);
                    Thread.Sleep(LinkManager.Timer);

                    //TODO: After buying items, update the inventory on our end without calling server. Saves requests too.
                    profile = _profileController.GetLatestPlayerProfile();

                    if (!haveBoughtItems)
                    {
                        continue;
                    }

                    var sellableItems = _profileController.GetSellableFromInventory();
                    //foreach (var sellableItem in sellableItems)
                    //{
                    //    var matchingBuyOffer = itemToBuy.First(itb => itb.Offer.items[0]._id == sellableItem.Item.Id);
                    //    sellableItem.ExpectedProfit = matchingBuyOffer.ExpectedProfit;
                    //}

                    //TODO: Update inventory situation based on the updates from buying/selling (delete/change properties). Cheaper than two profile lookups each time we buy a set.
                    bool sellSuccessful = _traderController.SellBulk(sellableItems);
                    if (sellSuccessful)
                    {
                        profile = _profileController.GetLatestPlayerProfile();
                        long amountAfterSelling = (LinkManager.CurrentRoubles = _profileController.GetCurrentRoubles());
                        long profitMade         = amountAfterSelling - currentRoubles;
                        Log($"Profit made: {profitMade}");
                        Console.Title = $"Current Roubles: {amountAfterSelling:C}";
                    }
                    else
                    {
                        Log($"Failed to sell items. Not calculating profit as there is none (pending items to sell)");
                    }

                    Thread.Sleep(LinkManager.Timer);
                }
                GetLastHourProfit();
                Thread.Sleep(LinkManager.Timer);
            }
        }
Exemple #24
0
 private void OnPlayerProfileButtonClicked(PlayerProfile playerProfile)
 {
     selectedPlayerProfile = playerProfile;
 }
Exemple #25
0
        private bool shouldSkipClanPlayer(PlayerProfile player, int smaller_team, int bigger_team, Dictionary<string, int>[] clan_stats) {
            string tag = player.getClanTag();

            if (!clan_stats[bigger_team].ContainsKey(tag))
                clan_stats[bigger_team].Add(tag, 0);

            if (!clan_stats[smaller_team].ContainsKey(tag))
                clan_stats[smaller_team].Add(tag, 0);

            if (player.isInClan() && (clan_stats[bigger_team][tag] + clan_stats[smaller_team][tag]) > 1) {
                /* if the majority of the players in the clan are in this team, skip this player */
                if (clan_stats[bigger_team][tag] >= clan_stats[smaller_team][tag]) {
                    DebugWrite("Skipping clan-player ^b" + player + "^n because majority of clan is in his team", 3);
                    return true;
                }

                /* update the clan stats */
                clan_stats[bigger_team][tag]--;
                clan_stats[smaller_team][tag]++;
            }
            return false;
        }
Exemple #26
0
 public override void ShowScorePanel(LevelBlueprint lvl, PlayerProfile profile, HashSet <FractionDifficulty> newDifficulties, bool playerHasWon, int addPoints, int time)
 {
     GameSpeedMode = GameSpeedModes.NORMAL;
     HUD.AddModal(new HUDMultiplayerScorePanel(lvl, profile, playerHasWon, addPoints, _server, () => { _doNotStop = true; }), false);
 }
Exemple #27
0
        public void TestAgeJohn()
        {
            var john = new PlayerProfile("John", PlayerProfile.FEMALE, new DateTime(1990, 2, 1));

            Assert.AreEqual(28, john.ComputeAge());
        }
Exemple #28
0
        public void TestAgeEugene()
        {
            var eugene = new PlayerProfile("Eugene", PlayerProfile.MALE, new DateTime(1990, 9, 13));

            Assert.AreEqual(27, eugene.ComputeAge());
        }
 private static void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile)//Setting player view and profile
 {
 }
Exemple #30
0
 /// <summary>
 /// Updates the Servers copy of PlayerProfile
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="callback"></param>
 public void Update(PlayerProfile profile, Action <PlayerProfile, PResponse> callback)
 {
     Update <PlayerProfile>(profile, callback);
 }
 public PlayerScoreData GetPlayerScores(PlayerProfile playerProfile)
 {
     return(playerScoreMap[playerProfile]);
 }
Exemple #32
0
 public void Init(PlayerProfile _playerProfile)
 {
     CurrentPlayer = _playerProfile;
 }
        public IActionResult Results(TriviaQuestionsViewModel triviaQuestionsViewModel)
        {
            TriviaQuestionsViewModel t = triviaQuestionsViewModel;
            string difficultySelect    = t.Questions.Results.First().Difficulty;
            string categorySelect      = t.Questions.Results.First().Category;
            string typeSelect          = t.Questions.Results.First().Type == "multiple" ? "Multiple Choice" : "True/False";


            var           userId     = _userManager.GetUserId(User);
            PlayerProfile player     = _profileRepository.FindByCondition(p => p.UserId == userId).First();
            Difficulty    difficulty = _difficultyRepository.FindByCondition(q => q.Name == difficultySelect).First();
            Category      category   = _categoryRepository.FindByCondition(q => q.Name == categorySelect).First();
            QuestionType  type       = _questionTypeRepository.FindByCondition(q => q.Name == typeSelect).First();


            //Adds Entry to Player's quizes
            PlayerQuiz quiz = new PlayerQuiz();

            quiz.Player       = player;
            quiz.Difficulty   = difficulty;
            quiz.QuestionType = type;
            quiz.Category     = category;
            quiz.Attempted    = t.Questions.Results.Select(q => q.Selected).Count();
            quiz.Correct      = t.Questions.Results.Where(q => q.Selected == "true").Count();
            _quizRepository.Create(quiz);



            //Adds Entry into Players Cash account
            PlayerCash playerCash = new PlayerCash();

            playerCash.ProfileId = player.Id;
            int multiplier = 0;

            switch (difficultySelect)
            {
            case "easy":
                multiplier += quiz.Correct * (typeSelect == "Multiple Choice" ? 2 : 1);
                break;

            case "medium":
                multiplier += quiz.Correct * (typeSelect == "Multiple Choice" ? 2 : 1) * 2;
                break;

            case "hard":
                multiplier += quiz.Correct * (typeSelect == "Multiple Choice" ? 2 : 1) * 3;
                break;
            }

            playerCash.Balance = _cashRepository
                                 .FindByCondition(p => p.ProfileId == player.Id)
                                 .OrderByDescending(c => c.CreatedDate)
                                 .Select(p => p.Balance)
                                 .FirstOrDefault();
            playerCash.Balance += (multiplier * 10);
            _cashRepository.Create(playerCash);


            //Adds Entry to Players Transactions
            PlayerTransaction playerTransaction = new PlayerTransaction();

            playerTransaction.ProfileId              = player.Id;
            playerTransaction.TransactionType        = "Trivia";
            playerTransaction.TransactionDescription = $"{quiz.Correct} ,{difficultySelect}, {typeSelect} questions";
            playerTransaction.Price = multiplier * 10;
            _transactionRepository.Create(playerTransaction);


            //Adds Entry to Players Prestige Score
            PlayerPrestigeScore playerPrestige = new PlayerPrestigeScore();

            playerPrestige.ProfileId = player.Id;
            playerPrestige.Source    = "Knowledge Reward";
            playerPrestige.Score     = _prestigeScoreRepository
                                       .FindByCondition(p => p.ProfileId == player.Id)
                                       .OrderByDescending(c => c.CreatedDate)
                                       .Select(p => p.Score)
                                       .FirstOrDefault();
            playerPrestige.Score       += multiplier * 10;
            playerPrestige.PointsEarned = multiplier * 10;
            _prestigeScoreRepository.Create(playerPrestige);



            return(RedirectToAction("Performance"));
        }
Exemple #34
0
 private bool movePlayer(PlayerProfile player, int teamId, int squadId) {
     return movePlayer(player, teamId, squadId, false, false);
 }
Exemple #35
0
    private void SendServerHello()
    {
        var message = clientMessageConstructor.ConstructClientHello(ClientMessageType.ClientHello, (ushort)PlayerProfile.Instance().Skin, PlayerProfile.Instance().Nickname);

        udpc.Send(message, message.Length);
    }
Exemple #36
0
        private bool isPlayerInWhiteList(PlayerProfile player, String list_name) {
            if (!getBooleanVarValue("use_white_list"))
                return false;

            if (!getPluginVars().Contains(list_name)) {
                DebugWrite("^1^bWARNING: ^n^0 unknown white list ^b" + list_name + "^n", 1);
                return false;
            }

            List<String> whitelist = getStringListVarValue(list_name);
            if (whitelist.Count == 0)
                return false;

            String field = "";
            if (Regex.Match(list_name, @"clan").Success)
                field = player.getClanTag();
            else if (Regex.Match(list_name, @"player").Success)
                field = player.name;
            else {
                DebugWrite("^1^bWARNING:^0^n white list ^b" + list_name + "^n does not contain 'player' or 'clan' sub-string", 1);
                return false;
            }

            if (Regex.Match(field, @"^\s*$").Success)
                return false;

            return whitelist.Contains(field);
        }
Exemple #37
0
 void Update()
 {
     text.text = "" + PlayerProfile.Instance().LastScore;
 }
Exemple #38
0
        private void enforceDelayedMove(PlayerProfile vp) {

            int dtid = vp.getDelayedTeamId();
            int dsid = vp.getDelayedSquadId();

            vp.resetDelayedTeamSquad();

            /* if player is already in the delayed team, ignore him */
            if (dtid == vp.getTeamId()) {
                DebugWrite("Player " + vp + " is already in to ^bDTeam(" + TN(dtid) + ")^n, will skip", 3);
                return;
            }

            /* if teams are already balanced, ignore this player */
            DebugWrite("I will now re-check if teams are balanced", 3);
            if (teamsBalanced()) {
                DebugWrite("Teams are balanced, will not move player " + vp, 3);
                return;
            } else {
                /* if teams are not balanced we still have to check direction of inbalancing because of possible manual move or standart balancer work! */
                Dictionary<int, int> player_count = getPlayerCount();

                int team_sz = serverInfo.MaxPlayerCount / 2;
                int bigger_team = (player_count[1] > player_count[2]) ? 1 : 2;
                int smaller_team = (player_count[1] > player_count[2]) ? 2 : 1;

                if (bigger_team == dtid) {
                    DebugWrite("Teams are unbalanced, but in other direction that was marked for this player. Will not move player " + vp, 3);
                    return;
                }

            }

            DebugWrite("Moving player " + vp + " from ^bTeam(" + TN(vp.getTeamId()) + ").Squad(" + SQN(vp.getSquadId()) + ")^n to ^bDTeam(" + TN(dtid) + ").DSquad(" + SQN(dsid) + ")^n", 3);
            movePlayer(vp, dtid, dsid);

        }
Exemple #39
0
 /// <summary>
 /// Load player profile to current data structures
 /// </summary>
 public void LoadProfile()
 {
     LocalPlayerData = _dataManager.LoadProfile();
 }
Exemple #40
0
        public void stats_fetching_loop() {
            DebugWrite("Starting stats fetching thread", 1);
            getPlayerList();
            while (true) {
                if (new_player_queue.Count == 0) {
                    // if there are no more players, put yourself to sleep
                    DebugWrite("No new players, stats fetching thread going to sleep", 1);
                    wake_handle.Reset();
                    wake_handle.WaitOne();
                    DebugWrite("Stats fetching thread is now awake!", 1);
                }


                InsaneBalancer plugin = this;

                while (new_player_queue.Count > 0) {
                    if (!plugin_enabled)
                        break;

                    List<String> keys = new List<string>(new_player_queue.Keys);

                    String name = keys[keys.Count - 1];

                    CPunkbusterInfo info = null;
                    new_player_queue.TryGetValue(name, out info);

                    if (info == null)
                        continue;

                    // make sure I am the only one modifying these dictionarie at this time
                    lock (mutex) {
                        if (new_player_queue.ContainsKey(name))
                            new_player_queue.Remove(name);

                        if (!new_players_batch.ContainsKey(name))
                            new_players_batch.Add(name, null);
                    }

                    String msg = new_player_queue.Count + " more player" + ((new_player_queue.Count > 1) ? "s" : "") + " in queue";
                    if (new_player_queue.Count == 0)
                        msg = "no more players in queue";

                    plugin.DebugWrite("Getting battlelog stats for ^b" + name + "^n, " + msg, 1);
                    if (new_players_batch.ContainsKey(info.SoldierName))
                        new_players_batch[name] = new PlayerProfile(plugin, info);
                }

                // abort the thread if the plugin was disabled
                if (!plugin_enabled) {
                    plugin.DebugWrite("detected that plugin was disabled, aborting stats fetching thread", 1);
                    lock (mutex) {
                        new_player_queue.Clear();
                        new_players_batch.Clear();
                        scratch_list.Clear();
                    }
                    return;
                }

                DebugWrite("Done fetching stats, " + new_players_batch.Count + " player" + ((new_players_batch.Count > 1) ? "s" : "") + " in new batch, waiting for players list now", 1);
                scratch_handle.Reset();
                getPlayerList();
                scratch_handle.WaitOne();
                scratch_handle.Reset();
                lock (mutex) {
                    // remove the nulls, and the ones that left
                    List<String> players_to_remove = new List<string>();
                    foreach (KeyValuePair<String, PlayerProfile> pair in new_players_batch)
                        if (pair.Value == null || !scratch_list.Contains(pair.Key))
                            if (!players_to_remove.Contains(pair.Key)) {
                                DebugWrite("Looks like ^b" + pair.Key + "^n left, removing him from new batch", 3);
                                players_to_remove.Add(pair.Key);
                            }


                    // now remove them
                    foreach (String pname in players_to_remove)
                        if (new_players_batch.ContainsKey(pname))
                            new_players_batch.Remove(pname);

                    if (new_players_batch.Count > 0)
                        DebugWrite("Queue exhausted, will insert now a batch of " + new_players_batch.Count + " player" + ((new_players_batch.Count > 1) ? "s" : ""), 1);
                    foreach (KeyValuePair<String, PlayerProfile> pair in new_players_batch)
                        if (pair.Value != null && scratch_list.Contains(pair.Key))
                            plugin.players.Add(pair.Key, pair.Value);

                    new_players_batch.Clear();
                }

            }

        }
Exemple #41
0
 public async Task StrongUpdate(PlayerProfile playerProfile)
 {
     _dbContext.PlayersProfiles.Update(playerProfile);
     await _dbContext.SaveChangesAsync().ConfigureAwait(false);
 }
Exemple #42
0
        private bool isPlayerIdle(PlayerProfile player) {
            int last_kill_time = getIntegerVarValue("last_kill_time");
            int last_death_time = getIntegerVarValue("last_death_time");
            int last_chat_time = getIntegerVarValue("last_chat_time");
            int last_spawn_time = getIntegerVarValue("last_spawn_time");
            int last_score_time = getIntegerVarValue("last_score_time");


            if (player.getLastKill() > last_kill_time &&
                player.getLastDeath() > last_death_time &&
                player.getLastChat() > last_chat_time &&
                player.getLastSpawn() > last_spawn_time &&
                player.getLastScore() > last_score_time)
                return true;

            return false;

        }
Exemple #43
0
    // Use this for initialization
    void Start()
    {
        playerDatabase = new PlayerDatabase();
        playerDatabase.ImportPlayerData();

        // Create each of the player profiles
        playerProfiles = new PlayerProfile[(int)DrafterEnum.TotalDrafters];
        for (int i = 0; i < (int)DrafterEnum.TotalDrafters; ++i)
        {
            playerProfiles[i]                    = new PlayerProfile();
            playerProfiles[i].playerName         = DrafterNames[i];
            playerProfiles[i].bonusTimeRemaining = maxBonusTime;
            playerProfiles[i].playerNameplate    = nameplateSprites[i];

            playerProfiles[i].oldThreeYearContracts = new List <string>();
            playerProfiles[i].oldTwoYearContracts   = new List <string>();
            playerProfiles[i].oldOneYearContracts   = new List <string>();

            playerProfiles[i].threeYearContract = null;
            playerProfiles[i].twoYearContracts  = new List <PlayerDatabase.PlayerData>();
            playerProfiles[i].oneYearContracts  = new List <PlayerDatabase.PlayerData>();

            playerProfiles[i].allPlayerPicks = new List <PlayerDatabase.PlayerData>();
        }

        // Import the previous year's contracts
        ImportContractPlayers();

        // Create the pick info structures
        int draftSnake     = 1;
        int currentDrafter = 0;

        pickInfo = new List <PickInfo> [totalRounds];
        for (int i = 0; i < totalRounds; ++i)
        {
            pickInfo[i] = new List <PickInfo>();
            for (int j = 0; j < (int)DrafterEnum.TotalDrafters; ++j)
            {
                pickInfo[i].Add(new PickInfo());
                pickInfo[i][j].roundNumber = i;
                pickInfo[i][j].pickNumber  = j;
                pickInfo[i][j].drafterID   = DraftOrder[currentDrafter];

                currentDrafter += draftSnake;
            }

            draftSnake     *= -1;
            currentDrafter += draftSnake;
        }

        currentPickTime = maxPickTime;

        pickTimerText      = GameObject.Find("PickTimer").GetComponent <Text>();
        pickTimerText.text = FormatTimeText(currentPickTime);

        int time          = 15;
        int rotationValue = 1;

        foreach (var ring in RingObjects)
        {
            ring.transform.DORotate(new Vector3(0, 0, 180 * rotationValue), time).SetLoops(-1, LoopType.Incremental).SetEase(Ease.Linear);

            rotationValue *= -1;
            time          += 2;
        }

        InitializeContractSerializer();
        InitializeDraftSerializer();
    }
Exemple #44
0
    public void ButtonPress()
    {
        if (Button.ms_active)
        {
            //Spawn a new Match
            //TODO: clean this up
            GameObject go       = MatchProfile.ms_currentMatch.NextMatchPostion();
            Vector3    position = go.transform.position;
            Quaternion rotation = go.transform.rotation;

            Debug.Log("Like");

            Profile.StopHighlightingParts(m_player, MatchProfile.ms_currentMatch);
            bool isMatch;

            if (m_player.CheckForMatch(MatchProfile.ms_currentMatch))
            {
                isMatch = true;

                int   numHearts = Random.Range(5, 20);
                float range     = .3f;

                for (int i = 0; i < numHearts; i++)
                {
                    (GameObject.Instantiate(mp_heart, PlayerProfile.GetPlayer().gameObject.transform.position + new Vector3(Random.Range(-range, range), Random.Range(-range, range), 1.0f), PlayerProfile.GetPlayer().gameObject.transform.rotation, null) as GameObject).GetComponent <Rigidbody2D>().AddForce(new Vector2(Random.Range(-100.0f, 100.0f), Random.Range(-100.0f, 300.0f)));
                }


                numHearts = Random.Range(5, 20);
                for (int i = 0; i < numHearts; i++)
                {
                    (GameObject.Instantiate(mp_heart, MatchProfile.ms_currentMatch.transform.position + new Vector3(Random.Range(-range, range), Random.Range(-range, range), 1.0f), MatchProfile.ms_currentMatch.transform.rotation, null) as GameObject).GetComponent <Rigidbody2D>().AddForce(new Vector2(Random.Range(-100.0f, 100.0f), Random.Range(-100.0f, 300.0f)));;
                }
                //Profile.HighLightMatchingParts (m_player, MatchProfile.ms_currentMatch);
                this.m_audioSource.PlayOneShot(m_matchLikeClip);
                PlayerProfile.AddMatch();
                MatchManager.SaveMatch(MatchProfile.ms_currentMatch.gameObject);

                MatchManager.InstantiateNewMatch(true);
            }
            else
            {
                this.m_player.DropMatchCorrections(MatchProfile.ms_currentMatch);
                isMatch = false;

                this.m_audioSource.PlayOneShot(m_noMatchLikeClip);
                //Profile.HighLightConflicts (m_player, MatchProfile.ms_currentMatch);
                PlayerProfile.RemoveMatch();
                MatchManager.SaveReject(MatchProfile.ms_currentMatch.gameObject);
                MatchManager.ShowWhyYouFailed(false);
            }
        }
    }
Exemple #45
0
        public void TestAgeTony()
        {
            var tony = new PlayerProfile("Tony", PlayerProfile.MALE, new DateTime(1990, 7, 30));

            Assert.AreEqual(27, tony.ComputeAge());
        }
Exemple #46
0
            static bool Prefix(Player __instance, Inventory ___m_inventory, ref float ___m_timeSinceDeath, float ___m_hardDeathCooldown, ZNetView ___m_nview, List <Player.Food> ___m_foods, Skills ___m_skills)
            {
                if (!modEnabled.Value)
                {
                    return(true);
                }

                ___m_nview.GetZDO().Set("dead", true);
                ___m_nview.InvokeRPC(ZNetView.Everybody, "OnDeath", new object[] { });
                Game.instance.GetPlayerProfile().m_playerStats.m_deaths++;

                Game.instance.GetPlayerProfile().SetDeathPoint(__instance.transform.position);

                if (createDeathEffects.Value)
                {
                    Traverse.Create(__instance).Method("CreateDeathEffects").GetValue();
                }

                List <ItemDrop.ItemData> dropItems = new List <ItemDrop.ItemData>();

                if (!keepAllItems.Value)
                {
                    List <Inventory> inventories = new List <Inventory>();

                    if (quickSlotsAssembly != null)
                    {
                        var extendedInventory = quickSlotsAssembly.GetType("EquipmentAndQuickSlots.InventoryExtensions").GetMethod("Extended", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { ___m_inventory });
                        inventories = (List <Inventory>)quickSlotsAssembly.GetType("EquipmentAndQuickSlots.ExtendedInventory").GetField("_inventories", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(extendedInventory);
                    }
                    else
                    {
                        inventories.Add(___m_inventory);
                    }

                    for (int i = 0; i < inventories.Count; i++)
                    {
                        Inventory inv = inventories[i];

                        if (quickSlotsAssembly != null && keepQuickSlotItems.Value && inv == (Inventory)quickSlotsAssembly.GetType("EquipmentAndQuickSlots.PlayerExtensions").GetMethod("GetQuickSlotInventory", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { __instance }))
                        {
                            Dbgl("Skipping quick slot inventory");
                            continue;
                        }

                        List <ItemDrop.ItemData> keepItems = new List <ItemDrop.ItemData>(inv.GetAllItems());

                        if (destroyAllItems.Value)
                        {
                            keepItems.Clear();
                        }
                        else
                        {
                            foreach (ItemDrop.ItemData item in inv.GetAllItems())
                            {
                                if (keepEquippedItems.Value && item.m_equiped)
                                {
                                    continue;
                                }

                                if (keepHotbarItems.Value && item.m_gridPos.y == 0)
                                {
                                    continue;
                                }

                                if (item.m_shared.m_questItem)
                                {
                                    continue;
                                }

                                if (destroyItemTypes.Value.Length > 0)
                                {
                                    string[] destroyTypes = destroyItemTypes.Value.Split(',');
                                    if (destroyTypes.Contains(Enum.GetName(typeof(ItemDrop.ItemData.ItemType), item.m_shared.m_itemType)))
                                    {
                                        keepItems.Remove(item);
                                        continue;
                                    }
                                }

                                if (keepItemTypes.Value.Length > 0)
                                {
                                    string[] keepTypes = keepItemTypes.Value.Split(',');
                                    if (keepTypes.Contains(Enum.GetName(typeof(ItemDrop.ItemData.ItemType), item.m_shared.m_itemType)))
                                    {
                                        continue;
                                    }
                                }
                                else if (dropItemTypes.Value.Length > 0)
                                {
                                    string[] dropTypes = dropItemTypes.Value.Split(',');
                                    if (dropTypes.Contains(Enum.GetName(typeof(ItemDrop.ItemData.ItemType), item.m_shared.m_itemType)))
                                    {
                                        keepItems.Remove(item);
                                        dropItems.Add(item);
                                    }
                                    continue;
                                }

                                keepItems.Remove(item);
                                dropItems.Add(item);
                            }
                        }
                        Traverse.Create(inv).Field("m_inventory").SetValue(keepItems);
                        Traverse.Create(inv).Method("Changed").GetValue();
                    }
                }

                if (useTombStone.Value && dropItems.Any())
                {
                    GameObject gameObject = Instantiate(__instance.m_tombstone, __instance.GetCenterPoint(), __instance.transform.rotation);
                    gameObject.GetComponent <Container>().GetInventory().RemoveAll();


                    int width  = Traverse.Create(___m_inventory).Field("m_width").GetValue <int>();
                    int height = Traverse.Create(___m_inventory).Field("m_height").GetValue <int>();
                    Traverse.Create(gameObject.GetComponent <Container>().GetInventory()).Field("m_width").SetValue(width);
                    Traverse.Create(gameObject.GetComponent <Container>().GetInventory()).Field("m_height").SetValue(height);


                    Traverse.Create(gameObject.GetComponent <Container>().GetInventory()).Field("m_inventory").SetValue(dropItems);
                    Traverse.Create(gameObject.GetComponent <Container>().GetInventory()).Method("Changed").GetValue();

                    TombStone     component     = gameObject.GetComponent <TombStone>();
                    PlayerProfile playerProfile = Game.instance.GetPlayerProfile();
                    component.Setup(playerProfile.GetName(), playerProfile.GetPlayerID());
                }
                else
                {
                    foreach (ItemDrop.ItemData item in dropItems)
                    {
                        Vector3    position = __instance.transform.position + Vector3.up * 0.5f + UnityEngine.Random.insideUnitSphere * 0.3f;
                        Quaternion rotation = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f);
                        ItemDrop.DropItem(item, 0, position, rotation);
                    }
                }

                if (!keepFoodLevels.Value)
                {
                    ___m_foods.Clear();
                }

                bool hardDeath = noSkillProtection.Value || ___m_timeSinceDeath > ___m_hardDeathCooldown;

                if (hardDeath && reduceSkills.Value)
                {
                    ___m_skills.OnDeath();
                }
                Game.instance.RequestRespawn(10f);

                ___m_timeSinceDeath = 0;

                if (!hardDeath)
                {
                    __instance.Message(MessageHud.MessageType.TopLeft, "$msg_softdeath", 0, null);
                }
                __instance.Message(MessageHud.MessageType.Center, "$msg_youdied", 0, null);
                __instance.ShowTutorial("death", false);
                string eventLabel = "biome:" + __instance.GetCurrentBiome().ToString();

                Gogan.LogEvent("Game", "Death", eventLabel, 0L);

                return(false);
            }
Exemple #47
0
        private int mergePlayerWithTeam(PlayerProfile pp, int toTeamId) {

            if (pp.getTeamId() == toTeamId)
                return 0;

            int players_moved = 0;
            int squad_max_sz = 4;
            int nosquadId = 0;

            List<PlayerSquad> squads = getAllSquads(toTeamId);

            /* sort the squads in increasing order of player count */
            squads.Sort(new Comparison<PlayerSquad>(squad_count_asc_cmp));

            DebugWrite("First looking for empty slots in squads for " + pp + " in Team(" + TN(toTeamId) + ")", 3);
            for (int i = 0; i < squads.Count; i++) {
                PlayerSquad sorted_squad = squads[i];

                if (sorted_squad.getCount() == squad_max_sz)
                    continue;

                if (movePlayer(pp, sorted_squad.getTeamId(), sorted_squad.getSquadId())) {
                    DebugWrite(pp + " moved to Team(" + TN(sorted_squad.getTeamId()) + ").Squad(" + SQN(sorted_squad.getTeamId()) + ")", 3);
                    sorted_squad.addPlayer(pp);
                    players_moved++;
                    break;
                }
            }

            if (players_moved > 0)
                return players_moved;

            DebugWrite("Could not find empty slots in squads for " + pp + " in Team(" + TN(toTeamId) + ")", 3);
            if (movePlayer(pp, toTeamId, nosquadId)) {
                DebugWrite(pp + " moved to Team(" + TN(toTeamId) + ").Squad(" + SQN(nosquadId) + ")", 3);
                players_moved++;
            }

            return players_moved;
        }
Exemple #48
0
        public void TestAgeZero()
        {
            var now = new PlayerProfile("The Zero", PlayerProfile.MALE, DateTime.Now);

            Assert.AreEqual(0, now.ComputeAge());
        }
Exemple #49
0
        private string getSortFieldValueStr(PlayerProfile player, string phase) {
            string sort_method = getStringVarValue(phase);

            if (sort_method.CompareTo("kdr_asc_round") == 0 || sort_method.CompareTo("kdr_desc_round") == 0)
                return "kdr_round: " + Math.Round(player.getRoundKdr(), 2);
            else if (sort_method.CompareTo("score_asc_round") == 0 || sort_method.CompareTo("score_desc_round") == 0)
                return "score_round: " + Math.Round(player.getRoundScore(), 2);
            else if (sort_method.CompareTo("spm_asc_round") == 0 || sort_method.CompareTo("spm_desc_round") == 0)
                return "spm_round: " + Math.Round(player.getRoundSpm(), 2);
            else if (sort_method.CompareTo("kpm_asc_round") == 0 || sort_method.CompareTo("kpm_desc_round") == 0)
                return "kpm_round: " + Math.Round(player.getRoundKpm(), 2);
            else if (sort_method.CompareTo("time_asc_round") == 0 || sort_method.CompareTo("time_desc_round") == 0)
                return "time_round: " + player.getRoundTime();
            else if (sort_method.CompareTo("random_value") == 0 || sort_method.CompareTo("random_value") == 0)
                return "random_value: " + player.getRandomValue();
            else if (sort_method.CompareTo("kdr_asc_online") == 0 || sort_method.CompareTo("kdr_desc_online") == 0)
                return "kdr_online: " + Math.Round(player.getOnlineKdr(), 2);
            else if (sort_method.CompareTo("kpm_asc_online") == 0 || sort_method.CompareTo("kpm_desc_online") == 0)
                return "kpm_online: " + Math.Round(player.getOnlineKpm(), 2);
            else if (sort_method.CompareTo("spm_asc_online") == 0 || sort_method.CompareTo("spm_desc_online") == 0)
                return "spm_online: " + Math.Round(player.getOnlineSpm(), 2);
            else if (sort_method.CompareTo("kills_asc_online") == 0 || sort_method.CompareTo("kills_desc_online") == 0)
                return "kills_online: " + player.getOnlineKills();
            else if (sort_method.CompareTo("deaths_asc_online") == 0 || sort_method.CompareTo("deaths_desc_online") == 0)
                return "deaths_online: " + player.getOnlineDeaths();
            else if (sort_method.CompareTo("skill_asc_online") == 0 || sort_method.CompareTo("skill_desc_online") == 0)
                return "skill_online: " + Math.Round(player.getOnlineSkill(), 2);
            else if (sort_method.CompareTo("quits_asc_online") == 0 || sort_method.CompareTo("quits_desc_online") == 0)
                return "quits_online: " + Math.Round(player.getOnlineQuits(), 2);
            else if (sort_method.CompareTo("accuracy_asc_online") == 0 || sort_method.CompareTo("accuracy_desc_online") == 0)
                return "accuracy_online: " + Math.Round(player.getOnlineAccuracy(), 2);
            else if (sort_method.CompareTo("score_asc_online") == 0 || sort_method.CompareTo("score_desc_online") == 0)
                return "score_online: " + player.getOnlineScore();
            else if (sort_method.CompareTo("rank_asc_online") == 0 || sort_method.CompareTo("rank_desc_online") == 0)
                return "rank_online: " + player.getOnlineRank();

            DebugWrite("^1^bWARNING^0^n: cannot find player sort method for ^b" + sort_method + "^0", 1);
            return "";
        }
Exemple #50
0
        public void TestAgeNadja()
        {
            var nadja = new PlayerProfile("Nadja", PlayerProfile.FEMALE, new DateTime(1990, 7, 22));

            Assert.AreEqual(27, nadja.ComputeAge());
        }
Exemple #51
0
        private bool isInKickWhiteList(PlayerProfile player) {
            bool result = isPlayerInWhiteList(player, "player_safe_wlist") || isPlayerInWhiteList(player, "clan_safe_wlist");

            if (getBooleanVarValue("use_extra_white_lists"))
                result |= isPlayerInWhiteList(player, "player_kick_wlist") || isPlayerInWhiteList(player, "clan_kick_wlist");

            return result;
        }
Exemple #52
0
        public void TestAgeBob()
        {
            var bob = new PlayerProfile("Bob", PlayerProfile.MALE, new DateTime(1990, 3, 1));

            Assert.AreEqual(27, bob.ComputeAge());
        }
Exemple #53
0
        private bool movePlayer(PlayerProfile player, int teamId, int squadId, bool force, bool ignore_white_list) {
            if (player == null)
                return false;

            if (!force && player.getTeamId() == teamId && player.getSquadId() == squadId) {
                DebugWrite("^1^bWARNING^0^n: not moving ^b" + player + "^n to same Team(" + TN(teamId) + ").Squad(" + SQN(squadId) + ")", 1);
                return false;
            } else if (!ignore_white_list && isInMoveWhiteList(player)) {
                DebugWrite("^b" + player.ToString() + "^n in white-list, will not move to Team(" + TN(teamId) + ").Squad(" + SQN(squadId) + ")", 1);
                return false;
            }


            /* first move player to the no-squad, to guarantee a spot (unless he is already going to the no-squad, or stays in the same team) */
            if ((squadId != 0 || player.getTeamId() != teamId) && !(virtual_mode || getBooleanVarValue("virtual_mode"))) {
                if (sleep)
                    Thread.Sleep(100);
                ExecCommand("admin.movePlayer", player.name, teamId.ToString(), "0", "true");
            }

            /* in virtual mode, don't actually do the move */
            if (!(virtual_mode || getBooleanVarValue("virtual_mode"))) {
                if (sleep)
                    Thread.Sleep(100);
                ExecCommand("admin.movePlayer", player.name, teamId.ToString(), squadId.ToString(), "true");
            }
            player.setTeamId(teamId);
            player.setSquadId(squadId);
            return true;
        }
Exemple #54
0
        public void TestAgeChris()
        {
            var chris = new PlayerProfile("Chris", PlayerProfile.MALE, new DateTime(1990, 3, 5));

            Assert.AreEqual(27, chris.ComputeAge());
        }
Exemple #55
0
        private void enforceImmediateMove(PlayerProfile vp) {

            int dtid = vp.getDelayedTeamId();
            int dsid = vp.getDelayedSquadId();

            vp.resetDelayedTeamSquad();

            DebugWrite("Moving player " + vp + " from ^bTeam(" + TN(vp.getSavedTeamId()) + ").Squad(" + SQN(vp.getSavedSquadId()) + ")^n to ^bDTeam(" + TN(dtid) + ").DSquad(" + SQN(dsid) + ")^n", 3);
            movePlayer(vp, dtid, dsid);

        }
Exemple #56
0
 public override void ShowScorePanel(LevelBlueprint lvl, PlayerProfile profile, HashSet <FractionDifficulty> newDifficulty, bool playerHasWon, int addPoints, int time)
 {
     //
 }
Exemple #57
0
        private void KickPlayerWithMessage(PlayerProfile player, string message) {
            if (player == null)
                return;

            player.state = PlayerState.kicked;
            this.ExecuteCommand("procon.protected.send", "admin.kickPlayer", player.name, message);
            if (players.ContainsKey(player.name))
                players.Remove(player.name);
        }
 public void IncrementProfileData(PlayerProfile _incrementData)
 {
     this.gamesPlayed += _incrementData.gamesPlayed;
     this.gamesWon    += _incrementData.gamesWon;
 }
Exemple #59
0
            public PlayerProfile(PlayerProfile player) {
                /* shallow copy */
                updateInfo(player.info);
                pbinfo = player.pbinfo;
                name = player.name;
                plugin = player.plugin;
                stats = player.stats;
                state = player.state;
                qmsg = player.qmsg;
                tag = player.tag;
                time = player.time;
                random_value = player.random_value;

                last_kill = player.last_kill;
                last_death = player.last_death;
                last_spawn = player.last_spawn;
                last_chat = player.last_chat;
                last_score = player.last_score;

                savedTeamId = player.savedTeamId;
                savedSquadId = player.savedSquadId;

                targetTeamId = player.targetTeamId;
                targetSquadId = player.targetSquadId;

                delayedTeamId = player.delayedTeamId;
                delayedSquadId = player.delayedSquadId;
            }
 private void LoadProfile()
 {
     playerProfile = FileBridge.LoadProfile();
 }