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
|
|
|
|
2018-10-07 00:28:00 +02:00
|
|
|
public class TargetOffer
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
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
|
|
|
|
2018-10-07 00:28:00 +02:00
|
|
|
public TargetOffer(ResultSet set) throws SQLException
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2018-10-07 00:28:00 +02:00
|
|
|
public void serialize(ServerMessage message, HabboOfferPurchase purchase)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
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));
|
|
|
|
message.appendInt(Math.max(Emulator.getIntUnixTimestamp() - this.expirationTime, 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);
|
|
|
|
for (String variable : this.vars)
|
2018-07-06 15:30:00 +02:00
|
|
|
{
|
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
|
|
|
|
|
|
|
public int getId()
|
|
|
|
{
|
|
|
|
return this.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getIdentifier()
|
|
|
|
{
|
|
|
|
return this.identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPriceInCredits()
|
|
|
|
{
|
|
|
|
return this.priceInCredits;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPriceInActivityPoints()
|
|
|
|
{
|
|
|
|
return this.priceInActivityPoints;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getActivityPointsType()
|
|
|
|
{
|
|
|
|
return this.activityPointsType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPurchaseLimit()
|
|
|
|
{
|
|
|
|
return this.purchaseLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getExpirationTime()
|
|
|
|
{
|
|
|
|
return this.expirationTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTitle()
|
|
|
|
{
|
|
|
|
return this.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription()
|
|
|
|
{
|
|
|
|
return this.description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getImageUrl()
|
|
|
|
{
|
|
|
|
return this.imageUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getIcon()
|
|
|
|
{
|
|
|
|
return this.icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String[] getVars()
|
|
|
|
{
|
|
|
|
return this.vars;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCatalogItem()
|
|
|
|
{
|
|
|
|
return this.catalogItem;
|
|
|
|
}
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|