pub fn roll_dice(&mut self, target: u8) -> HumanReadableDiceResult {

        // check called by real user NOT from other contracts
        let account_id = env::predecessor_account_id();
        assert_eq!(
            account_id.clone(),
            env::signer_account_id(),
            "This method must be called directly from user."
        );

        // check user has at least one dice remain
        let balance = self.accounts.get(&account_id).unwrap_or(0);
        assert!(
            balance / self.rolling_fee >= 1,
            "You must at least have one dice to play"
        );

        // update account dice
        let leftover = balance - self.rolling_fee;
        if leftover == 0 {
            self.accounts.remove(&account_id);
        } else {
            self.accounts.insert(&account_id, &leftover);
        }
        // always update jack_pod before rolling dice
        self.jack_pod += self.rolling_fee;

        // rolling dice here
        let random_u8: u8 = env::random_seed().iter().fold(0_u8, |acc, x| acc.wrapping_add(*x));
        let dice_point = self.dice_number as u16 * 6_u16 * random_u8 as u16 / 0x100_u16 + 1;

        let mut result = HumanReadableDiceResult {
            user: account_id.clone(),
            user_guess: target,
            dice_point: dice_point as u8,
            reward_amount: 0.into(),  // if win, need update
            jackpod_left: self.jack_pod.into(),  // if win, need update
            height: env::block_index().into(),
            ts: env::block_timestamp().into(),
        };

        // let's see how lucky caller is this time
        if target == dice_point as u8 {  // Wow, he wins
            // figure out gross reward and update jack pod
            let gross_reward = self.jack_pod / 2;
            self.jack_pod -= gross_reward;
            // split gross to net and owner fee
            let owners_fee = self.reward_fee_fraction.multiply(gross_reward);
            result.reward_amount = (gross_reward - owners_fee).into();
            result.jackpod_left = self.jack_pod.into();
            // update owner pod
            self.owner_pod += owners_fee;
            // records this winning
            self.win_history.push(&WinnerInfo {
                user: account_id.clone(),
                amount: gross_reward - owners_fee,
                height: env::block_index(),
                ts: env::block_timestamp(),
            });
        }

        result
    }
/// rolling dice
/// check the deposit is larger than rolling_fee NEAR, and return leftover back to caller at end of call,
/// add rolling_fee NEAR to jackpod and get random number between [1, self.dice_number * 6],
/// if identical to target, modify jackpod amount and transfer half of jackpod to caller (within a tip to the owner_pod)
rolling dice
check the deposit is larger than rolling_fee NEAR, and return leftover back to caller at end of call,
add rolling_fee NEAR to jackpod and get random number between [1, self.dice_number * 6],
if identical to target, modify jackpod amount and transfer half of jackpod to caller (within a tip to the owner_pod)
rolling dice check the deposit is larger than rolling_fee NEAR and return leftover back to caller at end of call add rolling_fee NEAR to jackpod and get random number between [ 1 self . dice_number * 6 ] if identical to target modify jackpod amount and transfer half of jackpod to caller ( within a tip to the owner_pod )
pub fn roll_dice(&mut self, target: u8) -> HumanReadableDiceResult {
        // check called by real user NOT from other contracts
        let account_id = env::predecessor_account_id();
        assert_eq!(
            account_id.clone(),
            env::signer_account_id(),
            "This method must be called directly from user."
        );
        // check user has at least one dice remain
        let balance = self.accounts.get(&account_id).unwrap_or(0);
        assert!(
            balance / self.rolling_fee >= 1,
            "You must at least have one dice to play"
        );
        // update account dice
        let leftover = balance - self.rolling_fee;
        if leftover == 0 {
            self.accounts.remove(&account_id);
        } else {
            self.accounts.insert(&account_id, &leftover);
        }
        // always update jack_pod before rolling dice
        self.jack_pod += self.rolling_fee;
        // rolling dice here
        let random_u8: u8 = env::random_seed().iter().fold(0_u8, |acc, x| acc.wrapping_add(*x));
        let dice_point = self.dice_number as u16 * 6_u16 * random_u8 as u16 / 0x100_u16 + 1;
        let mut result = HumanReadableDiceResult {
            user: account_id.clone(),
            user_guess: target,
            dice_point: dice_point as u8,
            reward_amount: 0.into(),  // if win, need update
            jackpod_left: self.jack_pod.into(),  // if win, need update
            height: env::block_index().into(),
            ts: env::block_timestamp().into(),
        };
        // let's see how lucky caller is this time
        if target == dice_point as u8 {  // Wow, he wins
            // figure out gross reward and update jack pod
            let gross_reward = self.jack_pod / 2;
            self.jack_pod -= gross_reward;
            // split gross to net and owner fee
            let owners_fee = self.reward_fee_fraction.multiply(gross_reward);
            result.reward_amount = (gross_reward - owners_fee).into();
            result.jackpod_left = self.jack_pod.into();
            // update owner pod
            self.owner_pod += owners_fee;
            // records this winning
            self.win_history.push(&WinnerInfo {
                user: account_id.clone(),
                amount: gross_reward - owners_fee,
                height: env::block_index(),
                ts: env::block_timestamp(),
            });
        }
        result
    }
pub fn roll_dice ( & mut self , target : u8 ) -> HumanReadableDiceResult { // check called by real user NOT from other contracts let account_id = env :: predecessor_account_id ( ) ; assert_eq ! ( account_id clone ( ) env signer_account_id ( ) " " ) ; // check user has at least one dice remain let balance = self . accounts . get ( & account_id ) . unwrap_or ( 0 ) ; assert ! ( balance self rolling_fee 1 " " ) ; // update account dice let leftover = balance - self . rolling_fee ; if leftover == 0 { self . accounts . remove ( & account_id ) ; } else { self . accounts . insert ( & account_id , & leftover ) ; } // always update jack_pod before rolling dice self . jack_pod += self . rolling_fee ; // rolling dice here let random_u8 : u8 = env :: random_seed ( ) . iter ( ) . fold ( 0_u8 , | acc , x | acc . wrapping_add ( * x ) ) ; let dice_point = self . dice_number as u16 * 6_u16 * random_u8 as u16 / 0x100_u16 + 1 ; let mut result = HumanReadableDiceResult { user : account_id . clone ( ) , user_guess : target , dice_point : dice_point as u8 , reward_amount : 0 . into ( ) , // if win, need update jackpod_left : self . jack_pod . into ( ) , // if win, need update height : env :: block_index ( ) . into ( ) , ts : env :: block_timestamp ( ) . into ( ) , } ; // let's see how lucky caller is this time if target == dice_point as u8 { // Wow, he wins // figure out gross reward and update jack pod let gross_reward = self . jack_pod / 2 ; self . jack_pod -= gross_reward ; // split gross to net and owner fee let owners_fee = self . reward_fee_fraction . multiply ( gross_reward ) ; result . reward_amount = ( gross_reward - owners_fee ) . into ( ) ; result . jackpod_left = self . jack_pod . into ( ) ; // update owner pod self . owner_pod += owners_fee ; // records this winning self . win_history . push ( & WinnerInfo { user : account_id . clone ( ) , amount : gross_reward - owners_fee , height : env :: block_index ( ) , ts : env :: block_timestamp ( ) , } ) ; } result }
rolling dice
check the deposit is larger than rolling_fee NEAR, and return leftover back to caller at end of call,
add rolling_fee NEAR to jackpod and get random number between [1, self.dice_number * 6],
if identical to target, modify jackpod amount and transfer half of jackpod to caller (within a tip to the owner_pod)
rolling dice check the deposit is larger than rolling_fee NEAR and return leftover back to caller at end of call add rolling_fee NEAR to jackpod and get random number between [ 1 self . dice_number * 6 ] if identical to target modify jackpod amount and transfer half of jackpod to caller ( within a tip to the owner_pod )
&mut self
target
u8