Jump to content
  • Advertisement

EliotAugusto

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

100 Neutral

About EliotAugusto

  • Rank
    Newbie
  1. EliotAugusto

    Symlinks in C#

    I do thank you for the input. The only issue is that a raid setup is unavailable at this moment. Plus the challenge of something so oblique is something I can't resist. I'm going to remove the answered questions, thanks again.
  2. EliotAugusto

    Symlinks in C#

    This is going to be a bit lengthy, I always tend to give too much information. But what I want is very specific, however what I want may be wrong. Skip down to the "Questions" portion if you don't care about the why. Purpose: Create a program that will handle current criteria with minimal impact to existing network structure, which poor at best. Learn more about programming and thinking abstractly when being forced to use systems already in place rather than inventing a new one. Also to document the process in case anyone having a situation similar to mine will be able to easily identify the steps and solve their issue quicker. Problem:The issue I am currently attempting to solve is that I have multiple files, on multiple HDDs, on multiple computers(rudimentary home network), all of which I want to access through one Virtual drive. I want to access it through virtual drive so that I can just share that one drive and have all computers access just those files. To narrow it down even further, the intended purpose is to share that virtual drive with a PS3 Media server and the computer that hooks up to the TV for movie viewing. I have found out that the PS3 recognizes Directory Junctions made with the cmd prompt, I am relatively certain it will recognize hard links with the command 'mklink' as well. CMD is a bit limited in what I'd like to create that will handle this whole process for me. Rather than just download a program that will do this, I want to learn more about programming by doing this task. Intended Solution: Create a program in C# or C++(both of which I have rudimentary knowledge of) that will scan selected directories and/or drives for files of type " \\...\*.avi/mp4/mp3/mkv etc..." make a symlink in a target directory of my choosing, in a sub-directory based on criteria(genre/year/alphabetically) that is provided manually or automatically through a script I may write later to learn Python, that can either grab a name automatically or allow me to edit the name. Add a .bat file to startup that will subst x: D:\Junction and all of the symlinks will be created in a directory structure similar to: D:\Junction\All\... D:\Junction\Action\... D:\Junction\Anime\... etc... I intend to have an actual GUI, and when I select run it will scan the selected directories, compared the results from the scan and compare with an index file to determine if the movie has already had a link created with it. I don't intend to have the original file renamed at any point negating a large portion of the negative aspects of using an index file that holds all the files that have already had a symlink created on their behalf. Unless there is a better solution I intend to have copies of the Symlink in each folder that the movie falls under. E.G. - Unstoppable would have a Symlink's created in: \\...\All \\...\Suspense \\...\Drama With this I hope to have it as close to a service like Netflix making it an easy to use file structure that can be used on a multitude of platforms(360/PS3/PC/Phone) that connect to my home network wirelessly. Questions: [s]-Is there a way I can search by a type of all video/audio formats rather than making a list of all formats and searching that way?[/s] [s]-Is using C#(preferred language) possible to create a system like this?[/s] [s]-Would I be better off just learning and making a Python script to accomplish the goals?[/s] [s]-Is there a better solution than using Symlinks to have a directory storing all files I want pointed there, without that directory taking up the space on the HDD with the junctions?[/s] -I have looked, but found very limited information on this topic. In regards to Symlinks, is there a good source that you know of that I may look at, read and solve the problem with lots of critical thought? -Any advice you have, I will gladly take. -More questions to come as my progress moves forward Progress: -Create GUI that has functionality - Current Task -Create Symlinks Automatically based off of criteria input in the GUI -Scan directories and create Symlinks based off of criteria input in the GYI -Create directories and sub-directories containing Symlinks -Bug Fixes *Note* Will post source code as I go, if you feel like critiquing it I will probably love you forever.
  3. EliotAugusto

    Coding 'Eloquence' - C#

    Yeah, that's why I'm here. I'm trying to get bad habits stopped before they start. Thanks for all the help so far!.
  4. EliotAugusto

    Coding 'Eloquence' - C#

    What would be the most recommended way to seed Rand? I read ages past to use system time or something like that...but I just need to figure out how to do it. Also for using choice.ToUpper & choice.ToLower, what is the general syntax and usage of that? That's my first run in with sub-variable variables, or at least how I understand them at first look.
  5. EliotAugusto

    Coding 'Eloquence' - C#

    Ahhh, ok. I always read stories about someone dredging up other files or reading other peoples work where confusion ensues. I just wanted to ensure any bad habits were curbed before they started. Secondly, what would you have done differently? And again, thank you for your input.
  6. EliotAugusto

    Coding 'Eloquence' - C#

    So I'd like to start off by saying what I'm asking for is someone more experience than I am to see if my code is eloquent, I don't know how else to put it. I looked around the other forums and decided for the type of question this was the best place for it. Anyways, to the meat and potatoes: I started earnestly learning C# a little under 5 hours ago from the time of this writing. Previously I had dabbled in web coding, C++, and scripting languages. I really never made it far past the "Hello World" stage. But I dove into this great resource that was perfect for me. I got to the method lesson about 2 hours ago, and the challenge presented to me took the remaining 2ish hours. The challenge is to turn a piece of code from solely inside 'static main()' and run it as much as possible outside of 'main' without any 'static' methods. Summary of code at bottom!!! And the two specific questions. *Note* This is supposed to be "game" between a monster and hero, but really just math with options. This is the original code: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Tutorial1 { class Program { static void Main(string[] args) { int heroHitPoints, monsterHitPoints, attackDamage; string battlechoice; Random rand; Console.WriteLine("You are facing a monster"); //this is outside the loop so that it will only print once heroHitPoints = 30;// our variables are assigned ouside monsterHitPoints = 25;//so that each loop won't "heal" them do { rand = new Random(); Console.Write(@" ************************************************ Your hero has {0}hp and the monster has {1}hp ************************************************", heroHitPoints, monsterHitPoints); Console.Write(@" __________________________ Please Choose an action: (A)ttack (D)efend __________________________"); Console.WriteLine(); battlechoice = Console.ReadLine(); switch (battlechoice) { case "a": case "A"://this way a or A work attackDamage = rand.Next(3, 7);//get our damage monsterHitPoints -= attackDamage;//subtract the damage Console.WriteLine("The hero attacks!"); Console.WriteLine("The monster loses {0}hp", attackDamage); break; case "d": case "D": Console.WriteLine("The Hero Defends"); break; default://defaults always a good idea with user input Console.WriteLine("Sorry that choice was invalid and the monster takes a cheap shot"); break; } Console.WriteLine(); if (monsterHitPoints > 0)//if the monster is still alive { Console.WriteLine("The Monster Attacks!"); attackDamage = rand.Next(3, 7);//get a random number if (battlechoice == "d" || battlechoice == "D") { //this is so that defend has some sort of benefit attackDamage /= 2; } heroHitPoints -= attackDamage;//subtract the damage Console.WriteLine("The Hero loses {0}hp", attackDamage); } Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); Console.Clear();//this clears the screen so that we don't have the //last turns info on it. } while (heroHitPoints > 0 && monsterHitPoints > 0); if (heroHitPoints > 0) { Console.WriteLine("You have defeated the monster"); } else { Console.WriteLine("The monster has defeated you"); } Console.ReadLine(); } } } and with the object being non-static methods I came up with this: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { int BattleChoice(string choice)//Receives input after 'Action Menu' appears and returns action chosen { int attackChoice = 0; //0 is no choice picked - 1 is attack - 2 is defend - 3 is health potion - 4 is damage potion switch (choice) { case "a": case "A": attackChoice = 1; break; case "d": case "D": attackChoice = 2; break; case "h": case "H": attackChoice = 3; break; case "p": case "P": attackChoice = 4; break; default: attackChoice = 0; break; } return attackChoice; } // Formatting comment int MonsterHealth(int health, int heroAttack)//Is called to obtain monster health before hit, and return post damage health { health -= heroAttack; return health; } // Formatting comment int MonsterAttack()//Is called to obtain damage for the monster, no outside modifiers { int attack; Random rand; rand = new Random(); attack = rand.Next(5, 10); return attack; } // Formatting comment int HeroHealth(int heroHealth, int monsterAttack) //Is called to obtain hero health before hit, and return post damage health { heroHealth -= monsterAttack; return heroHealth; } // Formatting comment int HeroAttack(int bonus) //Is called to obtain the damage for the hero { int attackDamage; Random rand; rand = new Random(); attackDamage = rand.Next(10, 20); if (bonus > 0) { attackDamage *= 2; } return attackDamage; } // Formatting comment static void Main(string[] args) { Program program = new Program(); // So I can get working methods int heroHitPoints, monsterHitPoints, heroAtkDmg, monsterAtkDmg; //stat variables int battleReturn, bonus; //battle action variables string localChoice; //created to send input to BattleChoice() heroHitPoints = 100; monsterHitPoints = 75; heroAtkDmg = 0; monsterAtkDmg = 0; bonus = 0; Console.WriteLine("A scary monster has appeared!"); Console.WriteLine(); Console.ReadLine(); do { Console.Clear(); Console.WriteLine(@" ************************************************ Your hero has {0}hp and the monster has {1}hp ************************************************", heroHitPoints, monsterHitPoints); Console.Write(@" __________________________ Please Choose an action: (A)ttack (D)efend (H)ealth Potion Damage (P)otion __________________________"); Console.WriteLine(); localChoice = Console.ReadLine(); battleReturn = program.BattleChoice(localChoice); //Below creates the if statement for the action menu. Using a method with this setup proved to be way to confusing if (battleReturn == 0) { Console.WriteLine("The monster has taken a cheap shot at you because you did something random."); monsterAtkDmg = program.MonsterAttack(); heroHitPoints = program.HeroHealth(heroHitPoints, monsterAtkDmg); Console.WriteLine("You have taken {0} points of damage.", monsterAtkDmg); } else if (battleReturn == 1) { heroAtkDmg = program.HeroAttack(bonus); Console.WriteLine("You attack the monster for {0} points of damage.", heroAtkDmg); monsterHitPoints = program.MonsterHealth(monsterHitPoints, heroAtkDmg); if (monsterHitPoints > 0) { monsterAtkDmg = program.MonsterAttack(); Console.WriteLine("The monster attacks back for {0} points of damage.", monsterAtkDmg); heroHitPoints = program.HeroHealth(heroHitPoints, monsterAtkDmg); } } else if (battleReturn == 2) { Console.WriteLine("You bolster your defenses preparing for the oncoming onslaught!"); monsterAtkDmg = program.MonsterAttack(); monsterAtkDmg /= 2; Console.ReadLine(); Console.WriteLine("Your defence has reduced the monsters damage in half, you only took {0} damage.", monsterAtkDmg); heroHitPoints = program.HeroHealth(heroHitPoints, monsterAtkDmg); } else if (battleReturn == 3) { Console.WriteLine("You chug a health potion returning lost hit points."); heroHitPoints = 100; monsterAtkDmg = program.MonsterAttack(); Console.WriteLine("The monster attacks you for {0} damage.", monsterAtkDmg); heroHitPoints = program.HeroHealth(heroHitPoints, monsterAtkDmg); } else if (battleReturn == 4) { Console.WriteLine("You chug a damage potion doubling your damage done."); bonus++; monsterAtkDmg = program.MonsterAttack(); Console.WriteLine("The monster attacks you for {0} damage.", monsterAtkDmg); heroHitPoints = program.HeroHealth(heroHitPoints, monsterAtkDmg); } heroAtkDmg = 0; // Resetting attack values to insure no numbers errors are created. monsterAtkDmg = 0; Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); } while (heroHitPoints > 0 && monsterHitPoints > 0); //Creates an endpoint if (heroHitPoints > 0) { Console.WriteLine("You have defeated the monster"); } else { Console.WriteLine("The monster has defeated you"); } Console.ReadLine(); //End of Main } } } I wanted to know if this was even remotely close to writing eloquent code, that looks nice and is purposeful. Also, the if statement in main that deals with the action menu actions, I attempted to write that into a non-static method, but quickly grew lost in the ever increasing list of variables and arguments that each method required. One of the methods I created there were 6 arguments required to get it working correctly, two of those arguments were functions which had 3 arguments each. Am I over complicating that part, or does the rest of my code just not support those types of actions? Summary of code: Original: A do/while loop inside of static main that chooses between two actions and reacts accordingly with an if/else statement. This repeats until 'while' is met. My copy: 5 non-static methods and static main. One method controls user input, two control the attack of each of the characters, and two control the health of each of the characters. Main then handles in the return values and chooses how to act according to 1, the others handle local variable changes and math for these variables. Also, because I learn by doing and exploring in my current field of study I added two menu options that act accordingly and currently thinking about modifying the do/while to incorporate a kill command from the player to exit the program, otherwise the monster will increment in power until the player is 1 shot. Also thinking about critical strikes and misses using Random(); I will greatly, greatly appreciate any help I get with this.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!