-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed crypto-kitties dependency from crypto-zombies
- Loading branch information
1 parent
ebd0826
commit df58c72
Showing
7 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use multiversx_sc::derive_imports::*; | ||
|
||
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] | ||
pub struct Kitty { | ||
pub genes: KittyGenes, | ||
pub birth_time: u64, // timestamp | ||
pub cooldown_end: u64, // timestamp, used for pregnancy timer and siring cooldown | ||
pub matron_id: u32, | ||
pub sire_id: u32, | ||
pub siring_with_id: u32, // for pregnant cats, 0 otherwise | ||
pub nr_children: u16, // cooldown period increases exponentially with every breeding/siring | ||
pub generation: u16, // max(sire_gen, matron_gen) + 1. Generation also influences cooldown. | ||
} | ||
|
||
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] | ||
pub struct KittyGenes { | ||
pub fur_color: Color, | ||
pub eye_color: Color, | ||
pub meow_power: u8, // the higher the value, the louder the cat | ||
} | ||
|
||
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, TypeAbi)] | ||
pub struct Color { | ||
pub r: u8, | ||
pub g: u8, | ||
pub b: u8, | ||
} | ||
|
||
impl KittyGenes { | ||
pub fn get_as_u64(&self) -> u64 { | ||
(self.fur_color.as_u64() << 12 | self.eye_color.as_u64()) << 4 | ||
| self.meow_power.to_be() as u64 | ||
} | ||
} | ||
|
||
impl Color { | ||
pub fn as_u64(&self) -> u64 { | ||
((self.r.to_be() as u64) << 4 | self.r.to_be() as u64) << 4 | self.r.to_be() as u64 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters