โ๏ธFairness
Card Flip SC Code:
let mut rand_source = RandomnessSource::<Self::Api>::new();
// Calculate a random number between 1 - 200 (x2), 1 - 300 (x3) and 1 - 400 (x4)
let random_result = rand_source.next_u16_in_range(1, game_mode * 100 + 1);
// The actual card is the rest from division + 1 since selected_card starts from 1
let result = (random_result % game_mode + 1) as u8;
// Caller LOST...
if selected_card != result {
self.distribute_tokens(collection, &token, &amount, false);
return ( ManagedBuffer::from(b"unlucky"), result ).into();
}
// Caller WON!
let multiplier = BigUint::from(game_mode as u32);
let amount_won = &amount * &multiplier;RPS SC Code:
Battle Arena SC Code:
Last updated
Was this helpful?