public static ErrorCodes LoadById(int id, out ProductionLine productionLine) { productionLine = null; var record = Db.Query().CommandText(SELECT_LINE + " where id=@ID").SetParameter("@ID", id) .ExecuteSingleRow(); if (record == null) { return(ErrorCodes.ItemNotFound); } productionLine = CreateFromRecord(record); return(ErrorCodes.NoError); }
public static ErrorCodes LoadByProductionId(Character character, int productionInProgressId, out ProductionLine productionLine) { productionLine = null; var record = Db.Query().CommandText(SELECT_LINE + " where characterid=@characterID and runningproductionid=@rpid") .SetParameter("@characterID", character.Id) .SetParameter("@rpid", productionInProgressId) .ExecuteSingleRow(); if (record == null) { return(ErrorCodes.ItemNotFound); } productionLine = CreateFromRecord(record); return(ErrorCodes.NoError); }
public IDictionary <string, object> LineStartInMill(Character character, Container sourceContainer, int lineId, int cycles, bool useCorporationWallet, bool searchInRobots, Mill mill, int rounds) { const int maxCycles = 1; cycles.ThrowIfGreater(maxCycles, ErrorCodes.ProductionMaxCyclesExceeded); var maxRounds = Mill.GetMaxRounds(character); if (rounds > maxRounds) { rounds = maxRounds; } ProductionLine productionLine; ProductionLine.LoadById(lineId, out productionLine).ThrowIfError(); productionLine.CharacterId.ThrowIfNotEqual(character.Id, ErrorCodes.OwnerMismatch); productionLine.IsActive().ThrowIfTrue(ErrorCodes.ProductionIsRunningOnThisLine); productionLine.IsAtZero().ThrowIfTrue(ErrorCodes.ProductionLineIsAtZero); if (productionLine.Rounds != rounds) { ProductionLine.SetRounds(rounds, productionLine.Id).ThrowIfError(); productionLine.Rounds = rounds; } bool hasBonus; var newProduction = mill.LineStart(character, productionLine, sourceContainer, cycles, useCorporationWallet, out hasBonus); if (newProduction == null) { if (useCorporationWallet) { throw new PerpetuumException(ErrorCodes.CorporationNotEnoughMoney); } throw new PerpetuumException(ErrorCodes.CharacterNotEnoughMoney); } //return info var replyDict = new Dictionary <string, object>(); var linesList = mill.GetLinesList(character); replyDict.Add(k.lines, linesList); replyDict.Add(k.lineCount, linesList.Count); var productionDict = newProduction.ToDictionary(); replyDict.Add(k.production, productionDict); var informDict = sourceContainer.ToDictionary(); replyDict.Add(k.sourceContainer, informDict); var facilityInfo = mill.GetFacilityInfo(character); replyDict.Add(k.facility, facilityInfo); replyDict.Add(k.hasBonus, hasBonus); return(replyDict); }