Exemple #1
0
        public byte Reward(byte OrbId, Keys victim)
        {
            byte temp;

            lock (MVP.RecordsLock) {
                lock (lock_reward) {
                    if (killed.Contains(victim) || HEADS[victim].Died)
                    {
                        return(0);
                    }
                    else if (!KingOfTheHill)
                    {
                        killed.Add(victim);
                    }

                    if (ChaosMode && Leader == victim)
                    {
                        Leader = this.KeyCode;
                    }

                    OnReward?.Invoke();
                    temp = this.Points;
                    Kills++;
                    this.Points += KingOfTheHill? (byte)1 : Kills;
                    if (HEADS[victim].isBounty)
                    {
                        this.Points++;
                    }
                    if (HEADS[victim].isDoubleBounty)
                    {
                        this.Points++;
                    }
                    this.Points += Orb.All[OrbId].KillStreak++;
                    key.Add(this.Points - temp);
                    key.points = Points;

                    if (Orb.All[OrbId].KillStreak > 1)
                    {
                        if (KingOfTheHill)
                        {
                            MVP.Flash("Collateral!");
                        }
                        else
                        {
                            MVP.Add(MVPTypes.COLLATERAL, DisplayKey, Orb.All[OrbId].KillStreak.ToString());
                        }
                    }

                    if (Died)
                    {
                        if (KingOfTheHill)
                        {
                            MVP.Flash("GhostKill!");
                        }
                        else
                        {
                            MVP.Add(MVPTypes.GHOSTKILL, DisplayKey);
                        }
                    }
                }
            }

            if (KingOfTheHill)
            {
                Map.Sort();
                IKey.UpdateAll();
                bool leader = true;
                int  second = 0;

                lock (ActiveLock)
                    foreach (Head head in HEADS.Values)
                    {
                        if (head.KeyCode == KeyCode)
                        {
                            continue;
                        }
                        if (this.Points < head.Points)
                        {
                            leader = false;
                        }
                        if (second < head.Points)
                        {
                            second = head.Points;
                        }
                    }

                if (leader)
                {
                    Leader = this.KeyCode;
                }

                if (this.Points >= Map.MaxPoints && Points - second > 1 && Map.phase != Phases.ENDGAME)
                {
                    MVP.Show(MVP.WinMessage(this.DisplayKey));
                    new Thread(Map.EndGame).Start();
                }
                else if (Kills >= 5 && !isBounty)
                {
                    MVP.Flash($"{DisplayKey} killstreak");
                    this.isBounty = true;
                }
                else if (this.Points >= Map.MaxPoints - 1 && !isBounty)
                {
                    this.isBounty = true;
                    MVP.Flash("Matchpoint!");
                }

                else if (isBounty && Kills >= 5 && this.Points >= Map.MaxPoints - 1 && !isDoubleBounty)
                {
                    MVP.Flash("Double Bounty!");
                    this.isDoubleBounty = true;
                }
            }
            return((byte)(Points - temp));
        }