Added models and DAOs for cards and DDR Ace profiles, as well as enums

for various options in-game for Ace. The next step is to actually
support carding in in-game, as well as creating new profiles in-game for
unbound cards.
This commit is contained in:
skogaby
2019-01-17 15:24:18 -06:00
parent a4a78855ad
commit 8654eac79f
35 changed files with 1118 additions and 87 deletions

View File

@@ -1,7 +1,7 @@
package com.buttongames.butterfly.hibernate.dao.impl;
import com.buttongames.butterfly.hibernate.dao.AbstractHibernateDao;
import com.buttongames.butterfly.model.Ddr16PcbEventLog;
import com.buttongames.butterfly.model.Card;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -9,16 +9,16 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
/**
* DAO for interacting with <code>Ddr16PcbEventLog</code> objects in the database.
* DAO for interacting with <code>Card</code> objects in the database.
* @author skogaby (skogabyskogaby@gmail.com)
*/
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Repository
public class Ddr16PcbEventLogDao extends AbstractHibernateDao<Ddr16PcbEventLog> {
public class CardDao extends AbstractHibernateDao<Card> {
@Autowired
public Ddr16PcbEventLogDao(final SessionFactory sessionFactory) {
public CardDao(final SessionFactory sessionFactory) {
super(sessionFactory);
setClazz(Ddr16PcbEventLog.class);
setClazz(Card.class);
}
}

View File

@@ -1,7 +1,7 @@
package com.buttongames.butterfly.hibernate.dao.impl;
package com.buttongames.butterfly.hibernate.dao.impl.ddr16;
import com.buttongames.butterfly.hibernate.dao.AbstractHibernateDao;
import com.buttongames.butterfly.model.Ddr16GameplayEventLog;
import com.buttongames.butterfly.model.ddr16.GameplayEventLog;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -9,16 +9,16 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
/**
* DAO for interacting with <code>Ddr16GameplayEventLog</code> objects in the database.
* DAO for interacting with <code>GameplayEventLog</code> objects in the database.
* @author skogaby (skogabyskogaby@gmail.com)
*/
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Repository
public class Ddr16GameplayEventLogDao extends AbstractHibernateDao<Ddr16GameplayEventLog> {
public class GameplayEventLogDao extends AbstractHibernateDao<GameplayEventLog> {
@Autowired
public Ddr16GameplayEventLogDao(final SessionFactory sessionFactory) {
public GameplayEventLogDao(final SessionFactory sessionFactory) {
super(sessionFactory);
setClazz(Ddr16GameplayEventLog.class);
setClazz(GameplayEventLog.class);
}
}

View File

@@ -0,0 +1,24 @@
package com.buttongames.butterfly.hibernate.dao.impl.ddr16;
import com.buttongames.butterfly.hibernate.dao.AbstractHibernateDao;
import com.buttongames.butterfly.model.ddr16.PcbEventLog;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
/**
* DAO for interacting with <code>PcbEventLog</code> objects in the database.
* @author skogaby (skogabyskogaby@gmail.com)
*/
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Repository
public class PcbEventLogDao extends AbstractHibernateDao<PcbEventLog> {
@Autowired
public PcbEventLogDao(final SessionFactory sessionFactory) {
super(sessionFactory);
setClazz(PcbEventLog.class);
}
}

View File

@@ -0,0 +1,24 @@
package com.buttongames.butterfly.hibernate.dao.impl.ddr16;
import com.buttongames.butterfly.hibernate.dao.AbstractHibernateDao;
import com.buttongames.butterfly.model.ddr16.UserProfile;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
/**
* DAO for interacting with <code>UserProfile</code> objects in the database.
* @author skogaby (skogabyskogaby@gmail.com)
*/
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Repository
public class ProfileDao extends AbstractHibernateDao<UserProfile> {
@Autowired
public ProfileDao(final SessionFactory sessionFactory) {
super(sessionFactory);
setClazz(UserProfile.class);
}
}

View File

@@ -1,7 +1,7 @@
package com.buttongames.butterfly.hibernate.dao.impl;
package com.buttongames.butterfly.hibernate.dao.impl.ddr16;
import com.buttongames.butterfly.hibernate.dao.AbstractHibernateDao;
import com.buttongames.butterfly.model.Ddr16Shop;
import com.buttongames.butterfly.model.ddr16.Shop;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
@@ -10,30 +10,30 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
/**
* DAO for interacting with <code>Ddr16Shop</code> objects in the database.
* DAO for interacting with <code>Shop</code> objects in the database.
* @author skogaby (skogabyskogaby@gmail.com)
*/
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Repository
public class Ddr16ShopDao extends AbstractHibernateDao<Ddr16Shop> {
public class ShopDao extends AbstractHibernateDao<Shop> {
@Autowired
public Ddr16ShopDao(final SessionFactory sessionFactory) {
public ShopDao(final SessionFactory sessionFactory) {
super(sessionFactory);
setClazz(Ddr16Shop.class);
setClazz(Shop.class);
}
/**
* Finds a shop by its PCBID.
* @param pcbId The PCBID to query for.
* @return The matching Ddr16Shop, or null if none are found.
* @return The matching Shop, or null if none are found.
*/
public Ddr16Shop findByPcbId(final String pcbId) {
public Shop findByPcbId(final String pcbId) {
this.openCurrentSession();
final Query<Ddr16Shop> query = this.currentSession.createQuery("from Ddr16Shop where pcb_id = :pcbid");
final Query<Shop> query = this.currentSession.createQuery("from Ddr16Shop where pcb_id = :pcbid");
query.setParameter("pcbid", pcbId);
final Ddr16Shop result = query.uniqueResult();
final Shop result = query.uniqueResult();
this.closeCurrentSession();
return result;

View File

@@ -226,7 +226,7 @@ public class ButterflyHttpServer {
})));
exception(CardCipherException.class, (((exception, request, response) -> {
response.status(403);
response.body(exception.getMessage());
response.body("Issue with converting the requested card ID, likely invalid ID.");
})));
}
@@ -298,7 +298,8 @@ public class ButterflyHttpServer {
if (machine == null) {
// create a machine and just ban it for now, unban it later if you want
final ButterflyUser newUser = new ButterflyUser("0000", LocalDateTime.now());
final LocalDateTime now = LocalDateTime.now();
final ButterflyUser newUser = new ButterflyUser("0000", now, now);
userDao.create(newUser);
machine = new Machine(newUser, requestBodyPcbId, LocalDateTime.now(), false, 0);

View File

@@ -6,11 +6,4 @@ package com.buttongames.butterfly.http.exception;
*/
public class CardCipherException extends RuntimeException {
public CardCipherException() {
super();
}
public CardCipherException(final String message) {
super(message);
}
}

View File

@@ -1,9 +1,9 @@
package com.buttongames.butterfly.http.handlers.impl;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16GameplayEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.GameplayEventLogDao;
import com.buttongames.butterfly.http.exception.InvalidRequestMethodException;
import com.buttongames.butterfly.http.handlers.BaseRequestHandler;
import com.buttongames.butterfly.model.Ddr16GameplayEventLog;
import com.buttongames.butterfly.model.ddr16.GameplayEventLog;
import com.buttongames.butterfly.util.TimeUtils;
import com.buttongames.butterfly.xml.builder.KXmlBuilder;
import com.buttongames.butterfly.xml.XmlUtils;
@@ -30,10 +30,10 @@ public class EventLogRequestHandler extends BaseRequestHandler {
/**
* The DAO for creating gameplay event logs in the database.
*/
private final Ddr16GameplayEventLogDao gameplayEventLogDao;
private final GameplayEventLogDao gameplayEventLogDao;
@Autowired
public EventLogRequestHandler(final Ddr16GameplayEventLogDao gameplayEventLogDao) {
public EventLogRequestHandler(final GameplayEventLogDao gameplayEventLogDao) {
this.gameplayEventLogDao = gameplayEventLogDao;
}
@@ -77,7 +77,7 @@ public class EventLogRequestHandler extends BaseRequestHandler {
final long numData2 = XmlUtils.longValueAtPath(requestBody, "/eventlog/data/numdata2");
final String locationId = XmlUtils.strValueAtPath(requestBody, "/eventlog/data/locationid");
final Ddr16GameplayEventLog event = new Ddr16GameplayEventLog(reqPcbId, reqModel, retryCount, eventId,
final GameplayEventLog event = new GameplayEventLog(reqPcbId, reqModel, retryCount, eventId,
eventOrder, pcbTime, gameSession, stringData1, stringData2, numData1, numData2, locationId);
this.gameplayEventLogDao.create(event);

View File

@@ -1,10 +1,10 @@
package com.buttongames.butterfly.http.handlers.impl;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16ShopDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.ShopDao;
import com.buttongames.butterfly.hibernate.dao.impl.MachineDao;
import com.buttongames.butterfly.http.exception.InvalidRequestMethodException;
import com.buttongames.butterfly.http.handlers.BaseRequestHandler;
import com.buttongames.butterfly.model.Ddr16Shop;
import com.buttongames.butterfly.model.ddr16.Shop;
import com.buttongames.butterfly.util.StringUtils;
import com.buttongames.butterfly.xml.builder.KXmlBuilder;
import org.apache.logging.log4j.LogManager;
@@ -27,7 +27,7 @@ public class FacilityRequestHandler extends BaseRequestHandler {
/**
* DAO for interacting with Ddr16Shops in the database.
*/
private final Ddr16ShopDao shopDao;
private final ShopDao shopDao;
/**
* DAO for interacting with Machines in the database.
@@ -35,7 +35,7 @@ public class FacilityRequestHandler extends BaseRequestHandler {
private final MachineDao machineDao;
@Autowired
public FacilityRequestHandler(final Ddr16ShopDao shopDao,
public FacilityRequestHandler(final ShopDao shopDao,
final MachineDao machineDao) {
this.shopDao = shopDao;
this.machineDao = machineDao;
@@ -67,11 +67,11 @@ public class FacilityRequestHandler extends BaseRequestHandler {
*/
private Object handleGetRequest(final Request request, final Response response) {
final String reqPcbId = request.attribute("pcbid");
Ddr16Shop shop = this.shopDao.findByPcbId(reqPcbId);
Shop shop = this.shopDao.findByPcbId(reqPcbId);
// if no shop exists for this PCB, just make a default one
if (shop == null) {
shop = new Ddr16Shop(reqPcbId, StringUtils.getRandomHexString(8), "BUTTERFLY", "US", "1", true);
shop = new Shop(reqPcbId, StringUtils.getRandomHexString(8), "BUTTERFLY", "US", "1", true);
shopDao.create(shop);
}

View File

@@ -1,9 +1,9 @@
package com.buttongames.butterfly.http.handlers.impl;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16PcbEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.PcbEventLogDao;
import com.buttongames.butterfly.http.exception.InvalidRequestMethodException;
import com.buttongames.butterfly.http.handlers.BaseRequestHandler;
import com.buttongames.butterfly.model.Ddr16PcbEventLog;
import com.buttongames.butterfly.model.ddr16.PcbEventLog;
import com.buttongames.butterfly.util.TimeUtils;
import com.buttongames.butterfly.xml.builder.KXmlBuilder;
import com.buttongames.butterfly.xml.XmlUtils;
@@ -29,10 +29,10 @@ public class PcbEventRequestHandler extends BaseRequestHandler {
/**
* The DAO for creating new PCB event logs.
*/
private final Ddr16PcbEventLogDao pcbEventLogDao;
private final PcbEventLogDao pcbEventLogDao;
@Autowired
public PcbEventRequestHandler(final Ddr16PcbEventLogDao pcbEventLogDao) {
public PcbEventRequestHandler(final PcbEventLogDao pcbEventLogDao) {
this.pcbEventLogDao = pcbEventLogDao;
}
@@ -71,7 +71,7 @@ public class PcbEventRequestHandler extends BaseRequestHandler {
final int value = XmlUtils.intValueAtPath(requestBody, "/pcbevent/item/value");
final LocalDateTime time2 = TimeUtils.timeFromEpoch(XmlUtils.longValueAtPath(requestBody, "/pcbevent/item/time"));
final Ddr16PcbEventLog event = new Ddr16PcbEventLog(reqPcbId, reqModel, time1, time2, sequence, name, value);
final PcbEventLog event = new PcbEventLog(reqPcbId, reqModel, time1, time2, sequence, name, value);
this.pcbEventLogDao.create(event);
// send the response

View File

@@ -32,6 +32,12 @@ public class ButterflyUser implements Externalizable {
@Column(name = "id")
private long id;
/**
* The user's card PIN.
*/
@Column(name = "pin")
private String pin;
/**
* The date and time this user was registered.
*/
@@ -39,30 +45,33 @@ public class ButterflyUser implements Externalizable {
private LocalDateTime registerTime;
/**
* The user's card PIN.
* The date and time this user last logged into a game on a card.
*/
@Column(name = "pin")
private String pin;
@Column(name = "last_play_time")
private LocalDateTime lastPlayTime;
public ButterflyUser() { }
public ButterflyUser(final String pin, final LocalDateTime registerTime) {
public ButterflyUser(final String pin, final LocalDateTime registerTime, final LocalDateTime lastPlayTime) {
this.pin = pin;
this.registerTime = registerTime;
this.lastPlayTime = lastPlayTime;
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeLong(this.id);
out.writeObject(this.registerTime);
out.writeUTF(this.pin);
out.writeObject(this.registerTime);
out.writeObject(this.lastPlayTime);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.setId(in.readLong());
this.setRegisterTime((LocalDateTime) in.readObject());
this.setPin(in.readUTF());
this.setRegisterTime((LocalDateTime) in.readObject());
this.setLastPlayTime((LocalDateTime) in.readObject());
}
public long getId() {
@@ -88,4 +97,12 @@ public class ButterflyUser implements Externalizable {
public void setPin(String pin) {
this.pin = pin;
}
public LocalDateTime getLastPlayTime() {
return lastPlayTime;
}
public void setLastPlayTime(LocalDateTime lastPlayTime) {
this.lastPlayTime = lastPlayTime;
}
}

View File

@@ -0,0 +1,180 @@
package com.buttongames.butterfly.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.time.LocalDateTime;
/**
* Model class that represents a shop housing a DDR 16 machine.
* @author skogaby (skogabyskogaby@gmail.com)
*/
@Entity
@Table(name = "cards")
public class Card implements Externalizable {
private static final long serialVersionUID = 1L;
/**
* ID of the object, primary key
* */
@Id
@GeneratedValue
@Column(name = "id")
private long id;
/**
* The user this card belongs to
*/
@ManyToOne
@JoinColumn(name = "user_id")
private ButterflyUser user;
/**
* The type of this card (old or FeliCa)
*/
@Column(name = "card_type")
@Enumerated(EnumType.STRING)
private CardType type;
/**
* The internal NFC ID for this card
*/
@Column(name = "nfc_id")
private String nfcId;
/**
* The external display ID for this card
*/
@Column(name = "display_id")
private String displayId;
/**
* The value to use for dataid/refid in the profile responses.
*/
@Column(name = "ref_id")
private String refId;
/**
* The date and time this card was registered
*/
@Column(name = "register_time")
private LocalDateTime registerTime;
/**
* The date and time this card last logged into a game
*/
@Column(name = "last_play_time")
private LocalDateTime lastPlayTime;
public Card() { }
public Card(final ButterflyUser user, final CardType type, final String nfcId, final String displayId,
final String refId, final LocalDateTime registerTime, final LocalDateTime lastPlayTime) {
this.user = user;
this.type = type;
this.nfcId = nfcId;
this.displayId = displayId;
this.refId = refId;
this.registerTime = registerTime;
this.lastPlayTime = lastPlayTime;
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeLong(this.id);
out.writeObject(this.user);
out.writeObject(this.type);
out.writeUTF(this.nfcId);
out.writeUTF(this.displayId);
out.writeUTF(this.refId);
out.writeObject(this.registerTime);
out.writeObject(this.lastPlayTime);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.setId(in.readLong());
this.setUser((ButterflyUser) in.readObject());
this.setType((CardType) in.readObject());
this.setNfcId(in.readUTF());
this.setDisplayId(in.readUTF());
this.setRefId(in.readUTF());
this.setRegisterTime((LocalDateTime) in.readObject());
this.setLastPlayTime((LocalDateTime) in.readObject());
}
public long getId() {
return id;
}
private void setId(long id) {
this.id = id;
}
public ButterflyUser getUser() {
return user;
}
public void setUser(ButterflyUser user) {
this.user = user;
}
public CardType getType() {
return type;
}
public void setType(CardType type) {
this.type = type;
}
public String getNfcId() {
return nfcId;
}
public void setNfcId(String nfcId) {
this.nfcId = nfcId;
}
public String getDisplayId() {
return displayId;
}
public void setDisplayId(String displayId) {
this.displayId = displayId;
}
public String getRefId() {
return refId;
}
public void setRefId(String refId) {
this.refId = refId;
}
public LocalDateTime getRegisterTime() {
return registerTime;
}
public void setRegisterTime(LocalDateTime registerTime) {
this.registerTime = registerTime;
}
public LocalDateTime getLastPlayTime() {
return lastPlayTime;
}
public void setLastPlayTime(LocalDateTime lastPlayTime) {
this.lastPlayTime = lastPlayTime;
}
}

View File

@@ -0,0 +1,9 @@
package com.buttongames.butterfly.model;
/**
* Enum for the different card types.
*/
public enum CardType {
OLD, // older style cards
FELICA // newer style, FeliCa cards
}

View File

@@ -1,11 +1,9 @@
package com.buttongames.butterfly.model;
package com.buttongames.butterfly.model.ddr16;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.io.Externalizable;
import java.io.IOException;
@@ -19,7 +17,7 @@ import java.time.LocalDateTime;
*/
@Entity
@Table(name = "ddr_16_gameplay_event_logs")
public class Ddr16GameplayEventLog implements Externalizable {
public class GameplayEventLog implements Externalizable {
private static final long serialVersionUID = 1L;
@@ -77,12 +75,12 @@ public class Ddr16GameplayEventLog implements Externalizable {
@Column(name = "location_id")
private String locationId;
public Ddr16GameplayEventLog() { }
public GameplayEventLog() { }
public Ddr16GameplayEventLog(final String pcbId, final String model, final int retryCount,
final String eventId, final int eventOrder, final LocalDateTime pcbTime, final long gameSession,
final String stringData1, final String stringData2, final long numData1, final long numData2,
final String locationId) {
public GameplayEventLog(final String pcbId, final String model, final int retryCount,
final String eventId, final int eventOrder, final LocalDateTime pcbTime, final long gameSession,
final String stringData1, final String stringData2, final long numData1, final long numData2,
final String locationId) {
this.pcbId = pcbId;
this.model = model;
this.retryCount = retryCount;

View File

@@ -1,4 +1,4 @@
package com.buttongames.butterfly.model;
package com.buttongames.butterfly.model.ddr16;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -17,7 +17,7 @@ import java.time.LocalDateTime;
*/
@Entity
@Table(name = "ddr_16_pcb_event_logs")
public class Ddr16PcbEventLog implements Externalizable {
public class PcbEventLog implements Externalizable {
private static final long serialVersionUID = 1L;
@@ -55,10 +55,10 @@ public class Ddr16PcbEventLog implements Externalizable {
@Column(name = "value")
private int value;
public Ddr16PcbEventLog() { }
public PcbEventLog() { }
public Ddr16PcbEventLog(final String pcbId, String model, final LocalDateTime time1,
final LocalDateTime time2, final long sequence, final String name, final int value) {
public PcbEventLog(final String pcbId, String model, final LocalDateTime time1,
final LocalDateTime time2, final long sequence, final String name, final int value) {
this.pcbId = pcbId;
this.model = model;
this.time1 = time1;

View File

@@ -1,4 +1,4 @@
package com.buttongames.butterfly.model;
package com.buttongames.butterfly.model.ddr16;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -16,11 +16,13 @@ import java.io.ObjectOutput;
*/
@Entity
@Table(name = "ddr_16_shops")
public class Ddr16Shop implements Externalizable {
public class Shop implements Externalizable {
private static final long serialVersionUID = 1L;
/** ID of the event, primary key. */
/**
* ID of the object, primary key.
*/
@Id
@GeneratedValue
@Column(name = "id")
@@ -50,10 +52,10 @@ public class Ddr16Shop implements Externalizable {
@Column(name = "is_public")
private boolean isPublic;
public Ddr16Shop() { }
public Shop() { }
public Ddr16Shop(final String pcbId, final String locationId, final String name,
final String country, final String region, final boolean isPublic) {
public Shop(final String pcbId, final String locationId, final String name,
final String country, final String region, final boolean isPublic) {
this.pcbId = pcbId;
this.locationId = locationId;
this.name = name;

View File

@@ -0,0 +1,551 @@
package com.buttongames.butterfly.model.ddr16;
import com.buttongames.butterfly.model.ButterflyUser;
import com.buttongames.butterfly.model.ddr16.options.AppearanceOption;
import com.buttongames.butterfly.model.ddr16.options.ArrowColorOption;
import com.buttongames.butterfly.model.ddr16.options.ArrowSkinOption;
import com.buttongames.butterfly.model.ddr16.options.BoostOption;
import com.buttongames.butterfly.model.ddr16.options.CutOption;
import com.buttongames.butterfly.model.ddr16.options.DancerOption;
import com.buttongames.butterfly.model.ddr16.options.FreezeArrowOption;
import com.buttongames.butterfly.model.ddr16.options.GuideLinesOption;
import com.buttongames.butterfly.model.ddr16.options.JudgementLayerOption;
import com.buttongames.butterfly.model.ddr16.options.JumpsOption;
import com.buttongames.butterfly.model.ddr16.options.LifeGaugeOption;
import com.buttongames.butterfly.model.ddr16.options.ScreenFilterOption;
import com.buttongames.butterfly.model.ddr16.options.ScrollOption;
import com.buttongames.butterfly.model.ddr16.options.SpeedOption;
import com.buttongames.butterfly.model.ddr16.options.StepZoneOption;
import com.buttongames.butterfly.model.ddr16.options.TurnOption;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
/**
* Model class that represents a user profile in DDR 16 (DDR A).
* @author skogaby (skogabyskogaby@gmail.com)
*/
@Entity
@Table(name = "ddr_16_profiles")
public class UserProfile implements Externalizable {
private static final long serialVersionUID = 1L;
/** ID of the object, primary key */
@Id
@GeneratedValue
@Column(name = "id")
private long id;
/** The user this profile belongs to */
@OneToOne
@JoinColumn(name = "user_id")
private ButterflyUser user;
/** The name of this profile */
@Column(name = "name")
private String name;
/** The dancer code for this profile */
@Column(name = "dancer_code")
private int dancerCode;
/** The area for this profile */
@Column(name = "area")
private int area;
/** Whether to display the weight */
@Column(name = "should_display_weight")
private boolean displayWeight;
/** Extra charge for this profile */
@Column(name = "extra_charge")
private int extraCharge;
/** Number of singles plays this profile has had */
@Column(name = "singles_plays")
private int singlesPlays;
/** Number of doubles plays this profile has had */
@Column(name = "doubles_plays")
private int doublesPlays;
/** Number of total plays this profile has had */
@Column(name = "total_plays")
private int totalPlays;
/** The player's weight (in kilograms) */
@Column(name = "weight")
private double weight;
/** The player's chosen dancer character */
@Column(name = "dancer_character")
@Enumerated(EnumType.STRING)
private DancerOption character;
/** The player's chosen speed option */
@Column(name = "option_speed")
@Enumerated(EnumType.STRING)
private SpeedOption speedOption;
/** The player's chosen boost option */
@Column(name = "option_boost")
@Enumerated(EnumType.STRING)
private BoostOption boostOption;
/** The player's chosen appearance option */
@Column(name = "option_appearance")
@Enumerated(EnumType.STRING)
private AppearanceOption appearanceOption;
/** The player's chosen turn option */
@Column(name = "option_turn")
@Enumerated(EnumType.STRING)
private TurnOption turnOption;
/** The player's chosen step zone option */
@Column(name = "option_step_zone")
@Enumerated(EnumType.STRING)
private StepZoneOption stepZoneOption;
/** The player's chosen scroll option */
@Column(name = "option_scroll")
@Enumerated(EnumType.STRING)
private ScrollOption scrollOption;
/** The player's chosen arrow color option */
@Column(name = "option_arrow_color")
@Enumerated(EnumType.STRING)
private ArrowColorOption arrowColorOption;
/** The player's chosen cut option */
@Column(name = "option_cut")
@Enumerated(EnumType.STRING)
private CutOption cutOption;
/** The player's chosen freeze arrow option */
@Column(name = "option_freeze_arrow")
@Enumerated(EnumType.STRING)
private FreezeArrowOption freezeArrowOption;
/** The player's chosen jump option */
@Column(name = "option_jumps")
@Enumerated(EnumType.STRING)
private JumpsOption jumpsOption;
/** The player's chosen arrow skin option */
@Column(name = "option_arrow_skin")
@Enumerated(EnumType.STRING)
private ArrowSkinOption arrowSkinOption;
/** The player's chosen screen filter option */
@Column(name = "option_screen_filter")
@Enumerated(EnumType.STRING)
private ScreenFilterOption screenFilterOption;
/** The player's chosen guidelines option */
@Column(name = "option_guidelines")
@Enumerated(EnumType.STRING)
private GuideLinesOption guideLinesOption;
/** The player's chosen life gauge option */
@Column(name = "option_life_gauge")
@Enumerated(EnumType.STRING)
private LifeGaugeOption lifeGaugeOption;
/** The player's chosen judgement layer option */
@Column(name = "option_judgement_layer")
@Enumerated(EnumType.STRING)
private JudgementLayerOption judgementLayerOption;
/** Calories from the last day (?) */
@Column(name = "last_calories")
private int lastCalories;
/** The player's first rival. */
@ManyToOne
@JoinColumn(name = "rival_1_id")
private UserProfile rival1;
/** The player's second rival. */
@ManyToOne
@JoinColumn(name = "rival_2_id")
private UserProfile rival2;
/** The player's third rival. */
@ManyToOne
@JoinColumn(name = "rival_3_id")
private UserProfile rival3;
public UserProfile() { }
public UserProfile(ButterflyUser user, String name, int dancerCode, int area, boolean displayWeight, int extraCharge,
int singlesPlays, int doublesPlays, int totalPlays, double weight, DancerOption character,
SpeedOption speedOption, BoostOption boostOption, AppearanceOption appearanceOption,
TurnOption turnOption, StepZoneOption stepZoneOption, ScrollOption scrollOption,
ArrowColorOption arrowColorOption, CutOption cutOption, FreezeArrowOption freezeArrowOption,
JumpsOption jumpsOption, ArrowSkinOption arrowSkinOption, ScreenFilterOption screenFilterOption,
GuideLinesOption guideLinesOption, LifeGaugeOption lifeGaugeOption, JudgementLayerOption judgementLayerOption,
int lastCalories, UserProfile rival1, UserProfile rival2, UserProfile rival3) {
this.user = user;
this.name = name;
this.dancerCode = dancerCode;
this.area = area;
this.displayWeight = displayWeight;
this.extraCharge = extraCharge;
this.singlesPlays = singlesPlays;
this.doublesPlays = doublesPlays;
this.totalPlays = totalPlays;
this.weight = weight;
this.character = character;
this.speedOption = speedOption;
this.boostOption = boostOption;
this.appearanceOption = appearanceOption;
this.turnOption = turnOption;
this.stepZoneOption = stepZoneOption;
this.scrollOption = scrollOption;
this.arrowColorOption = arrowColorOption;
this.cutOption = cutOption;
this.freezeArrowOption = freezeArrowOption;
this.jumpsOption = jumpsOption;
this.arrowSkinOption = arrowSkinOption;
this.screenFilterOption = screenFilterOption;
this.guideLinesOption = guideLinesOption;
this.lifeGaugeOption = lifeGaugeOption;
this.judgementLayerOption = judgementLayerOption;
this.lastCalories = lastCalories;
this.rival1 = rival1;
this.rival2 = rival2;
this.rival3 = rival3;
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeLong(this.id);
out.writeObject(this.user);
out.writeUTF(this.name);
out.writeInt(this.dancerCode);
out.writeInt(this.area);
out.writeBoolean(this.displayWeight);
out.writeInt(this.extraCharge);
out.writeInt(this.singlesPlays);
out.writeInt(this.doublesPlays);
out.writeInt(this.totalPlays);
out.writeDouble(this.weight);
out.writeObject(this.character);
out.writeObject(this.speedOption);
out.writeObject(this.boostOption);
out.writeObject(this.appearanceOption);
out.writeObject(this.turnOption);
out.writeObject(this.stepZoneOption);
out.writeObject(this.scrollOption);
out.writeObject(this.arrowColorOption);
out.writeObject(this.cutOption);
out.writeObject(this.freezeArrowOption);
out.writeObject(this.jumpsOption);
out.writeObject(this.arrowSkinOption);
out.writeObject(this.screenFilterOption);
out.writeObject(this.guideLinesOption);
out.writeObject(this.lifeGaugeOption);
out.writeObject(this.judgementLayerOption);
out.writeInt(this.lastCalories);
out.writeObject(this.rival1);
out.writeObject(this.rival2);
out.writeObject(this.rival3);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.setId(in.readLong());
this.setUser((ButterflyUser) in.readObject());
this.setName(in.readUTF());
this.setDancerCode(in.readInt());
this.setArea(in.readInt());
this.setDisplayWeight(in.readBoolean());
this.setExtraCharge(in.readInt());
this.setSinglesPlays(in.readInt());
this.setDoublesPlays(in.readInt());
this.setTotalPlays(in.readInt());
this.setWeight(in.readDouble());
this.setCharacter((DancerOption) in.readObject());
this.setSpeedOption((SpeedOption) in.readObject());
this.setBoostOption((BoostOption) in.readObject());
this.setAppearanceOption((AppearanceOption) in.readObject());
this.setTurnOption((TurnOption) in.readObject());
this.setStepZoneOption((StepZoneOption) in.readObject());
this.setScrollOption((ScrollOption) in.readObject());
this.setArrowColorOption((ArrowColorOption) in.readObject());
this.setCutOption((CutOption) in.readObject());
this.setFreezeArrowOption((FreezeArrowOption) in.readObject());
this.setJumpsOption((JumpsOption) in.readObject());
this.setArrowSkinOption((ArrowSkinOption) in.readObject());
this.setScreenFilterOption((ScreenFilterOption) in.readObject());
this.setGuideLinesOption((GuideLinesOption) in.readObject());
this.setLifeGaugeOption((LifeGaugeOption) in.readObject());
this.setJudgementLayerOption((JudgementLayerOption) in.readObject());
this.setLastCalories(in.readInt());
this.setRival1((UserProfile) in.readObject());
this.setRival2((UserProfile) in.readObject());
this.setRival3((UserProfile) in.readObject());
}
public long getId() {
return id;
}
private void setId(long id) {
this.id = id;
}
public ButterflyUser getUser() {
return user;
}
public void setUser(ButterflyUser user) {
this.user = user;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getDancerCode() {
return dancerCode;
}
public void setDancerCode(int dancerCode) {
this.dancerCode = dancerCode;
}
public int getArea() {
return area;
}
public void setArea(int area) {
this.area = area;
}
public boolean isDisplayWeight() {
return displayWeight;
}
public void setDisplayWeight(boolean displayWeight) {
this.displayWeight = displayWeight;
}
public int getExtraCharge() {
return extraCharge;
}
public void setExtraCharge(int extraCharge) {
this.extraCharge = extraCharge;
}
public int getSinglesPlays() {
return singlesPlays;
}
public void setSinglesPlays(int singlesPlays) {
this.singlesPlays = singlesPlays;
}
public int getDoublesPlays() {
return doublesPlays;
}
public void setDoublesPlays(int doublesPlays) {
this.doublesPlays = doublesPlays;
}
public int getTotalPlays() {
return totalPlays;
}
public void setTotalPlays(int totalPlays) {
this.totalPlays = totalPlays;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public DancerOption getCharacter() {
return character;
}
public void setCharacter(DancerOption character) {
this.character = character;
}
public SpeedOption getSpeedOption() {
return speedOption;
}
public void setSpeedOption(SpeedOption speedOption) {
this.speedOption = speedOption;
}
public BoostOption getBoostOption() {
return boostOption;
}
public void setBoostOption(BoostOption boostOption) {
this.boostOption = boostOption;
}
public AppearanceOption getAppearanceOption() {
return appearanceOption;
}
public void setAppearanceOption(AppearanceOption appearanceOption) {
this.appearanceOption = appearanceOption;
}
public TurnOption getTurnOption() {
return turnOption;
}
public void setTurnOption(TurnOption turnOption) {
this.turnOption = turnOption;
}
public StepZoneOption getStepZoneOption() {
return stepZoneOption;
}
public void setStepZoneOption(StepZoneOption stepZoneOption) {
this.stepZoneOption = stepZoneOption;
}
public ScrollOption getScrollOption() {
return scrollOption;
}
public void setScrollOption(ScrollOption scrollOption) {
this.scrollOption = scrollOption;
}
public ArrowColorOption getArrowColorOption() {
return arrowColorOption;
}
public void setArrowColorOption(ArrowColorOption arrowColorOption) {
this.arrowColorOption = arrowColorOption;
}
public CutOption getCutOption() {
return cutOption;
}
public void setCutOption(CutOption cutOption) {
this.cutOption = cutOption;
}
public FreezeArrowOption getFreezeArrowOption() {
return freezeArrowOption;
}
public void setFreezeArrowOption(FreezeArrowOption freezeArrowOption) {
this.freezeArrowOption = freezeArrowOption;
}
public JumpsOption getJumpsOption() {
return jumpsOption;
}
public void setJumpsOption(JumpsOption jumpsOption) {
this.jumpsOption = jumpsOption;
}
public ArrowSkinOption getArrowSkinOption() {
return arrowSkinOption;
}
public void setArrowSkinOption(ArrowSkinOption arrowSkinOption) {
this.arrowSkinOption = arrowSkinOption;
}
public ScreenFilterOption getScreenFilterOption() {
return screenFilterOption;
}
public void setScreenFilterOption(ScreenFilterOption screenFilterOption) {
this.screenFilterOption = screenFilterOption;
}
public GuideLinesOption getGuideLinesOption() {
return guideLinesOption;
}
public void setGuideLinesOption(GuideLinesOption guideLinesOption) {
this.guideLinesOption = guideLinesOption;
}
public LifeGaugeOption getLifeGaugeOption() {
return lifeGaugeOption;
}
public void setLifeGaugeOption(LifeGaugeOption lifeGaugeOption) {
this.lifeGaugeOption = lifeGaugeOption;
}
public JudgementLayerOption getJudgementLayerOption() {
return judgementLayerOption;
}
public void setJudgementLayerOption(JudgementLayerOption judgementLayerOption) {
this.judgementLayerOption = judgementLayerOption;
}
public int getLastCalories() {
return lastCalories;
}
public void setLastCalories(int lastCalories) {
this.lastCalories = lastCalories;
}
public UserProfile getRival1() {
return rival1;
}
public void setRival1(UserProfile rival1) {
this.rival1 = rival1;
}
public UserProfile getRival2() {
return rival2;
}
public void setRival2(UserProfile rival2) {
this.rival2 = rival2;
}
public UserProfile getRival3() {
return rival3;
}
public void setRival3(UserProfile rival3) {
this.rival3 = rival3;
}
}

View File

@@ -0,0 +1,13 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various appearance options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum AppearanceOption {
VISIBLE,
HIDDEN_PLUS,
SUDDEN_PLUS,
HIDDEN_AND_SUDDEN_PLUS,
STEALTH
}

View File

@@ -0,0 +1,12 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various arrow color options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum ArrowColorOption {
RAINBOW,
NOTE,
VIVID,
FLAT
}

View File

@@ -0,0 +1,16 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the arrow skins within DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum ArrowSkinOption {
NORMAL,
X,
CLASSIC,
CYBER,
MEDIUM,
SMALL,
DOT,
BUTTERFLY
}

View File

@@ -0,0 +1,12 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various boost options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum BoostOption {
NORMAL,
BOOST,
BRAKE,
WAVE
}

View File

@@ -0,0 +1,11 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various cut options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum CutOption {
OFF,
ON_1,
ON_2
}

View File

@@ -0,0 +1,27 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various dancers within DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum DancerOption {
RANDOM,
RANDOM_MALE,
RANDOM_FEMALE,
YUNI,
RAGE,
AFRO,
JENNY,
EMI,
BABYLON,
GUS,
RUBY,
ALICE,
JULIO,
BONNIE,
ZERO,
RINON,
RYUSEI_EMI,
RYUSEI_ALICE,
RYUSEI_RINON
}

View File

@@ -0,0 +1,10 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various freeze arrow options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum FreezeArrowOption {
ON,
OFF
}

View File

@@ -0,0 +1,11 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the guide line options within DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum GuideLinesOption {
OFF,
ARROW_CENTER,
ARROW_TOP
}

View File

@@ -0,0 +1,10 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the judgement layer options within DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum JudgementLayerOption {
FOREGROUND,
BACKGROUND
}

View File

@@ -0,0 +1,10 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various jump options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum JumpsOption {
ON,
OFF
}

View File

@@ -0,0 +1,11 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various life gauge options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum LifeGaugeOption {
NORMAL,
LIFE_4,
RISKY
}

View File

@@ -0,0 +1,12 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the screen filter options within DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum ScreenFilterOption {
OFF,
LIGHT,
MEDIUM,
DARK
}

View File

@@ -0,0 +1,10 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various scroll options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum ScrollOption {
NORMAL,
REVERSE
}

View File

@@ -0,0 +1,32 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various speed options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum SpeedOption {
X_0_25,
X_0_50,
X_0_75,
X_1_00,
X_1_25,
X_1_50,
X_1_75,
X_2_00,
X_2_25,
X_2_50,
X_2_75,
X_3_00,
X_3_25,
X_3_50,
X_3_75,
X_4_00,
X_4_50,
X_5_00,
X_5_50,
X_6_00,
X_6_50,
X_7_00,
X_7_50,
X_8_00,
}

View File

@@ -0,0 +1,10 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various step zone options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum StepZoneOption {
ON,
OFF
}

View File

@@ -0,0 +1,13 @@
package com.buttongames.butterfly.model.ddr16.options;
/**
* Enum for the various turn options in-game for DDR A.
* @author skogaby (skogabyskogaby@gmail.com)
*/
public enum TurnOption {
OFF,
MIRROR,
LEFT,
RIGHT,
SHUFFLE
}

View File

@@ -1,10 +1,12 @@
package com.buttongames.butterfly.spring.configuration;
import com.buttongames.butterfly.hibernate.dao.impl.CardDao;
import com.buttongames.butterfly.hibernate.dao.impl.MachineDao;
import com.buttongames.butterfly.hibernate.dao.impl.ButterflyUserDao;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16ShopDao;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16GameplayEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16PcbEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.ProfileDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.ShopDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.GameplayEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.PcbEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.UserPhasesDao;
import com.buttongames.butterfly.util.PathUtils;
import org.hibernate.SessionFactory;
@@ -97,17 +99,27 @@ public class HibernateConfiguration {
}
@Bean
public Ddr16GameplayEventLogDao ddr16GameplayEventLogDao(final SessionFactory sessionFactory) {
return new Ddr16GameplayEventLogDao(sessionFactory);
public GameplayEventLogDao gameplayEventLogDao(final SessionFactory sessionFactory) {
return new GameplayEventLogDao(sessionFactory);
}
@Bean
public Ddr16PcbEventLogDao ddr16PcbEventLogDao(final SessionFactory sessionFactory) {
return new Ddr16PcbEventLogDao(sessionFactory);
public PcbEventLogDao pcbEventLogDao(final SessionFactory sessionFactory) {
return new PcbEventLogDao(sessionFactory);
}
@Bean
public Ddr16ShopDao ddr16ShopDao(final SessionFactory sessionFactory) {
return new Ddr16ShopDao(sessionFactory);
public ShopDao shopDao(final SessionFactory sessionFactory) {
return new ShopDao(sessionFactory);
}
@Bean
public CardDao cardDao(final SessionFactory sessionFactory) {
return new CardDao(sessionFactory);
}
@Bean
public ProfileDao userProfileDao(final SessionFactory sessionFactory) {
return new ProfileDao(sessionFactory);
}
}

View File

@@ -1,9 +1,9 @@
package com.buttongames.butterfly.spring.configuration;
import com.buttongames.butterfly.hibernate.dao.impl.ButterflyUserDao;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16GameplayEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16PcbEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.Ddr16ShopDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.GameplayEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.PcbEventLogDao;
import com.buttongames.butterfly.hibernate.dao.impl.ddr16.ShopDao;
import com.buttongames.butterfly.hibernate.dao.impl.MachineDao;
import com.buttongames.butterfly.hibernate.dao.impl.UserPhasesDao;
import com.buttongames.butterfly.http.ButterflyHttpServer;
@@ -48,12 +48,12 @@ public class HttpConfiguration {
}
@Bean
public EventLogRequestHandler eventLogRequestHandler(final Ddr16GameplayEventLogDao gameplayEventLogDao) {
public EventLogRequestHandler eventLogRequestHandler(final GameplayEventLogDao gameplayEventLogDao) {
return new EventLogRequestHandler(gameplayEventLogDao);
}
@Bean
public FacilityRequestHandler facilityRequestHandler(final Ddr16ShopDao shopDao, final MachineDao machineDao) {
public FacilityRequestHandler facilityRequestHandler(final ShopDao shopDao, final MachineDao machineDao) {
return new FacilityRequestHandler(shopDao, machineDao);
}
@@ -68,7 +68,7 @@ public class HttpConfiguration {
}
@Bean
public PcbEventRequestHandler pcbEventRequestHandler(final Ddr16PcbEventLogDao pcbEventLogDao) {
public PcbEventRequestHandler pcbEventRequestHandler(final PcbEventLogDao pcbEventLogDao) {
return new PcbEventRequestHandler(pcbEventLogDao);
}