H
H
HusniddinEshmuhammatov2018-10-17 11:44:22
JavaScript
HusniddinEshmuhammatov, 2018-10-17 11:44:22

How to implement the logic of money in the game Durak Online?

How to implement money logic on the server in the Durak Online game using Node.js on javascipt. What is the point: for example, two players made a bet for 100 rubles, 1 player loses and his money goes to 2 player with a commission of 20% in favor of the game. That is, 2 players will have a balance of 180 rubles, and 20 will go to me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Step, 2018-10-24
@HusniddinEshmuhammatov

ummm, you wrote a fool game on the server and can't add up the money?
maybe I don't understand something, but
```
// balance - the money has already been transferred to the gaming platform - that is, the owner of the game already has it
const gameSessionPlayers = {
'id1':{balance:100},
'id2':{balance :100},
'id3':{balance:100},
}
const winner = function(winnerId){
let bank = 0
for(let playerId in gameSessionPlayers){
if (playerId===winnerId) continue
bank += gameSessionPlayers[playerId ].balance
gameSessionPlayers[playerId].balance = 0
}
// commission
bank = bank * 0.8
gameSessionPlayers[winnerId].balance += bank
}
winner('id2')
console.log(gameSessionPlayers)```

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question