Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Betting #2

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
820a47e
added last betting ops
MKashevsky Oct 18, 2018
16cbbc8
changed structure for operationids;
MKashevsky Oct 19, 2018
8f8ba55
added development_committee_empower_betting_moderator serialization
MKashevsky Oct 19, 2018
684724a
added development_committee_change_betting_resolve_delay serialization
MKashevsky Oct 19, 2018
8205e7b
updated imports in test_serialization.py
MKashevsky Oct 19, 2018
e2440cf
updated market and create_game serialization
MKashevsky Oct 19, 2018
2fea19c
betting tests moved to test_betting.py
MKashevsky Oct 19, 2018
9fa85e2
added cancel_gamr serialization tests
MKashevsky Oct 19, 2018
5f58858
added update_game_start_time serialization tests
MKashevsky Oct 19, 2018
b104ad5
added update_game_markets serialization
MKashevsky Oct 19, 2018
c33619a
added wincase related structures and tests
MKashevsky Oct 22, 2018
7711324
unified wincase and market structure
MKashevsky Oct 22, 2018
adf4b09
added test to check post_game_results_operation serialization
MKashevsky Oct 22, 2018
f689b63
added test to check post_bet_operation
MKashevsky Oct 23, 2018
538018e
added test to check cancel_pending_bets_operation
MKashevsky Oct 23, 2018
708f74d
changed version to 0.1.0
MKashevsky Oct 23, 2018
0389bf8
changed Game from Enum to StaticVariant;
MKashevsky Oct 24, 2018
899d57e
updated Odds16 serialization to json;
MKashevsky Oct 24, 2018
42f80dd
fixinf pipenv installation
alexplevako Oct 29, 2018
8875f36
fixed bug in post_game_results json creation
MKashevsky Oct 29, 2018
0151176
revert Pipfile and Pipfile.lock
alexplevako Oct 29, 2018
8c7e3a4
for create_game_operation changed name parameter to json_metadata
MKashevsky Oct 30, 2018
8d35181
changed odds type int16 -> int32
MKashevsky Nov 6, 2018
1a5c307
added delegate_sp_from_reg_pool_operation
MKashevsky Nov 7, 2018
939543c
added account_update_operation serialization
MKashevsky Nov 21, 2018
4e918a2
added function to create Wincase class form json;
MKashevsky Nov 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ pytest = "*"
pycrypto = "==2.6.1"
scrypt = "==0.8.0"
aiohttp = "*"
yarl = "*"
async-timeout = "*"
125 changes: 64 additions & 61 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion scorum/graphenebase/betting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .game import Game
from .market import Market
from .wincase import Wincase

__all__ = ["Game", "Market"]
__all__ = ["Game", "Market", "Wincase"]
26 changes: 17 additions & 9 deletions scorum/graphenebase/betting/game.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import struct
from enum import Enum
from scorum.graphenebase.objects import GrapheneObject, StaticVariantObject

GAMES = [
'soccer_game',
'hockey_game'
]

class Game(Enum):
soccer = 0
hockey = 1

def __bytes__(self):
return struct.pack("<B", self.value)
class Game(StaticVariantObject):
def __init__(self, game_type):
super().__init__(game_type, GAMES)
self.name = self.get_name(game_type) + "_game"
self.id = self.get_id(self.name)

def __str__(self):
return "{0}".format(self.name)

class Soccer(GrapheneObject):
pass


class Hockey(GrapheneObject):
pass
105 changes: 55 additions & 50 deletions scorum/graphenebase/betting/market.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,32 @@
import json
import re
from collections import OrderedDict

from scorum.graphenebase.graphene_types import Id, Uint16
from scorum.graphenebase.objects import GrapheneObject
from scorum.graphenebase.graphene_types import Int16
from scorum.graphenebase.objects import GrapheneObject, StaticVariantObject

MARKETS = [
"result_home_market",
"result_draw_market",
"result_away_market",
"round_market",
"handicap_market",
"correct_score_market",
"correct_score_parametrized_market",
"goal_market",
"total_market",
"total_goals_market",
"result_home",
"result_draw",
"result_away",
"round_home",
"handicap",
"correct_score_home",
"correct_score_draw",
"correct_score_away",
"correct_score",
"goal_home",
"goal_both",
"goal_away",
"total",
"total_goals_home",
"total_goals_away"
]


class Market:
class Market(StaticVariantObject):
def __init__(self, market_type):
self.market_type = market_type
self.name = self.get_market_name(market_type)
self.id = self.get_market_id(self.name)

@staticmethod
def get_market_id(name: str):
try:
return MARKETS.index(name)
except ValueError:
raise Exception("no such market %s" % name)

@staticmethod
def get_market_name(market_type):
""" Take a name of a class, like ResultHome and turn it into method name like result_home_market. """
class_name = type(market_type).__name__ # also store name
words = re.findall('[A-Z][^A-Z]*', class_name)

return '_'.join(map(str.lower, words)) + "_market"

def __bytes__(self):
return bytes(Id(self.id)) + bytes(self.market_type)

def __str__(self):
return json.dumps([self.name, self.market_type.toJson()])
super().__init__(market_type, MARKETS)
self.name = self.get_name(market_type)
self.id = self.get_id(self.name)


class ResultHome(GrapheneObject):
Expand All @@ -59,41 +41,64 @@ class ResultAway(GrapheneObject):
pass


class Round(GrapheneObject):
class RoundHome(GrapheneObject):
pass


class Handicap(GrapheneObject):
def __init__(self, threshold=0):
self.data = OrderedDict({"threshold": Uint16(threshold)})
self.data = OrderedDict([("threshold", Int16(threshold))])

super(Handicap, self).__init__(self.data)


class CorrectScore(GrapheneObject):
class CorrectScoreHome(GrapheneObject):
pass


class CorrectScoreDraw(GrapheneObject):
pass


class CorrectScoreAway(GrapheneObject):
pass


class CorrectScoreParametrized(GrapheneObject):
class CorrectScore(GrapheneObject):
def __init__(self, home=0, away=0):
self.data = OrderedDict({"home": Uint16(home), "away": Uint16(away)})
self.data = OrderedDict([("home", Int16(home)), ("away", Int16(away))])

super(CorrectScore, self).__init__(self.data)


super(CorrectScoreParametrized, self).__init__(self.data)
class GoalHome(GrapheneObject):
pass


class Goal(GrapheneObject):
class GoalBoth(GrapheneObject):
pass


class GoalAway(GrapheneObject):
pass


class Total(GrapheneObject):
def __init__(self, threshold=0):
self.data = OrderedDict({"threshold": Uint16(threshold)})
self.data = OrderedDict([("threshold", Int16(threshold))])

super(Total, self).__init__(self.data)


class TotalGoals(GrapheneObject):
class TotalGoalsHome(GrapheneObject):
def __init__(self, threshold=0):
self.data = OrderedDict([("threshold", Int16(threshold))])

super(TotalGoalsHome, self).__init__(self.data)


class TotalGoalsAway(GrapheneObject):
def __init__(self, threshold=0):
self.data = OrderedDict({"threshold": Uint16(threshold)})
self.data = OrderedDict([("threshold", Int16(threshold))])

super(TotalGoals, self).__init__(self.data)
super(TotalGoalsAway, self).__init__(self.data)
Loading