Beispiel #1
0
    public static Game Create(TextIO io, IRandom random)
    {
        io.Write(Resource.Streams.Introduction);

        var defense = new Defense(io.ReadDefense("Your starting defense will be"));
        var clock   = new Clock(io);

        io.WriteLine();

        var scoreboard = new Scoreboard(
            new Team("Dartmouth", new HomeTeamPlay(io, random, clock, defense)),
            new Team(io.ReadString("Choose your opponent"), new VisitingTeamPlay(io, random, clock, defense)),
            io);

        return(new Game(clock, scoreboard, io, random));
    }
Beispiel #2
0
    internal override bool Resolve(Scoreboard scoreboard)
    {
        var shot = _io.ReadShot("Your shot");

        if (_random.NextFloat() >= 0.5f && _clock.IsFullTime)
        {
            return(true);
        }

        if (shot is null)
        {
            _defense.Set(_io.ReadDefense("Your new defensive alignment is"));
            _io.WriteLine();
            return(false);
        }

        if (shot is JumpShot jumpShot)
        {
            if (ClockIncrementsToHalfTime(scoreboard))
            {
                return(false);
            }
            if (!Resolve(jumpShot, scoreboard))
            {
                return(false);
            }
        }

        do
        {
            if (ClockIncrementsToHalfTime(scoreboard))
            {
                return(false);
            }
        } while (Resolve(shot, scoreboard));

        return(false);
    }