Example #1
0
  public void leave(PartyMember member) {
    if (hasMember(member)) {
      if ((member.isLeader()) && (this.members.size() > 1)) {
        Random rand = new Random();
        PartyMember newLeader = null;

        while ((newLeader == null) || (newLeader == member)) {
          newLeader = (PartyMember) this.members.get(rand.nextInt(this.members.size()));
        }

        if (newLeader != null) {
          PartyController.instance()
              .promoteMember(
                  PartyController.instance().getMember(newLeader.username),
                  MemberType.LEADER,
                  true);
        }
      }
      this.members.remove(member);

      if (this.members.size() <= 0) {
        PartyController.instance().removeParty(this, true);
      }
    }
  }
Example #2
0
  public void promoteMember(PartyMember member, MemberType type) {
    if (hasMember(member)) {
      member.promoteTo(type);

      if ((type == MemberType.LEADER) && (hasLeader())) {
        this.leader.promoteTo(MemberType.MEMBER);
        this.leader = member;
      }
    }
  }