示例#1
0
 protected Subsystem(string name, Command command, IReadWrite io)
 {
     Name      = name;
     Command   = command;
     Condition = 0;
     _io       = io;
 }
示例#2
0
    internal static float ReadParameter(this IReadWrite io, string parameter)
    {
        var value = io.ReadNumber(parameter);

        io.WriteLine();
        return(value);
    }
 internal PhotonTubes(int tubeCount, Enterprise enterprise, IReadWrite io)
     : base("Photon Tubes", Command.TOR, io)
 {
     TorpedoCount = _tubeCount = tubeCount;
     _enterprise  = enterprise;
     _io          = io;
 }
 internal StatusReport(Game game, Galaxy galaxy, Enterprise enterprise, IReadWrite io)
     : base("Status report", io)
 {
     _game       = game;
     _galaxy     = galaxy;
     _enterprise = enterprise;
 }
 internal PhaserControl(Enterprise enterprise, IReadWrite io, IRandom random)
     : base("Phaser Control", Command.PHA, io)
 {
     _enterprise = enterprise;
     _io         = io;
     _random     = random;
 }
    private static bool TryReadInteger(this IReadWrite io, string prompt, out int intValue)
    {
        var floatValue = io.ReadNumber(prompt);

        intValue = (int)floatValue;
        return(intValue == floatValue);
    }
示例#7
0
 internal BallContest(float probability, string messageFormat, IReadWrite io, IRandom random)
 {
     _io            = io;
     _probability   = probability;
     _messageFormat = messageFormat;
     _random        = random;
 }
示例#8
0
 public Computer(int bank, IReadWrite io, IRandom random)
     : base(bank)
 {
     _io      = io;
     _random  = random;
     Strategy = Strategy.None;
 }
示例#9
0
        public WorkClass(IMainForm iMainForm, IReadWrite iReadWrite, IMessage iMessage)
        {
            _iMainForm = iMainForm;
            _iReadWrite = iReadWrite;
            _iMessage = iMessage;

            subscribeToAllEvent();
        }
 internal ShortRangeSensors(Enterprise enterprise, Galaxy galaxy, Game game, IReadWrite io)
     : base("Short Range Sensors", Command.SRS, io)
 {
     _enterprise = enterprise;
     _galaxy     = galaxy;
     _game       = game;
     _io         = io;
 }
示例#11
0
 internal static void WaitForAnyKeyButEnter(this IReadWrite io, string prompt)
 {
     io.Write($"Hit any key but Enter {prompt} ");
     while (io.ReadCharacter() == '\r')
     {
         ;
     }
 }
示例#12
0
        public DealService(IReadWrite <Deal> dealReadWrite)
        {
            if (dealReadWrite == null)
            {
                throw new ArgumentNullException(nameof(dealReadWrite));
            }

            _dealReadWrite = dealReadWrite;
        }
示例#13
0
    public Enterprise(int maxEnergy, Coordinates sector, IReadWrite io, IRandom random)
    {
        SectorCoordinates = sector;
        TotalEnergy = _maxEnergy = maxEnergy;

        _systems = new List<Subsystem>();
        _commandExecutors = new Dictionary<Command, Subsystem>();
        _io = io;
        _random = random;
    }
示例#14
0
        public void Inicijalizuj()
        {
            ICQRSRead      read       = new CQRSRead();
            ICQRSWrite     write      = new CQRSWrite();
            IEventSourcing es         = new EventSourcing(read, write);
            IAmbassador    ambassador = new Ambassador(es);

            _readWrite = new ReadWrite();
            IUser iu = new User(ambassador);
        }
示例#15
0
    public Table(IReadWrite io, IRandom random, Deck deck, Human human, Computer computer)
    {
        _io      = io;
        _random  = random;
        Deck     = deck;
        Human    = human;
        Computer = computer;

        human.Sit(this);
        computer.Sit(this);
    }
 public static float ReadDefense(this IReadWrite io, string prompt)
 {
     while (true)
     {
         var defense = io.ReadNumber(prompt);
         if (defense >= 6)
         {
             return(defense);
         }
     }
 }
 public static Shot?ReadShot(this IReadWrite io, string prompt)
 {
     while (true)
     {
         if (io.TryReadInteger(prompt, out var value) && Shot.TryGet(value, out var shot))
         {
             return(shot);
         }
         io.Write("Incorrect answer.  Retype it. ");
     }
 }
 internal static char GetYesNo(this IReadWrite io, string prompt)
 {
     while (true)
     {
         var response = io.ReadString($"{prompt} (Y-N)").FirstOrDefault();
         if ("YyNn".Contains(response))
         {
             return(char.ToUpperInvariant(response));
         }
     }
 }
示例#19
0
 /// <summary>
 /// 保存当前任务参数数据
 /// </summary>
 /// <param name="path"></param>
 public virtual void Save(string path)
 {
     foreach (var item in GetType().GetProperties())
     {
         if (typeof(IReadWrite).IsAssignableFrom(item.PropertyType))
         {
             IReadWrite readWrite = (IReadWrite)item.GetValue(this, null);
             string     fileName  = path + "\\" + Name + "_" + item.Name + ".Config";
             global::HzControl.Communal.Tools.Serialization.SaveToXml(readWrite, fileName);
         }
     }
 }
 internal static int ReadNumber(this IReadWrite io, string prompt, int max, string maxPrompt)
 {
     io.Write(prompt);
     while (true)
     {
         var response = io.ReadNumber();
         if (response <= max)
         {
             return((int)response);
         }
         io.WriteLine(maxPrompt);
     }
 }
示例#21
0
 /// <summary>
 /// 载入当前任务参数数据
 /// </summary>
 /// <param name="path"></param>
 public virtual void Load(string path)
 {
     foreach (var item in GetType().GetProperties())
     {
         if (typeof(IReadWrite).IsAssignableFrom(item.PropertyType))
         {
             IReadWrite readWrite = (IReadWrite)item.GetValue(this, null);
             string     fileName  = path + "\\" + Name + "_" + item.Name + ".Config";
             object     load      = global::HzControl.Communal.Tools.Serialization.LoadFromXml(readWrite.GetType(), fileName, true);
             item.SetValue(this, load, null);
         }
     }
 }
示例#22
0
    internal Quadrant(
        QuadrantInfo info,
        Enterprise enterprise,
        IRandom random,
        Galaxy galaxy,
        IReadWrite io)
    {
        _info   = info;
        _random = random;
        _io     = io;
        Galaxy  = galaxy;

        info.MarkAsKnown();
        _sectors = new() { [enterprise.SectorCoordinates] = _enterprise = enterprise };
示例#23
0
    internal static string ReadYesNo(this IReadWrite io, string prompt)
    {
        while (true)
        {
            var response = io.ReadString(prompt).ToLower();

            if (response == "yes" || response == "no")
            {
                return(response);
            }

            io.Write(Streams.YesOrNo);
        }
    }
    // Implements original code:
    //   120 PRINT "YOUR MOVE";
    //   121 INPUT M1,M2
    //   122 IF M1=INT(M1)AND M2=INT(M2)AND M1>0 AND M1<10 AND M2>0 AND M2<10 THEN 130
    //   123 PRINT "ILLEGAL CO-ORDINATES."
    //   124 GOTO 120
    internal static Move ReadMove(this IReadWrite io, string prompt)
    {
        while (true)
        {
            var(from, to) = io.Read2Numbers(prompt);

            if (Move.TryCreate(from, to, out var move))
            {
                return(move);
            }

            io.WriteLine("Illegal Coordinates.");
        }
    }
    internal static IEnumerable <int> Read10Digits(this IReadWrite io, string prompt, Stream retryText)
    {
        while (true)
        {
            var numbers = new float[10];
            io.ReadNumbers(prompt, numbers);

            if (numbers.All(n => n == 0 || n == 1 || n == 2))
            {
                return(numbers.Select(n => (int)n));
            }

            io.Write(retryText);
        }
    }
 internal static bool ReadYesNo(this IReadWrite io, string prompt)
 {
     while (true)
     {
         var response = io.ReadString(prompt);
         if (response.Equals("YES", InvariantCultureIgnoreCase))
         {
             return(true);
         }
         if (response.Equals("NO", InvariantCultureIgnoreCase))
         {
             return(false);
         }
         io.WriteLine("Answer Yes or No, please.");
     }
 }
    internal static float?ReadWager(this IReadWrite io, float balance)
    {
        io.Write(Streams.Wager);
        if (io.ReadNumber("") == 0)
        {
            return(null);
        }

        var prompt = Prompts.HowMuch;

        while (true)
        {
            var wager = io.ReadNumber(prompt);
            if (wager <= balance)
            {
                return(wager);
            }

            prompt = Prompts.BetAgain;
        }
    }
 internal static Strategy ReadHumanStrategy(this IReadWrite io, bool noCurrentBets)
 {
     while (true)
     {
         io.WriteLine();
         var bet = io.ReadNumber("What is your bet");
         if (bet != (int)bet)
         {
             if (noCurrentBets && bet == .5)
             {
                 return(Strategy.Check);
             }
             io.WriteLine("No small change, please.");
             continue;
         }
         if (bet == 0)
         {
             return(Strategy.Fold);
         }
         return(Strategy.Bet(bet));
     }
 }
示例#29
0
 internal WarpEngines(Enterprise enterprise, IReadWrite io)
     : base("Warp Engines", Command.NAV, io)
 {
     _enterprise = enterprise;
     _io         = io;
 }
 internal CumulativeGalacticRecord(IReadWrite io, Galaxy galaxy)
     : base("Cumulative galactic record", io, galaxy)
 {
 }
示例#31
0
 public Scoreboard(Team home, Team visitors, IReadWrite io)
 {
     _scores  = new() { [home] = 0, [visitors] = 0 };
示例#32
0
        public DealService(IReadWrite<Deal> dealReadWrite)
        {
            if (dealReadWrite == null) { throw new ArgumentNullException(nameof(dealReadWrite)); }

            _dealReadWrite = dealReadWrite;
        }