public bool UpdatePartyLeader(string proposedLeader) { if (!MemberIdToPit.ContainsKey(proposedLeader)) { return(false); } LeaderPlayerId = proposedLeader; return(true); }
public Member GetMember(string playerId) { if (!MemberIdToPit.ContainsKey(playerId)) { return(null); } var member = new Member(playerId, Id); member.PreviousState = member.SerializeToJson(); return(member); }
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); }
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); }