新DAPP《翻纸牌》申请上线



  • 1.游戏名称: 翻纸牌
    纸牌为传统的方块纸牌,玩家可以单押注纸牌大小(A~10)也可以单押四种花色(黑桃,红桃,梅花,方块),或者大小和花色的组合,与智能合约随机开出的纸牌进行大小和花色的比较。

    游戏规则:
    纸牌规定大小为A到10,花色为黑桃,红桃,梅花,方块,共四十张牌。大小选项为(小数A~5,大数6~10或者全选),花色选项为四种花色(可复选)。玩家可以:
    1.) 单压花色:勾选大小押注选项里的“全选”,即为单押花色,只要与智能合约开出的纸牌的花色相符即可。
    2.) 或者单压大小:玩家可以勾选花色押注选项里的“全选”,对大数小数进行押注。
    3.) 或者大小和花色的组合。
    最终的中奖概率计算为大小和花色概率相乘(当前押注组合的获奖概率及回报VITE数量会实时显示在界面中),例如:
    若单压花色,选中一种花色并且最终与开牌相符,则概率为25%,回报VITE数额为押注的四倍减掉手续费。
    若单压大小,选中小数和大数的概率各50%,回报为押注的两倍减掉手续费。
    若同时押注大小和花色的组合:则概率为两者相乘,总回报率同样为两者回报率相乘。

    2.押注金额:1~50VITE,单位为整数。

    3.上线状态:否

    4.dApp的合约地址:vite_8d5c6404d0fc2a5c2a2df0ea87c15242dfb89e734f4d805d0b,合约源代码已开源,地址:https://explorer.vite.net/account/vite_8d5c6404d0fc2a5c2a2df0ea87c15242dfb89e734f4d805d0b

    5.合约代码如下:

    contract ViteBet{
        address owner;
        tokenId token = "tti_5649544520544f4b454e6e40";
    
        event win(address indexed addr, uint256 rollTargets, uint256 suitTargets, uint256 betAmount, uint64 rollNum, uint64 suitNum, uint256 winAmount);
        event lose(address indexed addr, uint256 rollTargets, uint256 suitTargets, uint256 betAmount, uint64 rollNum, uint64 suitNum);
        event suspendBet(address indexed addr, uint256 rollTargets, uint256 suitTargets, uint256 betAmount, uint64 rollNum, uint64 suitNum);
    
        constructor() public {
            owner = msg.sender;
        }
    
        onMessage () payable {
        }
    
        onMessage DrawMoney(uint256 amount) {
            require(owner == msg.sender);
            require(amount <= balance(token));
            msg.sender.transfer(token, amount);
        }
    
        onMessage BetAndRoll(uint256 rollTargets, uint256 suitTargets) payable {
            uint256 betAmount = msg.amount;
            address betAddr = msg.sender;
            require(msg.tokenid == token);
            require(betAmount >= 1 vite && betAmount <= 1000 vite);
            require(rollTargets >= 1 && rollTargets <= 3); //  1 2 3
            require(suitTargets >= 4 && suitTargets < 10000); //4567
    
            uint64 rollNum = nextrandom() % 10 + 1; //rollNum 1 2 3 4 5 6 7 8 9 10
            uint64 suitNum = nextrandom() % 4 + 4;  //suitNum 4 5 6 7 
    
            bool winBet = false;
            bool winNum = false;
            bool winSuit = false;
            uint64 count = 0;
            
            if((rollNum<=5 && rollTargets==1) || 
               (rollNum>=6 && rollTargets==2) ||
               (rollTargets==3))
               {
                   winNum = true;
               }
    
            uint256 tempSuitTargets = suitTargets;
            while(tempSuitTargets % 10 > 0) {
                count++;
                uint64 suitTarget = uint64(tempSuitTargets % 10);
                require(suitTarget >= 4 && suitTarget <= 7);
                if(suitTarget == suitNum) {
                    winSuit = true;
                }
                tempSuitTargets = tempSuitTargets / 10;
            }
    
            if (winNum == true && winSuit == true)
            {
                winBet = true;
            }
    
            uint256 winAmount = calcWinAmount(betAmount, rollTargets, count);
            if(winBet == false) {
                betAddr.transfer(token, 0);
                emit lose(betAddr, rollTargets, suitTargets, betAmount, rollNum, suitNum);
            } else if(winBet == true && winAmount > balance(token)) {
                betAddr.transfer(token, betAmount);
                emit suspendBet(betAddr, rollTargets, suitTargets, betAmount, rollNum, suitNum);
            } else {
                betAddr.transfer(token, winAmount);
                emit win(betAddr, rollTargets, suitTargets, betAmount, rollNum, suitNum, winAmount);
            }
        }
    
        function calcWinAmount(uint256 betAmount, uint256 rollTargets, uint256 length) public pure returns(uint256) {
            uint256 bonus;
            if ( rollTargets == 1 || rollTargets == 2)
            {
                // betAmount * 4/length * 2
                bonus = betAmount * 8 / length;  
            }
            else  
            { 
                // rolltargets == 3
                bonus = betAmount * 4 / length;
            }
            
            return betAmount + (bonus - betAmount) * 95 / 100;
        }
    }
    

  • Reward

    nice bro ✊



  • Thanks dear friend!


Log in to reply
 

Suggested Topics