forked from GrugLikesRocks/Blob-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.cairo
114 lines (107 loc) · 4.02 KB
/
background.cairo
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
use blob_arena::components::stats::{Stats, StatsTrait};
const BACKGROUND_COUNT: u8 = 12;
#[derive(Copy, Drop, Print, Serde, SerdeLen, Introspect)]
enum Background {
AvnuBlue,
Blue,
CryptsAndCaverns,
FibrousFrame,
Green,
Holo,
Orange,
Purple,
RealmsDark,
Realms,
Terraforms,
Tulip,
}
impl BackgroundImpl of StatsTrait<Background> {
fn stats(self: Background) -> Stats {
match self {
Background::AvnuBlue => Stats { attack: 4, defense: 2, speed: 0, strength: 0, },
Background::Blue => Stats { attack: 2, defense: 2, speed: 0, strength: 0, },
Background::CryptsAndCaverns => Stats { attack: 2, defense: 5, speed: 0, strength: 0, },
Background::FibrousFrame => Stats { attack: 5, defense: 2, speed: 0, strength: 0, },
Background::Green => Stats { attack: 1, defense: 1, speed: 0, strength: 0, },
Background::Holo => Stats { attack: 5, defense: 5, speed: 0, strength: 0, },
Background::Orange => Stats { attack: 3, defense: 3, speed: 0, strength: 0, },
Background::Purple => Stats { attack: 4, defense: 4, speed: 0, strength: 0, },
Background::RealmsDark => Stats { attack: 4, defense: 5, speed: 0, strength: 0, },
Background::Realms => Stats { attack: 5, defense: 4, speed: 0, strength: 0, },
Background::Terraforms => Stats { attack: 5, defense: 5, speed: 0, strength: 0, },
Background::Tulip => Stats { attack: 3, defense: 5, speed: 0, strength: 0, },
}
}
fn index(self: Background) -> u8 {
match self {
Background::AvnuBlue => 0,
Background::Blue => 1,
Background::CryptsAndCaverns => 2,
Background::FibrousFrame => 3,
Background::Green => 4,
Background::Holo => 5,
Background::Orange => 6,
Background::Purple => 7,
Background::RealmsDark => 8,
Background::Realms => 9,
Background::Terraforms => 10,
Background::Tulip => 11,
}
}
}
impl U8IntoBackground of Into<u8, Background> {
fn into(self: u8) -> Background {
match self {
0 => Background::AvnuBlue,
1 => Background::Blue,
2 => Background::CryptsAndCaverns,
3 => Background::FibrousFrame,
4 => Background::Green,
5 => Background::Holo,
6 => Background::Orange,
7 => Background::Purple,
8 => Background::RealmsDark,
9 => Background::Realms,
10 => Background::Terraforms,
11 => Background::Tulip,
_ => panic!("wrong background index")
}
}
}
impl SU8IntoBackground of Into<@u8, Background> {
fn into(self: @u8) -> Background {
match *self {
0 => Background::AvnuBlue,
1 => Background::Blue,
2 => Background::CryptsAndCaverns,
3 => Background::FibrousFrame,
4 => Background::Green,
5 => Background::Holo,
6 => Background::Orange,
7 => Background::Purple,
8 => Background::RealmsDark,
9 => Background::Realms,
10 => Background::Terraforms,
11 => Background::Tulip,
_ => panic!("wrong background index")
}
}
}
impl BackgroundIntoByteArray of Into<Background, ByteArray> {
fn into(self: Background) -> ByteArray {
match self {
Background::AvnuBlue => "AvnuBlue",
Background::Blue => "Blue",
Background::CryptsAndCaverns => "CryptsAndCaverns",
Background::FibrousFrame => "FibrousFrame",
Background::Green => "Green",
Background::Holo => "Holo",
Background::Orange => "Orange",
Background::Purple => "Purple",
Background::RealmsDark => "RealmsDark",
Background::Realms => "Realms",
Background::Terraforms => "Terraforms",
Background::Tulip => "Tulip",
}
}
}