public IAccionesJuegoCommand BuscarCommand(string cKey) { IAccionesJuegoCommand AccionesJuegoCommand = null; if (lstAccionesJuegoCommand.Any(x => x.cComando == cKey)) { AccionesJuegoCommand = lstAccionesJuegoCommand.Where(x => x.cComando == cKey).FirstOrDefault(); } return(AccionesJuegoCommand); }
public void AgregarCommand(IAccionesJuegoCommand _accionesJuegoCommand) { if (_accionesJuegoCommand != null) { if (!lstAccionesJuegoCommand.Any() || lstAccionesJuegoCommand.Any(x => x.cComando != _accionesJuegoCommand.cComando)) { lstAccionesJuegoCommand.Add(_accionesJuegoCommand); } } }
static void AdministrarMenuAcciones(IAccionesReceiver _receiver, string _cNombreJugador) { Console.BackgroundColor = ConsoleColor.White; Console.Clear(); IRecuperadorMenuAcciones RecuperadorMenuAcciones = new RecuperadorMenuAcciones(); Console.ForegroundColor = ConsoleColor.Red; JugadorInvoker Invoker = new JugadorInvoker(); AgregarComandosAInvokerBasicos(Invoker, _receiver); string cOpcion = string.Empty; do { Console.Clear(); Console.WriteLine(RecuperadorMenuAcciones.RecuperarMenuAcciones(Invoker.iTipoMenu, _cNombreJugador)); cOpcion = Console.ReadLine(); if (cOpcion != "S") { IAccionesJuegoCommand EjecutarCommand = Invoker.BuscarCommand(cOpcion); if (EjecutarCommand != null) { Console.ForegroundColor = ConsoleColor.Black; Invoker.EjecutarComando(EjecutarCommand, _cNombreJugador); Console.ForegroundColor = ConsoleColor.Red; Console.ReadKey(); } else { AgregarNuevasAcciones(cOpcion, _receiver, Invoker); } } }while (cOpcion != "S"); if (cOpcion == "S") { InicializarAplicacion(); } }
public void EjecutarComando(IAccionesJuegoCommand _accionesJuego, string _cNombreJugador) { _accionesJuego.EjecutarAccion(_cNombreJugador); }