Czoko_Smieciarka/Trunk/MonoGameView/DataModels/Models/Steps/CollectStep.cs

38 lines
1.4 KiB
C#
Raw Normal View History

2019-03-13 15:31:33 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
2019-03-13 15:31:33 +01:00
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
2019-03-13 15:31:33 +01:00
{
public class CollectStep : IStep
{
2019-04-22 03:16:30 +02:00
public CollectStep(ITypeOfGarbage typeOfGarbage)
2019-03-13 15:31:33 +01:00
{
this._typeOfGarbage = typeOfGarbage;
}
private ITypeOfGarbage _typeOfGarbage;
2019-04-22 03:16:30 +02:00
public void Invoke(IGarbageCollector garbageCollector, object [,] grid)
2019-03-13 15:31:33 +01:00
{
2019-04-22 03:16:30 +02:00
/*
if(_garbageCollector.Coords != _garbageLocalization.Coords)
2019-03-13 16:55:34 +01:00
throw new WrongPositionException("Śmieciarka nie jest w miejscu oderbania śmieci");
2019-03-13 15:31:33 +01:00
var trashCans = _garbageLocalization.TrashCans.Where(t => t.TypeOfGarbage == _typeOfGarbage);
var garbage = trashCans.Select(t => t.TakeGarbage()).Aggregate((a,b)=>a+b);
2019-03-13 16:55:34 +01:00
if (_garbageCollector.TrashContainers.All(c => c.TypeOfGarbage != _typeOfGarbage))
throw new TrashContainerNotFound($"Nie znaleziono kontenera na {_typeOfGarbage.GarbageType}.");
2019-03-13 15:31:33 +01:00
2019-03-13 16:55:34 +01:00
_garbageCollector.TrashContainers.First(t => t.TypeOfGarbage == _typeOfGarbage).AddGarbage(garbage);
2019-04-22 03:16:30 +02:00
*/
2019-03-13 15:31:33 +01:00
}
}
}