Skip to content

Commit

Permalink
ScoreDatabaseAccessor : add seed
Browse files Browse the repository at this point in the history
  • Loading branch information
exch-bms2 committed Feb 13, 2021
1 parent 9f7f7aa commit a12b92c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
29 changes: 5 additions & 24 deletions src/bms/player/beatoraja/PlayDataAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,51 +430,32 @@ private String getScoreHash(ScoreData score) {
private ScoreLog updateScore(ScoreData score, ScoreData newscore, String hash, boolean updateScore) {
ScoreLog log = new ScoreLog();

final int clear = score.getClear();
log.setOldclear(clear);
log.setClear(clear);
if (clear < newscore.getClear()) {
score.setClear(newscore.getClear());
score.setOption(newscore.getOption());
log.setOldclear(score.getClear());
log.setClear(score.getClear());
if (score.getClear() < newscore.getClear()) {
log.setSha256(hash);
log.setClear(newscore.getClear());
}
log.setOldscore(score.getExscore());
log.setScore(score.getExscore());
if (score.getExscore() < newscore.getExscore() && updateScore) {
score.setEpg(newscore.getEpg());
score.setLpg(newscore.getLpg());
score.setEgr(newscore.getEgr());
score.setLgr(newscore.getLgr());
score.setEgd(newscore.getEgd());
score.setLgd(newscore.getLgd());
score.setEbd(newscore.getEbd());
score.setLbd(newscore.getLbd());
score.setEpr(newscore.getEpr());
score.setLpr(newscore.getLpr());
score.setEms(newscore.getEms());
score.setLms(newscore.getLms());
score.setOption(newscore.getOption());
score.setGhost(newscore.getGhost());
log.setSha256(hash);
log.setScore(newscore.getExscore());
}
log.setOldminbp(score.getMinbp());
log.setMinbp(score.getMinbp());
if (score.getMinbp() > newscore.getMinbp() && updateScore) {
score.setMinbp(newscore.getMinbp());
score.setOption(newscore.getOption());
log.setSha256(hash);
log.setMinbp(newscore.getMinbp());
}
log.setOldcombo(score.getCombo());
log.setCombo(score.getCombo());
if (score.getCombo() < newscore.getCombo() && updateScore) {
score.setCombo(newscore.getCombo());
score.setOption(newscore.getOption());
log.setSha256(hash);
log.setCombo(newscore.getCombo());
}

score.update(newscore, updateScore);

return log;
}
Expand Down
18 changes: 15 additions & 3 deletions src/bms/player/beatoraja/ScoreData.java
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,24 @@ public void encodeGhost(int[] value) {
* @return スコアデータが更新された場合はtrue
*/
public boolean update(ScoreData newscore) {
return update(newscore, true);
}

/**
* 指定したスコアデータを元に更新する
* @param newscore スコアデータ
* @param updateScore スコアを更新するかどうか。falseの場合はクリアのみ更新対象にする
* @return スコアデータが更新された場合はtrue
*/
public boolean update(ScoreData newscore, boolean updateScore) {
boolean update = false;
if (clear < newscore.getClear()) {
setClear(newscore.getClear());
setOption(newscore.getOption());
setSeed(newscore.getSeed());
update = true;
}
if (getExscore() < newscore.getExscore()) {
if (getExscore() < newscore.getExscore() && updateScore) {
setEpg(newscore.getEpg());
setLpg(newscore.getLpg());
setEgr(newscore.getEgr());
Expand All @@ -512,14 +522,16 @@ public boolean update(ScoreData newscore) {
setGhost(newscore.getGhost());
update = true;
}
if (getMinbp() > newscore.getMinbp()) {
if (getMinbp() > newscore.getMinbp() && updateScore) {
setMinbp(newscore.getMinbp());
setOption(newscore.getOption());
setSeed(newscore.getSeed());
update = true;
}
if (getCombo() < newscore.getCombo()) {
if (getCombo() < newscore.getCombo() && updateScore) {
setCombo(newscore.getCombo());
setOption(newscore.getOption());
setSeed(newscore.getSeed());
update = true;
}
return update;
Expand Down
1 change: 1 addition & 0 deletions src/bms/player/beatoraja/ScoreDatabaseAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public ScoreDatabaseAccessor(String path) throws ClassNotFoundException {
new Column("trophy", "TEXT"),
new Column("ghost", "TEXT"),
new Column("option", "INTEGER"),
new Column("seed", "INTEGER"),
new Column("random", "INTEGER"),
new Column("date", "INTEGER"),
new Column("state", "INTEGER"),
Expand Down

0 comments on commit a12b92c

Please sign in to comment.