Ejemplo n.º 1
0
        public bool UpdatePartyLeader(string proposedLeader)
        {
            if (!MemberIdToPit.ContainsKey(proposedLeader))
            {
                return(false);
            }

            LeaderPlayerId = proposedLeader;
            return(true);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }