Exemple #1
0
        private async Task <bool> AttemptToPlay(GameGraph game)
        {
            var ends = game.Ends(this).ToArray();

            while (true)
            {
                var end = await AwaitKey();

                if (end == null)
                {
                    Global.Logger.Comment("Skipping");
                    return(false);
                }

                Global.Logger.Comment(string.Format("You chose {0} end", end));
                if (end > ends.Count())
                {
                    Global.Logger.Comment("Invalid end");
                    continue;
                }

                var domino = await AwaitKey();

                Global.Logger.Comment(string.Format("You chose {0} domino", domino));
                if (domino > _hand.Count)
                {
                    Global.Logger.Comment("Invalid domino");
                    continue;
                }
                var d = _hand.ToArray()[domino.Value - 1];
                var e = ends[end.Value - 1];

                if (d.Matches(e.End))
                {
                    e.AddChild(d);
                    _hand.Remove(d);
                    if (e.Owner == Name())
                    {
                        Open = false;
                    }

                    Global.Logger.Comment(string.Format("{0} played {1} on {2}'s line and has {3} left", Name(), d, e.Owner, _hand.Count));
                    return(true);
                }
                else
                {
                    Global.Logger.Comment(string.Format("domino {0} doesn't match end {1}", d, e.Value));
                }
            }
        }
Exemple #2
0
 private bool LookFormatch(GameGraph game)
 {
     Match pick = _strat.Choose(_hand, game.Ends(this));            
     if (pick != null)
     {
         //use a class instead of this tuple?
         game.Add(pick.end, pick.domino, this);
         _hand.Remove(pick.domino);
         Global.Logger.Comment(string.Format("{0} played {1} on {2}'s line and has {3} left", Name(), pick.domino, pick.end.Owner, _hand.Count));
         if (Open && pick.end.Owner.Equals(this.Name()))
         {
             Global.Logger.Comment(string.Format("{0}'s line closed", Name()));
             Open = false;
         }
         return true;
     }                        
     return false;
 }
Exemple #3
0
        private bool LookFormatch(GameGraph game)
        {
            Match pick = _strat.Choose(_hand, game.Ends(this));

            if (pick != null)
            {
                //use a class instead of this tuple?
                game.Add(pick.end, pick.domino, this);
                _hand.Remove(pick.domino);
                Global.Logger.Comment(string.Format("{0} played {1} on {2}'s line and has {3} left", Name(), pick.domino, pick.end.Owner, _hand.Count));
                if (Open && pick.end.Owner.Equals(this.Name()))
                {
                    Global.Logger.Comment(string.Format("{0}'s line closed", Name()));
                    Open = false;
                }
                return(true);
            }
            return(false);
        }
Exemple #4
0
        private async Task<bool> AttemptToPlay(GameGraph game)
        {
            var ends = game.Ends(this).ToArray();
            while (true)
            {
                var end = await AwaitKey();
                if (end == null)
                {
                    Global.Logger.Comment("Skipping");
                    return false;
                }

                Global.Logger.Comment(string.Format("You chose {0} end", end));
                if (end > ends.Count())
                {
                    Global.Logger.Comment("Invalid end");
                    continue;
                }
                
                var domino = await AwaitKey();
                Global.Logger.Comment(string.Format("You chose {0} domino", domino));
                if (domino > _hand.Count)
                {
                    Global.Logger.Comment("Invalid domino");
                    continue;
                }
                var d =_hand.ToArray()[domino.Value-1];
                var e = ends[end.Value-1];
                
                if (d.Matches(e.End))
                {
                    e.AddChild(d);
                    _hand.Remove(d);
                    if (e.Owner == Name())
                    {
                        Open = false;
                    }

                    Global.Logger.Comment(string.Format("{0} played {1} on {2}'s line and has {3} left", Name(), d, e.Owner, _hand.Count));
                    return true;
                }
                else
                {
                    Global.Logger.Comment(string.Format("domino {0} doesn't match end {1}", d, e.Value));
                }
            }            
        }