public Deployer(ITerminal terminal)
		{
			if(terminal == null)
				throw new ArgumentNullException("terminal");

			_terminal = terminal;
		}
示例#2
0
 public Shell(ITerminal Term)
 {
     timer = timerReset;
     term = Term;
     allPrograms = new List<Program>();
     editMode = false;
 }
示例#3
0
 public override void SubscriptionToTerminalEvents(ITerminal terminal)
 {
     terminal.OutgoingRequest += (sender, info) =>
     {
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine(info.ToString());
         Console.ForegroundColor = ConsoleColor.Gray;
     };
     terminal.IncomingRequest += (sender, info) =>
     {
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine(info.ToString());
         Console.ForegroundColor = ConsoleColor.Gray;
     };
     terminal.StateChanged += (sender, state) => { Console.WriteLine(sender.ToString() + " - " + state); };
     terminal.AnsweredTheCall += (sender, args) =>
     {
         Console.ForegroundColor = ConsoleColor.Blue;
         Console.WriteLine(sender.ToString() + " answered the call");
         Console.ForegroundColor = ConsoleColor.Gray;
     };
     terminal.DroppedTheCall += (sender, args) =>
     {
         Console.ForegroundColor = ConsoleColor.Blue;
             Console.WriteLine(sender.ToString() + " dropped the call");
         Console.ForegroundColor = ConsoleColor.Gray;
     };
 }
示例#4
0
 private static IEnumerable<IProduction> ZeroOrOne(INonTerminal identifier, ITerminal[] terminals)
 {
     // NonTerminal -> Terminal | <null>
     return new[]{
             new Production(identifier, terminals),
             new Production(identifier) };
 }
示例#5
0
        public void AddTerminal(ITerminal terminal)
        {
            if (terminal == null) throw new ArgumentNullException(nameof(terminal));

            RegisterTerminal(terminal);
            _terminals.Add(terminal);
        }
		private void DisplayTcpServerInfo(TcpServer server, ITerminal output)
		{
			this.DisplayListenerInfo(server, output);

			if(!server.IsListening)
				return;

			output.WriteLine();
			output.Write(TerminalColor.DarkMagenta, "ID\t");
			output.Write(TerminalColor.DarkMagenta, ResourceUtility.GetString("${LastReceivedTime}") + "\t\t");
			output.Write(TerminalColor.DarkMagenta, ResourceUtility.GetString("${LastSendTime}") + "\t\t");
			output.Write(TerminalColor.DarkMagenta, ResourceUtility.GetString("${LocalEndPoint}") + "\t\t");
			output.WriteLine(TerminalColor.DarkMagenta, ResourceUtility.GetString("${RemoteEndPoint}") + "\t");

			var channels = server.ChannelManager.GetActivedChannels();

			foreach(TcpServerChannel channel in channels)
			{
				if(channel == this.Channel)
					output.Write(TerminalColor.Magenta, "* ");

				output.WriteLine(
					"{0}\t{1:yyyy-MM-dd HH:mm:ss}\t{2:yyyy-MM-dd HH:mm:ss}\t{3}\t\t{4}",
					channel.ChannelId,
					channel.LastReceivedTime,
					channel.LastSendTime,
					channel.LocalEndPoint,
					channel.RemoteEndPoint);
			}

			output.WriteLine();
		}
示例#7
0
文件: Command.cs 项目: adamedx/shango
        protected CommandBase(
            ICommandProcessor ParentCommandProcessor,
            ITerminal  Terminal)
        {
            _CommandProcessor = ParentCommandProcessor;

            _Terminal = Terminal;
        }
示例#8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LineGeometry"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        protected LineGeometry(EditDeserializer editDeserializer)
        {
            // When deserializing line geometry (in the context of line features), passing
            // the terminal down via the EditDeserializer is a bit too contrived. Instead,
            // we'll set the terminals back in LineFeature.ReadData.

            m_Start = m_End = null;
        }
示例#9
0
        /// <summary>
        /// Creates a new <c>LineGeometry</c> using the supplied terminals.
        /// </summary>
        /// <param name="start">The start of the line.</param>
        /// <param name="end">The end of the line.</param>
        protected LineGeometry(ITerminal start, ITerminal end)
        {
            if (start==null || end==null)
                throw new ArgumentNullException("Null terminal for line geometry");

            m_Start = start;
            m_End = end;
        }
示例#10
0
 /// <summary>
 /// Constructor for BlackJack game
 /// </summary>
 /// <param name="terminal"></param>
 public BlackJack(ITerminal terminal)
     : base(terminal)
 {
     _terminal = terminal;
     user = new Player(100);
     dealer = new Player(9999999);
     _cardGame = new CardGame(terminal);
 }
示例#11
0
 /// <summary>
 /// Default constructor
 /// </summary>
 internal PolygonFace()
 {
     m_Polygon = null;
     m_Divider = null;
     m_Begin = null;
     m_End = null;
     m_ExtraPoints = null;
 }
 public override void Initialize(IHostContext hostContext)
 {
     base.Initialize(hostContext);
     Trace.Verbose("Creating _store");
     _store = hostContext.GetService<IConfigurationStore>();
     Trace.Verbose("store created");
     _term = hostContext.GetService<ITerminal>();
 }
		public TerminalCommandExecutor(ITerminal terminal, ICommandLineParser parser)
		{
			if(terminal == null)
				throw new ArgumentNullException("terminal");

			_terminal = terminal;
			this.Parser = parser;
		}
		public static void WritePluginNode(ITerminal terminal, PluginTreeNode node, ObtainMode obtainMode, int maxDepth)
		{
			if(node == null)
				return;

			terminal.Write(TerminalColor.DarkYellow, "[{0}]", node.NodeType);
			terminal.WriteLine(node.FullPath);
			terminal.Write(TerminalColor.DarkYellow, "Plugin File: ");

			if(node.Plugin == null)
				terminal.WriteLine(TerminalColor.Red, "N/A");
			else
				terminal.WriteLine(node.Plugin.FilePath);

			terminal.Write(TerminalColor.DarkYellow, "Node Properties: ");
			terminal.WriteLine(node.Properties.Count);

			if(node.Properties.Count > 0)
			{
				terminal.WriteLine(TerminalColor.Gray, "{");

				foreach(PluginExtendedProperty property in node.Properties)
				{
					terminal.Write(TerminalColor.DarkYellow, "\t" + property.Name);
					terminal.Write(" = ");
					terminal.Write(property.RawValue);

					if(property.Value != null)
					{
						terminal.Write(TerminalColor.DarkGray, " [");
						terminal.Write(TerminalColor.Blue, property.Value.GetType().FullName);
						terminal.Write(TerminalColor.DarkGray, "]");
					}

					terminal.WriteLine();
				}

				terminal.WriteLine(TerminalColor.Gray, "}");
			}

			terminal.WriteLine(TerminalColor.DarkYellow, "Children: {0}", node.Children.Count);
			if(node.Children.Count > 0)
			{
				terminal.WriteLine();

				foreach(var child in node.Children)
				{
					terminal.WriteLine(child);
				}
			}

			object value = node.UnwrapValue(obtainMode, null);
			if(value != null)
			{
				terminal.WriteLine();
				Zongsoft.Runtime.Serialization.Serializer.Text.Serialize(terminal.OutputStream, value);
			}
		}
示例#15
0
 public Shell(ITerminal Term)
 {
     //timer = timerReset;
     term = Term;
     allPrograms = new List<Program>();
     editMode = false;
     programLog = new StringBuilder();
     sinceLastRun = TimeSpan.Zero;
 }
示例#16
0
 public bool PayBill(ITerminal terminal)
 {
     foreach (var c in this.CallHistory.Where(x => x.source.Number == terminal.Number)) {
       if (c.Paid == false) {
           c.Paid = true;
       }
       }
       return true;
 }
示例#17
0
        public RedirectedProcess( ITerminal ClientTerminal, ICommandClient CommandClient )
        {
            _InputHandler = new InputHandler();

            _TerminalClient = ClientTerminal;

            _ProcessExit = new ManualResetEvent( false );

            _CommandClient = CommandClient;
        }
示例#18
0
        private static IEnumerable<IProduction> ZeroOrMany(INonTerminal identifier, ITerminal[] terminals)
        {
            var recursiveProductionSymbols = new List<ISymbol>();
            recursiveProductionSymbols.Add(identifier);
            recursiveProductionSymbols.AddRange(terminals);

            // NonTerminal -> NonTerminal Terminal | <null>
            return new[]{
                new Production(identifier, recursiveProductionSymbols.ToArray()),
                new Production(identifier)};
        }
示例#19
0
 public OperatingContext(ITerminal Terminal, RegexSurfer Surfer, UsbConnectionFactory Usb, IProgressControllerFactory ProgressControllerFactory,
                         int BlockSize)
 {
     this.BlockSize = BlockSize;
     this.ProgressControllerFactory = ProgressControllerFactory;
     this.Usb = Usb;
     this.Terminal = Terminal;
     this.Surfer = Surfer;
     State = ProgrammingContextState.Unknown;
     NandSize = ulong.MaxValue;
 }
示例#20
0
        private void Disconnect()
        {
            foreach (var orderbook in _orderbooks)
                if (orderbook != null)
                    orderbook.Close();
            _orderbooks.Clear();

            if (_terminal != null)
                _terminal.Disconnect();
            _terminal = null;
        }
示例#21
0
        public string Parse(  
            ITerminal Terminal,
            string    Command,
            ref    string[]  Arguments)
        {
            string commandName = null;

            ParsedCommandLine Parsed = new ParsedCommandLine( Command );

            bool bParsed = Parsed.Parse();

            if ( ! bParsed )
            {
                Terminal.WriteTo( new StringBuilder( "Failed to parse\n" ), ConsoleProcessRedirection.OutputType.StandardError );
            }
            else
            {
                Parsed.Print( Terminal );
            }

            Command = Command.TrimStart(' ','\t');

            Command = Command.TrimEnd(' ','\t');

            if ( Command.Length > 0 )
            {
                Arguments = Command.Split( new char[] {' ','\t'} );

                if ( Arguments[0].ToLower().StartsWith("cd\\") )
                {
                    string[] NewArguments = new string[ Arguments.Length + 1 ];

                    NewArguments[0] = Arguments[0].Substring( 0, 2 );
                    NewArguments[1] = Arguments[0].Substring( 2, Arguments[0].Length - 2 );

                    if ( Arguments.Length > 1 )
                    {
                        NewArguments[1] += Arguments[1];

                        for ( int Argument = 1; Argument < Arguments.Length; Argument++ )
                        {
                            NewArguments[ Argument + 1 ] = Arguments[ Argument ];
                        }
                    }

                    Arguments = NewArguments;
                }

                commandName = Arguments[0].ToLower();
            }

            return commandName;
        }
示例#22
0
 public void RegisterEventsForTerminal(ITerminal terminal)
 {
     terminal.Plugging += (sender, args) => { this.State = PortState.Free; };
     terminal.UnPlugging += (sender, args) => { this.State = PortState.Off; };
     terminal.OutConnection += (sender, request) =>
     {
         if (request.Code == Request.OutcomingCall && this.State == PortState.Free)
         {
             this.State = PortState.Busy;
         }
     };
 }
示例#23
0
文件: Prompt.cs 项目: adamedx/shango
        public Prompt(
            ITerminal Terminal,
            string    DefaultPrompt
            )
        {
            _Terminal = Terminal;

            if ( null != DefaultPrompt )
            {
                _DefaultPrompt = DefaultPrompt;
            }
        }
示例#24
0
 public void InitTerminal(ITerminal terminal)
 {
     switch (terminal.Type)
     {
         case TerminalType.AlorTrade:
             InitAlorTerminal(terminal as AlorTerminal, -1);
             break;
         case TerminalType.Oec:
             InitOecTerminal(terminal as OecTerminal);
             break;
     }
 }
示例#25
0
        public void Add(ITerminal terminal)
        {
            var freePort = _ports.Except(_portMapping.Values).FirstOrDefault();
            if (freePort != null)
            {
                _terminals.Add(terminal);

                MapTerminalToPort(terminal, freePort);

                this.RegisterEventHandlersForTerminal(terminal);
                this.RegisterEventHandlersForPort(freePort,terminal);
            }
        }
		public Deployer(ITerminal terminal, string workingDirectory)
		{
			if(terminal == null)
				throw new ArgumentNullException("terminal");

			if(string.IsNullOrWhiteSpace(workingDirectory))
				throw new ArgumentNullException("workingDirectory");

			if(!File.Exists(workingDirectory))
				throw new DirectoryNotFoundException(workingDirectory);

			_workingDirectory = workingDirectory;
		}
示例#27
0
        public bool Add(ITerminal terminal)
        {
            var freePort = _portCollection.Except(PortsMapping.Values).FirstOrDefault();
            if (freePort == null) return false;
            _terminalCollection.Add(terminal);

            MapTerminalToPort(terminal, freePort);

            RegisterEventHandlersForTerminal(terminal);
            RegisterEventHandlersForPort(freePort);

            return true;
        }
示例#28
0
 protected internal BlockFormula(
     string name,
     INode referrers,
     ITerminal<ITypeDeclaration> type,
     IBlockFormula parentBlock,
     IBlockFormula childBlocks,
     INonterminal variables,
     INonterminal formulas,
     INonterminal result)
     : this(name,
         referrers,
         IBlockFormulaMixin.ToReadOnlyProperties(type, parentBlock, childBlocks, variables, formulas, result))
 {
 }
示例#29
0
        public void RequestHistoryBy(ITerminal terminal, HistoryFilter filter)
        {
            keySelector = null;
               Cost = 0;
              switch (filter)
              {
              case HistoryFilter.AbonentName: keySelector = x => x.target.UserName; break;
              case HistoryFilter.CallDate: keySelector = x => x.started; break;
              case HistoryFilter.CallDuration: keySelector = x => x.duration; break;
              default: keySelector = x => x.source.UserName; break;
              }

              Console.WriteLine("\n\t\tHistory by " + filter);

              foreach (var c in this.CallHistory.Where(x=>x.source.Number == terminal.Number).OrderBy(keySelector))
              {
                  Cost = 0;

                  if (c.CurrentTariffPlan == TariffPlans.ConstMedium)
                  {
                      if (c.duration.TotalSeconds == 0) { Cost = 0; }
                      else
                      {
                          Cost = Math.Round(c.duration.TotalSeconds) * 100;
                      }
                  }

                  if (c.CurrentTariffPlan == TariffPlans.FirstPartExpensiveAfterFree)
                  {
                      if (c.duration.TotalSeconds == 0) { Cost = 0; }
                      else
                      {
                          if (c.duration.TotalSeconds < 5)
                          {
                              Cost += Math.Round((c.duration.TotalSeconds + 1)) * 400;
                          }
                          else { Cost += 5 * 400; }
                      }
                  }

                  Console.WriteLine("\n\nName : " + c.source.UserName +
                      " \nTarget abonent : " + c.target.UserName +
                      "\nBegin call at : " + c.started + "\nDuration : " + c.duration +
                      "\nTariff plane : " + c.CurrentTariffPlan +
                      "\nCost : " + Cost +
                      "\nPayed : " + c.Paid
                      );

              }
        }
示例#30
0
        /// <summary>
        /// Creates a new <c>SectionDivider</c> that relates to the specified section of line,
        /// with undefined polygon rings on left and right.
        /// </summary>
        /// <param name="line">The line this topological section partially coincides with.</param>
        /// <param name="from">The start position for the topological section.</param>
        /// <param name="to">The end position for the topological section.</param>
        internal SectionDivider(LineFeature line, ITerminal from, ITerminal to)
            : base(line, from, to)
        {
            m_Left = m_Right = null;

            if (from is Intersection)
                (from as Intersection).Add(line);
            else if (from is PointFeature)
                (from as PointFeature).AddReference(line);

            if (to is Intersection)
                (to as Intersection).Add(line);
            else if (to is PointFeature)
                (to as PointFeature).AddReference(line);
        }
示例#31
0
 /// <summary>
 /// Don't forget to call InitAsync() to start reading from device+terminal and passing data from one to the other.
 /// </summary>
 /// <param name="terminal"></param>
 /// <param name="input_nrf"></param>
 public nRFUartTerminalAdapter(ITerminal terminal, Nordic_Uart input_nrf)
 {
     Terminal = terminal;
     nrf      = input_nrf;
 }
示例#32
0
 public TerminalToken(ITerminal terminal, ILocation location)
     : base(terminal)
 {
     Location = location;
 }
示例#33
0
        public void ExecuteSystemCall(ITerminal terminal, RuntimeContext ctx)
        {
            string dataStr = ctx.ReadString(ctx.UserRegisters[SysCallRegisters.ARG1_IDX].Value);

            terminal.PrintString(dataStr);
        }
 public override void RegisterEventHandlersForTerminal(ITerminal terminal)
 {
     terminal.OutgoingConnection += this.OnOutgoingRequest;
     terminal.IncomingRespond    += OnIncomingCallRespond;
 }
示例#35
0
 public virtual void RegisterEventForTerminal(ITerminal terminal)
 {
     terminal.OutConnection += RegisterOutgoingRequest;
     terminal.IncomRespond  += OnIncomingCallRespond;
 }
示例#36
0
 public static void DisplayCommandInfo(ITerminal terminal, ICommand command)
 {
     CommandHelper.DisplayCommandInfo(terminal, command);
 }
 public FormatAndDumpRegistersCommand(RegisterManager regMgr, ITerminal terminal)
 {
     m_Registers = regMgr;
     m_Terminal  = terminal;
 }
示例#38
0
 public override void CleanUpEarly(ITerminal term)
 {
     XingLock.Value = false;
 }
示例#39
0
 public override void Initialize(IHostContext hostContext)
 {
     base.Initialize(hostContext);
     _term = HostContext.GetService <ITerminal>();
 }
示例#40
0
 public WebClient(IUrl url, IReport report, ITerminal powerShell)
     : base(url, report)
 {
     PowerShell = powerShell;
 }
示例#41
0
 public FluentExpression(ITerminal <object> terminal)
 {
     this.terminal = (Terminal <object>)terminal;
 }
示例#42
0
 protected override void Drawing(ITerminal <TGlyph, TColor> terminal)
 {
     Focused?.Draw(terminal);
 }
示例#43
0
 public void ExecuteSystemCall(ITerminal terminal, RuntimeContext ctx)
 {
     ctx.UserRegisters[SysCallRegisters.SYSCALL_IDX].Value = terminal.ReadInt();
 }
示例#44
0
 public TerminalServiceTest()
 {
     _terminal        = new Terminal();
     _smartForTwo     = new SmartForTwo();
     _terminalService = new TerminalService(_terminal, _smartForTwo);
 }
示例#45
0
        private void PaintItem(int index, Item item)
        {
            Vec pos = new Vec(0, index) + 1;

            ITerminal terminal = Terminal;

            if (IsChoosable(item))
            {
                // hilight the item since it is choosable
                terminal[pos][TermColor.White].Write(GetKey(index));
                terminal[pos.OffsetX(1)][TermColor.Yellow].Write(Glyph.TriangleRight);
            }
            else
            {
                // don't hilight the item since it can't be chosen
                terminal[pos][TermColor.DarkGray].Write(GetKey(index));

                if (item != null)
                {
                    terminal[pos.OffsetX(1)][TermColor.DarkGray].Write(Glyph.TriangleRight);
                }
            }

            if (item != null)
            {
                // show the item in the slot
                terminal[pos.OffsetX(2)].Write(GameArt.Get(item));

                TermColor itemColor;
                TermColor priceColor;

                if (!HasFocus || IsChoosable(item))
                {
                    itemColor = TermColor.White;
                }
                else
                {
                    itemColor = TermColor.DarkGray;
                }

                if (IsChoosable(item))
                {
                    priceColor = (mViewing == Viewing.Store) ? TermColor.Green : TermColor.Gold;
                }
                else
                {
                    priceColor = (mViewing == Viewing.Store) ? TermColor.DarkGreen : TermColor.DarkGold;
                }

                terminal[pos.OffsetX(4)][itemColor].Write(item.ToString());

                // show its price
                if (mStore != null)
                {
                    int price;
                    if (mViewing == Viewing.Store)
                    {
                        price = mStore.GetBuyPrice(mGame.Hero, item);
                    }
                    else
                    {
                        price = mStore.GetSellPrice(mGame.Hero, item);
                    }

                    terminal[new Vec(-9, pos.Y)][priceColor].Write(price.ToString("n0").PadLeft(8, ' '));
                }
            }
            else
            {
                // no item in the slot, so show the category of item that can go there
                terminal[pos.OffsetX(4)][TermColor.DarkGray].Write(Items.GetCategory(index));
            }
        }
示例#46
0
 public PurchaseOrderScreen(IPurchaseOrderService purchaseOrderService, ITerminal terminal)
 {
     this.terminal             = terminal;
     this.purchaseOrderService = purchaseOrderService;
 }
示例#47
0
文件: User.cs 项目: Ulquiorrabl/Task3
 public User(string name, string surname, ITerminal terminal = null)
 {
     this.Name     = name;
     this.Surname  = surname;
     this.Terminal = terminal;
 }
示例#48
0
        // **********************************************************************
        // *                             Соединение                             *
        // **********************************************************************

        public void Connect()
        {
            terminal = new QuikTerminal(this);
            terminal.Connect();
        }
示例#49
0
 public DumpRegistersCommand(RegisterManager regMgr, ITerminal terminal)
 {
     m_RegMgr   = regMgr;
     m_Terminal = terminal;
 }
示例#50
0
 public Fr8TerminalAuthenticationAttribute(bool allowRequestsWithoutUser = false)
 {
     _terminal = ObjectFactory.GetInstance <ITerminal>();
     _allowRequestsWithoutUser = allowRequestsWithoutUser;
 }
 public ServicesController()
 {
     _terminal = ObjectFactory.GetInstance <ITerminal>();
 }
 public DumpMemoryCommand(RuntimeProcess proc, ITerminal terminal)
 {
     m_Proc     = proc;
     m_Terminal = terminal;
 }
示例#53
0
 public IPort GetPort(ITerminal terminal)
 {
     return(_portMap.FirstOrDefault(pair => pair.Value == terminal).Key);
 }
示例#54
0
 public override async Task RenderItems(ITerminal terminal, IAsyncEnumerable <(string, Package <BaseOperation>?)> items, PipelineContext pipeline)
示例#55
0
        protected override void OnPaint(ITerminal terminal)
        {
            terminal.Clear();

            const int StrikeX = 3;
            const int DamageX = 9;
            const int DodgeX  = 16;
            const int ArmorX  = 23;
            const int ElemX   = 27;
            const int StatX   = 32;
            const int ResistX = 51;
            const int LabelX  = 80;

            // draw the table
            terminal[0, 0, 80, 28][TermColor.DarkGray].DrawBox();
            terminal[31, 0, 1, 28][TermColor.DarkGray].DrawBox(DrawBoxOptions.DoubleLines);
            terminal[50, 0, 1, 28][TermColor.DarkGray].DrawBox(DrawBoxOptions.DoubleLines);

            terminal[31, 0][TermColor.DarkGray].Write(Glyph.BarDoubleDownSingleLeftRight);
            terminal[50, 0][TermColor.DarkGray].Write(Glyph.BarDoubleDownSingleLeftRight);
            terminal[31, 27][TermColor.DarkGray].Write(Glyph.BarDoubleUpSingleLeftRight);
            terminal[50, 27][TermColor.DarkGray].Write(Glyph.BarDoubleUpSingleLeftRight);

            // write the header
            terminal[14, 0][TermColor.Gray].Write("Melee");
            terminal[39, 0][TermColor.Gray].Write("Stats");
            terminal[60, 0][TermColor.Gray].Write("Resistances");

            terminal[1, 1].Write("Strike Damage Dodge Armor Elem");
            terminal[StatX, 1].Write("StrAgiStaWilIntCha");

            // write the elements in color
            int x = ResistX;

            foreach (Element element in Enum.GetValues(typeof(Element)))
            {
                terminal[x, 1][GameArt.GetColor(element)].Write(GameArt.GetAbbreviation2(element));
                x += 2;
            }

            int y = 2;

            DrawRowLine(terminal, y++);

            // write the base values
            terminal[LabelX, y].Write("Base");

            // melee
            terminal[StrikeX, y].Write(" 0");
            terminal[DamageX, y].Write("x1.0");
            terminal[DodgeX, y].Write(Hero.DodgeBase.ToString());
            terminal[ArmorX, y].Write(" 0");
            terminal[ElemX, y][GameArt.GetColor(Element.Anima)].Write(GameArt.GetAbbreviation4(Element.Anima));

            // stats
            x = StatX;
            foreach (Stat stat in mHero.Stats)
            {
                terminal[x, y].Write(stat.Base.ToString().PadLeft(2));
                x += 3;
            }

            // resists
            terminal[ResistX, y].Write("0 0 0 0 0 0 0 0 0 0 0 0 0 0");

            y++;

            DrawRowLine(terminal, y++);

            // draw the equipment
            for (int i = 0; i < mHero.Equipment.Count; i++)
            {
                Item item = mHero.Equipment[i];

                if (item != null)
                {
                    terminal[LabelX, y].Write(item.ToString());
                }
                else
                {
                    terminal[LabelX, y][TermColor.DarkGray].Write(mHero.Equipment.GetCategory(i));
                }

                // melee stats
                if (item != null)
                {
                    // strike
                    WriteBonus(terminal, StrikeX, y, item.StrikeBonus);

                    // damage
                    float bonus = item.DamageBonus;
                    if (bonus < 1.0f)
                    {
                        terminal[DamageX, y][TermColor.Red].Write("x" + bonus.ToString("F2"));
                    }
                    else if (bonus == 1.0f)
                    {
                        terminal[DamageX, y][TermColor.DarkGray].Write("  -  ");
                    }
                    else
                    {
                        terminal[DamageX, y][TermColor.Green].Write("x" + bonus.ToString("F2"));
                    }

                    // dodge
                    terminal[DodgeX + 1, y][TermColor.DarkGray].Write(Glyph.Dash);

                    // armor
                    TermColor color = TermColor.White;
                    if (item.ArmorBonus < 0)
                    {
                        color = TermColor.Red;
                    }
                    else if (item.ArmorBonus > 0)
                    {
                        color = TermColor.Green;
                    }
                    else if (item.TotalArmor == 0)
                    {
                        color = TermColor.DarkGray;
                    }

                    if (item.TotalArmor < 0)
                    {
                        terminal[ArmorX, y][color].Write(Glyph.ArrowDown);
                        terminal[ArmorX + 1, y][color].Write(Math.Abs(item.TotalArmor).ToString());
                    }
                    else if (item.TotalArmor == 0)
                    {
                        terminal[ArmorX + 1, y][color].Write(Glyph.Dash);
                    }
                    else
                    {
                        terminal[ArmorX, y][color].Write(Glyph.ArrowUp);
                        terminal[ArmorX + 1, y][color].Write(item.TotalArmor.ToString());
                    }

                    // element
                    if (item.Attack != null)
                    {
                        Element element = item.Attack.Element;
                        terminal[ElemX, y][GameArt.GetColor(element)].Write(GameArt.GetAbbreviation4(element));
                    }
                }

                // stat bonuses
                x = StatX;
                foreach (Stat stat in mHero.Stats)
                {
                    if (item != null)
                    {
                        WriteBonus(terminal, x, y, item.GetStatBonus(stat));
                    }
                    x += 3;
                }

                // resists
                x = ResistX;
                foreach (Element element in Enum.GetValues(typeof(Element)))
                {
                    if (item != null)
                    {
                        if (item.Resists(element))
                        {
                            terminal[x, y][TermColor.Green].Write(Glyph.ArrowUp);
                        }
                        else
                        {
                            terminal[x, y][TermColor.DarkGray].Write(Glyph.Dash);
                        }
                    }
                    x += 2;
                }

                y++;
            }

            DrawRowLine(terminal, y++);

            // draw the stats
            foreach (Stat stat in mHero.Stats)
            {
                terminal[LabelX, y].Write(stat.Name);

                // melee bonuses

                // strike
                if (stat == mHero.Stats.Agility)
                {
                    WriteBonus(terminal, StrikeX, y, mHero.Stats.Agility.StrikeBonus);
                }

                // damage
                if (stat == mHero.Stats.Strength)
                {
                    float bonus = mHero.Stats.Strength.DamageBonus;
                    if (bonus < 1.0f)
                    {
                        terminal[DamageX, y][TermColor.Red].Write("x" + bonus.ToString("F1"));
                    }
                    else if (bonus == 1.0f)
                    {
                        terminal[DamageX, y][TermColor.DarkGray].Write("  -  ");
                    }
                    else
                    {
                        terminal[DamageX, y][TermColor.Green].Write("x" + bonus.ToString("F1"));
                    }
                }

                // dodge
                if (stat == mHero.Stats.Agility)
                {
                    WriteBonus(terminal, DodgeX, y, mHero.Stats.Agility.StrikeBonus);
                }

                // armor

                y++;
            }

            DrawRowLine(terminal, y++);

            terminal[LabelX, y].Write("Total");

            // melee totals
            if (mHero.MeleeStrikeBonus < 0)
            {
                terminal[StrikeX, y][TermColor.Red].Write(mHero.MeleeStrikeBonus.ToString());
            }
            else if (mHero.MeleeStrikeBonus == 0)
            {
                terminal[StrikeX + 1, y][TermColor.DarkGray].Write(Glyph.Digit0);
            }
            else
            {
                terminal[StrikeX, y][TermColor.Green].Write(Glyph.Plus);
                terminal[StrikeX + 1, y][TermColor.Green].Write(mHero.MeleeStrikeBonus.ToString());
            }

            // damage
            if (mHero.MeleeDamageBonus < 1.0f)
            {
                terminal[DamageX, y][TermColor.Red].Write("x" + mHero.MeleeDamageBonus.ToString("F1"));
            }
            else if (mHero.MeleeDamageBonus == 1.0f)
            {
                terminal[DamageX, y][TermColor.DarkGray].Write("x" + mHero.MeleeDamageBonus.ToString("F1"));
            }
            else
            {
                terminal[DamageX, y][TermColor.Green].Write("x" + mHero.MeleeDamageBonus.ToString("F1"));
            }

            // dodge
            if (mHero.GetDodge() < Hero.DodgeBase)
            {
                terminal[DodgeX, y][TermColor.Red].Write(mHero.GetDodge().ToString());
            }
            else
            {
                terminal[DodgeX, y].Write(mHero.GetDodge().ToString());
            }

            // armor
            if (mHero.Armor < 0)
            {
                terminal[ArmorX, y][TermColor.Red].Write(mHero.Armor.ToString());
            }
            else if (mHero.Armor == 0)
            {
                terminal[ArmorX + 1, y][TermColor.DarkGray].Write("0");
            }
            else
            {
                terminal[ArmorX + 1, y][TermColor.Green].Write(mHero.Armor.ToString());
            }

            // stat totals
            x = StatX;
            foreach (Stat stat in mHero.Stats)
            {
                if (stat.IsLowered)
                {
                    terminal[x, y][TermColor.Red].Write(stat.Current.ToString().PadLeft(2));
                }
                else if (stat.IsRaised)
                {
                    terminal[x, y][TermColor.Green].Write(stat.Current.ToString().PadLeft(2));
                }
                else
                {
                    terminal[x, y].Write(stat.Current.ToString().PadLeft(2));
                }
                x += 3;
            }

            // resistance totals
            x = ResistX;
            foreach (Element element in Enum.GetValues(typeof(Element)))
            {
                int resists = mHero.GetNumResists(element);

                if (resists == 0)
                {
                    terminal[x, y].Write(Glyph.Digit0);
                }
                else
                {
                    terminal[x, y][TermColor.Green].Write(resists.ToString());
                }
                x += 2;
            }

            // element
            Element attackElement = Element.Anima;
            Item    weapon        = mHero.Equipment.MeleeWeapon;

            if (weapon != null)
            {
                if (weapon.Attack != null)
                {
                    attackElement = weapon.Attack.Element;
                }
            }
            terminal[ElemX, y][GameArt.GetColor(attackElement)].Write(GameArt.GetAbbreviation4(attackElement));

            y += 2;
            terminal[1, y].Write("A total armor of " + mHero.Armor + " reduces damage by " + (100 - (int)(100.0f * Entity.GetArmorReduction(mHero.Armor))) + "%.");
        }
示例#56
0
 public override void Initialize(IHostContext hostContext)
 {
     base.Initialize(hostContext);
     _windowsServiceHelper = HostContext.GetService <INativeWindowsServiceHelper>();
     _term = HostContext.GetService <ITerminal>();
 }
 public TerminalCommandExecutor(ITerminal terminal) : this(terminal, null)
 {
 }
示例#58
0
 public CommandLineTests()
 {
     _terminal    = new TestTerminal();
     _testProgram = new TestProgram();
 }
示例#59
0
 /// <summary>
 /// Отключить терминал от порта
 /// </summary>
 /// <param name="terminal"></param>
 /// <param name="port"></param>
 internal void DisconnectTerminal(ITerminal terminal)
 {
     PortDisconnected?.Invoke(this, new PortEventArgs($"Port №{PortNumber}:  Терминал {terminal.Name} отключен от порта с абон. номером {AbonentNumber}"));
 }
示例#60
0
 /// <summary>
 /// Подключить терминал к порту
 /// </summary>
 /// <param name="terminal"></param>
 internal void ConnectTerminal(ITerminal terminal)
 {
     PortConnected?.Invoke(this, new PortEventArgs($"Port №{PortNumber}:  Терминал {terminal.Name} подключен к порту с абон. номером {AbonentNumber}"));
 }