コード例 #1
0
        public Bet(UserDataManager manager, Match match, POCO.BetPoco poco)
        {
            Id = poco._id;
            MyMatch = match;
            MatchHash = poco.match_hash;
            UserContext = manager.User;

            SetOutcome(poco.outcome);

            if (match != null)
            {
                if (match.Player1 != null && poco.offerer_choice_id == match.Player1.Id)
                {
                    OffererChoice = match.Player1;
                    TakerChoice = match.Player2;
                }
                else
                {
                    OffererChoice = match.Player2;
                    TakerChoice = match.Player1;
                }
            }

            var offerer = new POCO.UserBase { _id = poco.offerer_id, username = poco.offerer_username };
            Offerer = manager.GetPgUser(offerer);
            OffererOdds = poco.offerer_odds;
            OffererWager = poco.offerer_wager;

            var taker = new POCO.UserBase { _id = poco.taker_id, username = poco.taker_username };
            if (!string.IsNullOrWhiteSpace(taker._id))
                Taker = manager.GetPgUser(taker);
        }
コード例 #2
0
        private static IBetOperand GetBetOperand(UserDataManager manager, string type, string id, string name)
        {
            if (id == null) return null;

            IBetOperand player = null;
            if (type == "Team")
            {
                player = manager.GetPgTeam(new POCO.TeamBase { _id = id, name = name });
            }
            else if (type == "User")
            {
                player = manager.GetPgUser(new POCO.UserBase { _id = id, username = name });
            }
            else
                throw new Exception("Player type " + type + " not recognized.");
            return player;
        }