MapleParty.java
Upload User: gwt600
Upload Date: 2021-06-03
Package Size: 704k
Code Size: 5k
Category:

Games

Development Platform:

Java

  1. /*
  2. This file is part of the OdinMS Maple Story Server
  3. Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
  4. Matthias Butz <matze@odinms.de>
  5. Jan Christian Meyer <vimes@odinms.de>
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License version 3
  8. as published by the Free Software Foundation. You may not use, modify
  9. or distribute this program under any other version of the
  10. GNU Affero General Public License.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18. package net.sf.odinms.net.world;
  19. import java.io.Serializable;
  20. import java.util.Collection;
  21. import java.util.Collections;
  22. import java.util.LinkedList;
  23. import java.util.List;
  24. public class MapleParty implements Serializable {
  25.     private static final long serialVersionUID = 9179541993413738569L;
  26.     private MaplePartyCharacter leader;
  27.     private List<MaplePartyCharacter> members = new LinkedList<MaplePartyCharacter>();
  28.     private int id;
  29.     private int CP;
  30.     private int team;
  31.     private int totalCP;
  32.     private boolean capture = false;
  33.     private boolean waiting = false;
  34.     private MapleParty enemy = null;
  35.     private boolean challenging = false;
  36.     private boolean challenged = false;
  37.     private MapleParty challenger = null;
  38.     private int points = 0;
  39.     public MapleParty(int id, MaplePartyCharacter chrfor) {
  40.         this.leader = chrfor;
  41.         this.members.add(this.leader);
  42.         this.id = id;
  43.     }
  44.     public boolean getCapture() {
  45.         return capture;
  46.     }
  47.     public boolean getWaiting() {
  48.         return waiting;
  49.     }
  50.     public boolean getChallenging() {
  51.         return challenging;
  52.     }
  53.     public boolean getChallenged() {
  54.         return challenged;
  55.     }
  56.     public MapleParty getChallenger() {
  57.         return challenger;
  58.     }
  59.     public int getPoints() {
  60.         return points;
  61.     }
  62.     public void setCapture(boolean c) {
  63.         this.capture = c;
  64.     }
  65.     public void setWaiting(boolean c) {
  66.         this.waiting = c;
  67.     }
  68.     public void setChallenging(boolean c) {
  69.         this.challenging = c;
  70.     }
  71.     public void setChallenged(boolean c) {
  72.         this.challenged = c;
  73.     }
  74.     public void setEnemy(MapleParty enemy) {
  75. this.enemy = enemy;
  76. }
  77.     public void setChallenger(MapleParty c) {
  78.         this.challenger = c;
  79.     }
  80.     public void setPoints(int c) {
  81.         this.points = c;
  82.     }
  83.     public boolean containsMembers(MaplePartyCharacter member) {
  84.         return members.contains(member);
  85.     }
  86.     public void setLeader(MaplePartyCharacter victim) {
  87.         this.leader = victim;
  88.     }
  89.     public void addMember(MaplePartyCharacter member) {
  90.         members.add(member);
  91.     }
  92.     public void removeMember(MaplePartyCharacter member) {
  93.         members.remove(member);
  94.     }
  95.     public void updateMember(MaplePartyCharacter member) {
  96.         for (int i = 0; i < members.size(); i++) {
  97.             MaplePartyCharacter chr = members.get(i);
  98.             if (chr.equals(member)) {
  99.                 members.set(i, member);
  100.             }
  101.         }
  102.     }
  103.     public MaplePartyCharacter getMemberById(int id) {
  104.         for (MaplePartyCharacter chr : members) {
  105.             if (chr.getId() == id) {
  106.                 return chr;
  107.             }
  108.         }
  109.         return null;
  110.     }
  111.     public Collection<MaplePartyCharacter> getMembers() {
  112.         return Collections.unmodifiableList(members);
  113.     }
  114.     public int getId() {
  115.         return id;
  116.     }
  117.     public void setId(int id) {
  118.         this.id = id;
  119.     }
  120.     public int getCP() {
  121.         return this.CP;
  122.     }
  123.     public int getTeam() {
  124.         return this.team;
  125.     }
  126.     public int getTotalCP() {
  127.         return this.totalCP;
  128.     }
  129.     public void setCP(int cp) {
  130.         this.CP = cp;
  131.     }
  132.     public void setTeam(int team) {
  133.         this.team = team;
  134.     }
  135.     public void setTotalCP(int totalcp) {
  136.         this.totalCP = totalcp;
  137.     }
  138.     public MaplePartyCharacter getLeader() {
  139.         return leader;
  140.     }
  141.     @Override
  142.     public int hashCode() {
  143.         final int prime = 31;
  144.         int result = 1;
  145.         result = prime * result + id;
  146.         return result;
  147.     }
  148.     @Override
  149.     public boolean equals(Object obj) {
  150.         if (this == obj) {
  151.             return true;
  152.         }
  153.         if (obj == null) {
  154.             return false;
  155.         }
  156.         if (getClass() != obj.getClass()) {
  157.             return false;
  158.         }
  159.         final MapleParty other = (MapleParty) obj;
  160.         if (id != other.id) {
  161.             return false;
  162.         }
  163.         return true;
  164.     }
  165. }