birthday represented as LocalDate
This commit is contained in:
@@ -98,7 +98,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
|||||||
private int accId = -4;
|
private int accId = -4;
|
||||||
private boolean loggedIn = false;
|
private boolean loggedIn = false;
|
||||||
private boolean inServerTransition = false;
|
private boolean inServerTransition = false;
|
||||||
private Calendar birthday = null; // TODO: convert to LocalDate
|
private LocalDate birthday = null;
|
||||||
private String accountName = null;
|
private String accountName = null;
|
||||||
private int world;
|
private int world;
|
||||||
private volatile long lastPong;
|
private volatile long lastPong;
|
||||||
@@ -289,10 +289,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
|||||||
this.pin = account.pin();
|
this.pin = account.pin();
|
||||||
this.pic = account.pic();
|
this.pic = account.pic();
|
||||||
this.gender = Objects.requireNonNullElse(account.gender(), Gender.NOT_SET);
|
this.gender = Objects.requireNonNullElse(account.gender(), Gender.NOT_SET);
|
||||||
Calendar calendar = Calendar.getInstance();
|
this.birthday = account.birthdate();
|
||||||
LocalDate birthdate = account.birthdate();
|
|
||||||
calendar.set(birthdate.getYear(), birthdate.getMonthValue() - 1, birthdate.getDayOfMonth());
|
|
||||||
this.birthday = calendar;
|
|
||||||
loggedIn = account.loginState() == LoginState.LOGGED_IN;
|
loggedIn = account.loginState() == LoginState.LOGGED_IN;
|
||||||
inServerTransition = account.loginState() == LoginState.SERVER_TRANSITION;
|
inServerTransition = account.loginState() == LoginState.SERVER_TRANSITION;
|
||||||
}
|
}
|
||||||
@@ -568,7 +565,9 @@ public class Client extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkBirthDate(Calendar date) {
|
public boolean checkBirthDate(Calendar date) {
|
||||||
return date.get(Calendar.YEAR) == birthday.get(Calendar.YEAR) && date.get(Calendar.MONTH) == birthday.get(Calendar.MONTH) && date.get(Calendar.DAY_OF_MONTH) == birthday.get(Calendar.DAY_OF_MONTH);
|
LocalDate toCheck = LocalDate.of(date.get(Calendar.YEAR), date.get(Calendar.MONTH),
|
||||||
|
date.get(Calendar.DAY_OF_MONTH));
|
||||||
|
return Objects.equals(birthday, toCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean tryDisconnect() {
|
public synchronized boolean tryDisconnect() {
|
||||||
|
|||||||
@@ -475,6 +475,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to util class. Method to parse LocalDate from this encoded int.
|
||||||
public static boolean checkBirthday(Client c, int idate) {
|
public static boolean checkBirthday(Client c, int idate) {
|
||||||
int year = idate / 10000;
|
int year = idate / 10000;
|
||||||
int month = (idate - year * 10000) / 100;
|
int month = (idate - year * 10000) / 100;
|
||||||
|
|||||||
Reference in New Issue
Block a user