コード例 #1
0
ファイル: Group.cs プロジェクト: vadian/Novus
        //the way this works is the current looter can either loot all or loot a specific item and then his turn is over and the next player gets a chance to loot.
        //the next player can choose to loot something from the current corpse
        private void NextPlayerLoots(User.User looter, List <string> commands, Character.NPC npc)
        {
            if (NextLooterList == null)
            {
                //create th elist of looters in no particular order
                NextLooterList = new Dictionary <int, string>();
                int index = 0;
                foreach (string player in PlayerList)
                {
                    NextLooterList.Add(index, player);
                    index++;
                }
            }

            if (looter.UserID == NextLooterList[CurrentLooter])
            {
                if (npc.Loot(looter, commands, true))
                {
                    //if the player actually loots something then we'll increment the counter
                    CurrentLooter++;
                    if (CurrentLooter > NextLooterList.Count)
                    {
                        CurrentLooter = 0;
                    }
                }
            }
            else
            {
                int playerPosition = 0;
                foreach (var keyValue in NextLooterList)
                {
                    if (keyValue.Value == looter.UserID)
                    {
                        break;
                    }
                    playerPosition++;
                }

                playerPosition -= CurrentLooter;

                if (playerPosition < 0)
                {
                    playerPosition = playerPosition + NextLooterList.Count;
                }

                MySockets.Server.GetAUser(looter.UserID).MessageHandler(string.Format("You are not eligible to loot at this time, it will be your turn in {0} more lootings.", playerPosition));
            }
        }
コード例 #2
0
ファイル: Group.cs プロジェクト: vadian/Novus
        //one player will randomly be chosen as the loot winner and can loot something. Once he loots something looting should be opne for all for
        //the corpse that was looted, otherwise another winner is randomly chosen again.
        //this has the drawback that only one corpse is remembered and not all the corpses that got looted not cool.
        private void ChanceLoot(User.User looter, List <string> commands, Character.NPC npc)
        {
            //we don't have a loot winner yet so let's roll the dice
            if (string.IsNullOrEmpty(MasterLooter))
            {
                int    highestRoll = 0;
                string winner      = null;
                foreach (string player in PlayerList)
                {
                    int currentRoll = Extensions.RandomNumber.GetRandomNumber().NextNumber(0, 20);
                    if (currentRoll > highestRoll)
                    {
                        winner = player;
                    }
                }
            }

            //so the looter was the winner or another player in the group is looting a corpse that was previously looted by a previous winner
            if (string.Equals(looter.UserID, MasterLooter) || LastLootedCorpse.Contains(npc.ID))
            {
                if (npc.Loot(looter, commands, true))
                {
                    //if player actually looted something
                    MasterLooter = null;
                    if (!LastLootedCorpse.Contains(npc.ID))
                    {
                        LastLootedCorpse.Add(npc.ID);
                    }
                }
                //we don't need to keep any old ID's since they probably rotted away anyways. Seriously doubt the group looted 100 bodies and then wanted to go
                //back and re-loot one of the 50 first corpses.  This number is subject to change once testing starts happening.
                if (LastLootedCorpse.Count > 100)
                {
                    LastLootedCorpse.RemoveRange(0, 49);
                }
            }
            else
            {
                MySockets.Server.GetAUser(looter.UserID).MessageHandler("You did not win the loot draw and can not loot this corpse.");
            }
        }