diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/TradeAction.java | |
| download | worlds.jar-main.tar.xz worlds.jar-main.zip | |
Diffstat (limited to 'NET/worlds/scape/TradeAction.java')
| -rw-r--r-- | NET/worlds/scape/TradeAction.java | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/NET/worlds/scape/TradeAction.java b/NET/worlds/scape/TradeAction.java new file mode 100644 index 0000000..fd147c6 --- /dev/null +++ b/NET/worlds/scape/TradeAction.java @@ -0,0 +1,172 @@ +/* */ package NET.worlds.scape; +/* */ +/* */ import NET.worlds.console.Console; +/* */ import NET.worlds.console.Main; +/* */ import NET.worlds.console.MainCallback; +/* */ import NET.worlds.console.OkCancelDialog; +/* */ import NET.worlds.console.PolledDialog; +/* */ import java.io.IOException; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class TradeAction +/* */ extends DialogAction +/* */ { +/* 25 */ int userItems = 1; +/* 26 */ String userItem = "A"; +/* 27 */ int serverItems = 1; +/* 28 */ String serverItem = "A"; +/* */ +/* */ +/* */ public void doIt() +/* */ { +/* 33 */ StringBuffer deal = new StringBuffer(); +/* 34 */ deal.append("&|+deal>TRADE "); +/* 35 */ if (this.userItems > 0) { +/* 36 */ deal.append(this.userItem); +/* 37 */ deal.append(this.userItems); +/* */ } +/* 39 */ deal.append(","); +/* 40 */ if (this.serverItems > 0) { +/* 41 */ deal.append(this.serverItem); +/* 42 */ deal.append(this.serverItems); +/* */ } +/* */ +/* 45 */ final String dealStr = deal.toString(); +/* */ +/* 47 */ Main.register(new MainCallback() { +/* */ public void mainCallback() { +/* 49 */ Pilot.sendText("TRADE", dealStr); +/* 50 */ Main.unregister(this); +/* */ } +/* */ }); +/* */ } +/* */ +/* */ public PolledDialog getDialog() +/* */ { +/* 57 */ if (InventoryManager.getInventoryManager().checkInventoryFor(this.userItem) >= this.userItems) { +/* 58 */ return new OkCancelDialog(Console.getFrame(), this, +/* 59 */ "Trade?", +/* 60 */ "No", "Yes", +/* 61 */ "Do you want to give " + +/* 62 */ InventoryManager.getInventoryManager().itemName(this.userItem, this.userItems) + +/* 63 */ " in return for " + +/* 64 */ InventoryManager.getInventoryManager().itemName(this.serverItem, this.serverItems) + +/* 65 */ "?", +/* 66 */ false); +/* */ } +/* 68 */ return new OkCancelDialog(Console.getFrame(), this, +/* 69 */ "Can't trade!", +/* 70 */ "Ok", null, +/* 71 */ "You need " + InventoryManager.getInventoryManager().itemName(this.userItem, this.userItems) + +/* 72 */ " in order to trade here.", +/* 73 */ false); +/* */ } +/* */ +/* */ +/* */ +/* */ public Object properties(int index, int offset, int mode, Object value) +/* */ throws NoSuchPropertyException +/* */ { +/* 81 */ Object ret = null; +/* 82 */ switch (index - offset) { +/* */ case 0: +/* 84 */ if (mode == 0) { +/* 85 */ ret = StringPropertyEditor.make( +/* 86 */ new Property(this, index, "User Item Type")); +/* 87 */ } else if (mode == 1) { +/* 88 */ ret = this.userItem; +/* 89 */ } else if (mode == 2) { +/* 90 */ this.userItem = ((String)value).toString().trim(); +/* */ } +/* 92 */ break; +/* */ case 1: +/* 94 */ if (mode == 0) { +/* 95 */ ret = IntegerPropertyEditor.make( +/* 96 */ new Property(this, index, "Number of User Items")); +/* 97 */ } else if (mode == 1) { +/* 98 */ ret = new Integer(this.userItems); +/* 99 */ } else if (mode == 2) +/* 100 */ this.userItems = ((Integer)value).intValue(); +/* 101 */ break; +/* */ case 2: +/* 103 */ if (mode == 0) { +/* 104 */ ret = StringPropertyEditor.make( +/* 105 */ new Property(this, index, "Merchant Item Type")); +/* 106 */ } else if (mode == 1) { +/* 107 */ ret = this.serverItem; +/* 108 */ } else if (mode == 2) { +/* 109 */ this.serverItem = ((String)value).toString().trim(); +/* */ } +/* 111 */ break; +/* */ case 3: +/* 113 */ if (mode == 0) { +/* 114 */ ret = IntegerPropertyEditor.make( +/* 115 */ new Property(this, index, "Number of Merchant Items")); +/* 116 */ } else if (mode == 1) { +/* 117 */ ret = new Integer(this.serverItems); +/* 118 */ } else if (mode == 2) +/* 119 */ this.serverItems = ((Integer)value).intValue(); +/* 120 */ break; +/* */ default: +/* 122 */ ret = super.properties(index, offset + 4, mode, value); +/* */ } +/* 124 */ return ret; +/* */ } +/* */ +/* */ public String toString() { +/* 128 */ return +/* */ +/* */ +/* */ +/* */ +/* 133 */ super.toString() + "[give " + InventoryManager.getInventoryManager().itemName(this.userItem, this.userItems) + " for " + InventoryManager.getInventoryManager().itemName(this.serverItem, this.serverItems) + "]"; +/* */ } +/* */ +/* */ +/* 137 */ private static Object classCookie = new Object(); +/* */ +/* */ public void saveState(Saver s) throws IOException +/* */ { +/* 141 */ s.saveVersion(0, classCookie); +/* 142 */ super.saveState(s); +/* */ +/* 144 */ s.saveString(this.userItem); +/* 145 */ s.saveInt(this.userItems); +/* 146 */ s.saveString(this.serverItem); +/* 147 */ s.saveInt(this.serverItems); +/* */ } +/* */ +/* */ public void restoreState(Restorer r) throws IOException, TooNewException +/* */ { +/* 152 */ int ver = r.restoreVersion(classCookie); +/* 153 */ switch (ver) { +/* */ case 0: +/* 155 */ super.restoreState(r); +/* 156 */ this.userItem = r.restoreString(); +/* 157 */ this.userItems = r.restoreInt(); +/* 158 */ this.serverItem = r.restoreString(); +/* 159 */ this.serverItems = r.restoreInt(); +/* 160 */ break; +/* */ +/* */ default: +/* 163 */ throw new TooNewException(); +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\TradeAction.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |