strange-labs-uk / ethereum-raffle

Simple raffle style lottery DApp
7 stars 2 forks source link

Create mechanism whereby the draw doesn't start until it has at least x players #18

Closed px3l closed 6 years ago

px3l commented 6 years ago

To avoid:

  1. Losing money deploying useless contracts
  2. The (amusing) scenario where there is 1 player or something who will lose 10% of their money but be the guaranteed winner
brtkwr commented 6 years ago

maybe greater than 1? then at least you end up with more than where you started?

binocarlos commented 6 years ago

So it sounds like we need to:

Then - on each call to play - it says are there enough players now - if yes and game has not started - set gameStarted to current block timestamp and gameWillEnd to gameStarted + gamePeriod

We probably need another var called gameActive so the various require statements in canPlayGame still work with regard to the game being active but the time period not technically started.

brtkwr commented 6 years ago

Ofcourse, player at index minPlayer will need to pay for a couple of lines of extra computational cost!

On 22 Mar 2018, at 12:06, Kai Davenport notifications@github.com wrote:

So it sounds like we need to:

have a parameter of a game called minPlayers merge the startGame and endGame absolute timestamps into a gamePeriod single, relative timestamp Then - on each call to play - it says are there enough players now - if yes and game has not started - set gameStarted to current block timestamp and gameWillEnd to gameStarted + gamePeriod

We probably need another var called gameActive so the various require statements in canPlayGame still work with regard to the game being active but the time period not technically started.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/strange-labs-uk/ethereum-raffle/issues/18#issuecomment-375281346, or mute the thread https://github.com/notifications/unsubscribe-auth/ACFJMv9TF9HvoYdxaeKNxu1_QOdF_bkzks5tg5PCgaJpZM4S2qJl.

binocarlos commented 6 years ago

New proposal - have a minPlayers variable as part of the contract - if the endTime comes and there are < X players - trigger the refundAll function