/// <summary> /// Reads stream to match it against a dictionary of all known units for an ingredient /// </summary> /// <param name="stream"></param> /// <param name="matchdata"></param> /// <returns></returns> public bool Read(Stream stream, MatchData matchdata) { if (data == null) { data = new UnitSynonyms(); } UnitNode node; var fMatch = false; var buffer = String.Empty; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char) curByte; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { stream.Seek(matchPos, SeekOrigin.Begin); break; //No reason to continue reading stream, let's see what we have.. } if (match == MatchPrecision.Exact) { matchPos = stream.Position; fMatch = true; matchdata.Amount.Unit = node.Unit; matchdata.Unit = node; } } return fMatch; }
/// <summary> /// Reads stream to match it against a dictionary of all known forms /// </summary> /// <param name="stream"></param> /// <param name="matchdata"></param> /// <returns></returns> public bool Read(Stream stream, MatchData matchdata) { if (data == null) { data = new FormSynonyms(); } FormNode node; matchdata.Form = null; var buffer = string.Empty; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char)curByte; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { break; // If there is no match, we check what we have to this moment. } if (match == MatchPrecision.Exact) { matchPos = stream.Position; matchdata.Form = node; } } stream.Seek(matchPos, SeekOrigin.Begin); return matchdata.Form != null; }
/// <summary> /// Reads stream to match it against a dictionary of all known units for an ingredient /// </summary> /// <param name="stream"></param> /// <param name="matchdata"></param> /// <returns></returns> public bool Read(Stream stream, MatchData matchdata) { if (data == null) { data = new NumericVocab(); } var matchFound = false; var buffer = string.Empty; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char)curByte; NumericNode node; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { stream.Seek(matchPos, SeekOrigin.Begin); break; } if (match == MatchPrecision.Exact) { matchPos = stream.Position; matchFound = true; matchdata.Amount = new Amount { SizeHigh = node.Value }; } } return matchFound; }
/// <summary> /// Reads stream to match it against a dictionary of all known units for an ingredient /// </summary> /// <param name="stream"></param> /// <param name="matchdata"></param> /// <returns></returns> public bool Read(Stream stream, MatchData matchdata) { if (data == null) { data = new NumericVocab(); } NumericNode node; var ifMatch = false; var buffer = string.Empty; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char)curByte; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { stream.Seek(matchPos, SeekOrigin.Begin); break; // If there is no match, we check what we have to this moment. } if (match == MatchPrecision.Exact) { matchPos = stream.Position; ifMatch = true; matchdata.Amount = new Amount(); matchdata.Amount.SizeHigh = node.Value; } } return ifMatch; }
/// <summary> /// Reads stream to match it against a dictionary of all known forms /// </summary> /// <param name="stream"></param> /// <param name="matchdata"></param> /// <returns></returns> public bool Read(Stream stream, MatchData matchdata) { if (data == null) { data = new FormSynonyms(); } FormNode node; matchdata.Form = null; var buffer = String.Empty; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char) curByte; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { break; //No reason to continue reading stream, let's see what we have.. } if (match == MatchPrecision.Exact) { matchPos = stream.Position; matchdata.Form = node; } } stream.Seek(matchPos, SeekOrigin.Begin); return (matchdata.Form != null); }
protected void AssertMatchDataEqual(MatchData expected, MatchData actual, string errorMessage, params object[] errorArgs) { Assert.AreEqual(expected.Match, actual.Match, errorMessage, errorArgs); Assert.AreEqual(expected.IgnoreCase, actual.IgnoreCase, errorMessage, errorArgs); }
private void ConsolidateMatches(MatchData match1, MatchData match2) { while (match2.indexList.Count > 0) { var newIndex = match2.indexList[0]; if (match1.indexList.Contains(newIndex) == false) match1.AddIndex(match2.indexList[0]); match2.indexList.RemoveAt(0); } }
private bool DoMatchesOverlap(MatchData match1, MatchData match2) { if (match1.gemType != match2.gemType) return false; foreach (int val in match1.indexList) { if (match2.indexList.Contains(val)) return true; } return false; }
/// <summary> /// Reads stream to match it against a fixed string ignoring any whitespace /// </summary> /// <param name="stream"></param> /// <param name="matchdata"></param> /// <returns></returns> public bool Read(Stream stream, MatchData matchdata) { while (stream.ReadByte() == ' ') { } //Burn off any leading spaces, they should not affect the grammar stream.Seek(-1, SeekOrigin.Current); //Set stream to first character after any whitespace (kinda a hack, maybe a better way to write this) //Read the stream to make sure it matches the complete token, return false if not var count = this.phrase.Length; var readBytes = new byte[count]; stream.Read(readBytes, 0, count); return (Encoding.Default.GetString(readBytes) == this.phrase); }
private void Reset() { mMatch = null; mMatchData = null; mFinalMessage = null; mMyMark = '\0'; mEndTurnCountdown = MaxTurnTime; mBlockInFlight = false; mEndingTurn = false; mShowInstructions = false; Util.MakeVisible(Playfield, false); UpdateLargeMarks(); foreach (GameObject o in GetAllGameBlocks()) { GameObject.Destroy(o); } }
/// <summary> /// Reads stream to match it against an amount, number or indefinite article. Sets any parsed value to usage.Amount /// </summary> /// <param name="stream"> /// </param> /// <param name="matchdata"> /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Read(Stream stream, MatchData matchdata) { // We probably have to detect a potential numeric match up front and then parsewith Validate, // otherwise scan till first space and check if it's a number (do we support numbers with spaces?) var matchPos = stream.Position; var origPos = matchPos; int curByte; matchdata.Amount = null; var curBuffer = string.Empty; var invalidNumeric = new Regex(@"[^0-9 /.-]"); while ((curByte = stream.ReadByte()) >= 0) { float parsedAmtHigh; float? parsedAmtLow; curBuffer += (char)curByte; if (Validate(curBuffer, out parsedAmtLow, out parsedAmtHigh)) { matchPos = stream.Position; matchdata.Amount = new Amount { SizeLow = parsedAmtLow, SizeHigh = parsedAmtHigh }; } else { if (invalidNumeric.IsMatch(curBuffer)) { stream.Seek(origPos, SeekOrigin.Begin); var numericParser = new NumericToken(); if (numericParser.Read(stream, matchdata)) { matchPos = stream.Position; } break; } } } stream.Seek(matchPos, SeekOrigin.Begin); return matchdata.Amount != null; }
public bool Read(Stream stream, MatchData matchData) { if (data == null) { data = new PrepNotes(); } var buffer = String.Empty; PrepNode foundPrep = null; var fFound = false; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char) curByte; //Prep tokens can have leading commas or parens - so trim these off buffer = Regex.Replace(buffer, @"^\s*(,|-|\()\s*", ""); buffer = Regex.Replace(buffer, @"\s*\)\s*$", ""); PrepNode node; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { break; //No reason to continue reading stream, let's see what we have.. } if (match == MatchPrecision.Exact) { matchPos = stream.Position; foundPrep = node; fFound = true; } } if (foundPrep != null) //Add the prep at the end of the loop in case we found multiple preps along the way { matchData.Preps.Add(foundPrep); } stream.Seek(matchPos, SeekOrigin.Begin); return fFound; }
/// <summary> /// Reads stream to match it against an amount, number or indefinite article. Sets any parsed value to usage.Amount /// </summary> /// <param name="stream"></param> /// <param name="matchdata"></param> /// <returns></returns> public bool Read(Stream stream, MatchData matchdata) { //We probably have to detect a potential numeric match up front and then parsewith Validate, otherwise scan till first space and check if it's a number (do we support numbers with spaces?) var matchPosition = stream.Position; var originalPosition = matchPosition; int currentByte; matchdata.Amount = null; var curBuffer = String.Empty; var invalidNumeric = new Regex(@"[^0-9 /.-]"); while ((currentByte = stream.ReadByte()) >= 0) { float parsedAmtHigh; float? parsedAmtLow; curBuffer += (char) currentByte; if (Validate(curBuffer, out parsedAmtLow, out parsedAmtHigh)) //Try to parse buffer as a valid number or fraction { matchPosition = stream.Position; matchdata.Amount = new Amount(); matchdata.Amount.SizeLow = parsedAmtLow; matchdata.Amount.SizeHigh = parsedAmtHigh; } else //Stop processing as soon as we hit something that can no longer be an amount { if (invalidNumeric.IsMatch(curBuffer)) //Buffer has something in it other than 0-9 /. { //Hold on, let's try parsing this buffer using the NumericToken parser stream.Seek(originalPosition, SeekOrigin.Begin); var numericParser = new NumericToken(); if (numericParser.Read(stream, matchdata)) { matchPosition = stream.Position; } break; } } } stream.Seek(matchPosition, SeekOrigin.Begin); return (matchdata.Amount != null); //We found a valid amount here }
public bool Read(Stream stream, MatchData matchData) { if (data == null) { data = new PrepNotes(); } var buffer = string.Empty; PrepNode foundPrep = null; var matchFound = false; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char)curByte; //Prep tokens can have leading commas or parens - so trim these off buffer = Regex.Replace(buffer, @"^\s*(,|-|\()\s*", ""); buffer = Regex.Replace(buffer, @"\s*\)\s*$", ""); PrepNode node; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { break; } if (match == MatchPrecision.Exact) { matchPos = stream.Position; foundPrep = node; matchFound = true; } } if (foundPrep != null) { matchData.Preps.Add(foundPrep); } stream.Seek(matchPos, SeekOrigin.Begin); return matchFound; }
public bool Read(Stream stream, MatchData matchData) { if (data == null) { data = new Anomalies(); } var buffer = string.Empty; AnomalousNode foundNode = null; var ifFound = false; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char)curByte; AnomalousNode node; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { break; // No reason to continue reading stream, let's see what we have.. } if (match == MatchPrecision.Exact) { matchPos = stream.Position; foundNode = node; ifFound = true; } } if (foundNode != null) { // Initialize match data with values from this anomaly } matchData.Ingredient = foundNode.Ingredient; stream.Seek(matchPos, SeekOrigin.Begin); return ifFound; }
public bool Read(Stream stream, MatchData matchData) { if (data == null) { data = new Anomalies(); } var buffer = string.Empty; AnomalousNode foundNode = null; var matchFound = false; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char)curByte; AnomalousNode node; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { break; } if (match == MatchPrecision.Exact) { matchPos = stream.Position; foundNode = node; matchFound = true; } } if (foundNode != null) { matchData.Ingredient = foundNode.Ingredient; } stream.Seek(matchPos, SeekOrigin.Begin); return matchFound; }
/// <summary> /// Reads stream to match it against a dictionary of all known ingredients and their aliases /// </summary> /// <param name="stream"></param> /// <param name="matchdata"></param> /// <returns></returns> public bool Read(Stream stream, MatchData matchdata) { if (data == null) { data = new IngredientSynonyms(); } IngredientNode node; matchdata.Ingredient = null; var buffer = String.Empty; var matchPos = stream.Position; int curByte; while ((curByte = stream.ReadByte()) >= 0) { buffer += (char) curByte; var match = data.Parse(buffer, out node); if (match == MatchPrecision.None) { break; //No reason to continue reading stream, let's see what we have.. } if (match == MatchPrecision.Exact) { matchPos = stream.Position; matchdata.Ingredient = node; } } //Add any prep notes from this ingredient alias to the prep node collection if (matchdata.Ingredient != null && matchdata.Ingredient.PrepNote != null) { matchdata.Preps.Add(matchdata.Ingredient.PrepNote); } stream.Seek(matchPos, SeekOrigin.Begin); return (matchdata.Ingredient != null); }
// private methods private bool IsBetterMatch(MatchData lhs, MatchData rhs) { if (lhs.ArgumentCount < rhs.ArgumentCount) { return false; } else if (lhs.ArgumentCount > rhs.ArgumentCount) { return true; } else if (lhs.DefaultValueCount < rhs.DefaultValueCount) { return false; } else if (lhs.DefaultValueCount > rhs.DefaultValueCount) { return true; } else { return false; } }
private MatchData GetOneIndexMatchData(int x, int y) { var index = BoardConfig.Instance.GetIndex(x, y); var gemCell = PuzzlePresentation.Instance.GetGemCellAtPos(x, y); if (IsCellMatchable(gemCell) == false) return null; var leftMatch = MatchLeftCount(x, y, gemCell); var rightMatch = MatchRightCount(x, y, gemCell); var upMatch = MatchUpCount(x, y, gemCell); var downMatch = MatchDownCount(x, y, gemCell); var horizontalMatch = 1 + leftMatch + rightMatch; var verticalMatch = 1 + upMatch + downMatch; if (horizontalMatch > 2 && verticalMatch > 2) { //corner match var matchData = new MatchData(index); matchData.AddIndex(BoardConfig.Instance.GetIndex(x, y)); while (leftMatch > 0) { leftMatch--; matchData.AddIndex(BoardConfig.Instance.GetIndex(x - leftMatch, y)); } while (rightMatch > 0) { rightMatch--; matchData.AddIndex(BoardConfig.Instance.GetIndex(x + rightMatch, y)); } while (upMatch > 0) { upMatch--; matchData.AddIndex(BoardConfig.Instance.GetIndex(x, y - upMatch)); } while (downMatch > 0) { downMatch--; matchData.AddIndex(BoardConfig.Instance.GetIndex(x, y + downMatch)); } return matchData; } else if (horizontalMatch > 2) { var startx = x + rightMatch; // simple side match var matchData = new MatchData(index); while (horizontalMatch > 0) { horizontalMatch--; matchData.AddIndex(BoardConfig.Instance.GetIndex(startx - horizontalMatch, y)); } return matchData; } else if (verticalMatch > 2) { var starty = y + downMatch; // vertical var matchData = new MatchData(index); while (verticalMatch > 0) { verticalMatch--; matchData.AddIndex(BoardConfig.Instance.GetIndex(x, starty - verticalMatch)); } return matchData; } return null; }
internal abstract void Add(MatchData matchData);
} // Update() private IEnumerator InitPlayer(string address) { // Grab Components yield return(StartCoroutine(GrabComponentsCoroutine())); // Determine of the main grid has been created yet GameObject testCard = GameObject.Find(CardUtility.CreateCardObjectName("Tile", 0, 0)); while (testCard == null) { testCard = GameObject.Find(CardUtility.CreateCardObjectName("Tile", 0, 0)); yield return(null); } // Get ID from MatchManager CmdInitId(address); while (this.id == -1) { yield return(null); } // Fetch username from PlayerDataController and send it serverside to MatchController InitUsername(); // Send our ID to the HudController, then force an update from it. this.hudController.GetComponent <HudController>().ThisPlayerId = this.id; this.hudController.UpdateHud(); // Grab the config from the broadcaster this.config = JsonUtility.FromJson <MatchConfig>(matchDataBroadcaster.MatchConfigStr); while (this.config == null) { yield return(null); } // Create hand card objects Debug.Log(debugTag + "Creating hand card objects for Player " + this.id); gridController.CreatePlayerHandObjects(this.id); // CmdGetHand(this.id); // Debug.Log(debug + "Hand size: " + this.hand.Count); // gridMan.CreateHandObjects(this.id, this.hand); this.knownOwnersList = new List <Coordinate2> [config.MaxPlayerCount]; // this.knownOwnersGrid = new int[config.GameGridWidth, config.GameGridHeight]; for (int i = 0; i < config.MaxPlayerCount; i++) { this.knownOwnersList[i] = new List <Coordinate2>(); } InitLocalResourcePrices(); this.matchData = JsonUtility.FromJson <MatchData>(matchDataBroadcaster.MatchDataStr); this.turnEventStr = matchDataBroadcaster.TurnEventStr; // InitLocalMarketGrid(); UpdateKnownInfo(); while (this.id == -1) { yield return(null); } for (int i = 0; i < config.PlayerHandSize; i++) { CmdGetHandCard(this.id, i); } // If this is Player 1 and it's the first Turn of the first Round if (this.id == 1 && this.matchData.Turn == 1 && this.matchData.Round == 1 && this.matchData.Phase == 1) { CardAnimations.HighlightCards(GetUnownedCards(), this.id); } this.initialzed = true; }
public MatchData match(string path) { int matchedSegments = 0; var pathSegments = path == "" ? new string[0] : path.Split('/'); if (pathSegments.Length > this.tokens.Length && this.partials == false) { return null; } var extractedVars = RouteParams.CreateDict(); for (int token = 0; token < this.tokens.Length; token++) { string value; var pathSeg = token < pathSegments.Length ? pathSegments[token] : null; if (tokens[token].extract(pathSeg, extractedVars)) { matchedSegments += token < pathSegments.Length ? 1 : 0; } else { return null; } } var ret = new MatchData(); ret.extracted = extractedVars; var remainingSegments = pathSegments.Length - matchedSegments; if (remainingSegments > 0) { // must start with a slash ret.pathRemaining = "/" + String.Join("/", pathSegments, matchedSegments, remainingSegments); } else { ret.pathRemaining = ""; } ret.pathMatched = String.Join("/", pathSegments, 0, matchedSegments); return ret; }
public TeamStats(Team team, DateTime fromDate, DateTime toDate, List <MatchType> matchTypes, Venue venue) { _team = team; ID = team.ID; FilteredMatchData = MatchData.Where(a => a.MatchDate > fromDate).Where(a => a.MatchDate < toDate).Where(a => matchTypes.Contains(a.Type)).Where(a => venue == null || a.VenueID == venue.ID).ToList(); }
public IEnumerable <Match> GetForCurrentWeek() { return(MatchData.GetAllMatchesForCurrentWeek()); }
public IEnumerable <Match> GetByDivisionForCurrentWeek(int id) { return(MatchData.GetMatchesByDivisionForCurrentWeek(id)); }
internal PcreMatch(MatchData result) { _result = result; _groups = new PcreGroup[result.Regex.CaptureCount + 1]; }
//Creates a new match and adds it to the end of the list of matches public void AddNewMatch(int p1, int p2, int board, int player) { MatchData newMatch = new MatchData(p1, p2, board, player); matchList.Add(newMatch); }
private MatchData GetMatchDataFromGenericSaveSystem(KartRace.SaveSystems.Domain.Entity.IDataSaver matchDataSaver) { MatchData matchData = matchDataSaver.LoadData <MatchData>("matchData"); return(matchData); }
private MatchData GetMatchDataFromInstallersSaveSystem(IMatchDataSaver matchDataSaver) { MatchData matchData = matchDataSaver.LoadMatchData(); return(matchData); }
public Container(MatchData match) { Match = match; Match.Initialize(); }
public void Add(MatchData matchData, string player) { _servers.Add(matchData.Endpoint); }
public static List <Shred> Backtrack(List <Shred> input) { // Build sorted List from the input shreds, and output nodes List <MatchData> list = BuildSortedList(input); int expected = input.Count; List <INode> clusters = new List <INode>(expected); // Create a stack and push the first position onto the stack Stack <int> stack = new Stack <int>(expected); // Place current pointer to list on the stack stack.Push(0); // Break when completed bool completed = false; INode root = null; while (!completed) { int pointer = stack.Peek(); INode node; if ((node = MatchData.SmartClusterNodes(list[pointer])) != null) { clusters.Add(node); // If we are complete, then return the flattened root if (node.Size() == expected) { completed = true; root = node; //return ((Cluster) node).Flattened; } // Not complete, lets try to combine the next best shred stack.Push(pointer + 1); } else { // No luck for given match, try next best if (pointer + 1 < expected) { stack.Push(stack.Pop() + 1); } else { // If we can backtrack if (stack.Count > 1) { // we have exhausted all options // discard the top pointer stack.Pop(); // Deconstruct the current shred // Implement INode.Orphan INode parent = clusters[clusters.Count - 1]; clusters.RemoveAt(clusters.Count - 1); parent.OrphanChildren(); // Try the next best match and continue stack.Push(stack.Pop() + 1); } else { // Can't back track give up completed = true; } } } } return(root == null?NaiveKruskalAlgorithm(input) : ((Cluster)root).Flattened); }
public bool CheckBoardForMatches() { BoardMatchData.Clear(); List <MatchData> horizontalMatches = new List <MatchData>(); List <MatchData> verticalMatches = new List <MatchData>(); // firstly go through the board and find the horizontal matches for (int y = 0; y < BoardConfig.Height; y++) { int xIndex = 0; while (xIndex < BoardConfig.Width) { var baseGem = PuzzleBoard.GetGemAtPos(xIndex, y); var xMatch = MatchRightCount(xIndex, y, baseGem) + 1; if (xMatch > 2) { MatchData match = new MatchData(baseGem); while (xMatch > 0) { match.AddIndex(BoardConfig.GetIndex(xIndex, y)); xMatch--; xIndex++; } horizontalMatches.Add(match); } else { xIndex += xMatch; } } } //now the vertical matches for (int x = 0; x < BoardConfig.Width; x++) { int yIndex = 0; while (yIndex < BoardConfig.Height) { var baseGem = PuzzleBoard.GetGemAtPos(x, yIndex); var yMatch = MatchDownCount(x, yIndex, baseGem) + 1; if (yMatch > 2) { MatchData match = new MatchData(baseGem); while (yMatch > 0) { match.AddIndex(BoardConfig.GetIndex(x, yIndex)); yMatch--; yIndex++; } verticalMatches.Add(match); } else { yIndex += yMatch; } } } if (horizontalMatches.Count == 0 && verticalMatches.Count == 0) { return(false); } if (horizontalMatches.Count > 0 && verticalMatches.Count > 0) { //horizontalMatches.Sort // go through all the horizontal matches and see if there's any vertical matches that cross // and if so it grabs the largest one and tags it as to be used with the horizontal and move on. } BoardMatchData.matchesFound.AddRange(horizontalMatches); BoardMatchData.matchesFound.AddRange(verticalMatches); foreach (var match in BoardMatchData.matchesFound) { foreach (var index in match.indexList) { if (BoardMatchData.markedDestroy.Contains(index) == false) { BoardMatchData.markedDestroy.Add(index); } } } return(BoardMatchData.matchesFound.Count > 0); }
private MatchData GetOneIndexMatchData(int x, int y) { var index = BoardConfig.GetIndex(x, y); int baseGem = PuzzleBoard.GetGemAtPos(x, y); if (baseGem == GemConverter.NoGem) return null; var leftMatch = MatchLeftCount(x, y, baseGem); var rightMatch = MatchRightCount(x, y, baseGem); var upMatch = MatchUpCount(x, y, baseGem); var downMatch = MatchDownCount(x, y, baseGem); var horizontalMatch = 1 + leftMatch + rightMatch; var verticalMatch = 1 + upMatch + downMatch; if (horizontalMatch > 2 && verticalMatch > 2) { //corner match var matchData = new MatchData(index); matchData.AddIndex(BoardConfig.GetIndex(x, y)); while (leftMatch > 0) { leftMatch--; matchData.AddIndex(BoardConfig.GetIndex(x - leftMatch, y)); } while (rightMatch > 0) { rightMatch--; matchData.AddIndex(BoardConfig.GetIndex(x + rightMatch, y)); } while (upMatch > 0) { upMatch--; matchData.AddIndex(BoardConfig.GetIndex(x, y - upMatch)); } while (downMatch > 0) { downMatch--; matchData.AddIndex(BoardConfig.GetIndex(x, y + downMatch)); } return matchData; } else if (horizontalMatch > 2) { var startx = x + rightMatch; // simple side match var matchData = new MatchData(index); while (horizontalMatch > 0) { horizontalMatch--; matchData.AddIndex(BoardConfig.GetIndex(startx - horizontalMatch, y)); } return matchData; } else if (verticalMatch > 2) { var starty = y + downMatch; // vertical var matchData = new MatchData(index); while (verticalMatch > 0) { verticalMatch--; matchData.AddIndex(BoardConfig.GetIndex(x, starty - verticalMatch)); } return matchData; } return null; }
public void AddMatch(MatchData match) { matchList.Add(match); }
public Match Get(int id) { return(MatchData.GetOrPlay(id)); }
public void AddMatch(MatchData match) { matchList.Add(match); }
void Start() { ///Gets the MatchData mData = GameObject.FindGameObjectWithTag("Manager").GetComponentInChildren<MatchData>(); Debug.Log(mData); }
public MatchPair(MatchData weight, BoardPiece piece) { Weight = weight; BoardPiece = piece; }
public void ShredChamferSimilarityTest() { //Create original Square Point[] patch1 = new Point[4]; patch1[0] = new Point(0, 0); patch1[1] = new Point(0, 10); patch1[2] = new Point(99, 10); patch1[3] = new Point(99, 0); Point[] patch2 = new Point[4]; patch2[0] = new Point(0, 50); patch2[1] = new Point(0, 60); patch2[2] = new Point(99, 60); patch2[3] = new Point(99, 50); // Create a Tester Square to compare Point[] patch3 = new Point[4]; patch3[0] = new Point(0, 100); patch3[1] = new Point(0, 110); patch3[2] = new Point(99, 110); patch3[3] = new Point(99, 100); Point[] patch4 = new Point[4]; patch4[0] = new Point(0, 150); patch4[1] = new Point(0, 160); patch4[2] = new Point(99, 160); patch4[3] = new Point(99, 150); // Create an Original Image var original = new Image <Bgr, Byte>(100, 100, new Bgr(Color.HotPink)); original.FillConvexPoly(patch1, new Bgr(Color.Gray)); original.FillConvexPoly(patch2, new Bgr(Color.Gray)); //Create Image to compare with var tester = new Image <Bgr, Byte>(100, 200, new Bgr(Color.HotPink)); tester.FillConvexPoly(patch3, new Bgr(Color.Gray)); tester.FillConvexPoly(patch4, new Bgr(Color.Gray)); const string filepath = "originalshrd.bmp"; const string filepath2 = "testshred.bmp"; // Delete Shred Files if (File.Exists(filepath)) { File.Delete(filepath); } if (File.Exists(filepath2)) { File.Delete(filepath2); } // Save bitmaps to load as shreds original.ToBitmap().Save(filepath); tester.ToBitmap().Save(filepath2); // Create new shreds Shred originalshred = new Shred(filepath); Shred testershred = new Shred(filepath2); // Run Similarity test var actual = MatchData.CompareShred( originalshred, testershred, Direction.FromLeft, Orientation.Regular, Direction.FromRight, Orientation.Regular ).Offset; const int expected = 100; Assert.IsTrue(actual == expected); }
//used for testing purposes to see if recording game moves. Call this with the number of the match. public void ReportGame(int num) { MatchData match = matchList[num]; //simply just get the data string message = "========\n" + "GAME" + num + "\n"; message += "Board Dimension of " + match.boardDimension + "\n"; message += ("Starting player was " + (match.startingPlayer) + ". ") + "\n"; message += ("Player 1 icon is " + match.pOneIcon) + "\n"; message += ("Player 2 icon is " + match.pTwoIcon) + "\n"; message += ("Game Result was " + match.GameResult + ". \n 0 = No Winner, 1 = Player 1, 2 = Player 2, 3 = Draw, 4 = Error") + "\n"; //figures out which is the highest count between both player arrays to determine who made the last move int c; if (match.playerOneMoves.Count > match.playerTwoMoves.Count) { c = match.playerOneMoves.Count; } else { c = match.playerTwoMoves.Count; } //container lists to store the data obtained from the record List <Vector2Int> firstPlayerMoves; List <Vector2Int> secondPlayerMoves; //figure out who went first and then adds that to the container if (match.startingPlayer == 0) { firstPlayerMoves = match.playerOneMoves; secondPlayerMoves = match.playerTwoMoves; } else { firstPlayerMoves = match.playerTwoMoves; secondPlayerMoves = match.playerOneMoves; } //iterate over the containers to log the message for (int i = 0; i < c; i++) { if (i < firstPlayerMoves.Count) { if (firstPlayerMoves[i].x == -1) { message += "Turn " + i + ": First Player Surrenders"; } else if (firstPlayerMoves[i].x == -2) { message += "Turn " + i + ": Game was ended on Second Player's turn."; } else { message += ("Turn " + i + ": Player " + match.startingPlayer + " moves to " + firstPlayerMoves[i] + "\n"); } } if (i < secondPlayerMoves.Count) { if (secondPlayerMoves[i].x == -1) { message += "Turn " + i + ": Second Player Surrenders"; } else if (secondPlayerMoves[i].x == -2) { message += "Turn " + i + ": Game was ended on First Player's turn."; } else { message += ("Turn " + i + ": Second Player moves to " + secondPlayerMoves[i] + "\n"); } } } Debug.Log(message); }
void RenderPlayer(MatchData matchData) { if (matchData.state == "running") { if (playersToRender != playersToRenderInRoundBefore) { playersToRender.Clear(); foreach (var player in matchData.players) { if (player.position_name == String.Empty) { //it is a thief if (matchData.mr_x_last_node_name != String.Empty) { playersToRender.Add(playerColorPlayerName["black"], matchData.mr_x_last_node_name); } } else { //it is a police playersToRender.Add(playerColorPlayerName[player.color], player.position_name); } } foreach (var player in playersToRender) { //Hide players that moved string value; playersToRenderInRoundBefore.TryGetValue(player.Key, out value); if (value != null && value != player.Value) { GameObject.Find(value + "/" + player.Key).GetComponent <Transform>().localScale = new Vector3(0, 0, 0); } //render players that are still there //rendering a thief with unknown position //a thief for that the position is not actualized is displayed with a darker skin //this way, users see, that the thief's shown position is the place where he was discovered for the last time if (player.Key == "thief") { string posThiefRoundBefore; playersToRenderInRoundBefore.TryGetValue("thief", out posThiefRoundBefore); if (posThiefRoundBefore != null) { if (posThiefRoundBefore == player.Value) { GameObject.Find(player.Value + "/" + "thief dark").GetComponent <Transform>().localScale = new Vector3(0.1f, 0.1f, 0.1f); } else { GameObject.Find(player.Value + "/" + player.Key).GetComponent <Transform>().localScale = new Vector3(0.1f, 0.1f, 0.1f); } } } else { //rendering other players GameObject.Find(player.Value + "/" + player.Key).GetComponent <Transform>().localScale = new Vector3(0.1f, 0.1f, 0.1f); } } playersToRenderInRoundBefore = new Dictionary <string, string>(playersToRender); } } else { if (matchData.state == "police_won") { StartViewing startViewing = new StartViewing(); startViewing.OnPoliceWon(); } if (matchData.state == "mr_x_won") { StartViewing startViewing = new StartViewing(); startViewing.OnThiefWon(); } } }
public bool CheckBoardForMatches() { BoardMatchData.Clear(); List<MatchData> horizontalMatches = new List<MatchData>(); List<MatchData> verticalMatches = new List<MatchData>(); // firstly go through the board and find the horizontal matches for (int y = 0; y < BoardConfig.Height; y++) { int xIndex = 0; while (xIndex < BoardConfig.Width) { var baseGem = PuzzleBoard.GetGemAtPos(xIndex, y); var xMatch = MatchRightCount(xIndex, y, baseGem) + 1; if (xMatch > 2) { MatchData match = new MatchData(baseGem); while (xMatch > 0) { match.AddIndex(BoardConfig.GetIndex(xIndex, y)); xMatch--; xIndex++; } horizontalMatches.Add(match); } else { xIndex += xMatch; } } } //now the vertical matches for (int x = 0; x < BoardConfig.Width; x++) { int yIndex = 0; while (yIndex < BoardConfig.Height) { var baseGem = PuzzleBoard.GetGemAtPos(x, yIndex); var yMatch = MatchDownCount(x, yIndex, baseGem) + 1; if (yMatch > 2) { MatchData match = new MatchData(baseGem); while (yMatch > 0) { match.AddIndex(BoardConfig.GetIndex(x, yIndex)); yMatch--; yIndex++; } verticalMatches.Add(match); } else { yIndex += yMatch; } } } if (horizontalMatches.Count == 0 && verticalMatches.Count == 0) return false; if (horizontalMatches.Count > 0 && verticalMatches.Count > 0) { //horizontalMatches.Sort // go through all the horizontal matches and see if there's any vertical matches that cross // and if so it grabs the largest one and tags it as to be used with the horizontal and move on. } BoardMatchData.matchesFound.AddRange(horizontalMatches); BoardMatchData.matchesFound.AddRange(verticalMatches); foreach (var match in BoardMatchData.matchesFound) { foreach (var index in match.indexList) { if (BoardMatchData.markedDestroy.Contains(index) == false) BoardMatchData.markedDestroy.Add(index); } } return BoardMatchData.matchesFound.Count > 0; }
private void StoreDataInDatabase() { string conn = "URI=file:" + Application.dataPath + "/SCRMG_Database.db"; IDbConnection dbconn; dbconn = (IDbConnection) new SqliteConnection(conn); IDbCommand dbcmd = dbconn.CreateCommand(); IDataReader reader; string sqlQuery; dbconn.Open(); #region Storing matchData sqlQuery = "SELECT name FROM sqlite_master WHERE type='table' AND name='MatchData' "; dbcmd.CommandText = sqlQuery; reader = dbcmd.ExecuteReader(); if (!reader.Read()) { try { reader.Close(); reader = null; sqlQuery = "CREATE TABLE MatchData (PK INTEGER PRIMARY KEY, matchID INT, startDate CHAR," + " startTime CHAR, matchDuration REAL, gameMode INT, humanPlayerWon INT, powerUpsOverall INT," + " powerUpBase1 INT, powerUpBase2 INT, powerUpBase3 INT, powerUpBase4 INT)"; dbcmd.CommandText = sqlQuery; dbcmd.ExecuteNonQuery(); } catch { Debug.LogWarning("Error while trying to create new table"); } } if (reader != null) { reader.Close(); reader = null; } int myMatchID = lastMatchData.matchID; string myStartDate = lastMatchData.startDate; string myStartTime = lastMatchData.startTime; float myMatchDuration = lastMatchData.matchDuration; int myGameMode = lastMatchData.gameMode; int myHumanPlayerWon = 0; if (lastMatchData.humanPlayerWon) { myHumanPlayerWon = 1; } int myPowerUpsPickedUpOverall = lastMatchData.powerUpsPickedUpOverall; int myPowerUpPlatformOneUsed = lastMatchData.powerUpPlatformOneUsed; int myPowerUpPlatformTwoUsed = lastMatchData.powerUpPlatformTwoUsed; int myPowerUpPlatformThreeUsed = lastMatchData.powerUpPlatformThreeUsed; int myPowerUpPlatformFourUsed = lastMatchData.powerUpPlatformFourUsed; try { sqlQuery = "INSERT INTO MatchData (matchID, startDate, startTime, matchDuration, gameMode, humanPlayerWon, powerUpsOverall, " + "powerUpBase1, powerUpBase2, powerUpBase3, powerUpBase4) " + "VALUES (" + myMatchID + ", '" + myStartDate + "', '" + myStartTime + "', " + myMatchDuration + ", " + myGameMode + ", " + myHumanPlayerWon + ", " + myPowerUpsPickedUpOverall + ", " + myPowerUpPlatformOneUsed + ", " + myPowerUpPlatformTwoUsed + ", " + myPowerUpPlatformThreeUsed + ", " + myPowerUpPlatformFourUsed + ")"; dbcmd.CommandText = sqlQuery; dbcmd.ExecuteNonQuery(); } catch { Debug.LogWarning("Error while writing to database"); } if (reader != null) { reader.Close(); reader = null; } #endregion #region Storing PlayerData sqlQuery = "SELECT name FROM sqlite_master WHERE type='table' AND name='PlayerData' "; dbcmd.CommandText = sqlQuery; reader = dbcmd.ExecuteReader(); if (!reader.Read()) { Debug.Log("PlayerData table not found, creating table"); try { reader.Close(); reader = null; sqlQuery = "CREATE TABLE PlayerData (PK INTEGER PRIMARY KEY, shipIndex INT, matchID INT, lifetime REAL," + " victory INT, projectileType0Spawns INT, projectileType1Spawns INT, projectileType2Spawns INT," + " projectileType3Spawns INT, projectileType0Hits INT, projectileType1Hits INT, projectileType2Hits INT," + " projectileType3Hits INT, powerUp1PickUps INT, powerUp2PickUps INT, powerUp3PickUps INT)"; dbcmd.CommandText = sqlQuery; dbcmd.ExecuteNonQuery(); } catch { Debug.Log("Error while trying to create new PlayerData table"); } } if (reader != null) { reader.Close(); reader = null; } foreach (PlayerData playerData in lastPlayers) { int myShipIndex = playerData.playerShipIndex; int myPlayerMatchID = playerData.matchID; float myLifetime = playerData.lifetime; int myVictory = 0; if (playerData.victory) { myVictory = 1; } int myProjectileTypeZeroSpawns = playerData.projectileTypeZeroSpawns; int myProjectileTypeOneSpawns = playerData.projectileTypeOneSpawns; int myProjectileTypeTwopawns = playerData.projectileTypeTwopawns; int myProjectileTypeThreeSpawns = playerData.projectileTypeThreeSpawns; int myProjectileTypeZeroHits = playerData.projectileTypeZeroHits; int myProjectileTypeOneHits = playerData.projectileTypeOneHits; int myProjectileTypeTwoHits = playerData.projectileTypeTwoHits; int myProjectileTypeThreeHits = playerData.projectileTypeThreeHits; int myTimesPickedUpPowerUpOne = playerData.timesPickedUpPowerUpOne; int myTimesPickedUpPowerUpTwo = playerData.timesPickedUpPowerUpTwo; int myTimesPickedUpPowerUpThree = playerData.timesPickedUpPowerUpThree; try { sqlQuery = "INSERT INTO PlayerData (shipIndex, matchID, lifetime, victory, projectileType0Spawns," + " projectileType1Spawns, projectileType2Spawns, projectileType3Spawns, projectileType0Hits," + " projectileType1Hits, projectileType2Hits, projectileType3Hits, powerUp1PickUps," + " powerUp2PickUps, powerUp3PickUps) VALUES (" + myShipIndex + ", " + myPlayerMatchID + ", " + myLifetime + ", " + myVictory + ", " + myProjectileTypeZeroSpawns + ", " + myProjectileTypeOneSpawns + ", " + myProjectileTypeTwopawns + ", " + myProjectileTypeThreeSpawns + ", " + myProjectileTypeZeroHits + ", " + myProjectileTypeOneHits + ", " + myProjectileTypeTwoHits + ", " + myProjectileTypeThreeHits + ", " + myTimesPickedUpPowerUpOne + ", " + myTimesPickedUpPowerUpTwo + ", " + myTimesPickedUpPowerUpThree + ")"; dbcmd.CommandText = sqlQuery; dbcmd.ExecuteNonQuery(); } catch { Debug.LogWarning("Error while writing to database"); } if (reader != null) { reader.Close(); reader = null; } } #endregion if (reader != null) { reader.Close(); reader = null; } dbcmd.Dispose(); dbcmd = null; dbconn.Dispose(); dbconn = null; lastMatchData = null; lastPlayers.Clear(); }
private void button3_Click(object sender, EventArgs e) { FileClass1 File1 = new FileClass1() { DataAllCount = 1, DataFlag1 = "dataflag1", DGICount = 1, DGIStr = "dgistr1" }; FileClass1 File2 = new FileClass1() { DataAllCount = 2, DataFlag1 = "dataflag2", DGICount = 2, DGIStr = "dgistr2" }; List<FileClass1> FileList1 = new List<FileClass1>(); FileList1.Add(File1); FileList1.Add(File2); FileClass2 File11 = new FileClass2() { DataAllCount = 1, DataFlag2 = "dataflag1", DGICount = 1, DGIStr = "dgistr1" }; FileClass2 File22 = new FileClass2() { DataAllCount = 2, DataFlag2 = "dataflag2", DGICount = 2, DGIStr = "dgistr2" }; List<FileClass2> FileList2 = new List<FileClass2>(); FileList2.Add(File11); FileList2.Add(File22); MatchData match = new MatchData(); match.Match(FileList1, FileList1, FileList2, "DataFlag1", "DataFlag2"); }
public void SaveTournamentData(string JsonValue, List <TournamentData> TournamentList, GameObject MatchContent) { TournamentList.Clear(); print(JsonValue); var Tournaments = JsonConvert.DeserializeObject <Dictionary <string, object> > (JsonValue); for (int i = 0; i < Tournaments.Count; i++) // Tournament Loop { TournamentData _TournamentData = new TournamentData(); _TournamentData.TournamentName = Tournaments.ElementAt(i).Key.ToString(); _TournamentData.index = i; var Matches = JsonConvert.DeserializeObject <Dictionary <string, object> > (Tournaments.ElementAt(i).Value.ToString()); for (int j = 0; j < Matches.Count; j++) // Games in each Tournament Loop { MatchData _MatchData = new MatchData(); _MatchData.MatchName = Matches.ElementAt(j).Key.ToString(); _MatchData.TournamentName = _TournamentData.TournamentName; _MatchData.index = j; var internalData = JsonConvert.DeserializeObject <Dictionary <string, object> > (Matches.ElementAt(j).Value.ToString()); _MatchData.Team1 = internalData.Where(a => a.Key.Contains("Team1")).First().Value.ToString(); _MatchData.Team2 = internalData.Where(a => a.Key.Contains("Team2")).First().Value.ToString(); _MatchData.Date = DateTime.Parse(internalData.Where(a => a.Key.Contains("Date")).First().Value.ToString()); _MatchData.isLive = bool.Parse(internalData.Where(a => a.Key.Contains("isLive")).First().Value.ToString()); try{ var TotalUserData = JsonConvert.DeserializeObject <Dictionary <string, object> > (internalData.Where(a => a.Key.Contains("Users")).First().Value.ToString()); var UserData = JsonConvert.DeserializeObject <Dictionary <string, object> > (TotalUserData.Where(a => a.Key.Contains(AuthenticationManager.TeamName)).First().Value.ToString()); for (int k = 0; k < UserData.Count; k++) // User team loop if exists { PlayerData _PlayerData = new PlayerData(); _PlayerData.PlayerID = UserData.ElementAt(k).Key.ToString(); var internalPlayerData = JsonConvert.DeserializeObject <Dictionary <string, string> > (UserData.ElementAt(k).Value.ToString()); _PlayerData.Name = internalPlayerData.Where(a => a.Key.Contains("Name")).First().Value.ToString(); _PlayerData.Credit = float.Parse(internalPlayerData.Where(a => a.Key.Contains("Credit")).First().Value.ToString()); // _PlayerData.FantasyPoints = float.Parse(internalPlayerData.Where (a=>a.Key.Contains("FantasyPoints")).First().Value); _PlayerData.Position = internalPlayerData.Where(a => a.Key.Contains("Position")).First().Value.ToString(); if (internalPlayerData.Where(a => a.Key.Contains("isCaptain")).First().Value.ToString() == "true") { _PlayerData.isCaptain = true; } if (internalPlayerData.Where(a => a.Key.Contains("isViceCaptain")).First().Value.ToString() == "true") { _PlayerData.isViceCaptain = true; } _MatchData.MyTeam.Add(_PlayerData); } } catch { } var Team1Data = JsonConvert.DeserializeObject <Dictionary <string, object> > (internalData.Where(a => a.Key.Contains("Team1Players")).First().Value.ToString()); for (int k = 0; k < Team1Data.Count; k++) { PlayerData _PlayerData = new PlayerData(); _PlayerData.PlayerID = Team1Data.ElementAt(k).Key.ToString(); var internalPlayerData = JsonConvert.DeserializeObject <Dictionary <string, string> > (Team1Data.ElementAt(k).Value.ToString()); _PlayerData.Name = internalPlayerData.Where(a => a.Key.Contains("Name")).First().Value.ToString(); _PlayerData.Credit = float.Parse(internalPlayerData.Where(a => a.Key.Contains("Credit")).First().Value.ToString()); _PlayerData.FantasyPoints = float.Parse(internalPlayerData.Where(a => a.Key.Contains("FantasyPoints")).First().Value); _PlayerData.Score = int.Parse(internalPlayerData.Where(a => a.Key.Contains("Score")).First().Value); _PlayerData.Position = internalPlayerData.Where(a => a.Key.Contains("Position")).First().Value.ToString(); _MatchData.Team1Players.Add(_PlayerData); } var Team2Data = JsonConvert.DeserializeObject <Dictionary <string, object> > (internalData.Where(a => a.Key.Contains("Team2Players")).First().Value.ToString()); for (int k = 0; k < Team2Data.Count; k++) { PlayerData _PlayerData = new PlayerData(); _PlayerData.PlayerID = Team2Data.ElementAt(k).Key.ToString(); var internalPlayerData = JsonConvert.DeserializeObject <Dictionary <string, string> > (Team2Data.ElementAt(k).Value.ToString()); _PlayerData.Name = internalPlayerData.Where(a => a.Key.Contains("Name")).First().Value.ToString(); _PlayerData.Credit = float.Parse(internalPlayerData.Where(a => a.Key.Contains("Credit")).First().Value.ToString()); _PlayerData.Position = internalPlayerData.Where(a => a.Key.Contains("Position")).First().Value.ToString(); _PlayerData.FantasyPoints = float.Parse(internalPlayerData.Where(a => a.Key.Contains("FantasyPoints")).First().Value); _PlayerData.Score = int.Parse(internalPlayerData.Where(a => a.Key.Contains("Score")).First().Value); _MatchData.Team2Players.Add(_PlayerData); } var FreeLeagueData = JsonConvert.DeserializeObject <Dictionary <string, object> > (internalData.Where(a => a.Key.Contains("FreeLeagues")).First().Value.ToString()); for (int k = 0; k < FreeLeagueData.Count; k++) { LeagueData _LeagueData = new LeagueData(); var internalLeagueData = JsonConvert.DeserializeObject <Dictionary <string, object> > (FreeLeagueData.ElementAt(k).Value.ToString()); _LeagueData.EntryFee = int.Parse(internalLeagueData.Where(a => a.Key.Contains("EntryFee")).First().Value.ToString()); _LeagueData.TotalTeams = int.Parse(internalLeagueData.Where(a => a.Key.Contains("TotalTeams")).First().Value.ToString()); bool isJoined = false; try{ var EnteredTeamsData = JsonConvert.DeserializeObject <Dictionary <string, object> > (internalLeagueData.Where(a => a.Key.Contains("EnteredTeams")).First().Value.ToString()); for (int l = 0; l < EnteredTeamsData.Count; l++) { TeamData _TeamData = new TeamData(); var TeamData = JsonConvert.DeserializeObject <Dictionary <string, object> > (EnteredTeamsData.ElementAt(l).Value.ToString()); _TeamData.TeamName = EnteredTeamsData.ElementAt(l).Key.ToString(); if (_TeamData.TeamName == AuthenticationManager.TeamName) { isJoined = true; } for (int b = 0; b < TeamData.Count; b++) // Entered teams loop if exists { PlayerData _PlayerData = new PlayerData(); _PlayerData.PlayerID = TeamData.ElementAt(b).Key.ToString(); var internalPlayerData = JsonConvert.DeserializeObject <Dictionary <string, string> > (TeamData.ElementAt(b).Value.ToString()); _PlayerData.Name = internalPlayerData.Where(a => a.Key.Contains("Name")).First().Value.ToString(); _PlayerData.Credit = float.Parse(internalPlayerData.Where(a => a.Key.Contains("Credit")).First().Value.ToString()); // _PlayerData.FantasyPoints = float.Parse(internalPlayerData.Where (a=>a.Key.Contains("FantasyPoints")).First().Value); _PlayerData.Position = internalPlayerData.Where(a => a.Key.Contains("Position")).First().Value.ToString(); if (internalPlayerData.Where(a => a.Key.Contains("isCaptain")).First().Value.ToString() == "true") { _PlayerData.isCaptain = true; } if (internalPlayerData.Where(a => a.Key.Contains("isViceCaptain")).First().Value.ToString() == "true") { _PlayerData.isViceCaptain = true; } _TeamData.PlayerList.Add(_PlayerData); } _LeagueData.EnteredTeams.Add(_TeamData); } } catch { } _MatchData.FreeLeagues.Add(_LeagueData); if (isJoined) { _MatchData.MyLeagues.Add(_LeagueData); } } var PaidLeagueData = JsonConvert.DeserializeObject <Dictionary <string, object> > (internalData.Where(a => a.Key.Contains("PaidLeagues")).First().Value.ToString()); for (int k = 0; k < PaidLeagueData.Count; k++) { LeagueData _LeagueData = new LeagueData(); var internalLeagueData = JsonConvert.DeserializeObject <Dictionary <string, object> > (PaidLeagueData.ElementAt(k).Value.ToString()); _LeagueData.EntryFee = int.Parse(internalLeagueData.Where(a => a.Key.Contains("EntryFee")).First().Value.ToString()); _LeagueData.TotalTeams = int.Parse(internalLeagueData.Where(a => a.Key.Contains("TotalTeams")).First().Value.ToString()); bool isJoined = false; try{ var EnteredTeamsData = JsonConvert.DeserializeObject <Dictionary <string, object> > (internalLeagueData.Where(a => a.Key.Contains("EnteredTeams")).First().Value.ToString()); for (int l = 0; l < EnteredTeamsData.Count; l++) { TeamData _TeamData = new TeamData(); var TeamData = JsonConvert.DeserializeObject <Dictionary <string, object> > (EnteredTeamsData.ElementAt(l).Value.ToString()); _TeamData.TeamName = EnteredTeamsData.ElementAt(l).Key.ToString(); if (_TeamData.TeamName == AuthenticationManager.TeamName) { isJoined = true; } for (int b = 0; b < TeamData.Count; b++) // Entered teams loop if exists { PlayerData _PlayerData = new PlayerData(); _PlayerData.PlayerID = TeamData.ElementAt(b).Key.ToString(); var internalPlayerData = JsonConvert.DeserializeObject <Dictionary <string, string> > (TeamData.ElementAt(b).Value.ToString()); _PlayerData.Name = internalPlayerData.Where(a => a.Key.Contains("Name")).First().Value.ToString(); _PlayerData.Credit = float.Parse(internalPlayerData.Where(a => a.Key.Contains("Credit")).First().Value.ToString()); // _PlayerData.FantasyPoints = float.Parse(internalPlayerData.Where (a=>a.Key.Contains ("FantasyPoints")).First().Value); _PlayerData.Position = internalPlayerData.Where(a => a.Key.Contains("Position")).First().Value.ToString(); if (internalPlayerData.Where(a => a.Key.Contains("isCaptain")).First().Value.ToString() == "true") { _PlayerData.isCaptain = true; } if (internalPlayerData.Where(a => a.Key.Contains("isViceCaptain")).First().Value.ToString() == "true") { _PlayerData.isViceCaptain = true; } _TeamData.PlayerList.Add(_PlayerData); } _LeagueData.EnteredTeams.Add(_TeamData); } } catch { } _MatchData.PaidLeagues.Add(_LeagueData); if (isJoined) { _MatchData.MyLeagues.Add(_LeagueData); } } _TournamentData.Tournaments.Add(_MatchData); } _TournamentData.Tournaments.Sort((x, y) => x.Date.CompareTo(y.Date)); TournamentList.Add(_TournamentData); } CreateObjects(TournamentList, MatchContent); // AppUIManager.instance.Loading (false); // UIManager.ShowNotification("Example_1_Notification_4", 0.5f, true, "Data retrieved", test); }
public int WriteMatches( MatchData matchData, MatchCommandOptions options, in CancellationToken cancellationToken = default)
public void CheckNeighboursForColor(List <ColorIndex> colorcheck, bool isDragDrop) { //Debug.Log("CHECKING FOR: "+colorcheck[0].ToString()+" "+colorcheck[1].ToString()+" "+colorcheck[2].ToString()); int neighbourHasColor = 0; bool MatchFound = false; for (int i = 0; i < colorcheck.Count; i++) { //Debug.Log("CURRENTLY CHECKING FOR: "+colorcheck[i]); //Debug.Log("CHECKING FOR: "+colorcheck[i].ToString()); if (colorcheck[i] != ColorIndex.NONE) { foreach (ReferencePointBehaviour neighbour in neighbours) { if (neighbour.GetComponent <RingPointManager>().HaveColor(colorcheck[i])) { neighbourHasColor++; Vector3 currentPosition = new Vector3(Xcoor, Ycoor, Zcoor); Vector3 neighbourPosition = new Vector3(neighbour.Xcoor, neighbour.Ycoor, neighbour.Zcoor); Vector3 backwardsVector = currentPosition - neighbourPosition; Vector3 forwardVector = backwardsVector * -1; // DO FORWARD CHECK (ASSUMING ITS THE END OF A 3 MATCH) ReferencePointBehaviour forwardNeighbour = TransformationGrid.instance.GetReferencePointByIndex(neighbourPosition + forwardVector); ReferencePointBehaviour backwardNeighbour = TransformationGrid.instance.GetReferencePointByIndex(currentPosition + backwardsVector); if (forwardNeighbour != null) { if (forwardNeighbour.GetComponent <RingPointManager>().HaveColor(colorcheck[i])) { // OKAY! I FOUND 3 IN A LINE, NOW ADD THE MATCH IN MATCHMANAGER //Debug.Log("WE FOUND MATCH"); MatchData foundMatch = new MatchData(); foundMatch.colorMark = colorcheck[i]; foundMatch.markedObjects = new List <RingBehaviour>(); foundMatch.markedObjects.Add(gameObject.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED OWN"); foundMatch.markedObjects.Add(neighbour.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED neighbour"); foundMatch.markedObjects.Add(forwardNeighbour.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED forwardneighbour"); MatchFound = true; MatchController.instance.StoreMatch(foundMatch); } } // DO BACKWARD CHECK (ASSUME ITS THE MIDDLE OF A 3 MATCH) if (backwardNeighbour != null) { if (backwardNeighbour.GetComponent <RingPointManager>().HaveColor(colorcheck[i])) { //Debug.Log("WE FOUND MATCH"); MatchData foundMatch = new MatchData(); foundMatch.colorMark = colorcheck[i]; foundMatch.markedObjects = new List <RingBehaviour>(); foundMatch.markedObjects.Add(gameObject.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED OWN"); foundMatch.markedObjects.Add(neighbour.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED neighbour"); foundMatch.markedObjects.Add(backwardNeighbour.GetComponent <RingPointManager>().Ring); //Debug.Log("ADDED forwardneighbour"); MatchFound = true; MatchController.instance.StoreMatch(foundMatch); } } } } } } if (!MatchFound) { // NO MATCH FOUND, RESET THE COMBO :< if (isDragDrop) { GameController.instance.onNoMatchEvent(); ScoreController.instance.ResetCombo(); } } else { // CHECKS HAS BEEN DONE - CLEAR ALL MARKED RINGS OFF GAME CONTROLLERS MatchController.instance.ClearPendingMatches(); } //Debug.Log("NEIGHBOURS HAS " + neighbourHasColor + " SIMILAR COLORS TIERS"); }
private void RaiseMatchEvent(MatchData match) { Debug.Log("Match!! " + match.indexList.Count); }
protected void AssertMatchDataEqual(MatchData expected, MatchData actual, string errorMessage, params object[] errorArgs) { Assert.AreEqual(expected.Match, actual.Match, errorMessage, errorArgs); Assert.AreEqual(expected.IgnoreCase, actual.IgnoreCase, errorMessage, errorArgs); }
public void LaunchMatch(TurnBasedMatch match) { Reset(); mMatch = match; MakeActive(); if (mMatch == null) { throw new System.Exception("PlayGui can't be started without a match!"); } try { // Note that mMatch.Data might be null (when we are starting a new match). // MatchData.MatchData() correctly deals with that and initializes a // brand-new match in that case. mMatchData = new MatchData(mMatch.Data); } catch (MatchData.UnsupportedMatchFormatException ex) { mFinalMessage = "Your game is out of date. Please update your game\n" + "in order to play this match."; Debug.LogWarning("Failed to parse board data: " + ex.Message); return; } // determine if I'm the 'X' or the 'O' player mMyMark = mMatchData.GetMyMark(match.SelfParticipantId); bool canPlay = (mMatch.Status == TurnBasedMatch.MatchStatus.Active && mMatch.TurnStatus == TurnBasedMatch.MatchTurnStatus.MyTurn); if (canPlay) { mShowInstructions = true; } else { mFinalMessage = ExplainWhyICantPlay(); } // if the match is in the completed state, acknowledge it if (mMatch.Status == TurnBasedMatch.MatchStatus.Complete) { PlayGamesPlatform.Instance.TurnBased.AcknowledgeFinished(mMatch.MatchId, (bool success) => { if (!success) { Debug.LogError("Error acknowledging match finish."); } }); } // set up the objects to show the match to the player SetupObjects(canPlay); }
public virtual void CreateRounds() { //Get teams that were added DataList.Clear(); List <TeamData> list = TournamentCreation.Instance.TeamList; List <TeamData> teams = new List <TeamData>(list); totalTeams = list.Count; if (totalTeams == 0) { return; } teamAmountLabel.text = totalTeams + " Teams"; if (totalTeams % 2 != 0) { totalTeams++; } int i = 0; foreach (TeamData team in list) { teams[i] = team; i++; } //Fill gaps with placeholders placeholderList = new List <TeamData>(); if (list.Count < totalTeams) { for (int t = i; t < totalTeams; t++) { teams.Add(placeholderTeam); } } //Create rounds int totalRounds = totalTeams - 1; int half = totalTeams / 2; List <TeamData> listA = new List <TeamData>(teams); List <TeamData> listB = new List <TeamData>(teams); TeamData homeTeam; TeamData awayTeam; int day = (int)WeekDay.Sunday; int maxGamesPerDay = half < 6 ? half : 6; int totalGames = 0; int totalGameDays = 0; int weekDay = 0; for (int round = 0; round < totalRounds; round++) { for (int t = 0; t < half; t++) { if (round % 2 == 0) { homeTeam = listA[t]; awayTeam = listA[totalRounds - t]; } else { homeTeam = listA[totalRounds - t]; awayTeam = listA[t]; } if (round > totalGameDays || totalGames % maxGamesPerDay == 0) { if (weekDay == 0) { day += 3; // if it's Sunday skips to Wednesday } else { day += 4; // if it's Wednesday skips to Sunday } weekDay = (weekDay == 0) ? 1 : 0; totalGameDays++; } totalGames++; MatchData data = new MatchData(homeTeam, awayTeam, round, day, TournmanentName, TournamentId); DataList.Add(data); } //Rotate teams listA = new List <TeamData>(listB); for (int k = 1; k < teams.Count; k++) { if (k == teams.Count - 1) { listA[1] = listB[k]; } else { listA[k + 1] = listB[k]; } } listB = new List <TeamData>(listA); } if (homeAwayTeams.isOn) { if (totalGames < maxGamesPerDay) { day += 7; } MatchData matchData; List <MatchData> dList = new List <MatchData>(DataList); int round; foreach (MatchData data in dList) { round = data.Round + totalRounds; if (totalGames % maxGamesPerDay == 0) { if (weekDay == 0) { day += 3; // if it's Sunday skips to Wednesday } else { day += 4; // if it's Wednesday skips to Sunday } weekDay = (weekDay == 0) ? 1 : 0; } matchData = new MatchData(data, round, day); DataList.Add(matchData); totalGames++; } } UpdateMatchList(); }
private MatchData GetOneIndexMatchData(int x, int y) { var index = BoardConfig.GetIndex(x, y); int baseGem = PuzzleBoard.GetGemAtPos(x, y); if (baseGem == GemConverter.NoGem) { return(null); } var leftMatch = MatchLeftCount(x, y, baseGem); var rightMatch = MatchRightCount(x, y, baseGem); var upMatch = MatchUpCount(x, y, baseGem); var downMatch = MatchDownCount(x, y, baseGem); var horizontalMatch = 1 + leftMatch + rightMatch; var verticalMatch = 1 + upMatch + downMatch; if (horizontalMatch > 2 && verticalMatch > 2) { //corner match var matchData = new MatchData(index); matchData.AddIndex(BoardConfig.GetIndex(x, y)); while (leftMatch > 0) { leftMatch--; matchData.AddIndex(BoardConfig.GetIndex(x - leftMatch, y)); } while (rightMatch > 0) { rightMatch--; matchData.AddIndex(BoardConfig.GetIndex(x + rightMatch, y)); } while (upMatch > 0) { upMatch--; matchData.AddIndex(BoardConfig.GetIndex(x, y - upMatch)); } while (downMatch > 0) { downMatch--; matchData.AddIndex(BoardConfig.GetIndex(x, y + downMatch)); } return(matchData); } else if (horizontalMatch > 2) { var startx = x + rightMatch; // simple side match var matchData = new MatchData(index); while (horizontalMatch > 0) { horizontalMatch--; matchData.AddIndex(BoardConfig.GetIndex(startx - horizontalMatch, y)); } return(matchData); } else if (verticalMatch > 2) { var starty = y + downMatch; // vertical var matchData = new MatchData(index); while (verticalMatch > 0) { verticalMatch--; matchData.AddIndex(BoardConfig.GetIndex(x, starty - verticalMatch)); } return(matchData); } return(null); }
public void Populate(MatchData _data) { match.Populate(_data); }
protected override MenuScreen ProtectedUpdate(MenuScreen.ScreenLayout layout) { DrawTitleString("Choose a game-type and level:", layout.Title); #region Draw matches and levels. //Some layout data. Rect body = layout.Body; float sSubtitleYOffset = body.height * Consts.Settings_SubtitleYOffset, sSubtitleHeight = body.height * Consts.Settings_SubtitleHeight; float sListYOffset = body.height * Consts.Settings_List_YOffset; float sListXOffset = body.width * Consts.Settings_List_XOffset; float sListSpacing = body.height * Consts.Settings_List_Spacing; Vector2 sListButtonSize = new Vector2(body.width * Consts.Settings_List_ButtonSize.x, body.height * Consts.Settings_List_ButtonSize.y); float sTooltipXOffset = body.width * Consts.Settings_TooltipXOffset, sTooltipYOffset = body.height * Consts.Settings_TooltipYOffset, sTooltipWidth = body.width * Consts.Settings_TooltipWidth; //Some layout rectangles. Rect matchesSubtitleRect = new Rect(body.xMin + sListXOffset, body.yMin + sSubtitleYOffset, sListButtonSize.x, sSubtitleHeight), levelsSubtitleRect = new Rect(body.xMax - sListXOffset - sListButtonSize.x, matchesSubtitleRect.yMin, matchesSubtitleRect.width, matchesSubtitleRect.height); MyGUI.RadioButtonsLayout matchesLayout = Consts.Settings_List_Layout(new Vector2(matchesSubtitleRect.xMin, matchesSubtitleRect.yMax + sListYOffset), body), levelsLayout = Consts.Settings_List_Layout(new Vector2(levelsSubtitleRect.xMin, levelsSubtitleRect.yMax + sListYOffset), body); Rect tooltipRect = new Rect(matchesSubtitleRect.xMax + sTooltipXOffset, body.yMin + sTooltipYOffset, sTooltipWidth, body.height - sTooltipYOffset); //Display the matches. if (matches == null) { GUI.color = Color.black; GUI.Label(body, "XML error when reading match settings:\n\"" + matchSettings.ErrorMessage + "\"."); } else { GUI.Label(matchesSubtitleRect, "Game-types", WorldConstants.GUIStyles.SubtitleLabels); selectedMatchIndex = MyGUI.RadioButtons(matches, selectedMatchIndex, matchesLayout, false, WorldConstants.GUIStyles.SettingsRadioButtons); selectedMatch = matches[selectedMatchIndex].text; MatchData.MatchSettings = matchSets[selectedMatchIndex]; } //Display the levels. if (levels == null) { GUI.color = Color.black; GUI.Label(body, "XML error when reading level settings:\n\"" + levelGeneration.ErrorMessage + "\"."); } else { GUI.Label(levelsSubtitleRect, "Levels", WorldConstants.GUIStyles.SubtitleLabels); int old = selectedLevelGenIndex; selectedLevelGenIndex = MyGUI.RadioButtons(levels, selectedLevelGenIndex, levelsLayout, false, WorldConstants.GUIStyles.SettingsRadioButtons); selectedLevelGen = levels[selectedLevelGenIndex].text; if (selectedLevelGen == "Open") { MatchStartData.IsGeneratingOpen = true; } else { MatchStartData.IsGeneratingOpen = false; } if (old != selectedLevelGenIndex) { MatchData.GeneratedLevel = levelGens[selectedLevelGenIndex]; MatchData.GenerateLevelAndSpawns(); } } GUI.color = Color.white; GUI.Label(tooltipRect, GUI.tooltip, WorldConstants.GUIStyles.SettingsTooltip); #endregion return(DrawButtonMenu(layout.ButtonMenu, new GUIContent[] { new GUIContent("Back"), new GUIContent("Continue") }, new GetData <MenuScreen>[] { () => new MainMenuScreen(MatchData, Consts, Owner), () => new LobbyMenuScreen(MatchData, Consts, Owner) }, this)); }
public VenueStats(Venue venue, DateTime fromDate, DateTime toDate, List <MatchType> matchTypes) { _venue = venue; ID = venue.ID; FilteredMatchData = MatchData.Where(a => a.MatchDate > fromDate).Where(a => a.MatchDate < toDate).Where(a => matchTypes.Contains(a.Type)).ToList(); }
private void AddMatch(MatchData matchData) { var regex = new Regex(@"^([0-9].11)"); var match = new InitialDataUpload.Models.Match(); match.MatchId = matchData.matchId; match.Is_Ranked = matchData.queueType.Equals("RANKED_SOLO_5x5"); match.Match_Region = dictRegion[matchData.region]; match.Pre_Change = regex.IsMatch(matchData.matchVersion); match.Players = new List<Player>(); foreach (InitialDataUpload.Models.Participant participant in matchData.participants) { var itemsBought = string.Format("{0},{1},{2},{3},{4},{5},{6}", participant.stats.item0, participant.stats.item1, participant.stats.item2, participant.stats.item3, participant.stats.item4, participant.stats.item5, participant.stats.item6); var player = new Player { Rank = dictRank[participant.highestAchievedSeasonTier], Region = dictRegion[matchData.region], Winner = participant.stats.winner, ItemsBought = itemsBought, Kills = participant.stats.kills, Deaths = participant.stats.deaths, Assists = participant.stats.assists, TripleKills = participant.stats.tripleKills, QuadraKills = participant.stats.quadraKills, PentaKills = participant.stats.pentaKills, MagicDamageDealt = participant.stats.magicDamageDealt, LargestKillingSpree = participant.stats.largestKillingSpree }; player.ChampionUsed = MatchesContext.Champions.Where(c => c.ChampionId == participant.championId).Single(); match.Players.Add(player); } match.Highest_Rank = (Rank)match.Players.Select(p => p.Rank).Max(); Matches.Add(match); }
public CreateMatchMenuScreen(MatchStartData matchStartData, FrontEndConstants consts, ScreenUI owner) : base(matchStartData, consts, owner) { //Initialize data. //Debug.Log("Reading matches:"); XmlDocument matchDoc = new XmlDocument(); matchDoc.LoadXml(Owner.MatchesFile.text); //matchDoc.LoadXml(Owner.MatchesFile.text.Substring(1, Owner.MatchesFile.text.Length - 1)); matchSettings = new MatchSettingsReadWrite(matchDoc); //Debug.Log("Read matches"); //Debug.Log("Reading levels:"); XmlDocument levelsDoc = new XmlDocument(); levelsDoc.LoadXml(Owner.LevelsFile.text); //levelsDoc.LoadXml(Owner.LevelsFile.text.Substring(1, Owner.LevelsFile.text.Length - 1)); levelGeneration = new LevelGenerationReadWrite(levelsDoc); //Debug.Log("Read levels"); selectedMatch = "Unreadable"; selectedLevelGen = "Unreadable"; selectedMatchIndex = 0; selectedLevelGenIndex = 0; //Read matches. if (matchSettings.ErrorMessage == "") { matches = new GUIContent[matchSettings.Matches.Count()]; matchSets = new Rules[matches.Length]; int count = 0; foreach (string rulesN in matchSettings.Matches) { matchSets[count] = matchSettings.ReadMatch(rulesN); if (matchSettings.ErrorMessage != "") { matches = null; matchSets = null; break; } matches[count] = new GUIContent(rulesN, matchSets[count].Description); count += 1; } selectedMatchIndex = Search(Convert(matches, m => m.text), "Brawl", (s1, s2) => s1 == s2); selectedMatch = matches[selectedMatchIndex].text; MatchData.MatchSettings = matchSets[selectedMatchIndex]; } else { matches = null; matchSets = null; } //Read levels. if (levelGeneration.ErrorMessage == "") { levels = new GUIContent[levelGeneration.Levels.Count()]; levelGens = new Generator[levels.Length]; int count = 0; foreach (string levelN in levelGeneration.Levels) { levelGens[count] = levelGeneration.ReadGenerator(levelN); if (levelGeneration.ErrorMessage != "") { levels = null; levelGens = null; break; } levels[count] = new GUIContent(levelN, levelGens[count].Description); count += 1; } selectedLevelGenIndex = Search(Convert(levels, l => l.text), "Corridor", (s1, s2) => s1 == s2); selectedLevelGen = levels[selectedLevelGenIndex].text; MatchData.GeneratedLevel = levelGens[selectedLevelGenIndex]; MatchData.GenerateLevelAndSpawns(); } else { levels = null; levelGens = null; } }