Пример #1
0
 public PrincessPropertyArrayItem addData(int propertyKey, int level, int experience) {
   PrincessPropertyArrayItem item = new PrincessPropertyArrayItem();
   item.setPropertyKey(propertyKey);
   item.setLevel(level);
   item.setExperience(experience);
   list.add(item);
   return item;
 }
Пример #2
0
 @Override
 public boolean validate() {
   for (PrincessPropertyArrayItem item : list) {
     if (!item.validate()) {
       return false;
     }
   }
   return true;
 }
Пример #3
0
 /** 编码 */
 @Override
 public void encode(Data data) {
   data.writeInt(list.size());
   for (PrincessPropertyArrayItem item : list) {
     data.writeInt(item.getPropertyKey());
     data.writeInt(item.getLevel());
     data.writeInt(item.getExperience());
   }
 }
Пример #4
0
 /** 解码 */
 @Override
 public void decode(Data data) {
   int size = data.getInt();
   for (int i = 0; i < size; i++) {
     PrincessPropertyArrayItem item = PrincessPropertyArrayItem.create();
     item.setPropertyKey(data.getInt());
     item.setLevel(data.getInt());
     item.setExperience(data.getInt());
     list.add(item);
   }
 }
Пример #5
0
 public String toString() {
   StringBuilder bb = new StringBuilder();
   bb.append("[");
   int i = 0;
   for (PrincessPropertyArrayItem item : list) {
     bb.append("{").append(item.toString()).append("}");
     i++;
     if (i != list.size()) {
       bb.append(", ");
     }
   }
   bb.append("]");
   return bb.toString();
 }