/cappoemu/src/Server/Furniture.java

https://github.com/GitLance/cappo-Java · Java · 427 lines · 398 code · 22 blank · 7 comment · 128 complexity · 97fdfcdc4b08582b249808128d2b5044 MD5 · raw file

  1. package Server;
  2. import Server.ItemInteractor.Interactor;
  3. import Server.ItemInteractor.InteractorTrax;
  4. import Server.ItemInteractor.InteractorWiredFurnis;
  5. import Server.ItemInteractor.InteractorBBTimer;
  6. import Server.ItemInteractor.InteractorNull;
  7. import Server.ItemInteractor.InteractorTeleport;
  8. import java.util.Map;
  9. import java.util.HashMap;
  10. import java.sql.ResultSet;
  11. /*
  12. *****************
  13. * @author capos *
  14. *****************
  15. */
  16. public class Furniture
  17. {
  18. public static final int BATTLEBANZAI_PIRAMID = 1;
  19. public static final int BATTLEBANZAI_COUNTER = 2;
  20. public static final int BATTLEBANZAI_SCORE_R = 3;
  21. public static final int BATTLEBANZAI_SCORE_G = 4;
  22. public static final int BATTLEBANZAI_SCORE_B = 5;
  23. public static final int BATTLEBANZAI_SCORE_Y = 6;
  24. public static final int BATTLEBANZAI_PATCH = 7;
  25. public static final int BATTLEBANZAI_GATER = 8;
  26. public static final int BATTLEBANZAI_GATEB = 9;
  27. public static final int BATTLEBANZAI_GATEG = 10;
  28. public static final int BATTLEBANZAI_GATEY = 11;
  29. public static final int WIRED_CONDITION = 12;
  30. public static final int WIRED_TRIGGER = 13;
  31. public static final int WIRED_EFFECT = 14;
  32. public static final int WIRED_OTHER = 15;
  33. public static final int XMAS2010 = 16;
  34. public static final int TELEPORT = 17;
  35. public static final int WALLPAPER = 18;
  36. public static final int LANDSCAPE = 19;
  37. public static final int ROLLER = 20;
  38. public static final int SKATES = 21;
  39. public static final int POSTIT = 22;
  40. public static final int DIMMER = 23;
  41. public static final int TROPHY = 24;
  42. public static final int WATER1 = 25;
  43. public static final int WATER2 = 26;
  44. public static final int WATER3 = 27;
  45. public static final int FLOOR = 28;
  46. public static final int BED = 29;
  47. public static final int BALL = 30;
  48. public Map<Integer, Item> Items = new HashMap<Integer, Item>();
  49. public Map<Integer, Item> IdsBySprite = new HashMap<Integer, Item>();
  50. private Interactor TeleInteractor = new InteractorTeleport();
  51. private Interactor InteractorTrax = new InteractorTrax();
  52. private Interactor BBTimerInteractor = new InteractorBBTimer();
  53. private Interactor NullInteractor = new InteractorNull();
  54. private Interactor WiredInteractor = new InteractorWiredFurnis();
  55. public Furniture(String[] DATA) throws Exception
  56. {
  57. DatabaseClient DB = new DatabaseClient(DATA);
  58. ResultSet table = DB.Query("SELECT * FROM furniture;");
  59. while (table.next())
  60. {
  61. Item Item = new Item();
  62. Item.Id = table.getInt("id");
  63. Item.PublicName = table.getString("public_name");
  64. Item.ItemName = table.getString("item_name");
  65. Item.Type = table.getString("type");
  66. Item.Width = table.getInt("width");
  67. Item.Length = table.getInt("length");
  68. Item.SpriteId = table.getInt("sprite_id");
  69. Item.VendingIds = table.getString("vending_ids");
  70. // Pending
  71. Item.InteractionCount = 0;
  72. if(Item.Type.equals("s"))
  73. {
  74. String ItemName = Item.ItemName.toLowerCase();
  75. if(Item.PublicName.startsWith("WIRED Trigger:"))
  76. {
  77. if(Item.PublicName.contains("User Says Keyword"))
  78. {
  79. Item.WiredType = 0;
  80. }
  81. if(Item.PublicName.contains("User Walks On Furni"))
  82. {
  83. Item.WiredType = 1;
  84. }
  85. else if(Item.PublicName.contains("Repeat Effect"))
  86. {
  87. Item.WiredType = 3;
  88. }
  89. else if(Item.PublicName.contains("At Set Time"))
  90. {
  91. Item.WiredType = 6;
  92. }
  93. else if(Item.PublicName.contains("User Enters Room"))
  94. {
  95. Item.WiredType = 7;
  96. }
  97. else if(Item.PublicName.contains("Game Starts"))
  98. {
  99. Item.WiredType = 8;
  100. }
  101. else if(Item.PublicName.contains("Score Is Achieved"))
  102. {
  103. Item.WiredType = 10;
  104. }
  105. Item.Interactor = WiredInteractor;
  106. Item.Interaction = WIRED_TRIGGER;
  107. Item.Walkable = true;
  108. Item.Stackable = true;
  109. Item.Height = 0.5;
  110. }
  111. else if(Item.PublicName.startsWith("WIRED Effect:"))
  112. {
  113. if(Item.PublicName.contains("Show Message"))
  114. {
  115. Item.WiredType = 7;
  116. }
  117. else if(Item.PublicName.contains("Move And Rotate Furni"))
  118. {
  119. Item.WiredType = 13;
  120. }
  121. else if(Item.PublicName.contains("Give Points"))
  122. {
  123. Item.WiredType = 14;
  124. }
  125. Item.Interactor = WiredInteractor;
  126. Item.Interaction = WIRED_EFFECT;
  127. Item.Walkable = true;
  128. Item.Stackable = true;
  129. Item.Height = 0.5;
  130. }
  131. else if(Item.PublicName.startsWith("WIRED Condition:"))
  132. {
  133. if(Item.PublicName.contains("More Than x Secs Elapsed Since Timer Reset"))
  134. {
  135. Item.WiredType = 3;
  136. }
  137. else if(Item.PublicName.contains("Less Than x Secs Elapsed Since Timer Reset"))
  138. {
  139. Item.WiredType = 4;
  140. }
  141. else if(Item.PublicName.contains("Furni has users"))
  142. {
  143. Item.WiredType = 5;
  144. }
  145. else if(Item.PublicName.contains("Has Furni On"))
  146. {
  147. Item.WiredType = 7;
  148. }
  149. else if(Item.PublicName.contains("Furni States And Positions Match"))
  150. {
  151. Item.WiredType = 8;
  152. }
  153. Item.Interactor = WiredInteractor;
  154. Item.Interaction = WIRED_CONDITION;
  155. Item.Walkable = true;
  156. Item.Stackable = true;
  157. Item.Height = 0.5;
  158. }
  159. else if(ItemName.substring(0, 3).equals("bw_"))
  160. {
  161. if(ItemName.equals("bw_water_1"))
  162. {
  163. Item.Interaction = WATER1;
  164. Item.Walkable = true;
  165. }
  166. else if(ItemName.equals("bw_water_2"))
  167. {
  168. Item.Interaction = WATER2;
  169. Item.Walkable = true;
  170. }
  171. else if(ItemName.equals("hween10_pond"))
  172. {
  173. Item.Interaction = WATER3;
  174. Item.Walkable = true;
  175. }
  176. else if(ItemName.equals("bw_tele"))
  177. {
  178. Item.Interaction = TELEPORT;
  179. Item.Interactor = TeleInteractor;
  180. }
  181. }
  182. else if(ItemName.substring(0, 3).equals("bb_"))
  183. {
  184. if(ItemName.equals("bb_gate_r"))
  185. {
  186. Item.Interaction = BATTLEBANZAI_GATER;
  187. Item.Walkable = true;
  188. }
  189. else if(ItemName.equals("bb_gate_g"))
  190. {
  191. Item.Interaction = BATTLEBANZAI_GATEG;
  192. Item.Walkable = true;
  193. }
  194. else if(ItemName.equals("bb_gate_b"))
  195. {
  196. Item.Interaction = BATTLEBANZAI_GATEB;
  197. Item.Walkable = true;
  198. }
  199. else if(ItemName.equals("bb_gate_y"))
  200. {
  201. Item.Interaction = BATTLEBANZAI_GATEY;
  202. Item.Walkable = true;
  203. }
  204. else if(ItemName.equals("bb_patch1"))
  205. {
  206. Item.Interaction = BATTLEBANZAI_PATCH;
  207. Item.Walkable = true;
  208. }
  209. else if(ItemName.equals("bb_counter"))
  210. {
  211. Item.Interaction = BATTLEBANZAI_COUNTER;
  212. Item.Interactor = BBTimerInteractor;
  213. }
  214. else if(ItemName.equals("bb_score_r"))
  215. {
  216. Item.Interaction = BATTLEBANZAI_SCORE_R;
  217. }
  218. else if(ItemName.equals("bb_score_g"))
  219. {
  220. Item.Interaction = BATTLEBANZAI_SCORE_G;
  221. }
  222. else if(ItemName.equals("bb_score_b"))
  223. {
  224. Item.Interaction = BATTLEBANZAI_SCORE_B;
  225. }
  226. else if(ItemName.equals("bb_score_y"))
  227. {
  228. Item.Interaction = BATTLEBANZAI_SCORE_Y;
  229. }
  230. else if(ItemName.equals("bb_pyramid"))
  231. {
  232. Item.Interaction = BATTLEBANZAI_PIRAMID;
  233. }
  234. }
  235. else if(ItemName.contains("deal_com"))
  236. {
  237. if(ItemName.contains("deal_com_shallow"))
  238. {
  239. Item.Interaction = WATER1;
  240. Item.Walkable = true;
  241. }
  242. else if(ItemName.contains("deal_com_deep"))
  243. {
  244. Item.Interaction = WATER2;
  245. Item.Walkable = true;
  246. }
  247. else if(ItemName.contains("bbtiles"))
  248. {
  249. Item.Interaction = BATTLEBANZAI_PATCH;
  250. Item.Walkable = true;
  251. }
  252. else if(ItemName.contains("pyramids"))
  253. {
  254. Item.Interaction = BATTLEBANZAI_PIRAMID;
  255. }
  256. else if(ItemName.contains("bbtele"))
  257. {
  258. // pending..
  259. }
  260. }
  261. else if(Item.PublicName.toLowerCase().contains("chair"))
  262. {
  263. Item.IsSeat = true;
  264. }
  265. else if(ItemName.contains("chair"))
  266. {
  267. Item.IsSeat = true;
  268. }
  269. else if(Item.PublicName.toLowerCase().contains("bed"))
  270. {
  271. Item.Interaction = BED;
  272. Item.IsSeat = true;
  273. }
  274. else if(Item.PublicName.toLowerCase().contains("rug"))
  275. {
  276. Item.Walkable = true;
  277. }
  278. else if(Item.PublicName.toLowerCase().contains("corner"))
  279. {
  280. Item.Stackable = true;
  281. Item.Height = 1.7;
  282. }
  283. else if(ItemName.contains("deal_roller"))
  284. {
  285. Item.Interaction = SKATES;
  286. Item.Walkable = true;
  287. }
  288. else if(ItemName.equals("val11_floor"))
  289. {
  290. Item.Interaction = SKATES;
  291. Item.Walkable = true;
  292. }
  293. else if(ItemName.contains("fball_ball") || ItemName.contains("bb_puck"))
  294. {
  295. Item.Height = 0.0;
  296. Item.Interaction = BALL;
  297. Item.Walkable = true;
  298. }
  299. else if(ItemName.contains("seat"))
  300. {
  301. Item.IsSeat = true;
  302. }
  303. else if(ItemName.contains("sofa"))
  304. {
  305. Item.IsSeat = true;
  306. }
  307. else if(ItemName.contains("STP"))
  308. {
  309. Item.IsSeat = true;
  310. }
  311. else if(ItemName.contains("beanbag"))
  312. {
  313. Item.IsSeat = true;
  314. }
  315. else if(ItemName.contains("BTP"))
  316. {
  317. Item.Stackable = true;
  318. Item.Height = 1.2;
  319. }
  320. else if(Item.PublicName.equals("Doormat"))
  321. {
  322. Item.Walkable = true;
  323. }
  324. else if(ItemName.startsWith("a2 ovi"))
  325. {
  326. Item.Interaction = TELEPORT;
  327. Item.Interactor = TeleInteractor;
  328. }
  329. else if(ItemName.startsWith("jukebox"))
  330. {
  331. Item.Interactor = InteractorTrax;
  332. }
  333. else if(ItemName.contains("tele"))
  334. {
  335. Item.Interaction = TELEPORT;
  336. Item.Interactor = TeleInteractor;
  337. }
  338. else if(ItemName.contains("elevator"))
  339. {
  340. Item.Interaction = TELEPORT;
  341. Item.Interactor = TeleInteractor;
  342. }
  343. else if(ItemName.contains("prizetrophy"))
  344. {
  345. Item.Interaction = TROPHY;
  346. }
  347. }
  348. else if(Item.Type.equals("i"))
  349. {
  350. if(Item.ItemName.contains("wallpaper_"))
  351. {
  352. Item.Interaction = WALLPAPER;
  353. }
  354. else if (Item.ItemName.contains("landscape_"))
  355. {
  356. Item.Interaction = LANDSCAPE;
  357. }
  358. else if (Item.ItemName.contains("floor_single_"))
  359. {
  360. Item.Interaction = FLOOR;
  361. }
  362. else if(Item.ItemName.contains("dimmer"))
  363. {
  364. Item.Interaction = DIMMER;
  365. }
  366. else if(Item.ItemName.contains("stick"))
  367. {
  368. Item.Interaction = POSTIT;
  369. }
  370. }
  371. if(Item.Interactor == null)
  372. {
  373. Item.Interactor = NullInteractor;
  374. }
  375. Items.put(Item.Id, Item);
  376. IdsBySprite.put(Item.SpriteId, Item);
  377. }
  378. table.close();
  379. DB.Close();
  380. }
  381. public class Item
  382. {
  383. public int Id;
  384. public String PublicName;
  385. public String ItemName;
  386. public String Type;
  387. public int Interaction;
  388. public int SpriteId;
  389. public int Width;
  390. public int Length;
  391. public int InteractionCount;
  392. public int WiredType;
  393. public String VendingIds;
  394. public double Height = 0.1;
  395. public boolean Stackable = false;
  396. public boolean Walkable = false;
  397. public boolean IsSeat = false;
  398. public boolean AllowRecycle = true;
  399. public boolean AllowTrade = true;
  400. public boolean AllowMarketplaceSell = true;
  401. public boolean AllowGift = true;
  402. public boolean AllowInventoryStack = true;
  403. public Interactor Interactor;
  404. }
  405. }