2022-04-27 04:24:25 +00:00
|
|
|
package emu.grasscutter.game.player;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2022-04-22 02:19:47 +00:00
|
|
|
import dev.morphia.annotations.Entity;
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.game.avatar.Avatar;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-05-11 04:30:07 +00:00
|
|
|
import static emu.grasscutter.Configuration.*;
|
|
|
|
|
2022-04-22 02:19:47 +00:00
|
|
|
@Entity
|
2022-04-17 12:43:07 +00:00
|
|
|
public class TeamInfo {
|
|
|
|
private String name;
|
|
|
|
private List<Integer> avatars;
|
|
|
|
|
|
|
|
public TeamInfo() {
|
|
|
|
this.name = "";
|
2022-05-11 04:30:07 +00:00
|
|
|
this.avatars = new ArrayList<>(GAME_OPTIONS.avatarLimits.singlePlayerTeam);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 06:10:23 +00:00
|
|
|
public TeamInfo(List<Integer> avatars) {
|
|
|
|
this.name = "";
|
|
|
|
this.avatars = avatars;
|
|
|
|
}
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Integer> getAvatars() {
|
|
|
|
return avatars;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int size() {
|
|
|
|
return avatars.size();
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public boolean contains(Avatar avatar) {
|
2022-04-17 12:43:07 +00:00
|
|
|
return getAvatars().contains(avatar.getAvatarId());
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public boolean addAvatar(Avatar avatar) {
|
2022-05-27 01:38:52 +00:00
|
|
|
if (contains(avatar)) {
|
2022-04-17 12:43:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
getAvatars().add(avatar.getAvatarId());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean removeAvatar(int slot) {
|
|
|
|
if (size() <= 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
getAvatars().remove(slot);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void copyFrom(TeamInfo team) {
|
2022-05-11 04:30:07 +00:00
|
|
|
copyFrom(team, GAME_OPTIONS.avatarLimits.singlePlayerTeam);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void copyFrom(TeamInfo team, int maxTeamSize) {
|
2022-04-18 06:36:47 +00:00
|
|
|
// Clone avatar ids from team to copy from
|
|
|
|
List<Integer> avatarIds = new ArrayList<>(team.getAvatars());
|
|
|
|
|
|
|
|
// Clear current avatar list first
|
2022-04-17 12:43:07 +00:00
|
|
|
this.getAvatars().clear();
|
|
|
|
|
|
|
|
// Copy from team
|
2022-04-18 06:36:47 +00:00
|
|
|
int len = Math.min(avatarIds.size(), maxTeamSize);
|
2022-04-17 12:43:07 +00:00
|
|
|
for (int i = 0; i < len; i++) {
|
2022-04-18 06:36:47 +00:00
|
|
|
int id = avatarIds.get(i);
|
2022-04-17 12:43:07 +00:00
|
|
|
this.getAvatars().add(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|