1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
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
*/
|