private int GetShotCount(bool isOpponentAttack) { int shotCount = 0; myShots.ForEach(r => { DbAttack attack = DbManager.Instance.GameDbManager.GetAttackById(r.AttackId); if (attack.IsOpponentAttack == isOpponentAttack) { shotCount += r.Count; } }); return(shotCount + GetGoalCount(isOpponentAttack)); }
private int GetReboundCount(bool isOpponentAttack) { int reboundCount = 0; myRebounds.ForEach(r => { DbAttack attack = DbManager.Instance.GameDbManager.GetAttackById(r.AttackId); if (attack.IsOpponentAttack == isOpponentAttack) { reboundCount += r.Count; } }); return(reboundCount); }
private void SetFormation() { DbAttack lastAttack = myGameDbManager.GetLastAttackOfGame(Game.Id); if (lastAttack == null) // start game { StartingFunction = Game.IsHome ? EZoneFunction.Attack : EZoneFunction.Defence; CurrentFunction = Game.IsHome ? EZoneFunction.Attack : EZoneFunction.Defence; } else { bool isGameH1 = Game.Status == "H1"; if (lastAttack.IsFirstHalf == isGameH1) { // half is started StartingFunction = lastAttack.ZoneStartFunction == "A" ? EZoneFunction.Attack : EZoneFunction.Defence; CurrentFunction = lastAttack.IsOpponentAttack ? EZoneFunction.Defence : EZoneFunction.Attack; ChangeFunction(lastAttack.GoalId != null); } else { // start H2 string lastDefendingZone = ""; if (lastAttack.IsOpponentAttack) { lastDefendingZone = lastAttack.ZoneStartFunction == "A" ? "A" : "D"; } else { lastDefendingZone = lastAttack.ZoneStartFunction == "A" ? "D" : "A"; } StartingFunction = lastAttack.ZoneStartFunction == "A" ? EZoneFunction.Attack : EZoneFunction.Defence; CurrentFunction = lastAttack.IsOpponentAttack ? EZoneFunction.Defence : EZoneFunction.Attack; ChangeFunction(lastAttack.GoalId != null); var newCurrentFunction = !Game.IsHome ? EZoneFunction.Attack : EZoneFunction.Defence; if (newCurrentFunction != CurrentFunction) { StartingFunction = StartingFunction == EZoneFunction.Attack ? EZoneFunction.Defence : EZoneFunction.Attack; } CurrentFunction = newCurrentFunction; Init(); } } CurrentAttack = new Attack(CurrentFunction, StartingFunction, Game.Id, true); }
private int GetAssitCount(bool isOpponent) { int assistCount = 0; myAssist.ForEach(g => { DbAttack attack = myAttacks.FirstOrDefault(a => { if (!a.GoalId.HasValue) { return(false); } return(a.GoalId.Value == g.Id); }); if (attack.IsOpponentAttack == isOpponent) { assistCount++; } }); return(assistCount); }