public static MatchStat CreateMatchStat(string Map) { var mtemp = new MatchStat { assists = 0, avatar = 1, command = 1, damage = 1000000, faction = 1, kills = 0, lance = 1, level = Map, matchscore = 1, matchType = "Conquest", team = "friendly", name = "DrAmensia", mech = "JR7-F", victory = 1, victoryType = "capture", ping = 100, status = 0, time = DateTime.UtcNow }; return(mtemp); }
private void WriteNewScore(int kamikaze_red, int kill_red, int kamikaze_blue, int kill_blue, int team_lose) { // Create new entry at /user-scores/$userid/$scoreid and at // /leaderboard/$scoreid simultaneously string key = mDatabase.Child("MatchInfo").Push().Key; MatchStat entry = new MatchStat(kamikaze_red, kill_red, kamikaze_blue, kill_blue, team_lose); Dictionary <string, System.Object> entryValues = entry.ToDictionary(); Dictionary <string, System.Object> childUpdates = new Dictionary <string, System.Object>(); childUpdates["/matchInfo/" + key] = entryValues; mDatabase.UpdateChildrenAsync(childUpdates); }
public static MatchStat ImportToMatchStat(MwoAMatchMetrics_import ims) { var ms = new MatchStat(); ms.assists = ims.assists; ms.damage = ims.damage; ms.kills = ims.kills; ms.lance = ims.lance; ms.level = ims.level; ms.matchType = ims.matchType; ms.matchscore = ims.matchscore; ms.mech = ims.mech; ms.name = ims.name; ms.ping = ims.ping; ms.team = ims.team; ms.time = DateTime.Parse(ims.time); ms.victory = ims.victory; ms.victoryType = ims.victoryType; ms.status = ims.status; return(ms); }
/*public static DropDeck12 SetChassis(this DropDeck12 dropdeck12, MwaDBContext db) * { * * } * */ public static MatchDrop GetLoggedMatchDrop(this MatchLogger.MatchLogger.LoggedMatch value, MwaDBContext db) { List <String> friendlyMechs = value.FriendlyMatchStats.Select(f => f.mech).OrderBy(m => m).ToList(); List <String> enemyMechs = value.EnemyMatchStats.Select(f => f.mech).OrderBy(m => m).ToList(); int tdmg = value.FriendlyMatchStats.Select(f => f.damage).Sum() + value.EnemyMatchStats.Select(e => e.damage).Sum(); MatchStat ms = value.FriendlyMatchStats.FirstOrDefault(l => l.level != "" && l.level != null); DropDeck12 fdd = SetDropDeck(friendlyMechs, db); DropDeck12 edd = SetDropDeck(enemyMechs, db); Association assoc = db.Associations.FirstOrDefault(a => a.AssociationName == value.AssociationName); var md = new MatchDrop { AssociationName = value.AssociationName, AssociationId = assoc.AssociationId, Association = db.Associations.FirstOrDefault(i => i.AssociationId == assoc.AssociationId), FriendlyDropDeck12 = db.DropDeck12s.FirstOrDefault(f => f.DropDeck12Id == fdd.DropDeck12Id), FriendlyDropDeck12Id = fdd.DropDeck12Id, EnemyDropDeck12 = db.DropDeck12s.FirstOrDefault(e => e.DropDeck12Id == edd.DropDeck12Id), EnemyDropDeck12Id = edd.DropDeck12Id, Map = db.Maps.FirstOrDefault(a => a.MapAltName1 == ms.level) }; md.MatchHash = md.CalcMatchHash(tdmg); if (db.MatchDrops.Any(m => m.MatchHash == md.MatchHash && m.AssociationName == value.AssociationName)) { md = db.MatchDrops.FirstOrDefault(m => m.MatchHash == md.MatchHash && m.AssociationName == value.AssociationName); } else { db.MatchDrops.Add(md); db.SaveChanges(); foreach (MatchStat fm in value.FriendlyMatchStats) { MWA.Models.MwoAMatchMetric matchtopush = new MWA.Models.MwoAMatchMetric(); matchtopush.assists = fm.assists; matchtopush.damage = fm.damage; matchtopush.kills = fm.kills; matchtopush.lance = fm.lance; matchtopush.level = fm.level; matchtopush.matchType = fm.matchType; matchtopush.matchscore = fm.matchscore; matchtopush.mech = fm.mech; matchtopush.name = fm.name; matchtopush.ping = fm.ping; matchtopush.status = fm.status; matchtopush.team = fm.team; matchtopush.victory = fm.victory; matchtopush.victoryType = fm.victoryType; matchtopush.time = fm.time.ToUniversalTime().ToString(); matchtopush.MatchHash = value.MatchHash; matchtopush.PublishFlag = 1; matchtopush.PublishingUserName = (value.PublishingUserName == fm.name); matchtopush.MatchDrop = db.MatchDrops.FirstOrDefault(m => m.MatchDropId == md.MatchDropId); db.MwoAMatchMetrics.Add(matchtopush); db.SaveChanges(); } foreach (MatchStat em in value.EnemyMatchStats) { MWA.Models.MwoAMatchMetric matchtopush = new MWA.Models.MwoAMatchMetric(); matchtopush.assists = em.assists; matchtopush.damage = em.damage; matchtopush.kills = em.kills; matchtopush.lance = em.lance; matchtopush.level = em.level; matchtopush.matchType = em.matchType; matchtopush.matchscore = em.matchscore; matchtopush.mech = em.mech; matchtopush.name = em.name; matchtopush.ping = em.ping; matchtopush.status = em.status; matchtopush.team = em.team; matchtopush.victory = em.victory; matchtopush.victoryType = em.victoryType; matchtopush.time = em.time.ToUniversalTime().ToString(); matchtopush.MatchHash = value.MatchHash; matchtopush.PublishFlag = 1; matchtopush.PublishingUserName = (value.PublishingUserName == em.name); matchtopush.MatchDrop = db.MatchDrops.FirstOrDefault(m => m.MatchDropId == md.MatchDropId); db.MwoAMatchMetrics.Add(matchtopush); db.SaveChanges(); } } return(md); }
public History AddMatch(MatchStat matchStat) { this._matches.Add(matchStat); return(this); }