-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathMrTS_Pickboard.js
718 lines (644 loc) · 22.2 KB
/
MrTS_Pickboard.js
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
//=============================================================================
// MrTS_Pickboard.js
//=============================================================================
/*:
* @plugindesc Reward board that takes currency or items to pick from.
* @author Mr. Trivel
*
* @param Gold Icon Id
* @desc Icon ID for drawing gold on reward tiles.
* Default: 313
* @default 313
*
* @param Variable Icon Id
* @desc Default icon ID for drawing variables on reward tiles.
* Default: 222
* @default 222
*
* @param Cursor Offset X
* @desc By how many pixels is the cursor offset in X axis?
* Default: 0
* @default 0
*
* @param Cursor Offset Y
* @desc By how many pixels is the cursor offset in Y axis?
* Default: 0
* @default 0
*
* @param Display Board Window
* @desc Display Board Window's Background? True/False
* Default: True
* @default True
*
* @param Display Cost Window
* @desc Display Cost Window's Background? True/False
* Default: True
* @default True
*
* @param Display Scene Background
* @desc If disabled will show usual map background unless specified.
* Default: True
* @default True
*
* @param Pick Get Sound
* @desc Sound name to play when picking.
* Default: Coin
* @default Coin
*
* @help
* --------------------------------------------------------------------------------
* Terms of Use
* --------------------------------------------------------------------------------
* Don't remove the header or claim that you wrote this plugin.
* Credit Mr. Trivel if using this plugin in your project.
* Free for commercial and non-commercial projects.
* --------------------------------------------------------------------------------
* Version 1.1
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Images
* --------------------------------------------------------------------------------
* *All images go into img\system folder!*
*
* pick_tileEmpty.png - Empty tile image, 48x48 pixels
* pick_tileUnknown.png - Unrevealed tile image, 48x48 pixels
* pick_Cursor.png - Cursor, 48 pixels height, (48 * Cursor Frames) pixels width
* pick_Background.png - default background, as big as the screen
*
* --------------------------------------------------------------------------------
* Plugin Calls
* --------------------------------------------------------------------------------
* Pickboard Start [Board ID] [X] [Y] - creates empty board with X Y dimensions
* Pickboard Reset [Board ID] - resets board of ID to empty state
* Pickboard IsComplete [Board ID] [Switch ID] - Saves answer to a switch
* Pickboard AddReward [Board ID] [RewardType] [ID] [Amount] [Tiles] [IconID]
* Pickboard SetPrice [Board ID] [PriceType] [ID] [Amount] [IconID]
* Pickboard Enter [Board ID] - go the scene with pickboard of ID
* Pickboard SetBackground [Board ID] [ImageName] - Changes background of pickboard
* Pickboard OpenTiles [Board ID] [NumberOfTiles] - opens a number of tiles
*
*
* [Board ID] - ID of the board you're changing
* [X] - Width of the board
* [Y] - Height of the board
* [Switch ID] - ID of the switch to save board's state
* [RewardType] - a, w, i, g, v - armor, weapon, item, gold, variable
* [PriceType] - a, w, i, g, v - armor, weapon, item, gold, variable
* [ID] - ID of item, if [Type] is gold -- then ID is irrelevant
* [Amount] - How much should be reward if adding it or taken if setting price
* [Tiles] - How many tiles on board has this reward
* *[IconID] - *OPTIONAL* changes any item, weapon, armor, variable id to a new one
*
* Example calls:
* Pickboard Start 3 5 5
* Pickboard Reset 3
* Pickboard IsComplete 3 173
* Pickboard AddReward 3 a 4 1 5
* Pickboard AddReward 3 g 0 1000 10
* Pickboard AddReward 3 i 1 5 7
* Pickboard SetPrice 3 i 5 1
* Pickboard Enter 3
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.1 - Variables added as reward choice or price choice.
* - Able to change any item, gold or variable displayed icon ID for any board.
* - Added transparency option for reward window background.
* - Added command to add different backgrounds to different pickboards.
* - Added option to not have a background by default.
* - Now the board is revealed if there's no more rewards to pick.
* - Added a new command to reveal X random tiles on the board.
* 1.0 - Release
*/
(function() {
//----------------------------------------------------------------------------
// Parameters
//
var parameters = PluginManager.parameters('MrTS_Pickboard');
var paramGoldIconId = Number(parameters['Gold Icon Id'] || 313);
var paramVariableIconId = Number(parameters['Variable Icon Id'] || 222);
var paramCursorOffsetX = Number(parameters['Cursor Offset X'] || 0);
var paramCursorOffsetY = Number(parameters['Cursor Offset Y'] || 0);
var paramDisplayBoardWindow = (parameters['Display Board Window'] || "true").toLowerCase() === "true";
var paramDisplayCostWindow = (parameters['Display Cost Window'] || "true").toLowerCase() === "true";
var paramDisplaySceneBackground = (parameters['Display Scene Background'] || "true").toLowerCase() === "true";
var paramPickSound = String(parameters['Pick Get Sound'] || "Coin");
//--------------------------------------------------------------------------
// Game_Interpreter
//
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command.toLowerCase() === "pickboard") {
switch (args[0].toLowerCase())
{
case 'start':
{
$gameSystem.pickboardStart(Number(args[1]), Number(args[2]), Number(args[3]));
} break;
case 'reset':
{
$gameSystem.resetPickboard(Number(args[1]));
} break;
case 'iscomplete':
{
$gameSystem.isPickboardComplete(Number(args[1]), Number(args[2]));
} break;
case 'addreward':
{
$gameSystem.addPickboardReward(Number(args[1]), String(args[2]), Number(args[3]),
Number(args[4]), Number(args[5]), Number(args[6]));
} break;
case 'setprice':
{
$gameSystem.setPickboardPrice(Number(args[1]), String(args[2]), Number(args[3]),
Number(args[4]), Number(args[5]));
} break;
case 'enter':
{
$gameSystem.enterPickboardScene(Number(args[1]));
} break;
case 'setbackground':
{
$gameSystem.setPickboardBackground(Number(args[1]), String(args[2]));
} break;
case 'opentiles':
{
$gameSystem.reserveSomeOpenTiles(Number(args[1]), Number(args[2]));
} break;
}
}
};
//--------------------------------------------------------------------------
// Game_System
//
var _GameSystem_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
_GameSystem_initialize.call(this);
this._pickboardData = {};
this._targetPickboardBoard = 0;
};
Game_System.prototype.createEmptyPickboardObject = function() {
var pickboard = {};
pickboard.board = [];
pickboard.emptyIndexes = [];
pickboard.width = 0;
pickboard.height = 0;
pickboard.price = {};
pickboard.price.type = 'empty';
pickboard.price.id = 0;
pickboard.price.amount = 0;
pickboard.price.iconId = 0;
pickboard.background = null;
pickboard.reserved = 0;
return pickboard;
};
Game_System.prototype.createEmptyPickboardRewardObject = function() {
var reward = {};
reward.type = 'empty';
reward.id = 0;
reward.amount = 0;
reward.open = false;
reward.iconId = 0;
return reward;
};
Game_System.prototype.pickboardStart = function(boardId, width, height) {
var emptyPickboard = this.createEmptyPickboardObject();
emptyPickboard.width = width;
emptyPickboard.height = height;
for (var i = 0; i < width*height; i++) {
emptyPickboard.board.push(this.createEmptyPickboardRewardObject());
emptyPickboard.emptyIndexes.push(i);
}
this._pickboardData[boardId] = emptyPickboard;
};
Game_System.prototype.resetPickboard = function(boardId) {
for (var i = 0; i < this._pickboardData[boardId].board.length; i++) {
this._pickboardData[boardId].board[i].open = false;
}
for (var i = this._pickboardData[boardId].board.length - 1; i > 0; i--) {
var j = Math.randomInt(i+1);
var tmp = this._pickboardData[boardId].board[i];
this._pickboardData[boardId].board[i] = this._pickboardData[boardId].board[j];
this._pickboardData[boardId].board[j] = tmp;
}
};
Game_System.prototype.revealPickboard = function(boardId) {
for (var i = 0; i < this._pickboardData[boardId].board.length; i++) {
this._pickboardData[boardId].board[i].open = true;
}
};
Game_System.prototype.isPickboardComplete = function(boardId, switchId) {
for (var i = 0; i < this._pickboardData[boardId].board.length; i++) {
if (!this._pickboardData[boardId].board[i].open)
{
$gameSwitches.setValue(switchId, false);
return false;
}
}
$gameSwitches.setValue(switchId, true);
return true;
};
Game_System.prototype.allRewardsPicked = function(boardId) {
for (var i = 0; i < this._pickboardData[boardId].board.length; i++) {
if (this._pickboardData[boardId].board[i].type !== 'empty' && !this._pickboardData[boardId].board[i].open)
{
return false;
}
}
return true;
};
Game_System.prototype.addPickboardReward = function(boardId, type, id, amount, tiles, iconId) {
iconId = iconId || 0;
var pickboard = this._pickboardData[boardId];
for (var i = 0; i < tiles; i++) {
if (pickboard.emptyIndexes.length === 0) continue;
var emptyIndex = Math.randomInt(pickboard.emptyIndexes.length);
var index = pickboard.emptyIndexes[emptyIndex];
pickboard.board[index].type = type;
pickboard.board[index].id = id;
pickboard.board[index].amount = amount;
pickboard.board[index].iconId = iconId;
pickboard.emptyIndexes.splice(emptyIndex, 1);
}
};
Game_System.prototype.setPickboardPrice = function(boardId, type, id, amount, iconId) {
iconId = iconId || 0;
var price = this._pickboardData[boardId].price;
price.type = type;
price.id = id;
price.amount = amount;
price.iconId = iconId;
};
Game_System.prototype.setPickboardBackground = function(boardId, imageName) {
this._pickboardData[boardId].background = imageName;
};
Game_System.prototype.enterPickboardScene = function(boardId) {
this._targetPickboardBoard = boardId;
SceneManager.push(Scene_Pickboard);
};
Game_System.prototype.openSomeTiles = function(boardId) {
var number = this._pickboardData[boardId].reserved;
if (number === 0) return;
var closedTileIndexes = [];
for (var i = 0; i < this._pickboardData[boardId].board.length; i++) {
if (!this._pickboardData[boardId].board[i].open) closedTileIndexes.push(i);
}
for (var i = 0; i < number; i++) {
var r = Math.randomInt(closedTileIndexes.length);
this.revealTile(boardId, closedTileIndexes[r]);
closedTileIndexes.splice(r, 1);
}
this._pickboardData[boardId].reserved = 0;
};
Game_System.prototype.reserveSomeOpenTiles = function(boardId, number) {
this._pickboardData[boardId].reserved += number;
};
Game_System.prototype.revealTile = function(boardId, index) {
var reward = this._pickboardData[boardId].board[index];
reward.open = true;
if (this.allRewardsPicked(boardId)) this.revealPickboard(boardId);
if (reward.type === 'empty') return;
var item = null;
switch (reward.type)
{
case 'g':
{
if (reward.iconId === 0) reward.iconId = paramGoldIconId;
$gameParty.gainGold(reward.amount);
return;
} break;
case 'w':
{
item = $dataWeapons[reward.id];
} break;
case 'a':
{
item = $dataArmors[reward.id];
} break;
case 'i':
{
item = $dataItems[reward.id];
} break;
case 'v':
{
if (reward.iconId === 0) reward.iconId = paramVariableIconId;
var oldValue = $gameVariables.value(reward.id);
$gameVariables.setValue(reward.id, oldValue + reward.amount);
} break;
}
if (item)
{
$gameParty.gainItem(item, reward.amount);
if (reward.iconId === 0) reward.iconId = item.iconIndex;
}
};
Game_System.prototype.getActivePickboardId = function() {
return this._targetPickboardBoard;
};
Game_System.prototype.getPickboardData = function(boardId) {
return this._pickboardData[boardId];
};
//--------------------------------------------------------------------------
// Scene_Pickboard
//
// Pickboard Scene where picking happens!
function Scene_Pickboard() {
this.initialize.apply(this, arguments);
};
Scene_Pickboard.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Pickboard.prototype.constructor = Scene_Pickboard;
Scene_Pickboard.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_Pickboard.prototype.createBackground = function() {
var boardId = $gameSystem.getActivePickboardId();
var boardData = $gameSystem.getPickboardData(boardId);
if (paramDisplaySceneBackground || boardData['background'])
{
this._backgroundSprite = new Sprite();
var image = boardData['background'] ? boardData['background'] : "pick_Background";
this._backgroundSprite.bitmap = ImageManager.loadSystem(image);
this.addChild(this._backgroundSprite);
}
else
{
Scene_MenuBase.prototype.createBackground.call(this);
}
};
Scene_Pickboard.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createWindowLayer();
this.createBoardWindow();
this.createPriceWindow();
};
Scene_Pickboard.prototype.createBoardWindow = function() {
this._pickboardWindow = new Window_PickboardSelect();
this._pickboardWindow.setHandler('ok', this.refreshPrice.bind(this));
this._pickboardWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._pickboardWindow);
this._pickboardWindow.activate();
this._pickboardWindow.select(0);
};
Scene_Pickboard.prototype.createPriceWindow = function() {
this._priceWindow = new Window_PickboardPrice(this._pickboardWindow);
this._pickboardWindow.y = Graphics.boxHeight / 2 -
(this._pickboardWindow.height+this._priceWindow.height)/2;
this._priceWindow.reposition();
this.addWindow(this._priceWindow);
};
Scene_Pickboard.prototype.refreshPrice = function() {
this._priceWindow.refresh();
};
//--------------------------------------------------------------------------
// Window_PickboardSelect
//
// Window that will draw tiles and cursor.
function Window_PickboardSelect() {
this.initialize.apply(this, arguments);
};
Window_PickboardSelect.prototype = Object.create(Window_Selectable.prototype);
Window_PickboardSelect.prototype.constructor = Window_PickboardSelect;
Window_PickboardSelect.prototype.initialize = function() {
this._boardId = $gameSystem.getActivePickboardId();
this._pickboard = $gameSystem.getPickboardData(this._boardId);
this._board = this._pickboard.board;
this._pickSound = AudioManager.makeEmptyAudioObject();
this._pickSound.name = paramPickSound;
this._pickSound.volume = 100;
this._pickSound.pitch = 100;
AudioManager.loadStaticSe(this._pickSound);
var ww = this._pickboard.width * 48 + this.standardPadding() * 2;
var wh = this._pickboard.height * 48 + this.standardPadding() * 2;
var wx = Graphics.boxWidth / 2 - ww/2;
var wy = Graphics.boxHeight / 2 - wh/2;
Window_Selectable.prototype.initialize.call(this, wx, wy, ww, wh);
if (!paramDisplayBoardWindow) this.opacity = 0;
this._emptyTileBitmap = ImageManager.loadSystem("pick_tileEmpty");
this._unknownTileBitmap = ImageManager.loadSystem("pick_tileUnknown");
this._tileArray = [];
for (var i = 0; i < this._pickboard.width * this._pickboard.height; i++) {
var spr = new Sprite(this._unknownTileBitmap);
spr.x = 48 * (i % this._pickboard.width) + this.standardPadding();
spr.y = 48 * Math.floor(i / this._pickboard.height) + this.standardPadding();
this.addChild(spr);
this._tileArray.push(spr);
}
this._cursorSprite = new Sprite(ImageManager.loadSystem("pick_Cursor"));
this.addChild(this._cursorSprite);
if (this._pickboard.reserved > 0)
{
$gameSystem.openSomeTiles(this._boardId);
}
this.updateAllTiles();
};
Window_PickboardSelect.prototype.updateTile = function(index) {
if (!this._tileArray[index]) return;
if (this._board[index].open)
{
this._tileArray[index].bitmap = this._emptyTileBitmap;
if (this._board[index].iconId !== 0)
{
var pw = Window_Base._iconWidth;
var ph = Window_Base._iconHeight;
var spr = new Sprite(new Bitmap(pw, ph));
var bitmap = ImageManager.loadSystem('IconSet');
var sx = this._board[index].iconId % 16 * pw;
var sy = Math.floor(this._board[index].iconId / 16) * ph;
spr.bitmap.blt(bitmap, sx, sy, pw, ph, 0, 0);
this._tileArray[index].addChild(spr);
spr.x = 48/2-pw/2;
spr.y = 48/2-ph/2;
}
}
else
this._tileArray[index].bitmap = this._unknownTileBitmap;
};
Window_PickboardSelect.prototype.maxItems = function() {
return this._pickboard ? this._pickboard.width * this._pickboard.height : 0;
};
Window_PickboardSelect.prototype.maxCols = function() {
return this._pickboard ? this._pickboard.width : 0;
};
Window_PickboardSelect.prototype.itemWidth = function() {
return 48;
};
Window_PickboardSelect.prototype.itemHeight = function() {
return 48;
};
Window_Selectable.prototype.spacing = function() {
return 0;
};
Window_PickboardSelect.prototype.paidPrice = function() {
var item = null;
var price = this._pickboard.price;
switch (price.type)
{
case 'g':
{
if ($gameParty.gold() >= price.amount)
{
$gameParty.loseGold(price.amount);
return true;
}
else return false;
} break;
case 'w':
{
item = $dataWeapons[price.id];
} break;
case 'a':
{
item = $dataArmors[price.id];
} break;
case 'i':
{
item = $dataItems[price.id];
} break;
case 'v':
{
if ($gameVariables.value(price.id) >= price.amount)
{
var oldValue = $gameVariables.value(price.id);
$gameVariables.setValue(price.id, oldValue - price.amount);
return true;
}
else return false;
} break;
case 'empty':
{
return true;
} break;
}
if (item)
{
if ($gameParty.numItems(item) >= price.amount)
{
$gameParty.loseItem(item, price.amount);
return true;
}
else return false;
}
return false;
};
Window_PickboardSelect.prototype.updateAllTiles = function() {
for (var i = 0; i < this._tileArray.length; i++) {
this.updateTile(i);
}
};
Window_PickboardSelect.prototype.processOk = function() {
if (!this._board[this.index()].open && this.paidPrice()) {
AudioManager.playStaticSe(this._pickSound);
$gameSystem.revealTile(this._boardId, this.index())
if ($gameSystem.allRewardsPicked(this._boardId))
this.updateAllTiles();
else
this.updateTile(this.index());
this.updateInputData();
this.callOkHandler();
} else {
this.playBuzzerSound();
}
};
Window_PickboardSelect.prototype.isOkEnabled = function() {
return true;
};
Window_PickboardSelect.prototype.updateCursor = function() {
this.setCursorRect(0, 0, 0, 0);
var rect = this.itemRect(this.index());
if (this._cursorSprite)
{
this._cursorSprite.x = rect.x + paramCursorOffsetX + this.standardPadding();
this._cursorSprite.y = rect.y + paramCursorOffsetY + this.standardPadding();
}
};
//--------------------------------------------------------------------------
// Window_PickboardPrice
//
// Shows the price of pickboard and how many picks are left.
function Window_PickboardPrice() {
this.initialize.apply(this, arguments);
};
Window_PickboardPrice.prototype = Object.create(Window_Base.prototype);
Window_PickboardPrice.prototype.constructor = Window_PickboardPrice;
Window_PickboardPrice.prototype.initialize = function(windowPickboard) {
this._boardId = $gameSystem.getActivePickboardId();
this._pickboard = $gameSystem.getPickboardData(this._boardId);
this._price = this._pickboard.price;
this._priceIconIndex = this._price.iconId;
this._item = this.saveItemPrice();
var wx = windowPickboard.x;
var wy = windowPickboard.y + windowPickboard.height;
var wh = this.fittingHeight(1);
var ww = windowPickboard.width;
this._windowPickboard = windowPickboard;
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
if (!paramDisplayCostWindow) this.opacity = 0;
this.refresh();
};
Window_PickboardPrice.prototype.saveItemPrice = function() {
var item = null;
switch (this._price.type)
{
case 'w':
{
item = $dataWeapons[this._price.id];
if (this._priceIconIndex === 0) this._priceIconIndex = item.iconIndex;
} break;
case 'a':
{
item = $dataArmors[this._price.id];
if (this._priceIconIndex === 0) this._priceIconIndex = item.iconIndex;
} break;
case 'i':
{
item = $dataItems[this._price.id];
if (this._priceIconIndex === 0) this._priceIconIndex = item.iconIndex;
} break;
}
if (item) return item;
return null;
};
Window_PickboardPrice.prototype.reposition = function() {
this.x = this._windowPickboard.x;
this.y = this._windowPickboard.y + this._windowPickboard.height;
this.height = this.fittingHeight(1);
this.width = this._windowPickboard.width;
};
Window_PickboardPrice.prototype.refresh = function() {
this.contents.clear();
var iconIndex = this._priceIconIndex
if (this._price.type === 'empty')
{
this.drawText("Free", 0, 0, this.contentsWidth(), 'center');
}
else
{
var have = 0;
if (this._price.type === 'g')
{
if (this._priceIconIndex === 0) iconIndex = paramGoldIconId;
have = $gameParty.gold();
}
else if (this._price.type === 'v')
{
if (this._priceIconIndex === 0) iconIndex = paramVariableIconId;
have = $gameVariables.value(this._price.id);
}
else
{
have = $gameParty.numItems(this._item);
}
var picksLeft = "Picks:";
var picksWidth = this.textWidth(picksLeft);
var amount = (Math.floor(have/this._price.amount));
var picks = amount > 99 ? "99+" : String(amount);
var x = this.contentsWidth()/2 - (picksWidth + this.textWidth(picks) + 24 + 8)/2;
this.drawText(picksLeft, x, 0);
this.drawIcon(iconIndex, x + picksWidth, 2);
this.drawText(picks, x + picksWidth + 24 + 8, 0);
}
};
})();