Exemple #1
0
        public bool UpdatePartyLeader(string proposedLeader)
        {
            if (!MemberIdToPit.ContainsKey(proposedLeader))
            {
                return(false);
            }

            LeaderPlayerId = proposedLeader;
            return(true);
        }
Exemple #2
0
        public Member GetMember(string playerId)
        {
            if (!MemberIdToPit.ContainsKey(playerId))
            {
                return(null);
            }

            var member = new Member(playerId, Id);

            member.PreviousState = member.SerializeToJson();
            return(member);
        }
Exemple #3
0
        public bool AddPlayerToParty(string playerId, string pit)
        {
            if (MemberIdToPit.ContainsKey(playerId))
            {
                return(false);
            }

            if (IsAtFullCapacity())
            {
                throw new Exception("The party is at full capacity");
            }

            MemberIdToPit[playerId] = pit;
            MemberIds.Add(playerId);
            return(true);
        }
Exemple #4
0
        public bool RemovePlayerFromParty(string playerId)
        {
            if (!MemberIdToPit.ContainsKey(playerId))
            {
                return(false);
            }

            if (MemberIdToPit.Count == 1)
            {
                throw new Exception("Cannot remove player if last member of the party");
            }

            MemberIdToPit.Remove(playerId);
            MemberIds.Remove(playerId);

            if (LeaderPlayerId == playerId)
            {
                LeaderPlayerId = MemberIdToPit.ElementAt(0).Key;
            }

            return(true);
        }