private CoinFlipMatch ( int lookUpId, string roundId, string hash, string salt, string percentage, MatchStatus status, List <CoinFlipBet> bets, DateTime?timerStarted, JackpotMatchSetting setting ) { LookUpId = lookUpId; RoundId = roundId; Hash = hash; _salt = salt; _percentage = percentage; Status = status; TimerStarted = timerStarted; Setting = setting; Bets = bets; ReadableStatus = status.ToString(); }
private Match(Guid id) { Id = id; _homeTeamScorers = new Collection <string>(); _awayTeamScorers = new Collection <string>(); _status = MatchStatus.Declared; }
public void SetMatch(BookInfo matchedBook, MatchStatus status, IEnumerable <string> newTypes) { this.MatchedBook = matchedBook; this.Status = status; this.NewTypes = newTypes; this.IsSelected = (status == MatchStatus.NewBook || status == MatchStatus.NewFiles); }
public void StartMatch(ForcePlayer playerOne, ForcePlayer playerTwo) { _playerOne = playerOne; _playerTwo = playerTwo; Status = MatchStatus.inProgress; _startTime = Time.time; }
public async Task <IActionResult> Edit(int id, [Bind("Id,MatchStatusName")] MatchStatus matchStatus) { if (id != matchStatus.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(matchStatus); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MatchStatusExists(matchStatus.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(matchStatus)); }
private List <Map.Tile> RecreateTilesFromMatchStatus(MatchStatus matchStatus) { var oldTiles = FindObjectsOfType <Map.Tile>(); foreach (var tile in oldTiles) { Destroy(tile); } var tiles = new List <Map.Tile>(); foreach (var statusTile in matchStatus.Tiles) { var tile = _tileFactory.CreateTile(statusTile.TileType, statusTile.Position.x, statusTile.Position.y, statusTile.Id); if (statusTile.Uncovered) { tile.Uncover(); } if (statusTile.Digged) { tile.Dig(); } tiles.Add(tile); } return(tiles); }
private void SetUpSnapshotAndMarkets(MatchStatus status = MatchStatus.InRunning) { _snapshot = new Fixture {Id = "123", MatchStatus = ((int) status).ToString()}; _snapshot.Tags.Add("Sport", "TestFootball"); _market1 = new Mock<Market>(); _market2 = new Mock<Market>(); _market3 = new Mock<Market>(); // Initial Active Market _market1.SetupAllProperties(); _market1.Setup(m => m.Selections).Returns(GetSelections(true, false)); _market1.Object.Id = "One"; _market1.Object.AddOrUpdateTagValue("name", "One"); // Initial Inactive (pending) Market _market2.SetupAllProperties(); _market2.Setup(m => m.Selections).Returns(GetSelections(false, false)); _market2.Object.Id = "Two"; _market2.Object.AddOrUpdateTagValue("name", "Two"); // Initial Active Market _market3.SetupAllProperties(); _market3.Setup(m => m.Selections).Returns(GetSelections(true, false)); _market3.Object.Id = "Three"; _market3.Object.AddOrUpdateTagValue("name", "Three"); _snapshot.Markets.Add(_market1.Object); _snapshot.Markets.Add(_market2.Object); _snapshot.Markets.Add(_market3.Object); }
/// <summary> /// stolen bet /// </summary> /// <param name="obj">obj is MatchStatus</param> public async void OnBetStolen(object obj) { MatchStatus matchStatus = (MatchStatus)obj; try { while (true) { // get odds account var service = new Sbobet(); var resp = service.GetOdds(this.Acc, matchStatus); if (resp != null && resp.Data != null && resp.Data.Count > 0) { var matches = resp.Data; Log("bet stolen found: {0} matches", matches.Count); } // delay for next run await Task.Delay(100); } } catch (Exception ex) { Log("Bet stolen error: {0}", ex.Message); } }
public async Task UpdateStatusForMatch(DatabaseModel.CoinFlip match, MatchStatus status) { var findFilter = GetFindFilter().Where(m => m.LookUpId == match.Id); var updateFilter = GetUpdateFilter().Set(m => m.Status, (int)status); await GetCollection().UpdateOneAsync(findFilter, updateFilter); }
public async Task <KeyValuePair <bool, string> > CheckInForMatch(int userId, int matchId) { var match = await _unitOfWork.Matchdays.GetById(matchId); if (match == null) { return(new KeyValuePair <bool, string>(false, "Specified match doesn't exist!")); } var matchStatus = await _unitOfWork.MatchStatuses.GetMatchStatusById(userId, matchId); if (matchStatus != null) { return(new KeyValuePair <bool, string>(false, "You are already checked in!")); } matchStatus = new MatchStatus { UserId = userId, MatchdayId = match.Id, Matchday = match, Checked = true, Confirmed = null }; _unitOfWork.MatchStatuses.Add(matchStatus); if (await _unitOfWork.Complete()) { return(new KeyValuePair <bool, string>(true, "Successfully checked in for match!")); } return(new KeyValuePair <bool, string>(false, "Couldn't check in for match!")); }
public Response <List <MatchOdd> > GetOdds(Account account, MatchStatus oddStatus) { Response <List <MatchOdd> > res = new Response <List <MatchOdd> >(); try { string url = ""; if (oddStatus == MatchStatus.Running) { url = string.Format("{0}/web-root/restricted/odds-display/today-data.aspx?od-param={1}&fi={2}&v={3}", account.BaseUrl, "1,1,1,1,1,2,2,2,0", 0, 0); } else if (oddStatus == MatchStatus.Today) { url = string.Format("{0}/web-root/restricted/odds-display/today-data.aspx?od-param={1}&fi={2}&v={3}&dl={4}", account.BaseUrl, "1,1,1,1,1,2,2,2,0", 1, 0, 0); } else { //http://602iy850872o.asia.com3456.com/web-root/restricted/odds-display/early-market-data.aspx?od-param=1,1,2,1,1,2,2,2,0&v=0 url = string.Format("{0}/web-root/restricted/odds-display/early-market-data.aspx?od-param={1}&v={2}", account.BaseUrl, "1,1,2,1,1,2,2,2,0", 0); } var str = url.GetStringFromUrl( requestFilter: getRequest => { getRequest.CookieContainer = new CookieContainer(); getRequest.CookieContainer.Add(account.Cookie); getRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; getRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0"; getRequest.Headers.Add("Accept-Language", "vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3"); getRequest.Referer = account.HomeUrl; getRequest.Headers.Add("X-Forwarded-For", account.FakeIp); }, responseFilter: response => { account.Cookie.Add(response.Cookies); }); res = oddStatus == MatchStatus.Running ? new Str2Obj().RunningOdds(str) : oddStatus == MatchStatus.Today ? new Str2Obj().TodayOdds(str) : new Str2Obj().EarlyOdds(str); } catch (Exception ex) { _log.ErrorFormat("GetOdds by {0} error: {1}", account.UserName, ex.Message); res.Data = new List <MatchOdd>(); res.Errors.Add("Get Sbobet Odds Errors: " + ex.Message); } return(res); }
public ManualMatchItem(T item, MatchStatus status, MatchItemHandler <T> handler) { Name = handler.Name(item); Open = new RelayCommand(() => handler.Open(item)); Caption = handler.Caption(item); OriginalItem = item; Status = status; }
public void AddMatch(TInternal _internal, MatchStatus internalStatus, TExternal _external, MatchStatus externalStatus) { Matched.Add(new ManualMatchedPair <TInternal, TExternal>( this, new ManualMatchItem <TInternal>(_internal, internalStatus, InternalHandler), new ManualMatchItem <TExternal>(_external, externalStatus, ExternalHandler) )); }
public void CancelMatch(GameResultEnum result) { if (PlayerManager.self.statusManager.currentStatus.Status() == StatusEnum.MATCH) { MatchStatus ms = PlayerManager.self.statusManager.currentStatus as MatchStatus; ms.CancelMatch(result); } }
public MatchScorecard(TeamPoints homeTeam, TeamPoints awayTeam, MatchStatus status) { if (homeTeam == null) throw new ArgumentNullException("homeTeam"); if (awayTeam == null) throw new ArgumentNullException("awayTeam"); _homeTeam = homeTeam; _awayTeam = awayTeam; _status = status; }
public void SimulateMatch() { Random rnd = new Random(); Team1Goals = rnd.Next(0, 5); Team2Goals = rnd.Next(0, 5); Status = MatchStatus.Finished; }
public Match(int id, string name, MatchStatus status, GameType gameType, List <Player> players) { Id = id; Name = name; Status = status; GameType = gameType; Players = players; }
private void Start() { StartGame = false; RoundEnded = false; GameStatus = MatchStatus.NotStarted; StartWait = new WaitForSeconds(StartDelay); EndWait = new WaitForSeconds(EndDelay); }
public void UpdateMatchStatus(MatchStatus status) { var @event = new MatchStatusUpdated { Status = EnumEx.MapByStringValue <MatchStatus, Contracts.MatchStatus>(status) }; RaiseDomainEvent(@event); }
public Result Finish(string principalId) { if (this.Players.Select(x => x.Player).Any(x => x.PrincipalId == principalId)) { this._matchStatus = MatchStatus.Finished; return(Result.Success()); } return(Result.Failure("Player is not part of match")); }
public static IHtmlString MatchStatuses(this HtmlHelper htmlHelper, string name="",MatchStatus? selected=default(MatchStatus)) { return htmlHelper.DropDownList(name, Enumerable.Range(-1, 5).Cast<MatchStatus>().Select(s => new SelectListItem() { Value = s.ToString(), Text = htmlHelper.ResourceText("MatchStatus." + s), Selected = selected.HasValue && selected.Value == s })); }
public PartialViewResult FootballMatches(string date, MatchStatus status) { FootballMatchesViewModel vm = new FootballMatchesViewModel(); DateTime selectedDate = _homeService.GetDateFromString(date); vm.Matches = _homeService.GetMatchesByDate(selectedDate, status); vm.MatchStatus = status; return(PartialView("_FootballMatchesTable", vm)); }
public LiveMatchStats(string matchId, int goalsScoredHomeSide, int goalsScoredAwaySide, int penaltiesScoredHomeSide, int penaltiesScoredAwaySide, MatchStatus matchStatus, string minute) { MatchId = matchId; GoalsScoredHomeSide = goalsScoredHomeSide; GoalsScoredAwaySide = goalsScoredAwaySide; PenaltiesScoredHomeSide = penaltiesScoredHomeSide; PenaltiesScoredAwaySide = penaltiesScoredAwaySide; MatchStatus = matchStatus; Minute = minute; }
public async void Login() { if (btnLoginB.Text == "Logout") { Program.Accounts.SingleOrDefault(x => x.Key == Acc.Key).LoginName = null; Program.Accounts.SingleOrDefault(x => x.Key == Acc.Key).Cookie = new System.Net.CookieCollection(); btnLoginB.Text = "Login"; btnDelete.Enabled = true; btnTrans.Enabled = false; this.BackColor = SystemColors.Info; _log.InfoFormat("Logout account {0} successfully!", Acc.UserName); return; } if (Program.Accounts.SingleOrDefault(x => x.Key == Acc.Key).UserName == "" || Program.Accounts.SingleOrDefault(x => x.Key == Acc.Key).Password == "") { MessageBox.Show("Please enter UserName & password!"); return; } btnLoginB.Enabled = false; Task <Response <bool> > loginTask = Task.Run(() => new Sbobet().Login(Program.Accounts.SingleOrDefault(x => x.Key == Acc.Key))); var res = await loginTask; if (res.Data && !res.HasError) { if (Program.Accounts.SingleOrDefault(x => x.Key == Acc.Key).Cookie.Count > 3 && !String.IsNullOrEmpty(Program.Accounts.SingleOrDefault(x => x.Key == Acc.Key).LoginName)) { ((Button)((frmMain)this.FindForm()).Controls.Find("btnStart", true).FirstOrDefault()).Enabled = true; ((Button)((frmMain)this.FindForm()).Controls.Find("btnStop", true).FirstOrDefault()).Enabled = true; btnLoginB.Text = "Logout"; btnLoginB.Enabled = true; btnTrans.Enabled = true; btnDelete.Enabled = false; this.BackColor = SystemColors.GradientActiveCaption; new Thread(new ThreadStart(GetOdds)).Start(); new Thread(new ThreadStart(Bet)).Start(); // get status filter var combobox = (this.FindForm() as frmMain).Controls.Find("cbMatchStyle", true).FirstOrDefault() as ComboBox; if (combobox != null) { MatchStatus status = GetMatchStatus(combobox.SelectedIndex); var thread = new Thread(new ParameterizedThreadStart(OnBetStolen)); thread.Start(status); } } } else { btnLoginB.Enabled = true; this.BackColor = SystemColors.Info; } }
public async Task <IActionResult> Create([Bind("Id,MatchStatusName")] MatchStatus matchStatus) { if (ModelState.IsValid) { _context.Add(matchStatus); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(matchStatus)); }
private void SetScores(string scoreString, MatchStatus status) { if (status != MatchStatus.Fixture) { var match = Regex.Match(scoreString, @"^(\d+)\s*\-\s*(\d+)$"); if (match.Success) { HomeScore = int.Parse(match.Groups[1].Value); AwayScore = int.Parse(match.Groups[2].Value); } } }
/// <summary> /// Constructor /// </summary> public Match() { matchIdField = 0; homeTeamField = new HomeTeam(); awayTeamField = new AwayTeam(); matchDateField = DateTime.MinValue; matchTypeField = MatchType.Unavailable; homeGoalsField = 0; awayGoalsField = 0; ordersGivenField = false; statusField = MatchStatus.Finished; }
/// <summary> /// Stop the this match /// </summary> public void End(MatchStatus newStatus) { Status = newStatus; Duration.End(); TennisSet _set = currentSet(); if (_set != null) { _set.End(Winner); } }
public Network() { _exePath = Process.GetCurrentProcess().MainModule.FileName; _state = MatchStatus.Idle; _connections = new List <Connection>(); _lockAnalyse = new object(); _recvBuffer = new byte[0x20000]; RcvAllIpLevel = new byte[] { 3, 0, 0, 0 }; }
// Private constructor: cross-platform matches should only created from GKTurnBasedMatch // or GPG TurnBasedMatch using the factory methods. protected TurnBasedMatch(string matchId, int playerCount, byte[] data, string selfParticipantId, Participant[] participants, string currentParticipantId, MatchStatus matchStatus) { mMatchId = matchId; mPlayerCount = playerCount; mData = data; mSelfParticipantId = selfParticipantId; mParticipants = participants; mCurrentParticipantId = currentParticipantId; mMatchStatus = matchStatus; }
public void UpdateFixtureState(string sport, string fixtureId, int sequence, MatchStatus matchStatus, int epoch) { _logger.DebugFormat("Updating state for Fixture fixtureId={0} sequence={1}", fixtureId, sequence); var fixtureState = GetFixtureState(fixtureId) ?? new FixtureState { Id = fixtureId, Sport = sport }; fixtureState.Sequence = sequence; fixtureState.MatchStatus = matchStatus; fixtureState.Epoch = epoch; Events.AddOrUpdate(fixtureId, fixtureState, (idX, fs) => fixtureState); }
private string GetStatusString(MatchStatus status) { switch (status) { case MatchStatus.Fixture: return "fixture"; case MatchStatus.Live: return "live"; case MatchStatus.Report: return "report"; } return String.Empty; }
public GamePark() { this._parkFriendsList = new Collection<FriendInfo>(); this._parkEmptyGarageFriendsList = new Collection<FriendInfo>(); this._carList = new Collection<CarInfo>(); this._seatList = new Collection<SeatInfo>(); this._validParkList = new Collection<int>(); this._parkcash = -1; this._allCarsInMarketList = new Collection<NewCarInfo>(); this._matchList = new Collection<MatchInfo>(); //this._buyNewCarList = new Collection<NewCarInfo>(); this._matchstatus = MatchStatus.UnKnown; }
public void Preffered_Classification_Opposed_Type_Should_Return_Bad() { //arrange Person person = new Person("Dogs", preferredClassification: PetClassification.Mammal, opposedType: PetType.Dog); Pet pet = new Pet("Fido", classification: PetClassification.Mammal, type: PetType.Dog, weight: 100); //Act MatchStatus statusResult = Utils.GetMatchStatus(person, pet); //Assert MatchStatus expectedResult = MatchStatus.Bad; Assert.Equal(expectedResult.ToString(), statusResult.ToString()); }
public void Match_Should_Return_Good() { //arrange Person person = new Person("Dogs", preferredType: PetType.Dog, opposedClassification: PetClassification.Mammal, opposedSize: PetSize.ExtraSmall); Pet pet = new Pet("Fido", classification: PetClassification.Mammal, type: PetType.Dog, weight: .01); //Act MatchStatus statusResult = Utils.GetMatchStatus(person, pet); //Assert MatchStatus expectedResult = MatchStatus.Good; Assert.Equal(expectedResult.ToString(), statusResult.ToString()); }
private IEnumerable<Match> GetMatches(HtmlDocument doc, MatchStatus status) { string statusString = GetStatusString(status); var searchString = string.Format("//tr[@class='{0}']", statusString); HtmlNodeCollection matchRows = doc.DocumentNode.SelectNodes(searchString); if (matchRows != null) { foreach (HtmlNode matchRow in matchRows) { yield return new Match(matchRow.OuterHtml, status); } } }
public static string Resolve(MatchStatus status) { switch (status) { case MatchStatus.Finished: return "Finished"; case MatchStatus.Live: return "Live"; case MatchStatus.NotYetStarted: return "Not yet started"; default: throw new ArgumentException("Unable to resolve match status \"{0}\"".FormatWith(status)); } }
public static int GetIntFromMatchStatus(MatchStatus status) { switch (status) { case MatchStatus.Closed: return(0); case MatchStatus.Open: return(1); default: throw new ArgumentOutOfRangeException(nameof(status), status, null); } }
public Match(string bbcPage, MatchStatus status) { var doc = new HtmlDocument(); doc.LoadHtml(bbcPage); HomeTeam = doc.DocumentNode.SelectNodes("//span[@class='team-home']").Single().InnerText; AwayTeam = doc.DocumentNode.SelectNodes("//span[@class='team-away']").Single().InnerText; Status = Enum.GetName(typeof(MatchStatus), status); var scoreString = doc.DocumentNode.SelectNodes("//span[@class='score']").Single().InnerText.Trim(); SetScores(scoreString, status); var elapsedTime = doc.DocumentNode.SelectNodes("//span[@class='elapsed-time']").Single().InnerText.Trim(); ElapsedMinutes = GetElapsedMinutes(elapsedTime, status); }
private int GetElapsedMinutes(string timeString, MatchStatus status) { switch (status) { case MatchStatus.Live: var match = Regex.Match(timeString, @"^(\d+)\s*mins$"); if (match.Success) return int.Parse(match.Groups[1].Value); else return 45; case MatchStatus.Report: return 90; case MatchStatus.Fixture: return 0; } return 0; }
internal TurnBasedMatch(string matchId, byte[] data, bool canRematch, string selfParticipantId, List<Participant> participants, uint availableAutomatchSlots, string pendingParticipantId, MatchTurnStatus turnStatus, MatchStatus matchStatus, uint variant, uint version) { mMatchId = matchId; mData = data; mCanRematch = canRematch; mSelfParticipantId = selfParticipantId; mParticipants = participants; // participant list is always sorted! mParticipants.Sort(); mAvailableAutomatchSlots = availableAutomatchSlots; mPendingParticipantId = pendingParticipantId; mTurnStatus = turnStatus; mMatchStatus = matchStatus; mVariant = variant; mVersion = version; }
/// <summary> /// Declares the match status for the current person the specified search result entry from <see cref="P:Results.Entries"/>. /// </summary> /// <param name="entry">The search result entry (from <see cref="P:Results.Entries"/>) to have the match status updated.</param> /// <param name="status">The new status to apply to the specified search result entry from <see cref="P:Results.Entries"/>.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="PersonMatchResultsState"/> instance containing the REST API response. /// </returns> public PersonMatchResultsState UpdateMatchStatus(Gx.Atom.Entry entry, MatchStatus status, params IStateTransitionOption[] options) { String updateStatusUri = GetSelfUri().SetQueryParam(FamilySearchOptions.STATUS, status.ToString().ToLower()).ToString(); IRestRequest request = CreateAuthenticatedRequest().ContentType(MediaTypes.GEDCOMX_JSON_MEDIA_TYPE) .SetEntity(new Gx.Gedcomx() { Persons = new List<Person>() { new Person() { Identifiers = new List<Identifier>() { new Identifier() { KnownType = IdentifierType.Persistent, Value = entry.Id } } } } }) .Build(updateStatusUri, Method.POST); return ((FamilySearchStateFactory)this.stateFactory).NewPersonMatchResultsState(request, Invoke(request, options), this.Client, this.CurrentAccessToken); }
private void UpdateWithServerData(Bundle serverData) { Lock(() => { if (serverData.Has("creator")) Creator = new GamerInfo(serverData["creator"]); if (serverData.Has("customProperties")) CustomProperties = serverData["customProperties"]; if (serverData.Has("domain")) Domain = serverData["domain"]; if (serverData.Has("description")) Description = serverData["description"]; if (serverData.Has("globalState")) GlobalState = serverData["globalState"]; MatchId = serverData["_id"]; if (serverData.Has("maxPlayers")) MaxPlayers = serverData["maxPlayers"]; if (serverData.Has("seed")) Seed = serverData["seed"]; Status = Common.ParseEnum<MatchStatus>(serverData["status"]); if (serverData.Has("shoe")) Shoe = serverData["shoe"]; // Process pending events if (serverData.Has("events")) { Moves.Clear(); foreach (var b in serverData["events"].AsArray()) { if (b["type"] == "match.move") { Moves.Add(new MatchMove(serverData["event"]["player_id"], serverData["event"]["move"])); } } } // Players if (serverData.Has("players")) { Players.Clear(); foreach (var b in serverData["players"].AsArray()) { Players.Add(new GamerInfo(b)); } } // Last event ID (null if 0; =first time) string lastEvent = serverData["lastEventId"]; if (lastEvent != "0") LastEventId = lastEvent; }); }
/// <summary>Terminates the match. You need to be the creator of the match to perform this operation.</summary> /// <returns>Promise resolved when the operation has completed.</returns> /// <param name="deleteToo">If true, deletes the match if it finishes successfully or is already finished.</param> /// <param name="notification">A notification that can be sent to all players currently playing the match (except you).</param> public Promise<Done> Finish(bool deleteToo = false, PushNotification notification = null) { UrlBuilder url = new UrlBuilder("/v1/gamer/matches").Path(MatchId).Path("finish"); url.QueryParam("lastEventId", LastEventId); HttpRequest req = Gamer.MakeHttpRequest(url); req.BodyJson = Bundle.CreateObject("osn", notification != null ? notification.Data : null); return Common.RunInTask<Done>(req, (response, task) => { UpdateWithServerData(response.BodyJson["match"]); // Affect match Status = MatchStatus.Finished; // Also delete match if (deleteToo) { Gamer.Matches.Delete(MatchId).ForwardTo(task); } else { task.PostResult(new Done(true, response.BodyJson)); } }); }
private string RequestCompetition() { HH.DelayedTime = Constants.DELAY_1SECONDS; string content = HH.Get("http://www.kaixin001.com/!parking/myteam.php"); string imageID = JsonHelper.GetMid(content, "<img src=\"http://img1.kaixin001.com.cn/i2/park/match/ts_", ".gif"); if (imageID == "3") this._matchstatus = MatchStatus.NotInMatch; else if (imageID == "2") this._matchstatus = MatchStatus.OriginateMatch; else if (imageID == "1") this._matchstatus = MatchStatus.InMatch; else if (content.IndexOf("你还没有组建你的车队") > -1) this._matchstatus = MatchStatus.WithoutTeam; return content; }
public void CanResolveMatchStatuses(string status, MatchStatus expectedMatchStatus) { MatchStatus actual = MatchStatusResolver.Resolve(status); actual.Should().Be(expectedMatchStatus); }
public void UpdateFixtureState(string sport, string fixtureId, int sequence, MatchStatus matchStatus, int epoch) { _logger.DebugFormat("Updating state for Fixture fixtureId={0} sequence={1}", fixtureId, sequence); var fixtureState = GetFixtureState(fixtureId) ?? new FixtureState {Id = fixtureId, Sport = sport}; fixtureState.Sequence = sequence; fixtureState.MatchStatus = matchStatus; fixtureState.Epoch = epoch; Events.AddOrUpdate(fixtureId, fixtureState, (idX, fs) => fixtureState); }
public void CanResolveMatchStatusesForDisplayValues(MatchStatus matchStatus, string expectedStatus) { string actual = MatchStatusResolver.Resolve(matchStatus); actual.Should().Be(expectedStatus); }
private void ReceivedLoopEvent(DomainEventLoop sender, EventLoopArgs e) { // Ignore events not for us if (!e.Message["type"].AsString().StartsWith("match.")) return; Lock(() => { // Update last event ID if (e.Message["event"].Has("_id")) { LastEventId = e.Message["event"]["_id"]; } switch (e.Message["type"].AsString()) { case "match.join": var joinEvent = new MatchJoinEvent(Gamer, e.Message); Players.AddRange(joinEvent.PlayersJoined); if (onPlayerJoined != null) onPlayerJoined(this, joinEvent); break; case "match.leave": var leaveEvent = new MatchLeaveEvent(Gamer, e.Message); foreach (var p in leaveEvent.PlayersLeft) Players.Remove(p); if (onPlayerLeft != null) onPlayerLeft(this, leaveEvent); break; case "match.finish": Status = MatchStatus.Finished; if (onMatchFinished != null) onMatchFinished(this, new MatchFinishEvent(Gamer, e.Message)); break; case "match.move": var moveEvent = new MatchMoveEvent(Gamer, e.Message); Moves.Add(new MatchMove(moveEvent.PlayerId, moveEvent.MoveData)); if (onMovePosted != null) onMovePosted(this, moveEvent); break; case "match.shoedraw": if (onShoeDrawn != null) onShoeDrawn(this, new MatchShoeDrawnEvent(Gamer, e.Message)); break; case "match.invite": // Do not notify them since we are already playing the match break; default: Common.LogError("Unknown match event type " + e.Message["type"]); break; } }); }
/// <summary> /// Creates a match status query string parameter. /// </summary> /// <param name="status">The value to use in the match status query string parameter. See remarks.</param> /// <returns>A match status query string parameter.</returns> /// <remarks> /// This could be used, for example, to filter the types of matches for a given person. /// </remarks> public static QueryParameter MatchStatus(MatchStatus status) { return new QueryParameter(false, STATUS, XmlQNameEnumUtil.GetNameValue(status)); }
public virtual void Accept(User user) { Status = MatchStatus.Accepted; Request.AcceptingUser = user; }
/// <summary> /// Attempts to match string to content from the online database. /// </summary> /// <param name="search">Search string to match against</param> /// <param name="rootFolder">The root folder the content will belong to</param> /// <param name="folderPath">Folder path where the content should be moved to</param> /// <returns>Match content item, null if no match</returns> protected bool ContentMatch(string search, string rootFolder, string folderPath, bool fast, bool threaded, out Content match, Content knownContent) { // Create empty content Content emptyContent; switch (this.ContentType) { case ContentType.Movie: emptyContent = new Movie(); break; case ContentType.TvShow: emptyContent = new TvShow(); break; default: throw new Exception("Unknown content type"); } emptyContent.Path = folderPath; emptyContent.RootFolder = rootFolder; emptyContent.Found = true; // Check for empty search condition if (string.IsNullOrEmpty(search)) { match = emptyContent; return false; } // Get year from search string int dirYear = FileHelper.GetYear(search); // Get list of simplified strings List<FileHelper.SimplifyStringResults> searches = new List<FileHelper.SimplifyStringResults>(); // Get list of search bases List<string> searchBases = GetModifiedSearches(search); // Fast search: use first search base only if (fast) { FileHelper.SimplifyStringResults result = FileHelper.BuildSimplifyResults(searchBases[0], false, false, FileHelper.OptionalSimplifyRemoves.YearAndFollowing, true, false, true, false); searches.Add(result); } // Full search: Go through each search base and get simplified search options else foreach (string searchBase in searchBases) { // Get results from current base List<FileHelper.SimplifyStringResults> currSearches = FileHelper.SimplifyString(searchBase); currSearches.Add(new FileHelper.SimplifyStringResults(searchBase, new Dictionary<FileWordType, List<string>>(), ContentSearchMod.None)); // Add each result to full list of searches foreach (FileHelper.SimplifyStringResults results in currSearches) { // Check if search already exist bool exists = false; foreach (FileHelper.SimplifyStringResults s in searches) if (s.SimplifiedString == results.SimplifiedString) { exists = true; break; } // If doesn't exist add it to searches if (!exists && !string.IsNullOrWhiteSpace(results.SimplifiedString)) searches.Add(results); } } searches.Sort(); // Create new status int currSeachCnt; MatchStatus status; lock (searchLock) { currSeachCnt = ++searchCount; status = new MatchStatus(searches.Count, this.ContentType); searchStatus.Add(currSeachCnt, status); } ContentSearchMod lowMods; Content lowestModsMatch; // Add thread to pool for each search that need to be performed int searchNum = 0; while (searchNum < searches.Count) { // Check for any search results so far if (status.GetSearchResultWithLowestMods(out lowMods, out lowestModsMatch)) { // If search results have no mods or just year removed use them as final results if (lowMods == ContentSearchMod.None || lowMods == ContentSearchMod.YearRemoved) { match = lowestModsMatch; return true; } } // Limit number of search threads created if (status.NumStarted - status.NumCompleted >= Settings.General.NumSimultaneousSearches) { Thread.Sleep(100); continue; } // Build search arguments object[] args = { currSeachCnt, searchNum, searches[searchNum].SimplifiedString, folderPath, rootFolder, dirYear, searches[searchNum].Modifications, knownContent }; // Threaded: add a search to thread pool if (threaded) { ThreadPool.QueueUserWorkItem(new WaitCallback(SearchThread), args); lock (searchLock) status.SetSearchStarted(searchNum); } // Synchronized: call search method else SearchThread(args); searchNum++; } // Wait for all search to complete while (status.NumCompleted < searches.Count) { // Check for any search results so far if (status.GetSearchResultWithLowestMods(out lowMods, out lowestModsMatch)) { // If search results have no mods or just year removed use them as final results if (lowMods == ContentSearchMod.None || lowMods == ContentSearchMod.YearRemoved) { match = lowestModsMatch; return true; } } Thread.Sleep(100); } // Clear status lock (searchLock) searchStatus.Remove(currSeachCnt); // Return result with lowest mods to search string if (status.GetSearchResultWithLowestMods(out lowMods, out lowestModsMatch)) { match = lowestModsMatch; return true; } else { match = emptyContent; return false; } }