/// <summary> /// Used by Fight class only /// </summary> /// <param name="fighter"></param> /// <returns></returns> internal void AddFighter(Fighter fighter) { if (Fighters.Any(x => x.Id == fighter.Id)) { throw new Exception(string.Format("Fighter with id {0} already exists", fighter.Id)); } m_fighters.Add(fighter); if (m_unknownLeaderId != null && fighter.Id == m_unknownLeaderId) { Leader = fighter; m_unknownLeaderId = null; } var evnt = FighterAdded; if (evnt != null) { evnt(this, fighter); } }
// public void AddLine(Zone line) { } // public void AddLine(Chat line) { } private void DeterminePrimaryMob(Attack line) { // If mob already set, don't change it if (PrimaryMob != Character.Unknown) { return; } // If it's a mob, set it if (CharResolver.WhichType(line.Attacker) == CharacterResolver.Type.NonPlayerCharacter) { PrimaryMob = line.Attacker; return; } if (CharResolver.WhichType(line.Defender) == CharacterResolver.Type.NonPlayerCharacter) { PrimaryMob = line.Defender; return; } // If we've got multiple lines, we should be able to see who's the main target by the fact that everyone keeps beating them up if (!Fighters.Any()) { return; } // Note: this finds the fighter who has the most combined attack lines // better would be to find the fight with the most distinct other fighters who have been attacking them var topFighter = Fighters.Aggregate((maxItem, nextItem) => maxItem.DefensiveStatistics.Lines.Count + maxItem.OffensiveStatistics.Lines.Count > nextItem.DefensiveStatistics.Lines.Count + nextItem.OffensiveStatistics.Lines.Count ? maxItem : nextItem); if (topFighter.DefensiveStatistics.Lines.Count + topFighter.OffensiveStatistics.Lines.Count >= 2) { PrimaryMob = topFighter.Character; } }
protected bool IsFreeCell(int cellId) { return(!Fighters.Any(f => f != null && f.CellId == cellId)); }
public bool IsInFight(string character) { return(Fighters.Any(x => x.Name.ToLower() == character.ToLower())); }