Skip to content

Commit

Permalink
Lots of refactors
Browse files Browse the repository at this point in the history
- RomPlmsEasy completed
- implemented factory pattern for RomPlms
- Controls bugfix for missing R/L
  • Loading branch information
Dessyreqt committed Feb 19, 2016
1 parent 418ad09 commit 6297127
Show file tree
Hide file tree
Showing 15 changed files with 846 additions and 926 deletions.
50 changes: 50 additions & 0 deletions .gitignore
@@ -0,0 +1,50 @@
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

#VS stuff
_Resharper*/
*.suo
*.user
bin/
obj/
12 changes: 6 additions & 6 deletions SuperMetroidRandomizer/Controls.cs
Expand Up @@ -42,10 +42,10 @@ private void Controls_Load(object sender, EventArgs e)
private void control_SelectedIndexChanged(object sender, EventArgs e)
{
var senderBox = (ComboBox) sender;
if (senderBox.Items.Contains("Off") && senderBox.SelectedItem.ToString() != "Off")

if (senderBox.Items.Contains("None") && senderBox.SelectedItem.ToString() != "None")
{
senderBox.Items.Remove("Off");
senderBox.Items.Remove("None");
}

var otherControl = (from control in Controls.OfType<ComboBox>()
Expand All @@ -60,12 +60,12 @@ private void control_SelectedIndexChanged(object sender, EventArgs e)
}
else
{
if (!otherControl.Items.Contains("Off"))
if (!otherControl.Items.Contains("None"))
{
otherControl.Items.Add("Off");
otherControl.Items.Add("None");
}

otherControl.SelectedItem = "Off";
otherControl.SelectedItem = "None";
}
controlsDict[otherControl.Name] = controlsDict[senderBox.Name];
}
Expand Down
11 changes: 9 additions & 2 deletions SuperMetroidRandomizer/IRomPlms.cs
Expand Up @@ -8,9 +8,16 @@ namespace SuperMetroidRandomizer
public interface IRomPlms
{
List<Plm> Plms { get; set; }
string DifficultyName { get; }
string SeedFileString { get; }
string SeedRomString { get; }

void ResetPlms();
List<Plm> GetAvailablePlms(List<ItemType> haveItems, RandomizerDifficulty difficulty);
List<Plm> GetUnavailablePlms(List<ItemType> haveItems, RandomizerDifficulty difficulty);
List<Plm> GetAvailablePlms(List<ItemType> haveItems);
List<Plm> GetUnavailablePlms(List<ItemType> haveItems);
void TryInsertCandidateItem(List<Plm> currentPlms, List<ItemType> candidateItemList, ItemType candidateItem);
int GetInsertedPlm(List<Plm> currentPlms, ItemType insertedItem, SeedRandom random);
ItemType GetInsertedItem(List<Plm> currentPlms, List<ItemType> itemPool, SeedRandom random);
List<ItemType> GetItemPool();
}
}
6 changes: 3 additions & 3 deletions SuperMetroidRandomizer/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 25 additions & 27 deletions SuperMetroidRandomizer/MainForm.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
Expand All @@ -18,7 +19,7 @@ public enum Suitless
public partial class MainForm : Form
{
private Thread checkUpdateThread;
public static string Version = "20";
public static string Version = "20P2";

public MainForm()
{
Expand Down Expand Up @@ -158,18 +159,18 @@ private void MainForm_Load(object sender, EventArgs e)

private void createV11_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(seedV11.Text.Replace("", "").Replace("", "")))
if (string.IsNullOrWhiteSpace(seedV11.Text))
{
switch (randomizerDifficulty.SelectedItem.ToString())
{
case "Easy":
seedV11.Text = string.Format("{0:0000000}", (new SeedRandom()).Next(10000000));
case "Casual":
seedV11.Text = string.Format("C{0:0000000}", (new SeedRandom()).Next(10000000));
break;
case "Hard":
seedV11.Text = string.Format("{0:0000000}", (new SeedRandom()).Next(10000000));
case "Masochist":
seedV11.Text = string.Format("M{0:0000000}", (new SeedRandom()).Next(10000000));
break;
default:
seedV11.Text = string.Format("{0:0000000}", (new SeedRandom()).Next(10000000));
seedV11.Text = string.Format("S{0:0000000}", (new SeedRandom()).Next(10000000));
break;
}
}
Expand All @@ -180,21 +181,22 @@ private void createV11_Click(object sender, EventArgs e)
RandomizerDifficulty difficulty;
var seedText = seedV11.Text;

if (seedText.Contains(""))
if (seedText.ToUpper().Contains("C"))
{
randomizerDifficulty.SelectedItem = "Easy";
seedText = seedText.Replace("", "");
randomizerDifficulty.SelectedItem = "Casual";
seedText = seedText.ToUpper().Replace("C", "");
difficulty = RandomizerDifficulty.Easy;
}
else if (seedText.Contains(""))
else if (seedText.ToUpper().Contains("M"))
{
randomizerDifficulty.SelectedItem = "Hard";
seedText = seedText.Replace("", "");
randomizerDifficulty.SelectedItem = "Masochist";
seedText = seedText.ToUpper().Replace("M", "");
difficulty = RandomizerDifficulty.Hard;
}
else
{
randomizerDifficulty.SelectedItem = "Normal";
randomizerDifficulty.SelectedItem = "Speedrunner";
seedText = seedText.ToUpper().Replace("S", "");
difficulty = RandomizerDifficulty.Normal;
}

Expand All @@ -205,21 +207,17 @@ private void createV11_Click(object sender, EventArgs e)
}
else
{
var randomizerV11 = new RandomizerV11(parsedSeed, difficulty);
var romPlms = RomPlmsFactory.GetRomPlms(difficulty);
var randomizerV11 = new RandomizerV11(parsedSeed, romPlms);
randomizerV11.CreateRom(filenameV11.Text);

switch (randomizerV11.Difficulty)
{
case RandomizerDifficulty.Easy:
WriteOutputV11(string.Format("Done!{1}{1}{1}Seed: ♥{0:0000000}♥ (Easy Difficulty){1}{1}", parsedSeed, Environment.NewLine));
break;
case RandomizerDifficulty.Hard:
WriteOutputV11(string.Format("Done!{1}{1}{1}Seed: ♦{0:0000000}♦ (Hard Difficulty){1}{1}", parsedSeed, Environment.NewLine));
break;
default:
WriteOutputV11(string.Format("Done!{1}{1}{1}Seed: {0:0000000} (Normal Difficulty){1}{1}", parsedSeed, Environment.NewLine));
break;
}
var outputString = new StringBuilder();

outputString.AppendFormat("Done!{0}{0}{0}Seed: ", Environment.NewLine);
outputString.AppendFormat(romPlms.SeedFileString, parsedSeed);
outputString.AppendFormat(" ({0} Difficulty){1}{1}", romPlms.DifficultyName, Environment.NewLine);

WriteOutputV11(outputString.ToString());
}

Settings.Default.RandomizerDifficulty = randomizerDifficulty.SelectedItem.ToString();
Expand Down
Binary file modified SuperMetroidRandomizer/MenuFileSaveIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6297127

Please sign in to comment.