forked from h1pp0/FFACETools_ffevo.net
/
Item.cs
1574 lines (1311 loc) · 58.6 KB
/
Item.cs
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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
namespace FFACETools
{
public partial class FFACE
{
/// <summary>
/// Wrapper class for item information from FFACE
/// </summary>
public class ItemTools
{
#region Constants
/// <summary>
/// Argument exception for inventory item calls
/// </summary>
private const string INVENTORY_RANGE = "Index must be between 0 and 80";
/// <summary>
/// Argument exception for non-inventory item calls (satchel/sack/etc)
/// </summary>
private const string OTHERBAG_RANGE = "Index must be between 1 and 80";
#endregion
#region Classes
public class TreasureItem
{
#region Members
public byte Flag { get; set; } //3=no item, 2=item
public short ItemID { get; set; }
public byte Count { get; set; }
public TreasureStatus Status { get; set; }
public short MyLot { get; set; }
public short WinLot { get; set; }
public int WinPlayerSrvID { get; set; }
public int WinPlayerID { get; set; }
public int TimeStamp { get; set; } //utc timestamp
public bool IsWon
{
get { return ( ( Flag != 3 ) && ( WinPlayerID == PlayerID ) && ( MyLot >= WinLot ) ); }
}
#endregion
/// <summary>
/// Interal PlayerID for checking whether or not we won an item.
/// </summary>
private int PlayerID { get; set; }
#region Constructors
public TreasureItem (int playerid, short itemID, byte count, TreasureStatus status, short mylot, short winlot, int winplayersrvid, int winplayerid, int timestamp, byte flag)
{
Flag = flag;
ItemID = itemID;
Count = count;
Status = status;
MyLot = mylot;
WinLot = winlot;
WinPlayerSrvID = winplayersrvid;
WinPlayerID = winplayerid;
TimeStamp = timestamp;
PlayerID = playerid;
}
#endregion
}
/// <summary>
/// Class container for Inventory Items
/// </summary>
public class InventoryItem
{
#region Constructors
public InventoryItem (ushort iD, byte index, uint count, uint flag, uint price, ushort extra, InventoryType loc)
{
ID = iD;
Index = index;
Count = count;
Flag = flag;
Price = price;
Extra = extra;
Location = loc;
}
public InventoryItem (ushort iD, byte index, uint count)
{
ID = iD;
Index = index;
Count = count;
}
#endregion
#region Members
/// <summary>
/// ID of the item
/// </summary>
public ushort ID { get; set; }
/// <summary>
/// Index of the item
/// </summary>
public byte Index { get; set; }
/// <summary>
/// Count of the item
/// </summary>
public uint Count { get; set; }
/// <summary>
/// Flags on the item
/// </summary>
public uint Flag { get; set; }
/// <summary>
/// Price of the item
/// </summary>
public uint Price { get; set; }
/// <summary>
/// Extra information about the item
/// </summary>
public ushort Extra { get; set; }
/// <summary>
/// Location item was in.
/// </summary>
public InventoryType Location { get; set; }
/// <summary>
/// Name of item
/// </summary>
public string Name { get; set; }
#endregion
} // @ public class InventoryItem
#endregion
#region Constructor
/// <summary>
/// Constructor
/// </summary>
/// <param name="instanceID">Instance ID generated by FFACE</param>
public ItemTools (FFACE fface)// int instanceID)
{
_FFACE = fface;
_InstanceID = fface._InstanceID;
} // @ public InventoryWrapper(int instanceID)
#endregion
#region Members
/// <summary>
/// Our link to the Player Tools
/// </summary>
private FFACE _FFACE { get; set; }
/// <summary>
/// Instance ID generated by FFACE
/// </summary>
private int _InstanceID { get; set; }
/// <summary>
/// Player's Current Gil
/// </summary>
public uint CurrentGil
{
get { return GetInventoryItem(0) == null ? 0 : GetInventoryItem(0).Count; }
}
/// <summary>
/// Maximum amount of inventory slots player has
/// </summary>
public short InventoryMax
{
get { return GetInventoryMax(_InstanceID); }
} // @ public short Max
/// <summary>
/// Maximum amount of safe slots player has
/// </summary>
public short SafeMax
{
get { return GetSafeMax(_InstanceID); }
} // @ public short SafeMax
/// <summary>
/// Maximum amount of storage slots player has
/// </summary>
public short StorageMax
{
get { return GetStorageMax(_InstanceID); }
} // @ public short StorageMax
/// <summary>
/// Maximum amount of temporary slots player has
/// </summary>
public short TemporaryMax
{
get { return GetTempMax(_InstanceID); }
} // @ public short TemporaryMax
/// <summary>
/// Maximum amount of locker slots player has
/// </summary>
public short LockerMax
{
get { return GetLockerMax(_InstanceID); }
} // @ public short LockerMax
/// <summary>
/// Maximum amount of satchel slots player has
/// </summary>
public short SatchelMax
{
get { return GetSatchelMax(_InstanceID); }
} // @ public short SatchelMax
/// <summary>
/// Maximum amount of sack slots player has
/// </summary>
public short SackMax
{
get { return GetSackMax(_InstanceID); }
} // @ public short SatchelMax
/// <summary>
/// Maximum amount of case slots player has
/// </summary>
public short CaseMax
{
get { return GetCaseMax(_InstanceID); }
} // @ public short CaseMax
/// <summary>
/// Maximum amount of case slots player has
/// </summary>
public short WardrobeMax
{
get { return 80; }
} // @ public short WardrobeMax
/// <summary>
/// Inventory slots in use, returns -1 on error
/// </summary>
public short InventoryCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning), count Gil too because of this.
short count = -1;
for (ushort i = 0; i <= 80; i++)
{
if (GetInventoryItem(i) != null)
{
count++;
}
}
return count;
}
} // @ public short InventoryCount
/// <summary>
/// Sack slots in use, returns -1 on error
/// </summary>
public short SackCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning)
short count = -1;
for (byte i = 1; i <= 80; i++)
{
if (GetSackItem(i) != null)
{
count++;
}
}
// since we found at least ONE item, we want to report count+1 (0 == 1 item)
// since we started counting at item 1
if (count != -1)
count++;
return count;
}
} // @ public short SackCount
/// <summary>
/// Locker slots in use, returns -1 on error
/// </summary>
public short LockerCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning)
short count = -1;
for (ushort i = 1; i <= 80; i++)
{
if (GetLockerItem(i) != null)
{
count++;
}
}
// since we found at least ONE item, we want to report count+1 (0 == 1 item)
// since we started counting at item 1
if (count != -1)
count++;
return count;
}
} // @ public short LockerCount
/// <summary>
/// Safe slots in use, returns -1 on error
/// </summary>
public short SafeCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning)
short count = -1;
for (byte i = 1; i <= 80; i++)
{
if (GetSafeItem(i) != null)
{
count++;
}
}
// since we found at least ONE item, we want to report count+1 (0 == 1 item)
// since we started counting at item 1
if (count != -1)
count++;
return count;
}
} // @ public short SafeCount
/// <summary>
/// Storage slots in use, returns -1 on error
/// </summary>
public short StorageCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning)
short count = -1;
for (byte i = 1; i <= 80; i++)
{
if (GetStorageItem(i) != null)
{
count++;
}
}
// since we found at least ONE item, we want to report count+1 (0 == 1 item)
// since we started counting at item 1
if (count != -1)
count++;
return count;
}
} // @ public short StorageCount
/// <summary>
/// Temporary slots in use, returns -1 on error
/// </summary>
public short TemporaryCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning)
short count = -1;
for (byte i = 1; i <= 80; i++)
{
if (GetTempItem(i) != null)
{
count++;
}
}
// since we found at least ONE item, we want to report count+1 (0 == 1 item)
// since we started counting at item 1
if (count != -1)
count++;
return count;
}
} // @ public short TemporaryCount
/// <summary>
/// Satchel slots in use, returns -1 on error
/// </summary>
public short SatchelCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning)
short count = -1;
for (byte i = 1; i <= 80; i++)
{
if (GetSatchelItem(i) != null)
{
count++;
}
}
// since we found at least ONE item, we want to report count+1 (0 == 1 item)
// since we started counting at item 1
if (count != -1)
count++;
return count;
}
} // @ public short SatchelCount
/// <summary>
/// Case slots in use, returns -1 on error
/// </summary>
public short CaseCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning)
short count = -1;
for (byte i = 1; i <= 80; i++)
{
if (GetCaseItem(i) != null)
{
count++;
}
}
// since we found at least ONE item, we want to report count+1 (0 == 1 item)
// since we started counting at item 1
if (count != -1)
count++;
return count;
}
} // @ public short CaseCount
/// <summary>
/// Case slots in use, returns -1 on error
/// </summary>
public short WardrobeCount
{
get
{
// calculate amount of slots are not empty
// -1 for error (loading/zoning)
short count = -1;
for (byte i = 1; i <= 80; i++)
{
if (GetWardrobeItem(i) != null)
{
count++;
}
}
// since we found at least ONE item, we want to report count+1 (0 == 1 item)
// since we started counting at item 1
if (count != -1)
count++;
return count;
}
} // @ public short CaseCount
/// <summary>
/// Name of the selected item
/// </summary>
public string SelectedItemName
{
get
{
if (_FFACE.Menu.IsOpen)
{
String s = FFACE.ParseResources.GetItemName(SelectedItemID);
if (String.IsNullOrEmpty(s))
{
// get the string from FFACE
int size = 20;
byte[] buffer = new byte[20];
GetSelectedItemName(_InstanceID, buffer, ref size);
// convert to a string
return System.Text.Encoding.GetEncoding(1252).GetString(buffer, 0, size - 1);
}
else
return s;
}
return String.Empty; // Menu is not open so return an empty string
}
}// @ public string SelectedItemName
/// <summary>
/// Index of the selected item
/// </summary>
public short SelectedItemIndex
{
get { return GetSelectedItemIndex(_InstanceID); }
} // @ public short SelectedItemIndex
///<summary>
/// Id of the selected item
///</summary>
public int SelectedItemID
{
get
{
InventoryType it = InventoryType.None;
if (_FFACE.Menu.IsOpen)
{
String selection = _FFACE.Menu.Selection;
if (selection.Contains("Satchel"))
it = InventoryType.Satchel;
else if (selection.Contains("Mog Sack"))
it = InventoryType.Sack;
else if (selection.Contains("Mog Safe"))
it = InventoryType.Safe;
else if (selection.Contains("Locker"))
it = InventoryType.Locker;
else if (selection.Contains("Storage"))
it = InventoryType.Storage;
else if (selection.Contains("Temp"))
it = InventoryType.Temp;
//else if (selection.Contains("Equipment"))
// it = InventoryType.Inventory;
else
it = InventoryType.Inventory;
byte index = GetSelectedItemIndex(_InstanceID);
if (( it == InventoryType.Inventory ) && ( ( index < 0 ) || ( index > 80 ) ))
return 0;
if (index < 1 || index > 80)
return 0;
return GetItemIDByIndex(index, it);
}
return 0;
}
}// @ public int SelectedItemID
/// <summary>
/// Place in inventory (1 -> max inventory)
/// </summary>
public int SelectedItemNum
{
get { return GetSelectedItemNum(_InstanceID); }
} // @ public short SelectedItemNum
#endregion
#region Methods
#region Methods replacing old Get*ItemCountByIndex, Get*ItemIDByIndex, Get*ItemCount, Get*Item
//public delegate InventoryItem GetItem(byte index, InventoryType location);
private void DoRangeChecks (int index, InventoryType location)
{
if (IsSet(location, InventoryType.None))
throw new ArgumentOutOfRangeException("Location was set to InventoryType.None");
// 0 is gil, rest is 1-80
if (IsSet(location, InventoryType.Inventory) && ( ( index < 0 ) || ( index > 80 ) ))
throw new ArgumentOutOfRangeException(INVENTORY_RANGE);
else if (!IsSet(location, InventoryType.Inventory) && ( ( index < 1 ) || ( index > 80 ) ))
throw new ArgumentOutOfRangeException(OTHERBAG_RANGE);
}
public bool LocationHas (ushort ID, InventoryType location)
{
for (int i = 0; i < 80; i++)
{
if (( i == 0 ) && !IsSet(location, InventoryType.Inventory))
continue;
InventoryItem item = GetItem(i, location);
if (item != null && item.ID == ID)
return true;
}
return false;
}
/// <summary>
/// Gets the first index taken by item with matching ID
/// </summary>
/// <param name="ID">ID of item to find</param>
/// <param name="location">location indicated by InventoryType (Works best with one location at a time)</param>
/// <returns>First Index taken by item with matching ID, 0 on error</returns>
public int GetFirstIndexByItemID (int ID, InventoryType location)
{
if (ID <= 0)
return 0;
if (IsSet(location, InventoryType.None))
return 0;
System.Collections.Generic.List<InventoryItem> list = GetItemList(ID, location);
if (list.Count <= 0)
return 0;
return list[0].Index;
}
/// <summary>
/// The count of an item by index
/// </summary>
/// <param name="index">Index of the item</param>
/// <param name="location">LocationType of the location to search (SINGLE LOCATION)</param>
/// <returns>Number of items at index passed on success, 0 on error</returns>
public uint GetItemCountByIndex (int index, InventoryType location)
{
if (IsSet(location, InventoryType.None))
return 0;
DoRangeChecks(index, location);
InventoryItem item = GetItem(index, location);
if (item != null)
return item.Count;
return 0;
} // @ public uint GetItemCountByIndex(byte index, InventoryType location)
/// <summary>
/// Will get an item ID by index in the passed location
/// </summary>
/// <param name="index">Index of the item in your inventory</param>
/// <param name="location">InventoryType of the location to search (SINGLE LOCATION)</param>
public int GetItemIDByIndex (int index, InventoryType location)
{
if (IsSet(location, InventoryType.None))
return 0;
DoRangeChecks(index, location);
InventoryItem item = GetItem(index, location);
if (item != null)
return item.ID;
return 0;
} // @ public int GetItemIDByIndex(byte index, InventoryType location)
/// <summary>
/// The amount of items matching iD that you have in your inventory
/// </summary>
/// <param name="iD">ID of the item to count</param>
/// <param name="location">InventoryType of the location(s) to search.</param>
/// <returns>Total count of all items matching ID in the location(s) passed.</returns>
public uint GetItemCount (int iD, InventoryType location)
{
// Don't even bother to do range checks here.
// We're doing the looping ourselves.
// DoRangeChecks(1, location);
// Check to ensure iD passed isn't 0
if (iD <= 0)
return 0;
if (IsSet(location, InventoryType.None))
return 0;
System.Collections.Generic.List<InventoryItem> list = GetItemList(iD, location);
if (list.Count <= 0)
return 0;
uint count = 0;
for (int i = 0; i < list.Count; i++)
{
count += list[i].Count;
}
return count;
} // @ public uint GetItemCount(ushort iD, InventoryType location)
/// <summary>
/// Used internally for assigning a function to a variable.
/// </summary>
/// <param name="instanceID">InstanceID of FFACE for FFACE functions.</param>
/// <param name="index">index into the particular location</param>
/// <returns>Private INVENTORYITEM struct used internally for sending item data to public accessibility.</returns>
private delegate INVENTORYITEM FFACEGetItem (int instanceID, int index);
/// <summary>
/// Gets information about an item from your inventory
/// </summary>
/// <param name="index">Index of the item</param>
/// <param name="location">Location to check (SINGLE LOCATION)</param>
/// <returns>InventoryItem filled with data about item, null if no item or error.</returns>
public InventoryItem GetItem (int index, InventoryType location)
{
if (IsSet(location, InventoryType.None))
return null;
DoRangeChecks(index, location);
// done this way because INVENTORYITEM is a private structure
FFACEGetItem func = null;
if (IsSet(location, InventoryType.Inventory))
{
func = FFACE.GetInventoryItem;
location = InventoryType.Inventory;
}
else if (IsSet(location, InventoryType.Locker))
{
func = FFACE.GetLockerItem;
location = InventoryType.Locker;
}
else if (IsSet(location, InventoryType.Sack))
{
func = FFACE.GetSackItem;
location = InventoryType.Sack;
}
else if (IsSet(location, InventoryType.Safe))
{
func = FFACE.GetSafeItem;
location = InventoryType.Safe;
}
else if (IsSet(location, InventoryType.Case))
{
func = FFACE.GetCaseItem;
location = InventoryType.Case;
}
else if (IsSet(location, InventoryType.Satchel))
{
func = FFACE.GetSatchelItem;
location = InventoryType.Satchel;
}
else if (IsSet(location, InventoryType.Storage))
{
func = FFACE.GetStorageItem;
location = InventoryType.Storage;
}
else if (IsSet(location, InventoryType.Temp))
{
func = FFACE.GetTempItem;
location = InventoryType.Temp;
}
else if (IsSet(location, InventoryType.Wardrobe))
{
func = FFACE.GetWardrobeItem;
location = InventoryType.Wardrobe;
}
if (func == null)
return null;
INVENTORYITEM item = func(_InstanceID, index);
if (item.ID <= 0)
{
return null;
}
return new InventoryItem(item.ID, item.Index, item.Count, item.Flag, item.Price, item.Extra, location);
} // @ public InventoryItem GetItem(int index, InventoryType location)
/// <summary>
/// Returns a list of all inventory items matching ID
/// </summary>
/// <param name="iD">ID of item to get list of.</param>
/// <returns></returns>
public System.Collections.Generic.List<InventoryItem> GetItemList (int iD, InventoryType location)
{
var retList = new System.Collections.Generic.List<InventoryItem>();
if (IsSet(location, InventoryType.None))
{
return retList;
}
if (location != InventoryType.None)
{
int start = 0;
bool inventory = IsSet(location, InventoryType.Inventory),
locker = IsSet(location, InventoryType.Locker),
sack = IsSet(location, InventoryType.Sack),
_case = IsSet(location, InventoryType.Case),
wardrobe = IsSet(location, InventoryType.Wardrobe),
safe = IsSet(location, InventoryType.Safe),
satchel = IsSet(location, InventoryType.Satchel),
storage = IsSet(location, InventoryType.Storage),
temp = IsSet(location, InventoryType.Temp);
// if inventory is not set at all, just skip the 0
if (!inventory)
start = 1;
// Check all bags in parallel
for (int i = start; i <= 80; i++)
{
// inventory index is allowed to be 0
InventoryItem item;
if (inventory)
{
item = GetItem(i, InventoryType.Inventory);
if (( item != null ) && ( item.ID == iD ))
retList.Add(item);
}
// Inventory is only one allowed to start at 0
if (i == 0)
continue;
if (locker)
{
item = GetItem(i, InventoryType.Locker);
if (( item != null ) && ( item.ID == iD ))
retList.Add(item);
}
if (sack)
{
item = GetItem(i, InventoryType.Sack);
if (( item != null ) && ( item.ID == iD ))
retList.Add(item);
}
if (_case)
{
item = GetItem(i, InventoryType.Case);
if (( item != null ) && ( item.ID == iD ))
retList.Add(item);
}
if (safe)
{
item = GetItem(i, InventoryType.Safe);
if (( item != null ) && ( item.ID == iD ))
retList.Add(item);
}
if (satchel)
{
item = GetItem(i, InventoryType.Satchel);
if (( item != null ) && ( item.ID == iD ))
retList.Add(item);
}
if (storage)
{
item = GetItem(i, InventoryType.Storage);
if (( item != null ) && ( item.ID == iD ))
retList.Add(item);
}
if (temp)
{
item = GetItem(i, InventoryType.Temp);
if (( item != null ) && ( item.ID == iD ))
retList.Add(item);
}
if (wardrobe)
{
item = GetItem(i, InventoryType.Wardrobe);
if ((item != null) && (item.ID == iD))
retList.Add(item);
}
}
}
return retList;
}
#endregion
#region Methods relating to inventory
/// <summary>
/// The count of an item by index
/// </summary>
/// <param name="index">Index of the item</param>
public uint GetInventoryItemCountByIndex (int index)
{
return GetItemCountByIndex(index, InventoryType.Inventory);
//// 0 is gil, rest is 1-80
//if (0 > index || 80 < index)
// throw new ArgumentOutOfRangeException(INVENTORY_RANGE);
//return GetInventoryItem(index).Count;
}
/// <summary>
/// Will get an inventory item ID by index
/// </summary>
/// <param name="index">Index of the item in your inventory</param>
public int GetInventoryItemIDByIndex (byte index)
{
if (0 > index || 80 < index)
throw new ArgumentOutOfRangeException(INVENTORY_RANGE);
return GetItemIDByIndex(index, InventoryType.Inventory);
//return GetInventoryItem(index).ID;
} // @ public int GetItemIDByIndex(short index)
/// <summary>
/// The amount of items matching iD that you have in your inventory
/// </summary>
/// <param name="iD">ID of the item to count</param>
public uint GetInventoryItemCount (ushort iD)
{
return GetItemCount(iD, InventoryType.Inventory);
//uint count = 0;
//for (byte i = 0; i <= 80; i++)
//{
// InventoryItem item = GetInventoryItem(i);
// if (item.ID == iD)
// count += item.Count;
//} // @ for (short i = 0; i < 80; i++)
//return count;
} // @ public int ItemCount(short ID)
/// <summary>
/// Gets information about an item from your inventory
/// </summary>
/// <param name="index">Index of the item</param>
public InventoryItem GetInventoryItem (int index)
{
if (0 > index || 80 < index)
throw new ArgumentOutOfRangeException(INVENTORY_RANGE);
return GetItem(index, InventoryType.Inventory);
//// done this way because INVENTORYITEM is a private structure
//INVENTORYITEM item = FFACE.GetInventoryItem(_InstanceID, index);
//return new InventoryItem(item.ID, item.Index, item.Count, item.Flag, item.Price, item.Extra, InventoryType.Inventory);
} // @ public INVENTORYITEM GetInventoryItem(int index)
#endregion
#region Methods relating to Safe
/// <summary>
/// The count of an item by index
/// </summary>
/// <param name="index">Index of the item</param>
public uint GetSafeItemCountByIndex (byte index)
{
if (1 > index || 80 < index)
throw new ArgumentOutOfRangeException(OTHERBAG_RANGE);
return GetItemCountByIndex(index, InventoryType.Safe);
//return GetSafeItem(index).Count;
} // @ public byte GetItemCountByIndex(byte index)
/// <summary>
/// Will get a Safe item ID by index
/// </summary>
/// <param name="index">Index of the item in your Safe</param>
public int GetSafeItemIDByIndex (byte index)
{
if (1 > index || 80 < index)
throw new ArgumentOutOfRangeException(OTHERBAG_RANGE);
return GetItemIDByIndex(index, InventoryType.Safe);
//return GetSafeItem(index).ID;
} // @ public int GetItemIDByIndex(short index)
/// <summary>
/// The amount of passed items you have in your safe
/// </summary>
/// <param name="iD">ID of the item to count</param>
public uint GetSafeItemCount (ushort iD)
{
return GetItemCount(iD, InventoryType.Safe);
//uint count = 0;
//for (byte i = 1; i <= 80; i++)
//{