コード例 #1
0
ファイル: Party.java プロジェクト: WhiteGems/AE2
  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);
      }
    }
  }
コード例 #2
0
ファイル: Party.java プロジェクト: WhiteGems/AE2
  public void join(PartyMember member) {
    if ((member != null) && (this.members.size() < this.memberSizeLimit) && (!hasMember(member))) {
      Party party;
      if (PartyController.instance().inParty(member.username)) {
        party =
            PartyController.instance()
                .getParty(PartyController.instance().getMember(member.username));
      }

      if (isRequestedPlayer(member.username)) {
        removeRequestedPlayer(member.username);
      }

      this.members.add(member);
    }
  }