tf2-enum 0.13.0

Provides enumerated types for models related to the Team Fortress 2 item schema.
Documentation
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
//! Includes commonly-used non-enumerated attributes related to economy items. Included for 
//! convenience.
//! 
//! While the attribute values don't change much, there is no guarantee that Valve won't update
//! them. The defindex values, however, will always remain the same.

use crate::{
    Attribute,
    Attributes,
    AttributeDef,
    AttributeValue,
    DescriptionFormat,
    EffectType,
    ItemAttribute,
    TryFromIntAttributeValue,
};
use std::borrow::Borrow;
use std::ops::Deref;

macro_rules! impl_from_u32 {
    ($t:ty) => {
        impl TryFromIntAttributeValue for $t {}
        
        impl From<u32> for $t {
            fn from(val: u32) -> Self {
                Self(val)
            }
        }
        
        impl From<&u32> for $t {
            fn from(val: &u32) -> Self {
                Self(*val)
            }
        }
        
        impl std::ops::Deref for $t {
            type Target = u32;
            
            fn deref(&self) -> &Self::Target {
                &self.0
            }
        }

        impl AsRef<u32> for $t {
            fn as_ref(&self) -> &u32 {
                &self.0
            }
        }

        impl std::borrow::Borrow<u32> for $t {
            fn borrow(&self) -> &u32 {
                &self.0
            }
        }
    };
}
    
macro_rules! impl_attr {
    (
        unit,
        $t:ty,
        $defindex:expr,
        $name:expr,
        $attribute_class:expr,
        $description_string:expr,
        $description_format:expr,
        $effect_type:expr,
        $hidden:expr,
        $stored_as_integer:expr
    ) => {
        impl Attribute for $t {
            const DEFINDEX: u32 = $defindex;
            const USES_FLOAT_VALUE: bool = true;
            const ATTRIBUTE: AttributeDef = AttributeDef {
                defindex: $defindex,
                name: $name,
                attribute_class: $attribute_class,
                description_string: $description_string,
                description_format: $description_format,
                effect_type: $effect_type,
                hidden: $hidden,
                stored_as_integer: $stored_as_integer,
            };
            
            // These attributes are booleans but our structs are unit types because we assume if an
            // item has attribute that this is set to true.
            fn attribute_float_value(&self) -> Option<f32> {
                Some(1.0)
            }
        }
    };
    (
        u32,
        $t:ty,
        $defindex:expr,
        $name:expr,
        $attribute_class:expr,
        $description_string:expr,
        $description_format:expr,
        $effect_type:expr,
        $hidden:expr,
        $stored_as_integer:expr
    ) => {
        impl Attribute for $t {
            const DEFINDEX: u32 = $defindex;
            const USES_FLOAT_VALUE: bool = false;
            const ATTRIBUTE: AttributeDef = AttributeDef {
                defindex: $defindex,
                name: $name,
                attribute_class: $attribute_class,
                description_string: $description_string,
                description_format: $description_format,
                effect_type: $effect_type,
                hidden: $hidden,
                stored_as_integer: $stored_as_integer,
            };
            
            fn attribute_value(&self) -> AttributeValue {
                self.0.into()
            }
            
            fn attribute_float_value(&self) -> Option<f32> {
                None
            }
        }
        
        impl From<$t> for ItemAttribute {
            fn from(val: $t) -> Self {
                ItemAttribute {
                    defindex: <$t as Attribute>::DEFINDEX,
                    value: val.attribute_value(),
                    float_value: val.attribute_float_value(),
                }
            }
        }
        
        impl_from_u32!($t);
    };
    (
        u32_float,
        $t:ty,
        $defindex:expr,
        $name:expr,
        $attribute_class:expr,
        $description_string:expr,
        $description_format:expr,
        $effect_type:expr,
        $hidden:expr,
        $stored_as_integer:expr
    ) => {
        impl Attribute for $t {
            const DEFINDEX: u32 = $defindex;
            const USES_FLOAT_VALUE: bool = true;
            const ATTRIBUTE: AttributeDef = AttributeDef {
                defindex: $defindex,
                name: $name,
                attribute_class: $attribute_class,
                description_string: $description_string,
                description_format: $description_format,
                effect_type: $effect_type,
                hidden: $hidden,
                stored_as_integer: $stored_as_integer,
            };
            
            fn attribute_float_value(&self) -> Option<f32> {
                Some(self.0 as f32)
            }
        }
        
        impl_from_u32!($t);
    };
    (
        string,
        $t:ty,
        $defindex:expr,
        $name:expr,
        $attribute_class:expr,
        $description_string:expr,
        $description_format:expr,
        $effect_type:expr,
        $hidden:expr,
        $stored_as_integer:expr
    ) => {
        impl Attribute for $t {
            const DEFINDEX: u32 = $defindex;
            const USES_FLOAT_VALUE: bool = false;
            const ATTRIBUTE: AttributeDef = AttributeDef {
                defindex: $defindex,
                name: $name,
                attribute_class: $attribute_class,
                description_string: $description_string,
                description_format: $description_format,
                effect_type: $effect_type,
                hidden: $hidden,
                stored_as_integer: $stored_as_integer,
            };
            
            fn attribute_value(&self) -> AttributeValue {
                self.0.clone().into()
            }

            fn attribute_float_value(&self) -> Option<f32> {
                None
            }
        }
        
        impl From<$t> for ItemAttribute {
            fn from(val: $t) -> Self {
                ItemAttribute {
                    defindex: <$t as Attribute>::DEFINDEX,
                    value: val.attribute_value(),
                    float_value: val.attribute_float_value(),
                }
            }
        }
        
        impl From<String> for $t {
            fn from(val: String) -> Self {
                Self(val)
            }
        }
        
        impl From<&String> for $t {
            fn from(val: &String) -> Self {
                Self(val.to_owned())
            }
        }
        
        impl From<&str> for $t {
            fn from(val: &str) -> Self {
                Self(val.to_owned())
            }
        }
        
        impl Deref for $t {
            type Target = str;
            fn deref(&self) -> &Self::Target {
                &self.0
            }
        }

        impl AsRef<str> for $t {
            fn as_ref(&self) -> &str {
                &self.0
            }
        }

        impl Borrow<str> for $t {
            fn borrow(&self) -> &str {
                &self.0
            }
        }

        impl From<$t> for String {
            fn from(val: $t) -> Self {
                val.0
            }
        }
    };
}

/// Represents the "is_festivized" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct IsFestivized;

impl_attr!(
    unit,
    IsFestivized,
    2053,
    "is_festivized",
    Some("is_festivized"),
    Some("Festivized"),
    Some(DescriptionFormat::ValueIsAdditive),
    EffectType::Unusual,
    false,
    false
);

/// Represents the "is_australium_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct IsAustralium;

impl_attr!(
    unit,
    IsAustralium,
    2027,
    "is australium item",
    Some("is_australium_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Unusual,
    true,
    true
);

/// Represents the "kill eater" attribute.
/// 
/// This attribute is included with items that have a strange counter, regardless of quality which
/// allows strangified non-strange items to be identified.
/// 
/// The value refers to the number of kills, or score count.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct KillEater(pub u32);

impl_attr!(
    u32,
    KillEater,
    214,
    "kill eater",
    Some("kill_eater"),
    None,
    None,
    EffectType::Positive,
    true,
    true
);

/// Represents the "taunt attach particle index" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TauntAttachParticleIndex(pub u32);

impl_attr!(
    u32,
    TauntAttachParticleIndex,
    2041,
    "taunt attach particle index",
    None,
    Some("★ Unusual Effect: %s1"),
    Some(DescriptionFormat::ValueIsParticleIndex),
    EffectType::Unusual,
    false,
    true
);

/// Represents the "set_attached_particle" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SetAttachedParticle(pub u32);

impl_attr!(
    u32_float,
    SetAttachedParticle,
    134,
    "attach particle effect",
    Some("set_attached_particle"),
    Some("★ Unusual Effect: %s1"),
    Some(DescriptionFormat::ValueIsParticleIndex),
    EffectType::Unusual,
    false,
    false
);

/// Represents the "paintkit_proto_def_index" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct PaintkitProtoDefIndex(pub u32);

impl_attr!(
    u32,
    PaintkitProtoDefIndex,
    834,
    "paintkit_proto_def_index",
    Some("paintkit_proto_def_index"),
    None,
    Some(DescriptionFormat::ValueIsAdditive),
    EffectType::Neutral,
    false,
    true
);

/// Represents the "tool_target_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ToolTargetItem(pub u32);

impl_attr!(
    u32_float,
    ToolTargetItem,
    2012,
    "tool target item",
    Some("tool_target_item"),
    None,
    None,
    EffectType::ValueIsFromLookupTable,
    true,
    false
);

/// Represents the "supply_crate_series" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SupplyCrateSeries(pub u32);

impl_attr!(
    u32_float,
    SupplyCrateSeries,
    187,
    "set supply crate series",
    Some("supply_crate_series"),
    Some("Crate Series #%s1"),
    Some(DescriptionFormat::ValueIsAdditive),
    EffectType::Positive,
    false,
    false
);

/// Represents the "series_number" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SeriesNumber(pub u32);

impl_attr!(
    u32_float,
    SeriesNumber,
    2031,
    "series number",
    Some("series_number"),
    None,
    None,
    EffectType::ValueIsFromLookupTable,
    true,
    false
);

/// Represents the "custom_name_attr" attribute.
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
pub struct CustomNameAttr(pub String);

impl_attr!(
    string,
    CustomNameAttr,
    500,
    "custom name attr",
    Some("custom_name_attr"),
    None,
    None,
    EffectType::Positive,
    true,
    false
);

/// Represents the "custom_desc_attr" attribute.
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
pub struct CustomDescAttr(pub String);

impl_attr!(
    string,
    CustomDescAttr,
    501,
    "custom desc attr",
    Some("custom_desc_attr"),
    None,
    None,
    EffectType::Positive,
    true,
    false
);

/// Represents the "unique_craft_index" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct UniqueCraftIndex(pub u32);

impl_attr!(
    u32,
    UniqueCraftIndex,
    229,
    "unique craft index",
    Some("unique_craft_index"),
    None,
    None,
    EffectType::Positive,
    true,
    true
);

/// Represents the "makers_mark_id" attribute. The integer refers to the account's 32-bit SteamID
/// of the crafter.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MakersMarkId(pub u32);

impl_attr!(
    u32,
    MakersMarkId,
    228,
    "makers mark id",
    Some("makers_mark_id"),
    Some("Crafted by %s1"),
    Some(DescriptionFormat::ValueIsAccountId),
    EffectType::Positive,
    true,
    true
);

/// Represents the "gifter_account_id" attribute. The integer refers to the account's 32-bit
/// SteamID.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct GifterAccountId(pub u32);

impl_attr!(
    u32,
    GifterAccountId,
    186,
    "gifter account id",
    Some("gifter_account_id"),
    Some("\nGift from: %s1"),
    Some(DescriptionFormat::ValueIsAccountId),
    EffectType::Positive,
    true,
    true
);

/// Represents the "event_date" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EventDate(pub u32);

impl_attr!(
    u32,
    EventDate,
    185,
    "event date",
    Some("event_date"),
    Some("Date Received: %s1"),
    Some(DescriptionFormat::ValueIsDate),
    EffectType::Neutral,
    true,
    true
);

/// Represents the "is_australium_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TradableAfterDate(pub u32);

impl_attr!(
    u32,
    TradableAfterDate,
    211,
    "tradable after date",
    Some("tradable_after_date"),
    Some("\nTradable After: %s1"),
    Some(DescriptionFormat::ValueIsDate),
    EffectType::Negative,
    true,
    true
);

/// Represents the "custom_texture_lo" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct CustomTextureLo(pub u32);

impl_attr!(
    u32,
    CustomTextureLo,
    152,
    "custom texture lo",
    Some("custom_texture_lo"),
    None,
    None,
    EffectType::Positive,
    true,
    true
);

/// Represents the "custom_texture_hi" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct CustomTextureHi(pub u32);

impl_attr!(
    u32,
    CustomTextureHi,
    227,
    "custom texture hi",
    Some("custom_texture_hi"),
    None,
    None,
    EffectType::Positive,
    true,
    true
);

/// Represents the "halloween_voice_modulation" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct HalloweenVoiceModulation;

impl_attr!(
    unit,
    HalloweenVoiceModulation,
    1006,
    "SPELL: Halloween voice modulation",
    Some("halloween_voice_modulation"),
    Some("Voices from Below"),
    Some(DescriptionFormat::ValueIsAdditive),
    EffectType::Positive,
    false,
    false
);

/// Represents the "halloween_pumpkin_explosions" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct HalloweenPumpkinExplosions;

impl_attr!(
    unit,
    HalloweenPumpkinExplosions,
    1007,
    "SPELL: Halloween pumpkin explosions",
    Some("halloween_pumpkin_explosions"),
    Some("Pumpkin Bombs"),
    Some(DescriptionFormat::ValueIsAdditive),
    EffectType::Positive,
    false,
    false
);

/// Represents the "halloween_green_flames" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct HalloweenGreenFlames;

impl_attr!(
    unit,
    HalloweenGreenFlames,
    1008,
    "SPELL: Halloween green flames",
    Some("halloween_green_flames"),
    Some("Halloween Fire"),
    Some(DescriptionFormat::ValueIsAdditive),
    EffectType::Positive,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct HalloweenDeathGhosts;

impl_attr!(
    unit,
    HalloweenDeathGhosts,
    1009,
    "SPELL: Halloween death ghosts",
    Some("halloween_death_ghosts"),
    Some("Exorcism"),
    Some(DescriptionFormat::ValueIsAdditive),
    EffectType::Positive,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem1;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem1,
    2000,
    "recipe component defined item 1",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem2;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem2,
    2001,
    "recipe component defined item 2",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem3;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem3,
    2002,
    "recipe component defined item 3",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem4;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem4,
    2003,
    "recipe component defined item 4",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem5;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem5,
    2004,
    "recipe component defined item 5",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem6;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem6,
    2005,
    "recipe component defined item 6",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem7;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem7,
    2006,
    "recipe component defined item 7",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem8;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem8,
    2007,
    "recipe component defined item 8",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem9;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem9,
    2008,
    "recipe component defined item 9",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attribute.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem10;

impl_attr!(
    unit,
    DynamicRecipeComponentDefinedItem10,
    2009,
    "recipe component defined item 10",
    Some("dynamic_recipe_component_defined_item"),
    None,
    Some(DescriptionFormat::ValueIsFromLookupTable),
    EffectType::Neutral,
    false,
    false
);

/// Represents the "dynamic_recipe_component_defined_item" attributes.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DynamicRecipeComponentDefinedItem;

impl Attributes for DynamicRecipeComponentDefinedItem {
    const DEFINDEX: &'static [u32] = &[
        2000,
        2001,
        2002,
        2003,
        2004,
        2005,
        2006,
        2007,
        2008,
        2009,
    ];
    const USES_FLOAT_VALUE: bool = true;
    const ATTRIBUTES: &'static [AttributeDef] = &[
        DynamicRecipeComponentDefinedItem1::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem2::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem3::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem4::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem5::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem6::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem7::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem8::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem9::ATTRIBUTE,
        DynamicRecipeComponentDefinedItem10::ATTRIBUTE,
    ];
}

/// Represents the "kill_eater", "kill_eater_2", and "kill_eater_3" attributes. The integer
/// refers to the score count.
pub struct KillEaterScore(pub u32);

impl Attributes for KillEaterScore {
    const DEFINDEX: &'static [u32] = &[
        214,
        294,
        494,
    ];
    const USES_FLOAT_VALUE: bool = false;
    const ATTRIBUTES: &'static [AttributeDef] = &[
        AttributeDef {
            defindex: 214,
            name: "kill eater",
            attribute_class: Some("kill_eater"),
            description_string: None,
            description_format: None,
            effect_type: EffectType::Positive,
            hidden: true,
            stored_as_integer: true,
        },
        AttributeDef {
            defindex: 294,
            name: "kill eater 2",
            attribute_class: Some("kill_eater_2"),
            description_string: None,
            description_format: None,
            effect_type: EffectType::Positive,
            hidden: true,
            stored_as_integer: true,
        },
        AttributeDef {
            defindex: 494,
            name: "kill eater 3",
            attribute_class: Some("kill_eater_3"),
            description_string: None,
            description_format: None,
            effect_type: EffectType::Positive,
            hidden: true,
            stored_as_integer: true,
        },
    ];
}

/// Represents the "kill_eater_user_1", "kill_eater_user_2", and "kill_eater_user_3" attributes.
pub struct KillEaterUserScore(pub u32);

impl Attributes for KillEaterUserScore {
    const DEFINDEX: &'static [u32] = &[
        379,
        381,
        383,
    ];
    const USES_FLOAT_VALUE: bool = false;
    const ATTRIBUTES: &'static [AttributeDef] = &[
        AttributeDef {
            defindex: 379,
            name: "kill eater user 1",
            attribute_class: Some("kill_eater_user_1"),
            description_string: None,
            description_format: None,
            effect_type: EffectType::Positive,
            hidden: true,
            stored_as_integer: true,
        },
        AttributeDef {
            defindex: 381,
            name: "kill eater user 2",
            attribute_class: Some("kill_eater_user_2"),
            description_string: None,
            description_format: None,
            effect_type: EffectType::Positive,
            hidden: true,
            stored_as_integer: true,
        },
        AttributeDef {
            defindex: 383,
            name: "kill eater user 3",
            attribute_class: Some("kill_eater_user_3"),
            description_string: None,
            description_format: None,
            effect_type: EffectType::Positive,
            hidden: true,
            stored_as_integer: true,
        },
    ];
}

#[cfg(test)]
mod tests {
    use super::*;
    
    #[test]
    fn uses_correct_value() {
        assert!(SeriesNumber::from(1u32).attribute_float_value().is_some());
        assert_eq!(SeriesNumber::from(1u32).attribute_float_value().unwrap(), 1.0);
        assert!(SupplyCrateSeries::from(42u32).attribute_float_value().is_some());
        assert_eq!(SupplyCrateSeries::from(42u32).attribute_float_value().unwrap(), 42.0);
        assert_eq!(KillEater::from(123u32).attribute_value(), AttributeValue::from(123u32));
        assert_eq!(CustomNameAttr::from("TestName").attribute_value(), AttributeValue::from("TestName"));
    }
    
    #[test]
    fn equals() {
        assert_eq!(SupplyCrateSeries::from(1u32), SupplyCrateSeries::from(1u32));
        assert_eq!(*SupplyCrateSeries::from(1u32).deref(), 1u32);
    }
    
    #[test]
    fn gets_attribute_values() {
        let series_number = SeriesNumber::from(2u32);
        let series_number_value_float = series_number.attribute_float_value().unwrap();
        let series_number_value = series_number.attribute_value();
        
        assert_eq!(series_number_value_float, 2.0);
        assert_eq!(series_number_value, AttributeValue::from(series_number_value_float.to_bits()));
    }
}