package gtanks.users.garage; import gtanks.users.garage.enums.ItemType; import…
- User
package gtanks.users.garage;
import gtanks.users.garage.enums.ItemType; import gtanks.users.garage.items.Item; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException;
@Entity @org.hibernate.annotations.Entity @Table( name = "garages" ) public class Garage implements Serializable { private static final long serialVersionUID = 2342422342L; @Id @GeneratedValue( strategy = GenerationType.IDENTITY ) @Column( name = "uid", nullable = false, unique = true ) private long id; @Column( name = "turrets", nullable = false ) private String _json_turrets; @Column( name = "hulls", nullable = false ) private String _json_hulls; @Column( name = "colormaps", nullable = false ) private String _json_colormaps; @Column( name = "inventory", nullable = false ) private String _json_inventory; @Column( name = "effects", nullable = false ) private String _json_effects; @Column( name = "userid", nullable = false, unique = true ) private String userId; @Transient public ArrayList items = new ArrayList(); @Transient public Item mountTurret; @Transient public Item mountHull; @Transient public Item mountColormap;
public Garage() { this.items.add(((Item)GarageItemsLoader.items.get("up_score_small")).clone()); this.items.add(((Item)GarageItemsLoader.items.get("smoky")).clone()); this.items.add(((Item)GarageItemsLoader.items.get("wasp")).clone()); this.items.add(((Item)GarageItemsLoader.items.get("green")).clone()); this.items.add(((Item)GarageItemsLoader.items.get("holiday")).clone()); this.mountItem("wasp_m0"); this.mountItem("smoky_m0"); this.mountItem("green_m0"); }
public boolean containsItem(String id) { Iterator var3 = this.items.iterator();
codewhile(var3.hasNext()) { Item item = (Item)var3.next(); if (item.id.equals(id)) { return true; } } return false;}
public Item getItemById(String id) { Iterator var3 = this.items.iterator();
codewhile(var3.hasNext()) { Item item = (Item)var3.next(); if (item.id.equals(id)) { return item; } } return null;}
public boolean mountItem(String id) { Item item = this.getItemById(id.substring(0, id.length() - 3)); if (item != null && Integer.parseInt(id.substring(id.length() - 1, id.length())) == item.modificationIndex) { if (item.itemType == ItemType.WEAPON) { this.mountTurret = item; return true; }
- Assistant
Для добавления поля multicounted в класс Garage нужно сделать следующее:
- Добавить поле multicounted типа String в класс Garage:
java@Column( name = "multicounted", nullable = false ) private String _json_multicounted;