public int CountByUnitDefId(PlayerId playerId, UnitDefId unitDefId) { world.ValidatePlayer(playerId); return(Units(playerId) .Where(x => x.UnitDefId.Equals(unitDefId)) .Sum(x => x.Count)); }
public IEnumerable <UnitImmutable> GetByUnitDefId(PlayerId playerId, UnitDefId unitDefId) { world.ValidatePlayer(playerId); return(Units(playerId) .Where(x => x.UnitDefId.Equals(unitDefId)) .Select(x => x.ToImmutable())); }
private void AddUnit(PlayerId playerId, UnitDefId unitDefId, int count) { Units(playerId).Add(new Unit { UnitId = Id.NewUnitId(), UnitDefId = unitDefId, Count = count }); }
public UnitDefNotFoundException(UnitDefId unitDefId) : base($"Unit '{unitDefId.Id}' does not exist.") { }
private void RemoveUnitsOfType(PlayerId playerId, UnitDefId unitDefId) { Units(playerId).RemoveAll(x => x.UnitDefId == unitDefId); }