naprawione smieci
This commit is contained in:
parent
e861f1fa7b
commit
a70153a4d3
@ -141,7 +141,7 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
||||
|
||||
Console.WriteLine(collector.HouseCounter);
|
||||
|
||||
if (collector.Counter> 100 || length > 100)
|
||||
if (collector.Counter> 100 || length > 1000)
|
||||
return new KeyValuePair<List<IStep>, int>(null,length);
|
||||
count++;
|
||||
if (Houses.All(c => (grid[c.X, c.Y] as IGarbageLocalization).TrashCans.All(j => j.FillPercent == 0.0))
|
||||
|
@ -30,17 +30,17 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
||||
get { return ((double)Garbage.Volume) / this.MaxVolume; }
|
||||
}
|
||||
|
||||
public virtual void AddGarbage(AGarbage garbage)
|
||||
public virtual bool AddGarbage(AGarbage garbage)
|
||||
{
|
||||
//if (this.TypeOfGarbage.GarbageType != garbage.TypeOfGarbage.GarbageType)
|
||||
// throw new Exception("You cannot add up different type garbage!");
|
||||
|
||||
var newGarbage = this.Garbage + garbage;
|
||||
//if (newGarbage.Volume > this.MaxVolume)
|
||||
// throw new Exception("Trash overload");
|
||||
if (newGarbage.Volume > this.MaxVolume)
|
||||
return false;
|
||||
|
||||
this.Garbage = newGarbage;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual object Clone()
|
||||
@ -52,7 +52,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
||||
{
|
||||
|
||||
if (this.Garbage.Weight == 0)
|
||||
throw new Exception("Pusty śmietnik matole");
|
||||
return null;
|
||||
var result = (AGarbage)this.Garbage.Clone();
|
||||
this.Garbage.Weight = 0;
|
||||
return result;
|
||||
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Exceptions;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
@ -28,13 +29,15 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||
|
||||
var trashCans = _garbageLocalization.TrashCans.Where(t => t.TypeOfGarbage.GarbageType == _typeOfGarbage);
|
||||
if (!trashCans.Any()) return false;
|
||||
var garbage = trashCans.Select(t => t.TakeGarbage()).Aggregate((a,b)=>a+b);
|
||||
var preGarbage = trashCans.Select(t => t.TakeGarbage()).ToList();
|
||||
if (preGarbage.Any(x => x == null)) return false;
|
||||
var garbage = preGarbage.Aggregate((a,b)=>a+b);
|
||||
|
||||
if (_garbageCollector.TrashContainers.All(c => c.TypeOfGarbage.GarbageType != _typeOfGarbage))
|
||||
return false;
|
||||
|
||||
_garbageCollector.TrashContainers.First(t => t.TypeOfGarbage.GarbageType == _typeOfGarbage).AddGarbage(garbage);
|
||||
|
||||
var r = _garbageCollector.TrashContainers.First(t => t.TypeOfGarbage.GarbageType == _typeOfGarbage).AddGarbage(garbage);
|
||||
if (!r) return false;
|
||||
for (int x= 0;x < grid.GetLength(0); x++){
|
||||
for (int y = 0; y < grid.GetLength(1); y++)
|
||||
{
|
||||
|
@ -32,8 +32,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||
var containers = _garbageCollector.TrashContainers.Where(t => t.TypeOfGarbage.GarbageType == _typeOfGarbage && t.FillPercent > 0);
|
||||
if (containers.Any())
|
||||
{
|
||||
var garbage = containers.Select(t => t.TakeGarbage()).Aggregate((a, b) => a + b);
|
||||
_dump.AddGarbage(garbage);
|
||||
var preGarbage = containers.Select(t => t.TakeGarbage()).ToList();
|
||||
if (preGarbage.Any(x => x == null)) return false;
|
||||
var garbage = preGarbage.Aggregate((a, b) => a + b);
|
||||
if (!_dump.AddGarbage(garbage)) return false;
|
||||
for (int x = 0; x < grid.GetLength(0); x++)
|
||||
{
|
||||
for (int y = 0; y < grid.GetLength(1); y++)
|
||||
|
Loading…
Reference in New Issue
Block a user