Fix hair, dick around with new game screen.
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / screens / InventoryScreen.as
blob1a77dd359320eaef9cf1f08b88bf851a27795bf5
1 package org.sevenchan.dongs.screens
3 import org.sevenchan.dongs.Item;
4 import org.sevenchan.dongs.Screen;
5 /**
6 * ...
7 * @author Harbinger
8 */
9 public class InventoryScreen extends Screen
11 private var text:String = "";
12 private var menu:String = "main";
13 private var newItem:Item = null;
14 public function InventoryScreen(new_itm:Item=null)
16 newItem = new_itm;
17 clearButtons();
20 override public function processButtonPress(id:int):Boolean
22 clearButtons();
23 if (menu == "gtfo") {
24 return true;
27 if (menu == "add") {
28 var foundSlot:Boolean = false;
29 text = "<h2>Inventory</h2><p>You also picked up a " + newItem.descr+".</p>";
30 for (var ii:int = 0; ii < main.player.inventory.length; ii++) {
31 if ((main.player.inventory[i] as Item).id == newItem.id) {
32 (main.player.inventory[i] as Item).amount++;
33 text += "You shove it into the " + Utils.nTh(i + 1) + " slot in your inventory, give you a total of " + (main.player.inventory[i] as Item).amount + " " + (main.player.inventory[i] as Item).name + "s.</p>";
34 foundSlot = true;
37 if (!foundSlot) {
38 if (main.player.inventory.length == 11) {
39 menu = "replace";
40 return processButtonPress( -1);
41 } else {
42 text += "You shove it into the " + Utils.nTh(main.player.inventory.length) + " slot in your inventory, give you a total of " + (main.player.inventory[i] as Item).amount + " " + (main.player.inventory[i] as Item).name + "s.</p>";
43 main.player.inventory.push(newItem);
44 foundSlot = true;
47 if (foundSlot) {
48 setButton(NEXT_BUTTON, "Next");
49 if (id == 0) {
50 return true;
52 updateScreen();
56 if (menu == "replace") {
58 text += "<p>However, you don't have enough room. Either DISCARD the item, or click on a slot to replace it with.</p>";
59 text += "<ul>";
60 setButton(0, "DISCARD");
61 for (var i:int = 0; i < main.player.inventory.length;i++ ) {
62 var item:Item = Item(main.player.inventory[i]);
63 text += "<li><b>" + item.amount + "x " + item.name + "</b> - " + item.descr + "</li>";
64 setButton(i + 1, item.name);
66 text += "</ul>";
67 updateScreen();
68 if (id == -1) {
69 return false;
70 } else if(id==0) {
71 return true;
72 } else {
73 main.player.inventory[id - 1]=newItem;
74 return true;
77 if (menu == "main") {
78 text = "<h2>Inventory</h2><p>You peer into your canvas bag of stuff and find";
79 if (main.player.inventory.length == 0) {
80 menu = "gtfo";
81 text += " nothing of value. You should explore more. Purchased items will also end up here.</p>";
82 setButton(NEXT_BUTTON, "Next");
83 updateScreen();
84 return false;
85 } else {
86 text += ":<ul>";
87 setButton(0, "BACK");
88 for (i = 0; i < main.player.inventory.length;i++ ) {
89 item = Item(main.player.inventory[i]);
90 text += "<li><b>" + item.amount + "x " + item.name + "</b> - " + item.descr + "</li>";
91 setButton(i + 1, item.name);
93 text += "</ul>";
94 updateScreen();
95 if (id == -1) {
96 return false;
97 } else if(id==0) {
98 return true;
99 } else {
100 if ((main.player.inventory[id - 1] as Item).Use(main.player)) {
101 (main.player.inventory[id - 1] as Item).amount--;
102 if ((main.player.inventory[id - 1] as Item).amount == 0) {
103 main.player.inventory.splice(id - 1,1);
106 return true;
110 return false;
113 override public function getScreenText():String
115 return text;