This repository has been archived by the owner on Jan 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* RTC messaging bugfix
- Loading branch information
Showing
7 changed files
with
206 additions
and
92 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -1,60 +1,61 @@ | ||
const GameLogic = function(){ | ||
var balance = 0 | ||
var history = [] | ||
|
||
var setBalance = function(deposit){ | ||
balance = deposit*1 | ||
return balance | ||
} | ||
|
||
var getBalance = function(){ | ||
return balance | ||
} | ||
window.MyDApp = (function(){ | ||
|
||
var Roll = function(user_bet, user_num, random_hash){ | ||
let profit = -user_bet | ||
|
||
const random_num = DCLib.Utils.bigInt(random_hash,16).divmod(65536).remainder.value | ||
|
||
if (user_num > random_num) { | ||
profit = (user_bet * (65536 - 1310) / user_num) - user_bet | ||
} | ||
if (user_num == random_num) { | ||
profit = user_bet | ||
} | ||
|
||
balance += profit*1 | ||
const GameLogic = function(){ | ||
var balance = 0 | ||
var history = [] | ||
|
||
const roll_item = { | ||
timestamp : new Date().getTime(), | ||
user_bet : user_bet, | ||
profit : profit, | ||
user_num : user_num, | ||
balance : balance, | ||
random_hash : random_hash, | ||
random_num : random_num, | ||
var setBalance = function(deposit){ | ||
balance = deposit*1 | ||
return balance | ||
} | ||
|
||
history.push(roll_item) | ||
var getBalance = function(){ | ||
return balance | ||
} | ||
|
||
return roll_item | ||
} | ||
var Roll = function(user_bet, user_num, random_hash){ | ||
let profit = -user_bet | ||
|
||
const random_num = DCLib.Utils.bigInt(random_hash,16).divmod(65536).remainder.value | ||
|
||
if (user_num > random_num) { | ||
profit = (user_bet * (65536 - 1310) / user_num) - user_bet | ||
} | ||
if (user_num == random_num) { | ||
profit = user_bet | ||
} | ||
|
||
balance += profit*1 | ||
|
||
const roll_item = { | ||
timestamp : new Date().getTime(), | ||
user_bet : user_bet, | ||
profit : profit, | ||
user_num : user_num, | ||
balance : balance, | ||
random_hash : random_hash, | ||
random_num : random_num, | ||
} | ||
|
||
history.push(roll_item) | ||
|
||
return roll_item | ||
} | ||
|
||
return { | ||
setBalance: setBalance, | ||
getBalance: getBalance, | ||
roll: Roll, | ||
history: history, | ||
return { | ||
setBalance: setBalance, | ||
getBalance: getBalance, | ||
roll: Roll, | ||
history: history, | ||
} | ||
} | ||
} | ||
|
||
window.MyDApp = new DCLib.DApp({ | ||
code : 'dicegame_v2', | ||
logic : GameLogic, | ||
}) | ||
|
||
|
||
console.log('Use console to see what inside MyDApp object') | ||
console.log('MyDApp', MyDApp) | ||
|
||
return new DCLib.DApp({ | ||
code : 'dicegame_v2', | ||
logic : GameLogic, | ||
}) | ||
|
||
})() |
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,58 @@ | ||
window.MyDApp2 = (function(){ | ||
|
||
return new DCLib.DApp({ | ||
code : 'test_v2', | ||
|
||
logic : function(){ | ||
var balance = 0 | ||
var history = [] | ||
|
||
var setBalance = function(deposit){ | ||
balance = deposit*1 | ||
return balance | ||
} | ||
|
||
var getBalance = function(){ | ||
return balance | ||
} | ||
|
||
var Roll = function(user_bet, user_num, random_hash){ | ||
let profit = -user_bet | ||
|
||
const random_num = DCLib.Utils.bigInt(random_hash,16).divmod(65536).remainder.value | ||
|
||
if (user_num > random_num) { | ||
profit = (user_bet * (65536 - 1310) / user_num) - user_bet | ||
} | ||
if (user_num == random_num) { | ||
profit = user_bet | ||
} | ||
|
||
balance += profit*1 | ||
|
||
const roll_item = { | ||
user_bet : user_bet, | ||
profit : profit, | ||
user_num : user_num, | ||
balance : balance, | ||
random_hash : random_hash, | ||
random_num : random_num, | ||
} | ||
|
||
history.push(roll_item) | ||
|
||
return roll_item | ||
} | ||
|
||
return { | ||
setBalance: setBalance, | ||
getBalance: getBalance, | ||
roll: Roll, | ||
} | ||
} | ||
}) | ||
|
||
})() | ||
|
||
|
||
|
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,8 @@ | ||
{ | ||
"name" : "TestDapp2", | ||
"code" : "testdapp_v2", | ||
|
||
"run" : { | ||
"client" : "client.js" | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.