Beispiel #1
0
 public GiveScalarDialog(App game, GiveType type, int otherPlayer, string template = "dialogGiveScalar")
     : base(game, template)
 {
     this._otherPlayer           = otherPlayer;
     this._type                  = type;
     this._give                  = new GiveInfo();
     this._give.InitiatingPlayer = game.LocalPlayer.ID;
     this._give.ReceivingPlayer  = this._otherPlayer;
     this._give.Type             = type;
 }
Beispiel #2
0
        List <List <Swap> > FindAllSwaps(Outcome outcome, GiveType type)
        {
            var swaps  = new List <List <Swap> >();
            var orders = outcome.Persons.Permutations();

            foreach (var order in orders)
            {
                var candySwapChain = GetDeepChains(order, outcome);
                var first          = order[0];
                var second         = order[1];
                var third          = order[2];
                var fourth         = order[3];
                foreach (var chain in candySwapChain)
                {
                    var firstCandy  = chain[0];
                    var secondCandy = chain[1];
                    var thirdCandy  = chain[2];
                    var fourthCandy = chain[3];

                    var swapList = new List <Swap>();

                    swapList.Add(new Swap()
                    {
                        From = first,
                        To   = second,
                        Give = firstCandy,
                    });

                    if (type != GiveType.A_B)
                    {
                        swapList.Add(new Swap()
                        {
                            From = second,
                            To   = third,
                            Give = secondCandy,
                        });
                    }


                    if (type == GiveType.A_B_C)
                    {
                        ;
                    }

                    else if (type == GiveType.A_B_C_A)
                    {
                        swapList.Add(new Swap()
                        {
                            From = third,
                            To   = first,
                            Give = thirdCandy,
                        });
                    }

                    else if (type == GiveType.A_B_C_D)
                    {
                        swapList.Add(new Swap()
                        {
                            From = third,
                            To   = fourth,
                            Give = thirdCandy,
                        });
                    }

                    else if (type == GiveType.A_B_C_D_A)
                    {
                        swapList.Add(new Swap()
                        {
                            From = third,
                            To   = fourth,
                            Give = thirdCandy,
                        });

                        swapList.Add(new Swap()
                        {
                            From = fourth,
                            To   = first,
                            Give = fourthCandy,
                        });
                    }

                    //if (swapList.Sum(x => x.Value) > 0)
                    swaps.Add(swapList);
                }
            }

            return(swaps);
        }