Ejemplo n.º 1
0
        private void ParseAttachmentCommand(Player player, PlayerGameSave gameSave, string command)
        {
            command = CleanText(command);
            var commandSplit = command.Split(' ');

            if (command.StartsWith("imageBuild"))
            {
                ResolveImageBuildCommand(commandSplit);
            }
            else if (command.StartsWith("save"))
            {
                var dataName = commandSplit[1];
                _gameDataService.SaveData(gameSave, dataName);
            }
            else if (command.StartsWith("set"))
            {
                var dataName = commandSplit[1];
                if (commandSplit[2] == "=")
                {
                    var valueSet = ResolveValue(ConcatSplitAfterIndex(commandSplit, 3), gameSave);
                    _gameDataService.SaveData(gameSave, dataName, valueSet);
                }
                else if (commandSplit[2] == "--")
                {
                    _gameDataService.DecrementData(gameSave, dataName);
                }
                else if (commandSplit[2] == "++")
                {
                    _gameDataService.IncrementData(gameSave, dataName);
                }
                else
                {
                    throw new Exception("Error parsing: " + command + " as an attachment state command");
                }
            }
            else if (command.StartsWith("delete"))
            {
                var dataName = commandSplit[1];
                _gameDataService.DeleteData(gameSave, dataName);
            }
            else if (command.StartsWith("achievement"))
            {
                var dataValue = command.Substring(11, command.Length - 11).Trim();
                _gameDataService.SavePermanentData(player, gameSave.GameName, dataValue, PlayerSaveDataType.ACHIEVEMENT);
            }
        }