tf2_enum/
econ_attributes.rs

1//! Includes commonly-used non-enumerated attributes related to economy items. Included for 
2//! convenience.
3//! 
4//! While the attribute values don't change much, there is no guarantee that Valve won't update
5//! them. The defindex values, however, will always remain the same.
6
7use crate::{
8    Attribute,
9    Attributes,
10    AttributeDef,
11    AttributeValue,
12    DescriptionFormat,
13    EffectType,
14    ItemAttribute,
15    TryFromIntAttributeValue,
16};
17use std::borrow::Borrow;
18use std::ops::Deref;
19
20macro_rules! impl_from_u32 {
21    ($t:ty) => {
22        impl TryFromIntAttributeValue for $t {}
23        
24        impl From<u32> for $t {
25            fn from(val: u32) -> Self {
26                Self(val)
27            }
28        }
29        
30        impl From<&u32> for $t {
31            fn from(val: &u32) -> Self {
32                Self(*val)
33            }
34        }
35        
36        impl std::ops::Deref for $t {
37            type Target = u32;
38            
39            fn deref(&self) -> &Self::Target {
40                &self.0
41            }
42        }
43
44        impl AsRef<u32> for $t {
45            fn as_ref(&self) -> &u32 {
46                &self.0
47            }
48        }
49
50        impl std::borrow::Borrow<u32> for $t {
51            fn borrow(&self) -> &u32 {
52                &self.0
53            }
54        }
55    };
56}
57    
58macro_rules! impl_attr {
59    (
60        unit,
61        $t:ty,
62        $defindex:expr,
63        $name:expr,
64        $attribute_class:expr,
65        $description_string:expr,
66        $description_format:expr,
67        $effect_type:expr,
68        $hidden:expr,
69        $stored_as_integer:expr
70    ) => {
71        impl Attribute for $t {
72            const DEFINDEX: u32 = $defindex;
73            const USES_FLOAT_VALUE: bool = true;
74            const ATTRIBUTE: AttributeDef = AttributeDef {
75                defindex: $defindex,
76                name: $name,
77                attribute_class: $attribute_class,
78                description_string: $description_string,
79                description_format: $description_format,
80                effect_type: $effect_type,
81                hidden: $hidden,
82                stored_as_integer: $stored_as_integer,
83            };
84            
85            // These attributes are booleans but our structs are unit types because we assume if an
86            // item has attribute that this is set to true.
87            fn attribute_float_value(&self) -> Option<f32> {
88                Some(1.0)
89            }
90        }
91    };
92    (
93        u32,
94        $t:ty,
95        $defindex:expr,
96        $name:expr,
97        $attribute_class:expr,
98        $description_string:expr,
99        $description_format:expr,
100        $effect_type:expr,
101        $hidden:expr,
102        $stored_as_integer:expr
103    ) => {
104        impl Attribute for $t {
105            const DEFINDEX: u32 = $defindex;
106            const USES_FLOAT_VALUE: bool = false;
107            const ATTRIBUTE: AttributeDef = AttributeDef {
108                defindex: $defindex,
109                name: $name,
110                attribute_class: $attribute_class,
111                description_string: $description_string,
112                description_format: $description_format,
113                effect_type: $effect_type,
114                hidden: $hidden,
115                stored_as_integer: $stored_as_integer,
116            };
117            
118            fn attribute_value(&self) -> AttributeValue {
119                self.0.into()
120            }
121            
122            fn attribute_float_value(&self) -> Option<f32> {
123                None
124            }
125        }
126        
127        impl From<$t> for ItemAttribute {
128            fn from(val: $t) -> Self {
129                ItemAttribute {
130                    defindex: <$t as Attribute>::DEFINDEX,
131                    value: val.attribute_value(),
132                    float_value: val.attribute_float_value(),
133                }
134            }
135        }
136        
137        impl_from_u32!($t);
138    };
139    (
140        u32_float,
141        $t:ty,
142        $defindex:expr,
143        $name:expr,
144        $attribute_class:expr,
145        $description_string:expr,
146        $description_format:expr,
147        $effect_type:expr,
148        $hidden:expr,
149        $stored_as_integer:expr
150    ) => {
151        impl Attribute for $t {
152            const DEFINDEX: u32 = $defindex;
153            const USES_FLOAT_VALUE: bool = true;
154            const ATTRIBUTE: AttributeDef = AttributeDef {
155                defindex: $defindex,
156                name: $name,
157                attribute_class: $attribute_class,
158                description_string: $description_string,
159                description_format: $description_format,
160                effect_type: $effect_type,
161                hidden: $hidden,
162                stored_as_integer: $stored_as_integer,
163            };
164            
165            fn attribute_float_value(&self) -> Option<f32> {
166                Some(self.0 as f32)
167            }
168        }
169        
170        impl_from_u32!($t);
171    };
172    (
173        string,
174        $t:ty,
175        $defindex:expr,
176        $name:expr,
177        $attribute_class:expr,
178        $description_string:expr,
179        $description_format:expr,
180        $effect_type:expr,
181        $hidden:expr,
182        $stored_as_integer:expr
183    ) => {
184        impl Attribute for $t {
185            const DEFINDEX: u32 = $defindex;
186            const USES_FLOAT_VALUE: bool = false;
187            const ATTRIBUTE: AttributeDef = AttributeDef {
188                defindex: $defindex,
189                name: $name,
190                attribute_class: $attribute_class,
191                description_string: $description_string,
192                description_format: $description_format,
193                effect_type: $effect_type,
194                hidden: $hidden,
195                stored_as_integer: $stored_as_integer,
196            };
197            
198            fn attribute_value(&self) -> AttributeValue {
199                self.0.clone().into()
200            }
201
202            fn attribute_float_value(&self) -> Option<f32> {
203                None
204            }
205        }
206        
207        impl From<$t> for ItemAttribute {
208            fn from(val: $t) -> Self {
209                ItemAttribute {
210                    defindex: <$t as Attribute>::DEFINDEX,
211                    value: val.attribute_value(),
212                    float_value: val.attribute_float_value(),
213                }
214            }
215        }
216        
217        impl From<String> for $t {
218            fn from(val: String) -> Self {
219                Self(val)
220            }
221        }
222        
223        impl From<&String> for $t {
224            fn from(val: &String) -> Self {
225                Self(val.to_owned())
226            }
227        }
228        
229        impl From<&str> for $t {
230            fn from(val: &str) -> Self {
231                Self(val.to_owned())
232            }
233        }
234        
235        impl Deref for $t {
236            type Target = str;
237            fn deref(&self) -> &Self::Target {
238                &self.0
239            }
240        }
241
242        impl AsRef<str> for $t {
243            fn as_ref(&self) -> &str {
244                &self.0
245            }
246        }
247
248        impl Borrow<str> for $t {
249            fn borrow(&self) -> &str {
250                &self.0
251            }
252        }
253
254        impl From<$t> for String {
255            fn from(val: $t) -> Self {
256                val.0
257            }
258        }
259    };
260}
261
262/// Represents the "is_festivized" attribute.
263#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
264pub struct IsFestivized;
265
266impl_attr!(
267    unit,
268    IsFestivized,
269    2053,
270    "is_festivized",
271    Some("is_festivized"),
272    Some("Festivized"),
273    Some(DescriptionFormat::ValueIsAdditive),
274    EffectType::Unusual,
275    false,
276    false
277);
278
279/// Represents the "is_australium_item" attribute.
280#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
281pub struct IsAustralium;
282
283impl_attr!(
284    unit,
285    IsAustralium,
286    2027,
287    "is australium item",
288    Some("is_australium_item"),
289    None,
290    Some(DescriptionFormat::ValueIsFromLookupTable),
291    EffectType::Unusual,
292    true,
293    true
294);
295
296/// Represents the "kill eater" attribute.
297/// 
298/// This attribute is included with items that have a strange counter, regardless of quality which
299/// allows strangified non-strange items to be identified.
300/// 
301/// The value refers to the number of kills, or score count.
302#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
303pub struct KillEater(pub u32);
304
305impl_attr!(
306    u32,
307    KillEater,
308    214,
309    "kill eater",
310    Some("kill_eater"),
311    None,
312    None,
313    EffectType::Positive,
314    true,
315    true
316);
317
318/// Represents the "taunt attach particle index" attribute.
319#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
320pub struct TauntAttachParticleIndex(pub u32);
321
322impl_attr!(
323    u32,
324    TauntAttachParticleIndex,
325    2041,
326    "taunt attach particle index",
327    None,
328    Some("★ Unusual Effect: %s1"),
329    Some(DescriptionFormat::ValueIsParticleIndex),
330    EffectType::Unusual,
331    false,
332    true
333);
334
335/// Represents the "set_attached_particle" attribute.
336#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
337pub struct SetAttachedParticle(pub u32);
338
339impl_attr!(
340    u32_float,
341    SetAttachedParticle,
342    134,
343    "attach particle effect",
344    Some("set_attached_particle"),
345    Some("★ Unusual Effect: %s1"),
346    Some(DescriptionFormat::ValueIsParticleIndex),
347    EffectType::Unusual,
348    false,
349    false
350);
351
352/// Represents the "paintkit_proto_def_index" attribute.
353#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
354pub struct PaintkitProtoDefIndex(pub u32);
355
356impl_attr!(
357    u32,
358    PaintkitProtoDefIndex,
359    834,
360    "paintkit_proto_def_index",
361    Some("paintkit_proto_def_index"),
362    None,
363    Some(DescriptionFormat::ValueIsAdditive),
364    EffectType::Neutral,
365    false,
366    true
367);
368
369/// Represents the "tool_target_item" attribute.
370#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
371pub struct ToolTargetItem(pub u32);
372
373impl_attr!(
374    u32_float,
375    ToolTargetItem,
376    2012,
377    "tool target item",
378    Some("tool_target_item"),
379    None,
380    None,
381    EffectType::ValueIsFromLookupTable,
382    true,
383    false
384);
385
386/// Represents the "supply_crate_series" attribute.
387#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
388pub struct SupplyCrateSeries(pub u32);
389
390impl_attr!(
391    u32_float,
392    SupplyCrateSeries,
393    187,
394    "set supply crate series",
395    Some("supply_crate_series"),
396    Some("Crate Series #%s1"),
397    Some(DescriptionFormat::ValueIsAdditive),
398    EffectType::Positive,
399    false,
400    false
401);
402
403/// Represents the "series_number" attribute.
404#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
405pub struct SeriesNumber(pub u32);
406
407impl_attr!(
408    u32_float,
409    SeriesNumber,
410    2031,
411    "series number",
412    Some("series_number"),
413    None,
414    None,
415    EffectType::ValueIsFromLookupTable,
416    true,
417    false
418);
419
420/// Represents the "custom_name_attr" attribute.
421#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
422pub struct CustomNameAttr(pub String);
423
424impl_attr!(
425    string,
426    CustomNameAttr,
427    500,
428    "custom name attr",
429    Some("custom_name_attr"),
430    None,
431    None,
432    EffectType::Positive,
433    true,
434    false
435);
436
437/// Represents the "custom_desc_attr" attribute.
438#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
439pub struct CustomDescAttr(pub String);
440
441impl_attr!(
442    string,
443    CustomDescAttr,
444    501,
445    "custom desc attr",
446    Some("custom_desc_attr"),
447    None,
448    None,
449    EffectType::Positive,
450    true,
451    false
452);
453
454/// Represents the "unique_craft_index" attribute.
455#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
456pub struct UniqueCraftIndex(pub u32);
457
458impl_attr!(
459    u32,
460    UniqueCraftIndex,
461    229,
462    "unique craft index",
463    Some("unique_craft_index"),
464    None,
465    None,
466    EffectType::Positive,
467    true,
468    true
469);
470
471/// Represents the "makers_mark_id" attribute. The integer refers to the account's 32-bit SteamID
472/// of the crafter.
473#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
474pub struct MakersMarkId(pub u32);
475
476impl_attr!(
477    u32,
478    MakersMarkId,
479    228,
480    "makers mark id",
481    Some("makers_mark_id"),
482    Some("Crafted by %s1"),
483    Some(DescriptionFormat::ValueIsAccountId),
484    EffectType::Positive,
485    true,
486    true
487);
488
489/// Represents the "gifter_account_id" attribute. The integer refers to the account's 32-bit
490/// SteamID.
491#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
492pub struct GifterAccountId(pub u32);
493
494impl_attr!(
495    u32,
496    GifterAccountId,
497    186,
498    "gifter account id",
499    Some("gifter_account_id"),
500    Some("\nGift from: %s1"),
501    Some(DescriptionFormat::ValueIsAccountId),
502    EffectType::Positive,
503    true,
504    true
505);
506
507/// Represents the "event_date" attribute.
508#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
509pub struct EventDate(pub u32);
510
511impl_attr!(
512    u32,
513    EventDate,
514    185,
515    "event date",
516    Some("event_date"),
517    Some("Date Received: %s1"),
518    Some(DescriptionFormat::ValueIsDate),
519    EffectType::Neutral,
520    true,
521    true
522);
523
524/// Represents the "is_australium_item" attribute.
525#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
526pub struct TradableAfterDate(pub u32);
527
528impl_attr!(
529    u32,
530    TradableAfterDate,
531    211,
532    "tradable after date",
533    Some("tradable_after_date"),
534    Some("\nTradable After: %s1"),
535    Some(DescriptionFormat::ValueIsDate),
536    EffectType::Negative,
537    true,
538    true
539);
540
541/// Represents the "custom_texture_lo" attribute.
542#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
543pub struct CustomTextureLo(pub u32);
544
545impl_attr!(
546    u32,
547    CustomTextureLo,
548    152,
549    "custom texture lo",
550    Some("custom_texture_lo"),
551    None,
552    None,
553    EffectType::Positive,
554    true,
555    true
556);
557
558/// Represents the "custom_texture_hi" attribute.
559#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
560pub struct CustomTextureHi(pub u32);
561
562impl_attr!(
563    u32,
564    CustomTextureHi,
565    227,
566    "custom texture hi",
567    Some("custom_texture_hi"),
568    None,
569    None,
570    EffectType::Positive,
571    true,
572    true
573);
574
575/// Represents the "halloween_voice_modulation" attribute.
576#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
577pub struct HalloweenVoiceModulation;
578
579impl_attr!(
580    unit,
581    HalloweenVoiceModulation,
582    1006,
583    "SPELL: Halloween voice modulation",
584    Some("halloween_voice_modulation"),
585    Some("Voices from Below"),
586    Some(DescriptionFormat::ValueIsAdditive),
587    EffectType::Positive,
588    false,
589    false
590);
591
592/// Represents the "halloween_pumpkin_explosions" attribute.
593#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
594pub struct HalloweenPumpkinExplosions;
595
596impl_attr!(
597    unit,
598    HalloweenPumpkinExplosions,
599    1007,
600    "SPELL: Halloween pumpkin explosions",
601    Some("halloween_pumpkin_explosions"),
602    Some("Pumpkin Bombs"),
603    Some(DescriptionFormat::ValueIsAdditive),
604    EffectType::Positive,
605    false,
606    false
607);
608
609/// Represents the "halloween_green_flames" attribute.
610#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
611pub struct HalloweenGreenFlames;
612
613impl_attr!(
614    unit,
615    HalloweenGreenFlames,
616    1008,
617    "SPELL: Halloween green flames",
618    Some("halloween_green_flames"),
619    Some("Halloween Fire"),
620    Some(DescriptionFormat::ValueIsAdditive),
621    EffectType::Positive,
622    false,
623    false
624);
625
626/// Represents the "dynamic_recipe_component_defined_item" attribute.
627#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
628pub struct HalloweenDeathGhosts;
629
630impl_attr!(
631    unit,
632    HalloweenDeathGhosts,
633    1009,
634    "SPELL: Halloween death ghosts",
635    Some("halloween_death_ghosts"),
636    Some("Exorcism"),
637    Some(DescriptionFormat::ValueIsAdditive),
638    EffectType::Positive,
639    false,
640    false
641);
642
643/// Represents the "dynamic_recipe_component_defined_item" attribute.
644#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
645pub struct DynamicRecipeComponentDefinedItem1;
646
647impl_attr!(
648    unit,
649    DynamicRecipeComponentDefinedItem1,
650    2000,
651    "recipe component defined item 1",
652    Some("dynamic_recipe_component_defined_item"),
653    None,
654    Some(DescriptionFormat::ValueIsFromLookupTable),
655    EffectType::Neutral,
656    false,
657    false
658);
659
660/// Represents the "dynamic_recipe_component_defined_item" attribute.
661#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
662pub struct DynamicRecipeComponentDefinedItem2;
663
664impl_attr!(
665    unit,
666    DynamicRecipeComponentDefinedItem2,
667    2001,
668    "recipe component defined item 2",
669    Some("dynamic_recipe_component_defined_item"),
670    None,
671    Some(DescriptionFormat::ValueIsFromLookupTable),
672    EffectType::Neutral,
673    false,
674    false
675);
676
677/// Represents the "dynamic_recipe_component_defined_item" attribute.
678#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
679pub struct DynamicRecipeComponentDefinedItem3;
680
681impl_attr!(
682    unit,
683    DynamicRecipeComponentDefinedItem3,
684    2002,
685    "recipe component defined item 3",
686    Some("dynamic_recipe_component_defined_item"),
687    None,
688    Some(DescriptionFormat::ValueIsFromLookupTable),
689    EffectType::Neutral,
690    false,
691    false
692);
693
694/// Represents the "dynamic_recipe_component_defined_item" attribute.
695#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
696pub struct DynamicRecipeComponentDefinedItem4;
697
698impl_attr!(
699    unit,
700    DynamicRecipeComponentDefinedItem4,
701    2003,
702    "recipe component defined item 4",
703    Some("dynamic_recipe_component_defined_item"),
704    None,
705    Some(DescriptionFormat::ValueIsFromLookupTable),
706    EffectType::Neutral,
707    false,
708    false
709);
710
711/// Represents the "dynamic_recipe_component_defined_item" attribute.
712#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
713pub struct DynamicRecipeComponentDefinedItem5;
714
715impl_attr!(
716    unit,
717    DynamicRecipeComponentDefinedItem5,
718    2004,
719    "recipe component defined item 5",
720    Some("dynamic_recipe_component_defined_item"),
721    None,
722    Some(DescriptionFormat::ValueIsFromLookupTable),
723    EffectType::Neutral,
724    false,
725    false
726);
727
728/// Represents the "dynamic_recipe_component_defined_item" attribute.
729#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
730pub struct DynamicRecipeComponentDefinedItem6;
731
732impl_attr!(
733    unit,
734    DynamicRecipeComponentDefinedItem6,
735    2005,
736    "recipe component defined item 6",
737    Some("dynamic_recipe_component_defined_item"),
738    None,
739    Some(DescriptionFormat::ValueIsFromLookupTable),
740    EffectType::Neutral,
741    false,
742    false
743);
744
745/// Represents the "dynamic_recipe_component_defined_item" attribute.
746#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
747pub struct DynamicRecipeComponentDefinedItem7;
748
749impl_attr!(
750    unit,
751    DynamicRecipeComponentDefinedItem7,
752    2006,
753    "recipe component defined item 7",
754    Some("dynamic_recipe_component_defined_item"),
755    None,
756    Some(DescriptionFormat::ValueIsFromLookupTable),
757    EffectType::Neutral,
758    false,
759    false
760);
761
762/// Represents the "dynamic_recipe_component_defined_item" attribute.
763#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
764pub struct DynamicRecipeComponentDefinedItem8;
765
766impl_attr!(
767    unit,
768    DynamicRecipeComponentDefinedItem8,
769    2007,
770    "recipe component defined item 8",
771    Some("dynamic_recipe_component_defined_item"),
772    None,
773    Some(DescriptionFormat::ValueIsFromLookupTable),
774    EffectType::Neutral,
775    false,
776    false
777);
778
779/// Represents the "dynamic_recipe_component_defined_item" attribute.
780#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
781pub struct DynamicRecipeComponentDefinedItem9;
782
783impl_attr!(
784    unit,
785    DynamicRecipeComponentDefinedItem9,
786    2008,
787    "recipe component defined item 9",
788    Some("dynamic_recipe_component_defined_item"),
789    None,
790    Some(DescriptionFormat::ValueIsFromLookupTable),
791    EffectType::Neutral,
792    false,
793    false
794);
795
796/// Represents the "dynamic_recipe_component_defined_item" attribute.
797#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
798pub struct DynamicRecipeComponentDefinedItem10;
799
800impl_attr!(
801    unit,
802    DynamicRecipeComponentDefinedItem10,
803    2009,
804    "recipe component defined item 10",
805    Some("dynamic_recipe_component_defined_item"),
806    None,
807    Some(DescriptionFormat::ValueIsFromLookupTable),
808    EffectType::Neutral,
809    false,
810    false
811);
812
813/// Represents the "dynamic_recipe_component_defined_item" attributes.
814#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
815pub struct DynamicRecipeComponentDefinedItem;
816
817impl Attributes for DynamicRecipeComponentDefinedItem {
818    const DEFINDEX: &'static [u32] = &[
819        2000,
820        2001,
821        2002,
822        2003,
823        2004,
824        2005,
825        2006,
826        2007,
827        2008,
828        2009,
829    ];
830    const USES_FLOAT_VALUE: bool = true;
831    const ATTRIBUTES: &'static [AttributeDef] = &[
832        DynamicRecipeComponentDefinedItem1::ATTRIBUTE,
833        DynamicRecipeComponentDefinedItem2::ATTRIBUTE,
834        DynamicRecipeComponentDefinedItem3::ATTRIBUTE,
835        DynamicRecipeComponentDefinedItem4::ATTRIBUTE,
836        DynamicRecipeComponentDefinedItem5::ATTRIBUTE,
837        DynamicRecipeComponentDefinedItem6::ATTRIBUTE,
838        DynamicRecipeComponentDefinedItem7::ATTRIBUTE,
839        DynamicRecipeComponentDefinedItem8::ATTRIBUTE,
840        DynamicRecipeComponentDefinedItem9::ATTRIBUTE,
841        DynamicRecipeComponentDefinedItem10::ATTRIBUTE,
842    ];
843}
844
845/// Represents the "kill_eater", "kill_eater_2", and "kill_eater_3" attributes. The integer
846/// refers to the score count.
847pub struct KillEaterScore(pub u32);
848
849impl Attributes for KillEaterScore {
850    const DEFINDEX: &'static [u32] = &[
851        214,
852        294,
853        494,
854    ];
855    const USES_FLOAT_VALUE: bool = false;
856    const ATTRIBUTES: &'static [AttributeDef] = &[
857        AttributeDef {
858            defindex: 214,
859            name: "kill eater",
860            attribute_class: Some("kill_eater"),
861            description_string: None,
862            description_format: None,
863            effect_type: EffectType::Positive,
864            hidden: true,
865            stored_as_integer: true,
866        },
867        AttributeDef {
868            defindex: 294,
869            name: "kill eater 2",
870            attribute_class: Some("kill_eater_2"),
871            description_string: None,
872            description_format: None,
873            effect_type: EffectType::Positive,
874            hidden: true,
875            stored_as_integer: true,
876        },
877        AttributeDef {
878            defindex: 494,
879            name: "kill eater 3",
880            attribute_class: Some("kill_eater_3"),
881            description_string: None,
882            description_format: None,
883            effect_type: EffectType::Positive,
884            hidden: true,
885            stored_as_integer: true,
886        },
887    ];
888}
889
890/// Represents the "kill_eater_user_1", "kill_eater_user_2", and "kill_eater_user_3" attributes.
891pub struct KillEaterUserScore(pub u32);
892
893impl Attributes for KillEaterUserScore {
894    const DEFINDEX: &'static [u32] = &[
895        379,
896        381,
897        383,
898    ];
899    const USES_FLOAT_VALUE: bool = false;
900    const ATTRIBUTES: &'static [AttributeDef] = &[
901        AttributeDef {
902            defindex: 379,
903            name: "kill eater user 1",
904            attribute_class: Some("kill_eater_user_1"),
905            description_string: None,
906            description_format: None,
907            effect_type: EffectType::Positive,
908            hidden: true,
909            stored_as_integer: true,
910        },
911        AttributeDef {
912            defindex: 381,
913            name: "kill eater user 2",
914            attribute_class: Some("kill_eater_user_2"),
915            description_string: None,
916            description_format: None,
917            effect_type: EffectType::Positive,
918            hidden: true,
919            stored_as_integer: true,
920        },
921        AttributeDef {
922            defindex: 383,
923            name: "kill eater user 3",
924            attribute_class: Some("kill_eater_user_3"),
925            description_string: None,
926            description_format: None,
927            effect_type: EffectType::Positive,
928            hidden: true,
929            stored_as_integer: true,
930        },
931    ];
932}
933
934#[cfg(test)]
935mod tests {
936    use super::*;
937    
938    #[test]
939    fn uses_correct_value() {
940        assert!(SeriesNumber::from(1u32).attribute_float_value().is_some());
941        assert_eq!(SeriesNumber::from(1u32).attribute_float_value().unwrap(), 1.0);
942        assert!(SupplyCrateSeries::from(42u32).attribute_float_value().is_some());
943        assert_eq!(SupplyCrateSeries::from(42u32).attribute_float_value().unwrap(), 42.0);
944        assert_eq!(KillEater::from(123u32).attribute_value(), AttributeValue::from(123u32));
945        assert_eq!(CustomNameAttr::from("TestName").attribute_value(), AttributeValue::from("TestName"));
946    }
947    
948    #[test]
949    fn equals() {
950        assert_eq!(SupplyCrateSeries::from(1u32), SupplyCrateSeries::from(1u32));
951        assert_eq!(*SupplyCrateSeries::from(1u32).deref(), 1u32);
952    }
953    
954    #[test]
955    fn gets_attribute_values() {
956        let series_number = SeriesNumber::from(2u32);
957        let series_number_value_float = series_number.attribute_float_value().unwrap();
958        let series_number_value = series_number.attribute_value();
959        
960        assert_eq!(series_number_value_float, 2.0);
961        assert_eq!(series_number_value, AttributeValue::from(series_number_value_float.to_bits()));
962    }
963}