Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
Merge pull request #44 from DaoCasino/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
alexstep committed Dec 5, 2017
2 parents fe06ffb + 5c4d948 commit ec6a281
Show file tree
Hide file tree
Showing 19 changed files with 343 additions and 214 deletions.
1 change: 1 addition & 0 deletions DApps/FindTheEthereum
Submodule FindTheEthereum added at a944ed
9 changes: 3 additions & 6 deletions DApps/dicedapp_v2/bankroller.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@

//(function(){
window.MyDApp_debug = (function(){
var myDApp = new DCLib.DApp({code : 'dicedapp_v2'})
window.MultDApp = (function(){
let DApp = new DCLib.DApp({slug : 'dicegame_v3'})

// Banroller side code
// console.log(myDApp)

return myDApp
return DApp
})()

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "DiceDAppExample2",
"code" : "dicedapp_v2",
"name" : "Dice Game v.2",
"slug" : "dicegame_v3",

"index" : "./index.html",
"logic" : "./dapp_logic.js",
Expand Down
4 changes: 2 additions & 2 deletions DApps/dicedapp_v2/dapp_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Define our DApp logic constructor,
* for use it in frontend and bankroller side
*/
DCLib.defineDAppLogic('dicedapp_v2', function(){
DCLib.defineDAppLogic('dicegame_v3', function(){
const _self = this

const MAX_RAND_NUM = 65536
Expand All @@ -12,7 +12,7 @@ DCLib.defineDAppLogic('dicedapp_v2', function(){

var Roll = function(user_bet, user_num, random_hash){
// convert 1BET to 100000000
user_bet = DCLib.Utils.bet4dec(user_bet)
user_bet = DCLib.Utils.bet2dec(user_bet)

// generate random number
const random_num = DCLib.numFromHash(random_hash, 0, 65536)
Expand Down
13 changes: 7 additions & 6 deletions DApps/dicedapp_v2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// Create our DApp
DCLib.on('ready', function(){
window.MyDApp = new DCLib.DApp({code :'dicedapp_v2'})
window.MyDApp = new DCLib.DApp({slug : 'dicegame_v3'})
})


Expand All @@ -43,15 +43,16 @@

function startGame(deposit){
MyDApp.connect({
bankroller : 'auto',
paychannel : { deposit : deposit }
bankroller : '0x146c5e3b9395738eb67feceb5e37cd5a56d63342',
paychannel : { deposit : deposit } ,
gamedata : {type:'uint', value: [0, 0, 0]}
},
function(connected, info){
console.log('connect result:', connected)
console.log('connect info:', info)
if (!connected) return

let maxbet = DCLib.Utils.bet2dec( info.channel.player_deposit )
let maxbet = DCLib.Utils.dec2bet( info.channel.player_deposit )

$('#user_bet')[0].max = Math.ceil( maxbet )
$('#user_bet').val( (maxbet*0.1).toFixed(2) )
Expand Down Expand Up @@ -198,7 +199,7 @@ <h3>1. Open game-channel</h3>
<form>
<label>
Set game deposit:
<input id="user_deposit" type="number" value="1.1" min="0" max="4" step="0.1">
<input id="user_deposit" type="number" value="1.1" min="0" max="4" step="0.001">
</label>
<input type="submit" value="Set">
</form>
Expand All @@ -212,7 +213,7 @@ <h3>1. Open game-channel</h3>
<h3>2. Play</h3>
<label>
your bet:
<input id="user_bet" type="number" value="1" min="0" max="4" step="0.1">
<input id="user_bet" type="number" value="1" min="0" max="4" step="0.001">
</label>
<label>
your num:
Expand Down
2 changes: 1 addition & 1 deletion DApps/dicedapp_v2/lib/DC.js

Large diffs are not rendered by default.

Binary file modified DApps/example.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BankRollerApp",
"version": "0.2.3",
"version": "0.2.6",
"description": "Dao.Casino app for bankroller",
"author": "Dao Casino <team@dao.casino>",
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions public/index.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const url = require('url')
require('electron-debug')({
enabled: true ,
showDevTools: false ,
});
})


// Check updates
Expand Down Expand Up @@ -87,9 +87,9 @@ function createWindow () {
const trayIcon = new Tray(path.join(__dirname, 'static/icons/icon-38.png'))
trayIcon.setToolTip('Dao.Casino')
trayIcon.setContextMenu(Menu.buildFromTemplate([
// { label: 'Show App', click:() => {
// mainWindow.show()
// } },
{ label: 'Show Dev Tools', click:() => {
mainWindow.webContents.openDevTools()
} },
{ label: 'Quit', click:() => {
app.isQuiting = true
app.quit()
Expand Down
2 changes: 0 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
<meta name="format-detection" content="address=no"/>

%META_INFORMATION%

<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.20.19/system-production.js" type="text/javascript"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app</noscript>
Expand Down
26 changes: 15 additions & 11 deletions public/server.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,21 @@ const DApps = {
})
},

readManifest: function(path){
try {
let dapp_config = JSON.parse(fs.readFileSync(path))
if (typeof dapp_config.run !== 'object') {
let str = ''+dapp_config.run
dapp_config.run = {client:str}
readManifest: function(file_path){
const tryReadFile = (path)=>{
try {
let dapp_config = JSON.parse(fs.readFileSync(path))
if (typeof dapp_config.run !== 'object') {
let str = ''+dapp_config.run
dapp_config.run = {client:str}
}
return dapp_config
} catch(e){
return false
}
return dapp_config
} catch(e){
return false
}

return tryReadFile(file_path) || tryReadFile(file_path+'.json')
},

upload: function(data, callback){
Expand Down Expand Up @@ -153,10 +157,10 @@ const DApps = {

fse.copySync(
cp_from,
dapps_path + dapp_config.code
dapps_path + dapp_config.slug
)

this.init([dapp_config.code], callback )
this.init([dapp_config.slug], callback )
},

remove: function(key, callback){
Expand Down
8 changes: 4 additions & 4 deletions src/index.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const url = require('url')
require('electron-debug')({
enabled: true ,
showDevTools: false ,
});
})


// Check updates
Expand Down Expand Up @@ -87,9 +87,9 @@ function createWindow () {
const trayIcon = new Tray(path.join(__dirname, 'static/icons/icon-38.png'))
trayIcon.setToolTip('Dao.Casino')
trayIcon.setContextMenu(Menu.buildFromTemplate([
// { label: 'Show App', click:() => {
// mainWindow.show()
// } },
{ label: 'Show Dev Tools', click:() => {
mainWindow.webContents.openDevTools()
} },
{ label: 'Quit', click:() => {
app.isQuiting = true
app.quit()
Expand Down
Loading

0 comments on commit ec6a281

Please sign in to comment.