2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.catalog;
|
|
|
|
|
|
|
|
|
2018-10-07 00:28:00 +02:00
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.users.cache.HabboOfferPurchase;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.messages.ServerMessage;
|
|
|
|
|
2018-10-07 00:28:00 +02:00
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class TargetOffer {
|
2018-10-07 00:28:00 +02:00
|
|
|
public static int ACTIVE_TARGET_OFFER_ID = 0;
|
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
private final int id;
|
2018-10-07 00:28:00 +02:00
|
|
|
private final int catalogItem;
|
2018-07-06 15:30:00 +02:00
|
|
|
private final String identifier;
|
|
|
|
private final int priceInCredits;
|
|
|
|
private final int priceInActivityPoints;
|
|
|
|
private final int activityPointsType;
|
|
|
|
private final int purchaseLimit;
|
|
|
|
private final int expirationTime;
|
|
|
|
private final String title;
|
|
|
|
private final String description;
|
|
|
|
private final String imageUrl;
|
2018-10-07 00:28:00 +02:00
|
|
|
private final String icon;
|
|
|
|
private final String[] vars;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public TargetOffer(ResultSet set) throws SQLException {
|
2018-10-07 00:28:00 +02:00
|
|
|
this.id = set.getInt("id");
|
|
|
|
this.identifier = set.getString("offer_code");
|
|
|
|
this.priceInCredits = set.getInt("credits");
|
|
|
|
this.priceInActivityPoints = set.getInt("points");
|
|
|
|
this.activityPointsType = set.getInt("points_type");
|
|
|
|
this.title = set.getString("title");
|
|
|
|
this.description = set.getString("description");
|
|
|
|
this.imageUrl = set.getString("image");
|
|
|
|
this.icon = set.getString("icon");
|
|
|
|
this.purchaseLimit = set.getInt("purchase_limit");
|
|
|
|
this.expirationTime = set.getInt("end_timestamp");
|
|
|
|
this.vars = set.getString("vars").split(";");
|
|
|
|
this.catalogItem = set.getInt("catalog_item");
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void serialize(ServerMessage message, HabboOfferPurchase purchase) {
|
2018-10-07 00:28:00 +02:00
|
|
|
message.appendInt(purchase.getState());
|
2018-07-06 15:30:00 +02:00
|
|
|
message.appendInt(this.id);
|
|
|
|
message.appendString(this.identifier);
|
2018-10-07 00:28:00 +02:00
|
|
|
message.appendString(this.identifier);
|
2018-07-06 15:30:00 +02:00
|
|
|
message.appendInt(this.priceInCredits);
|
|
|
|
message.appendInt(this.priceInActivityPoints);
|
|
|
|
message.appendInt(this.activityPointsType);
|
2018-10-07 00:28:00 +02:00
|
|
|
message.appendInt(Math.max(this.purchaseLimit - purchase.getAmount(), 0));
|
2018-11-17 14:28:00 +01:00
|
|
|
message.appendInt(Math.max(this.expirationTime - Emulator.getIntUnixTimestamp(), 0));
|
2018-07-06 15:30:00 +02:00
|
|
|
message.appendString(this.title);
|
|
|
|
message.appendString(this.description);
|
|
|
|
message.appendString(this.imageUrl);
|
2018-10-07 00:28:00 +02:00
|
|
|
message.appendString(this.icon);
|
|
|
|
message.appendInt(0);
|
|
|
|
message.appendInt(this.vars.length);
|
2019-05-26 20:14:53 +02:00
|
|
|
for (String variable : this.vars) {
|
2018-10-07 00:28:00 +02:00
|
|
|
message.appendString(variable);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-07 00:28:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getId() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.id;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getIdentifier() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.identifier;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getPriceInCredits() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.priceInCredits;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getPriceInActivityPoints() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.priceInActivityPoints;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getActivityPointsType() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.activityPointsType;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getPurchaseLimit() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.purchaseLimit;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getExpirationTime() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.expirationTime;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getTitle() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.title;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getDescription() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.description;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getImageUrl() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.imageUrl;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getIcon() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.icon;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String[] getVars() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.vars;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getCatalogItem() {
|
2018-10-07 00:28:00 +02:00
|
|
|
return this.catalogItem;
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|