public GalaxyNumberSytemController() { model = new GalaxyModel(); metalObj = new ProcessMetal(); symbolObj = new ProcessSymbol(); questionObj = new ProcessQuestion(); }
internal void New() { _selectedGalaxy = new GalaxyModel(); _galaxies.Add(_selectedGalaxy); _player.CreatedGalaxies++; GameModel.Set <GalaxyModel>(_selectedGalaxy); }
/// <summary> /// Processes Symbols and adds to Model object /// </summary> /// <param name="model"></param> /// <param name="userEnteredLine"></param> /// <param name="inputExtract"></param> /// <returns></returns> public dynamic Process(GalaxyModel model, string userEnteredLine, List <string> inputExtract) { var roman = model.RomanSystem.GetRomanCurrencyValue(inputExtract[1][0]); var result = model.GalaxySymbols.Exists(item => item.SymbolName.Equals(inputExtract[0])); if (!result) { model.GalaxySymbols.Add(new GalaxySymbol { SymbolName = inputExtract[0], RomanEquivalent = inputExtract[1][0], SymbolValue = roman.SymbolValue }); } return(null); }
public static string ValidateSubstaction(GalaxyModel model, List <string> partOne, string symbol, int nextIndex) { if (nextIndex < partOne.Count - 1) { var symbolBaseData = model.GalaxySymbols.Find(item => item.SymbolName.Equals(symbol)); var nextSymbol = partOne[nextIndex + 1]; var nextSymbolBaseData = model.GalaxySymbols.Find(item => item.SymbolName.Equals(nextSymbol)); if (nextSymbolBaseData != null) { switch (symbolBaseData.RomanEquivalent) { case 'I': if (nextSymbolBaseData.RomanEquivalent != 'I') { if (nextSymbolBaseData.RomanEquivalent != 'V' && nextSymbolBaseData.RomanEquivalent != 'X') { return(string.Format("Can not substract {0} symbol from {1}", symbol, nextSymbol)); } } break; case 'X': if (nextSymbolBaseData.RomanEquivalent != 'X') { if (nextSymbolBaseData.RomanEquivalent != 'L' && nextSymbolBaseData.RomanEquivalent != 'C') { return(string.Format("Can not substract {0} symbol from {1}", symbol, nextSymbol)); } } break; case 'C': if (nextSymbolBaseData.RomanEquivalent != 'C') { if (nextSymbolBaseData.RomanEquivalent != 'M' || nextSymbolBaseData.RomanEquivalent != 'D') { return(string.Format("Can not substract {0} symbol from {1}", symbol, nextSymbol)); } } break; } } } return(string.Empty); }
static void Main(string[] args) { GalaxyModel model = new GalaxyModel(); model.InputData = new List <string>(); model.InputData.Add("glob is I"); model.InputData.Add("prok is V"); model.InputData.Add("pish is X"); model.InputData.Add("tegj is L"); model.InputData.Add("glob glob Silver is 34 Credits"); model.InputData.Add("glob prok Gold is 57800 Credits"); model.InputData.Add("pish pish Iron is 3910 Credits"); model.InputData.Add("how much is pish tegj glob glob ?"); foreach (string line in model.InputData) { Processor.ConversionProcess(model, line); } }
public static string Occurances(GalaxyModel model, List <string> questionStatement, string currentSymbol) { var symbolBaseData = model.GalaxySymbols.Find(item => item.SymbolName.Equals(currentSymbol)); int nextSymbolIndex = questionStatement.FindIndex(item => item.Equals(currentSymbol)); if (nextSymbolIndex < questionStatement.Count - 2) { var levelTwoSymbol = questionStatement[nextSymbolIndex + 1]; if (currentSymbol == levelTwoSymbol) { if (symbolBaseData != null) { var romanBaseData = model.RomanSystem.GetRomanCurrencyValue(symbolBaseData.RomanEquivalent); if (romanBaseData.Reapat == false) { return(currentSymbol + " " + Validator.CanNotRepeatMessage); } } var levelThreeSymbol = questionStatement[nextSymbolIndex + 2]; if (currentSymbol == levelThreeSymbol) { var levelFourSymbol = questionStatement[nextSymbolIndex + 3]; if (currentSymbol == levelFourSymbol) { return(currentSymbol + " is exceeding repetitions in (" + string.Join(" ", questionStatement) + ")"); } } } } return(string.Empty); }
public void Translate(GalaxyModel model) { string[] words = model.InputData[0].Split(new[] { " is " }, StringSplitOptions.RemoveEmptyEntries); }
/// <summary> /// Method to process all the questions /// </summary> /// <param name="model"></param> /// <param name="userEnteredLine"></param> /// <param name="inputExtract"></param> /// <returns></returns> public dynamic Process(GalaxyModel model, string userEnteredLine, List <string> inputExtract) { var questionStatement = Regex.Split(inputExtract[1], " ").ToList(); double questionValue = 0; List <double> valueHolder = new List <double>(); double metalValue = 0; string message; for (int i = 0; i < questionStatement.Count; i++) { var symbol = questionStatement[i]; message = Validator.Occurances(model, questionStatement, symbol); if (!string.IsNullOrEmpty(message)) { return(message); } message = Validator.ValidateSubstaction(model, questionStatement, symbol, i); if (!string.IsNullOrEmpty(message)) { return(message); } var result = model.GalaxySymbols.Exists(item => item.SymbolName.Equals(symbol)); if (result) { valueHolder.Add(model.GalaxySymbols.Where(item => item.SymbolName.Equals(symbol)).Select(item => item.SymbolValue).FirstOrDefault()); } else { metalValue = model.Metals.Where(item => item.MetalName.Equals(symbol)).Select(item => item.MetalValue).FirstOrDefault(); } } for (int i = 0; i < valueHolder.Count; i++) { if (i == valueHolder.Count - 1) { break; } double currentValue = valueHolder[i]; double nextValue = valueHolder[i + 1]; if (currentValue < nextValue) { valueHolder[i] = valueHolder[i] * (-1); } } questionValue = valueHolder.Sum(); message = inputExtract[1] + " is " + questionValue; if (metalValue > 0) { questionValue = valueHolder.Sum() * metalValue; message = inputExtract[1] + " is " + questionValue + " credits"; } if (questionValue == 0) { return(Validator.NotLegalValue); } return(message); }
internal static void ConversionProcess(GalaxyModel model, string line) { }
private void OnGalaxyChange(GalaxyModel value) { _galaxy = value; _stars = value._Stars; }
private static void Create_NewGame() { #region Prepare UI and get menu result ZConsoleMain.ClearScreen(); Draw_Interface(); Draw_Credits(); var loadGameFileName = MainMenu(); #endregion #region Create Galaxy, Player and all area handlers GameConfig.Reset(); Galaxy = GalaxyModel.Create(GameConfig.CurrentGalaxySizeX, GameConfig.CurrentGalaxySizeY); Player = PlayerModel.Create(); CurrentStarSystem.IsExplored = true; GalaxyMap = new GalaxyMap(GalaxyArea, GameConfig.CurrentGalaxySizeX, GameConfig.CurrentGalaxySizeY); EventLog = new EventLog(EventArea); ActionPanel = new ActionPanel(ActionArea); PlayerStats = new PlayerStats(PlayerStatsArea); BattleStats = new BattleStats(BattleStatsArea); EventLog.ClearArea(); #endregion #region Load game or show Intro Text and get Player name if (!string.IsNullOrEmpty(loadGameFileName)) { SaveLoad.LoadGame(loadGameFileName); } else { PrintIntroText(); EventLog.Print("Common_EnterYourName"); ZCursor.SetCursorVisibility(true); Player.Name = ZInput.ReadLine(2 + Lang["Common_EnterYourName"].Length, 7, 9, Color.Yellow, Color.Black, false, "Jameson"); ZCursor.SetCursorVisibility(false); } #endregion #region Prepare UI, draw galaxy, etc. Draw_Controls(true); GlobalEvent.Create(Galaxy, CurrentStarSystem); ActionPanel.ClearArea(); PlayerStats.Draw_PlayerStats(); GalaxyMap.Draw_GalaxyMap(); GalaxyMap.HighlightArea(); EventLog.Print("Galaxy_ChooseSystem"); #endregion }
public void Translate(GalaxyModel model) { throw new NotImplementedException(); }
public dynamic Process(GalaxyModel model, string userEnteredLine, List <string> inputExtract) { List <double> metalValue = new List <double>(); var symbolStatement = Regex.Split(inputExtract[0], " ").ToList(); string metalName = string.Empty; string message = string.Empty; for (int i = 0; i < symbolStatement.Count; i++) { var symbol = symbolStatement[i]; message = Validator.Occurances(model, symbolStatement, symbol); if (!string.IsNullOrEmpty(message)) { return(message); } message = Validator.ValidateSubstaction(model, symbolStatement, symbol, i); if (!string.IsNullOrEmpty(message)) { return(message); } var result = model.GalaxySymbols.Exists(item => item.SymbolName.Equals(symbol)); if (result) { metalValue.Add(model.GalaxySymbols.Where(item => item.SymbolName.Equals(symbol)).Select(item => item.SymbolValue).FirstOrDefault()); } else { metalName = symbol; } } for (int i = 0; i < metalValue.Count; i++) { if (i == metalValue.Count - 1) { break; } double currentValue = metalValue[i]; double nextValue = metalValue[i + 1]; if (currentValue < nextValue) { metalValue[i] = metalValue[i] * (-1); } } var metalSum = metalValue.Sum(); var partTwo = Regex.Split(inputExtract[1], " ").ToList(); var credits = Convert.ToInt32(partTwo[0]); var FinalValue = credits / metalSum; model.Metals.Add(new Metal { MetalName = metalName, MetalValue = FinalValue }); return(message); }
internal void Load(int index) { _selectedGalaxy = _galaxies[index]; GameModel.Set <GalaxyModel>(_selectedGalaxy); }