Exemple #1
0
    private bool PrepareChopStrawberries(out Command command)
    {
        command = null;

        var myChef = _game.Players[0];

        int requiredChoppedStrawBerries  = _game.CustomerOrders.Count(order => order.Items.Contains("CHOPPED_STRAWBERRIES"));
        int availableChoppedStrawberries = _game.Tables.Count(table => table.HasItems && table.Items.Content.Contains("CHOPPED_STRAWBERRIES"));
        int chefHolding = _game.Players.Count(p => p.Items.Content.Contains("CHOPPED_STRAWBERRIES"));

        if (availableChoppedStrawberries + chefHolding < requiredChoppedStrawBerries)
        {
            MainClass.LogDebug("Let's chop some strawberries");

            if (myChef.Items.Content == "NONE")
            {
                command = new UseCommand(_game.Strawberry.Position);
            }
        }

        if (myChef.Items.Content == "STRAWBERRIES")
        {
            command = new UseCommand(_game.ChoppingBoard.Position);
        }
        else if (myChef.Items.Content == "CHOPPED_STRAWBERRIES")
        {
            var closestEmptyTable = GetClosestEmptyTable(myChef.Position);
            command = new UseCommand(closestEmptyTable.Position);
        }

        return(command != null);
    }
Exemple #2
0
    private bool PrepareCroissant(out Command command)
    {
        command = null;

        var myChef = _game.Players[0];

        int requiredCroissantCount  = _game.CustomerOrders.Count(order => order.Items.Contains("CROISSANT"));
        int availableCroissantCount = _game.Tables.Count(table => table.HasItems && table.Items.Content.Contains("CROISSANT")) +
                                      _game.Players.Count(p => p.Items.Content.Contains("CROISSANT"));

        MainClass.LogDebug($"PrepareCroissant : {availableCroissantCount}/{requiredCroissantCount}");

        if (availableCroissantCount < requiredCroissantCount)
        {
            MainClass.LogDebug("Let's cook a croissant");

            if (_game.OventContents != "NONE")
            {
                if (myChef.Items.Content == "NONE")
                {
                    command = new UseCommand(_game.Oven.Position);
                }
                else
                {
                    var closestEmptyTable = GetClosestEmptyTable(myChef.Position);
                    command = new UseCommand(closestEmptyTable.Position);
                }
            }
            else
            {
                if (myChef.Items.Content == "NONE")
                {
                    command = new UseCommand(_game.Dough.Position);
                }
                else if (myChef.Items.Content == "DOUGH")
                {
                    command = new UseCommand(_game.Oven.Position);
                }
                else if (myChef.Items.Content == "CROISSANT")
                {
                    var closestEmptyTable = GetClosestEmptyTable(myChef.Position);
                    command = new UseCommand(closestEmptyTable.Position);
                }
            }
        }
        else
        {
            if (myChef.Items.Content == "CROISSANT")
            {
                var closestEmptyTable = GetClosestEmptyTable(myChef.Position);
                command = new UseCommand(closestEmptyTable.Position);
            }
        }


        return(command != null);
    }
Exemple #3
0
    private bool MyChefCompletedCustomerOrder(out Command finishComand)
    {
        finishComand = null;
        var myChefContentItems = _game.Players[0].Items.Content.Split('-');

        foreach (var customerOrder in _game.CustomerOrders)
        {
            if (MyChefContentMatchesExactly(customerOrder, myChefContentItems))
            {
                finishComand = new UseCommand(_game.Window.Position);
            }
        }

        return(finishComand != null);
    }
Exemple #4
0
        public void UseNewDocumentBase()
        {
            Context context = new Context();

            context.Engine = new Engine();

            UseCommand command = new UseCommand("Genesis");

            command.Execute(context);

            Assert.IsNotNull(context.DocumentBase);
            Assert.AreEqual("Genesis", context.DocumentBase.Name);
            Assert.IsNotNull(context.Engine.GetDocumentBase("Genesis"));
            Assert.AreSame(context.DocumentBase, context.Engine.GetDocumentBase("Genesis"));

            var result = context.GetMember("db");

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DbObject));
            Assert.AreSame(context.DocumentBase, ((DbObject)result).DocumentBase);
        }
Exemple #5
0
    private bool MyChefIsHoldingIrrelevantStuff(CustomerOrder order, out Command command)
    {
        command = null;

        var myChef = _game.Players[0];

        if (myChef.Items.Content != "NONE")
        {
            var myChefItems = myChef.Items.Content.Split('-');
            var orderItems  = order.Items.Split('-').ToHashSet();

            foreach (var holdingItem in myChefItems)
            {
                if (orderItems.Contains(holdingItem) == false)
                {
                    var closestEmptyTable = GetClosestEmptyTable(myChef.Position);
                    command = new UseCommand(closestEmptyTable.Position, "MyChefIsHoldingIrrelevantStuff");
                }
            }
        }

        return(command != null);
    }
Exemple #6
0
    private bool TryCompleteOrder(CustomerOrder candidateOrder, out Command command)
    {
        command = null;

        var myChef = _game.Players[0];


        //All items
        var remainingItems = candidateOrder.Items.Split('-').ToList();

        //Remove already picked items
        var myChefItems = myChef.Items.Content.Split('-').ToList();

        myChefItems.ForEach(it => remainingItems.Remove(it));

        foreach (var remainingItem in remainingItems)
        {
            if (remainingItem == "CROISSANT" || remainingItem == "TART" || remainingItem == "CHOPPED_STRAWBERRIES")
            {
                if (myChef.Items.Content == "NONE")
                {
                    var tableWithRemainingItem = _game.Tables.FirstOrDefault(table => table.HasItems && table.Items.Content == remainingItem);
                    if (tableWithRemainingItem != null)
                    {
                        command = new UseCommand(tableWithRemainingItem.Position);
                        break;
                    }

                    if (_game.OventContents == remainingItem)
                    {
                        command = new UseCommand(_game.Oven.Position);
                        break;
                    }
                }
                else
                {
                    if (remainingItems.Contains("DISH"))
                    {
                        command = new UseCommand(_game.Dishwasher.Position);
                        break;
                    }
                    else
                    {
                        var tableWithRemainingItem = _game.Tables.FirstOrDefault(table => table.HasItems && table.Items.Content == remainingItem);
                        if (tableWithRemainingItem != null)
                        {
                            command = new UseCommand(tableWithRemainingItem.Position);
                            break;
                        }

                        if (_game.OventContents == remainingItem)
                        {
                            command = new UseCommand(_game.Oven.Position);
                            break;
                        }
                    }
                }
            }
            else if (remainingItem == "BLUEBERRIES")
            {
                if (myChef.Items.Content == "NONE")
                {
                    command = new UseCommand(_game.Blueberry.Position);
                    break;
                }
                else
                {
                    if (remainingItems.Contains("DISH"))
                    {
                        command = new UseCommand(_game.Dishwasher.Position);
                        break;
                    }
                    else
                    {
                        command = new UseCommand(_game.Blueberry.Position);
                        break;
                    }
                }
            }
            else if (remainingItem == "ICE_CREAM")
            {
                if (myChef.Items.Content == "NONE")
                {
                    command = new UseCommand(_game.IceCream.Position);
                    break;
                }
                else
                {
                    if (remainingItems.Contains("DISH"))
                    {
                        command = new UseCommand(_game.Dishwasher.Position);
                        break;
                    }
                    else
                    {
                        command = new UseCommand(_game.IceCream.Position);
                        break;
                    }
                }
            }
        }

        return(command != null);
    }
Exemple #7
0
    private bool PrepareTart(out Command command)
    {
        command = null;

        var  myChef              = _game.Players[0];
        int  requiredTartCount   = _game.CustomerOrders.Count(order => order.Items.Contains("TART"));
        bool availableTartInOven = _game.OventContents == "TART";

        int availableTartCount =
            (availableTartInOven ? 1 : 0) +
            _game.Tables.Count(table => table.HasItems && table.Items.Content.Contains("TART")) +
            _game.Players.Count(p => p.Items.Content.Contains("-TART") || p.Items.Content == "TART");

        MainClass.LogDebug($"Prepare Tart : {availableTartCount}/{requiredTartCount}");

        if (availableTartCount < requiredTartCount)
        {
            if (_game.OventContents != "NONE")
            {
                if (myChef.Items.Content == "NONE")
                {
                    command = new UseCommand(_game.Oven.Position);
                }
                else
                {
                    var closestEmptyTable = GetClosestEmptyTable(myChef.Position);
                    command = new UseCommand(closestEmptyTable.Position);
                }
            }
            else
            {
                if (myChef.Items.Content == "NONE")
                {
                    command = new UseCommand(_game.Dough.Position);
                }
                else if (myChef.Items.Content == "DOUGH")
                {
                    command = new UseCommand(_game.ChoppingBoard.Position);
                }
                else if (myChef.Items.Content == "CHOPPED_DOUGH")
                {
                    command = new UseCommand(_game.Blueberry.Position);
                }
                else if (myChef.Items.Content == "RAW_TART")
                {
                    command = new UseCommand(_game.Oven.Position);
                }
                else if (myChef.Items.Content == "TART")
                {
                    var closestEmptyTable = GetClosestEmptyTable(myChef.Position);
                    command = new UseCommand(closestEmptyTable.Position);
                }
            }
        }
        else
        {
            if (myChef.Items.Content == "TART")
            {
                var closestEmptyTable = GetClosestEmptyTable(myChef.Position);
                command = new UseCommand(closestEmptyTable.Position);
            }
        }


        return(command != null);
    }